14 #define DSHOT_DMA_DATA_LEN 16U
15 #define DSHOT_DMA_EXTRADATA_LEN 2U
18 #if STM32_DMA_SUPPORTS_DMAMUX == false
23 #define DSHOT_CONCAT_CAPTURE_NX(pre, tim, stream, channel) pre ## tim ## stream , pre ## tim ## channel
24 #define DSHOTS_1STREAM(tim) DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH1_DMA_STREAM, _CH1_DMA_CHANNEL)
25 #define DSHOTS_2STREAMS(tim) DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH1_DMA_STREAM, _CH1_DMA_CHANNEL), \
26 DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH2_DMA_STREAM, _CH2_DMA_CHANNEL)
27 #define DSHOTS_3STREAMS(tim) DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH1_DMA_STREAM, _CH1_DMA_CHANNEL), \
28 DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH2_DMA_STREAM, _CH2_DMA_CHANNEL), \
29 DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH3_DMA_STREAM, _CH3_DMA_CHANNEL)
30 #define DSHOTS_4STREAMS(tim) DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH1_DMA_STREAM, _CH1_DMA_CHANNEL), \
31 DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH2_DMA_STREAM, _CH2_DMA_CHANNEL), \
32 DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH3_DMA_STREAM, _CH3_DMA_CHANNEL), \
33 DSHOT_CONCAT_CAPTURE_NX(STM32_TIM, tim, _CH4_DMA_STREAM, _CH4_DMA_CHANNEL)
41 #define DSHOT_CONCAT_CAPTURE_NX(pre, tim, event) {STM32_DMA_STREAM_ID_ANY , pre ## tim ## event}
42 #define DSHOTS_1STREAM(tim) DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH1)
43 #define DSHOTS_2STREAMS(tim) DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH1), \
44 DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH2)
45 #define DSHOTS_3STREAMS(tim) DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH1), \
46 DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH2), \
47 DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH3)
48 #define DSHOTS_4STREAMS(tim) DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH1), \
49 DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH2), \
50 DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH3), \
51 DSHOT_CONCAT_CAPTURE_NX(STM32_DMAMUX1_TIM, tim, _CH4)
54 #if DSHOT_CHANNELS == 1
55 #define DSHOTS_CAPTURE_STREAMS(tim) DSHOTS_1STREAM(tim)
56 #elif DSHOT_CHANNELS == 2
57 #define DSHOTS_CAPTURE_STREAMS(tim) DSHOTS_2STREAMS(tim)
58 #elif DSHOT_CHANNELS == 3
59 #define DSHOTS_CAPTURE_STREAMS(tim) DSHOTS_3STREAMS(tim)
60 #elif DSHOT_CHANNELS == 4
61 #define DSHOTS_CAPTURE_STREAMS(tim) DSHOTS_4STREAMS(tim)
63 #error DSHOT_CHANNELS must be 1 to 4
67 #if !defined STM32_SYSCLK && !defined STM32_SYS_CK
68 #error neither STM32_SYSCLK or STM32_SYS_CK defined
70 #if !defined STM32_SYSCLK
71 #define STM32_SYSCLK STM32_SYS_CK
81 #if STM32_DMA_SUPPORTS_DMAMUX
96 __attribute__((aligned(32)))
126 bool dcache_memory_in_use;
168 #ifdef DSHOT_STATISTICS
198 return drcp->
rpms[index];
209 return (drcp->accumDecodeTime * 1e9f) /
STM32_SYSCLK / drcp->nbDecode;
TimICDriver icd
: input capture timer driver
#define DSHOT_DMA_EXTRADATA_LEN
TimICConfig icCfg
: input capture timer configuration
void dshotRpmCaptureStart(DshotRpmCapture *drcp, const DshotRpmCaptureConfig *cfg, stm32_tim_t *timer)
Configures and activates the DSHOT ERPS CAPTURE driver.
const DshotRpmCaptureConfig * config
: pointer to configuration structure
TimerDmaCache cache
: cache for timer and dma configuration
uint32_t rpms[DSHOT_CHANNELS]
: array of rpms
DshotRpmCaptureDmaBuffer * dma_capture
: pointer to the input capture DMA buffer
static uint32_t dshotRpmGetFrame(const DshotRpmCapture *drcp, uint8_t index)
return last collected erps frame
#define DSHOT_DMA_DATA_LEN
void dshotRpmCatchErps(DshotRpmCapture *drcp)
capture the DSHOT ERPS frame(s) : one frame for each DSHOT_CHANNELS
void dshotRpmCaptureStop(DshotRpmCapture *drcp)
stop the the DSHOT ERPS CAPTURE driver.
GPTDriver * gptd
: GPT Driver to manage microseconds timeout
structure defining dma channel
: DSHOT Rpm Capture Driver configuration structure.
DMA capture if (errFrame > 2000) { chSysHalt("p *dshotd.config.dma_capt_cfg.dma_capture"); } buffer.
STM32 DMA subsystem driver header.
DMA stream configuration structure.
Structure representing a DMA driver.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned long long uint64_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.