...just some ideas
This commit is contained in:
parent
95c9100ecb
commit
e4a5e1f304
18
DShotRMT.cpp
18
DShotRMT.cpp
|
|
@ -65,7 +65,6 @@ bool DShotRMT::begin()
|
|||
//
|
||||
bool DShotRMT::setThrottle(uint16_t throttle)
|
||||
{
|
||||
|
||||
// DShot Frame Container
|
||||
dshot_packet_t packet = {};
|
||||
|
||||
|
|
@ -80,6 +79,23 @@ bool DShotRMT::setThrottle(uint16_t throttle)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
bool DShotRMT::sendDShotCommand(uint16_t command)
|
||||
{
|
||||
// DShot Frame Container
|
||||
dshot_packet_t packet = {};
|
||||
|
||||
// Create DShot packet
|
||||
packet.throttle_value = constrain(command, DSHOT_CMD_MOTOR_STOP, DSHOT_CMD_MAX);
|
||||
packet.telemetric_request = _is_bidirectional;
|
||||
packet.checksum = _calculateCRC(packet);
|
||||
|
||||
if (!_sendDShotFrame(packet))
|
||||
{
|
||||
return DSHOT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
uint32_t DShotRMT::getERPM()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <driver/gpio.h>
|
||||
#include <driver/rmt_tx.h>
|
||||
#include <driver/rmt_rx.h>
|
||||
#include <hw_defaults.h>
|
||||
|
||||
static constexpr bool DSHOT_OK = 0;
|
||||
static constexpr bool DSHOT_ERROR = 1;
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@
|
|||
#include <DShotRMT.h>
|
||||
|
||||
// USB serial port settings
|
||||
constexpr auto &USB_SERIAL = Serial0;
|
||||
constexpr uint32_t USB_SERIAL_BAUD = 115200;
|
||||
static constexpr auto &USB_SERIAL = Serial0;
|
||||
static constexpr uint32_t USB_SERIAL_BAUD = 115200;
|
||||
|
||||
// Motor configuration
|
||||
constexpr gpio_num_t MOTOR01_PIN = GPIO_NUM_17;
|
||||
constexpr dshot_mode_t DSHOT_MODE = DSHOT300;
|
||||
static constexpr gpio_num_t MOTOR01_PIN = PIN_UART2_RX;
|
||||
static constexpr dshot_mode_t DSHOT_MODE = DSHOT300;
|
||||
|
||||
// BiDirectional DShot Support (default: false)
|
||||
constexpr bool IS_BIDIRECTIONAL = false;
|
||||
static constexpr bool IS_BIDIRECTIONAL = false;
|
||||
|
||||
// Motor magnet count for RPM calculation
|
||||
constexpr uint8_t MOTOR01_MAGNET_COUNT = 14;
|
||||
static constexpr uint8_t MOTOR01_MAGNET_COUNT = 14;
|
||||
|
||||
// Setup Motor Pin, DShot Mode and optional BiDirectional Support
|
||||
DShotRMT motor01(MOTOR01_PIN, DSHOT_MODE, IS_BIDIRECTIONAL);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @file hw_defaults.h
|
||||
* @brief Some Shortcuts
|
||||
* @author Wastl Kraus
|
||||
* @date 2025-08-02
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
#ifdef ESP32
|
||||
// USB-Serial (UART0): GPIO1/3 in use by default
|
||||
|
||||
// Serial1
|
||||
constexpr auto PIN_UART1_TX = GPIO_NUM_13;
|
||||
constexpr auto PIN_UART1_RX = GPIO_NUM_14;
|
||||
|
||||
// Serial2
|
||||
constexpr auto PIN_UART2_TX = GPIO_NUM_16;
|
||||
constexpr auto PIN_UART2_RX = GPIO_NUM_17;
|
||||
|
||||
// SPI (VSPI)
|
||||
constexpr auto PIN_SPI_SCLK = GPIO_NUM_18;
|
||||
constexpr auto PIN_SPI_MISO = GPIO_NUM_19;
|
||||
constexpr auto PIN_SPI_MOSI = GPIO_NUM_23;
|
||||
constexpr auto PIN_SPI_SS = GPIO_NUM_5;
|
||||
|
||||
// I2C (Wire)
|
||||
constexpr auto PIN_I2C_SDA = GPIO_NUM_21;
|
||||
constexpr auto PIN_I2C_SCL = GPIO_NUM_22;
|
||||
|
||||
// RMT (5 Channels)
|
||||
constexpr auto PIN_RMT_CH0 = GPIO_NUM_25;
|
||||
constexpr auto PIN_RMT_CH1 = GPIO_NUM_26;
|
||||
constexpr auto PIN_RMT_CH2 = GPIO_NUM_27;
|
||||
constexpr auto PIN_RMT_CH3 = GPIO_NUM_32;
|
||||
constexpr auto PIN_RMT_CH4 = GPIO_NUM_33;
|
||||
#endif // ESP32
|
||||
Loading…
Reference in New Issue