42 #ifndef DSHOT_CHANNEL_FIRST_INDEX
43 #define DSHOT_CHANNEL_FIRST_INDEX 0U
48 #define DSHOT_BIT_WIDTHS 16U
49 #define DSHOT_PRE_FRAME_SILENT_SYNC_BITS 2U
50 #define DSHOT_POST_FRAME_SILENT_SYNC_BITS 4U
51 #define DSHOT_DMA_BUFFER_SIZE (DSHOT_BIT_WIDTHS + \
52 DSHOT_PRE_FRAME_SILENT_SYNC_BITS + \
53 DSHOT_POST_FRAME_SILENT_SYNC_BITS )
56 #if STM32_DMA_SUPPORTS_DMAMUX
57 #define DSHOT_EMIT_STREAM_NX(tim) STM32_DMAMUX1_TIM ## tim ## _UP
58 #define DSHOT_EMIT_STREAM(tim) DSHOT_EMIT_STREAM_NX(tim)
65 #define DSHOT_BIDIR_ERR_CRC UINT32_MAX
66 #define DSHOT_BIDIR_TLM_EDT (UINT32_MAX-1U)
74 #define DSHOT_ALL_MOTORS 255U
148 __attribute__ ((__packed__));
167 #if DSHOT_AT_LEAST_ONE_32B_TIMER
191 #if STM32_DMA_SUPPORTS_DMAMUX
231 bool dcache_memory_in_use;
ERPS complete frame, raw and decoded.
: DSHOT Rpm Capture Driver configuration structure.
void dshotStart(DSHOTDriver *driver, const DSHOTConfig *config)
Configures and activates the DSHOT peripheral.
void dshotSetThrottle(DSHOTDriver *driver, const uint8_t index, const uint16_t throttle)
prepare throttle order for specified ESC
DshotTelemetry dshotGetTelemetry(DSHOTDriver *driver, const uint32_t index)
return last received telemetry data
uint32_t dshotGetTelemetryFrameCount(const DSHOTDriver *driver)
return number of telemetry succesfull frame since dshotStart
SerialDriver * tlm_sd
if non null : dshot telemetry serial driver
PWMDriver * pwmp
PWM driver that feed up to 4 dshot lines.
#define DSHOT_DMA_BUFFER_SIZE
uint8_t dma_channel
: dma channel associated with pwm timer used to generate dshot output
uint16_t speed_khz
dynamic dshot speed, when speed id not known at compilation
void dshotSendThrottles(DSHOTDriver *driver, const uint16_t throttles[DSHOT_CHANNELS])
send throttle packed order to all of the ESCs
DshotTelemetryFrame frame
uint32_t dma_stream
: dma stream associated with pwm timer used to generate dshot output
uint32_t dshotGetCrcErrorCount(const DSHOTDriver *driver)
return number of telemetry crc error since dshotStart
void dshotStop(DSHOTDriver *driver)
stop the DSHOT driver and free the related resources : pwm driver and dma driver.
void dshotSendFrame(DSHOTDriver *driver)
send throttle order
DshotDmaBuffer * dma_buf
dshot dma buffer, should be defined in a non Dcached region
void dshotSendSpecialCommand(DSHOTDriver *driver, const uint8_t index, const dshot_special_commands_t specmd)
send special order to one of the ESC (BHELIX, KISS, ...)
dshot_special_commands_t
DSHOT special commands (0-47) for KISS and BLHELI ESC.
@ DSHOT_CMD_SPIN_DIRECTION_REVERSED
@ DSHOT_CMD_SILENT_MODE_ON_OFF
@ DSHOT_CMD_SAVE_SETTINGS
@ DSHOT_CMD_AUDIO_STREAM_MODE_ON_OFF
@ DSHOT_CMD_SETTINGS_REQUEST
@ DSHOT_CMD_BIDIR_EDT_MODE_OFF
@ DSHOT_CMD_SPIN_DIRECTION_NORMAL
@ DSHOT_CMD_SPIN_DIRECTION_1
@ DSHOT_CMD_SPIN_DIRECTION_2
@ DSHOT_CMD_BIDIR_EDT_MODE_ON
DSHOT Driver configuration structure.
telemetry packed as sent by some KISS ESC
STM32 DMA subsystem driver header.
DMA stream configuration structure.
Structure representing a DMA driver.
static const struct usb_config_descriptor config
uint32_t crc_errors
number of crc errors
DshotPackets dshotMotors
object managing dma control frame for outgoing command
mailbox_t mb
mailbox for dshot telemetry thread
DMADriver dmap
DMA driver associated with pwm timer.
PWMConfig pwm_conf
PWM config associated with pwm timer.
const DSHOTConfig * config
DMA config associated with pwm timer.
msg_t _mbBuf[1]
mailbox buffer for dshot telemetry thread
THD_WORKING_AREA(waDshotTlmRec, 512)
stack working area for dshot telemetry thread
uint32_t tlm_frame_nb
number of sucessful telemetry frame received
DMAConfig dma_conf
DMA config associated with pwm timer.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.