[G4] DShot support (pure HAL)
This commit is contained in:
parent
b55f37b730
commit
b94659412c
|
@ -62,13 +62,15 @@ motorDevice_t *dshotPwmDevInit(const struct motorDevConfig_s *motorConfig, uint1
|
||||||
// For H7, DMA buffer is placed in a dedicated segment for coherency management
|
// For H7, DMA buffer is placed in a dedicated segment for coherency management
|
||||||
#if defined(STM32H7)
|
#if defined(STM32H7)
|
||||||
#define DSHOT_DMA_BUFFER_ATTRIBUTE DMA_RAM
|
#define DSHOT_DMA_BUFFER_ATTRIBUTE DMA_RAM
|
||||||
|
#elif defined(STM32G4)
|
||||||
|
#define DSHOT_DMA_BUFFER_ATTRIBUTE DMA_RAM_W
|
||||||
#elif defined(STM32F7)
|
#elif defined(STM32F7)
|
||||||
#define DSHOT_DMA_BUFFER_ATTRIBUTE FAST_RAM_ZERO_INIT
|
#define DSHOT_DMA_BUFFER_ATTRIBUTE FAST_RAM_ZERO_INIT
|
||||||
#else
|
#else
|
||||||
#define DSHOT_DMA_BUFFER_ATTRIBUTE
|
#define DSHOT_DMA_BUFFER_ATTRIBUTE // None
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
|
#if defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32G4)
|
||||||
#define DSHOT_DMA_BUFFER_UNIT uint32_t
|
#define DSHOT_DMA_BUFFER_UNIT uint32_t
|
||||||
#else
|
#else
|
||||||
#define DSHOT_DMA_BUFFER_UNIT uint8_t
|
#define DSHOT_DMA_BUFFER_UNIT uint8_t
|
||||||
|
@ -93,7 +95,7 @@ typedef struct {
|
||||||
#if defined(USE_DSHOT)
|
#if defined(USE_DSHOT)
|
||||||
uint16_t outputPeriod;
|
uint16_t outputPeriod;
|
||||||
#if defined(USE_DSHOT_DMAR)
|
#if defined(USE_DSHOT_DMAR)
|
||||||
#if defined(STM32F7) || defined(STM32H7)
|
#if defined(STM32F7) || defined(STM32H7) || defined(STM32G4)
|
||||||
TIM_HandleTypeDef timHandle;
|
TIM_HandleTypeDef timHandle;
|
||||||
DMA_HandleTypeDef hdma_tim;
|
DMA_HandleTypeDef hdma_tim;
|
||||||
#endif
|
#endif
|
||||||
|
@ -113,7 +115,7 @@ typedef struct motorDmaOutput_s {
|
||||||
uint16_t timerDmaSource;
|
uint16_t timerDmaSource;
|
||||||
uint8_t timerDmaIndex;
|
uint8_t timerDmaIndex;
|
||||||
bool configured;
|
bool configured;
|
||||||
#ifdef STM32H7
|
#if defined(STM32H7) || defined(STM32G4)
|
||||||
TIM_HandleTypeDef TimHandle;
|
TIM_HandleTypeDef TimHandle;
|
||||||
DMA_HandleTypeDef hdma_tim;
|
DMA_HandleTypeDef hdma_tim;
|
||||||
IO_t io;
|
IO_t io;
|
||||||
|
|
|
@ -386,10 +386,12 @@ P - High - High -
|
||||||
motor->timer->hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD ;
|
motor->timer->hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD ;
|
||||||
motor->timer->hdma_tim.Init.Mode = DMA_NORMAL;
|
motor->timer->hdma_tim.Init.Mode = DMA_NORMAL;
|
||||||
motor->timer->hdma_tim.Init.Priority = DMA_PRIORITY_HIGH;
|
motor->timer->hdma_tim.Init.Priority = DMA_PRIORITY_HIGH;
|
||||||
|
#if !defined(STM32G4)
|
||||||
motor->timer->hdma_tim.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
motor->timer->hdma_tim.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
motor->timer->hdma_tim.Init.PeriphBurst = DMA_PBURST_SINGLE;
|
motor->timer->hdma_tim.Init.PeriphBurst = DMA_PBURST_SINGLE;
|
||||||
motor->timer->hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE;
|
motor->timer->hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE;
|
||||||
motor->timer->hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
motor->timer->hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
motor->timer->dmaBurstBuffer = &dshotBurstDmaBuffer[timerIndex][0];
|
motor->timer->dmaBurstBuffer = &dshotBurstDmaBuffer[timerIndex][0];
|
||||||
motor->timer->timHandle = motor->TimHandle;
|
motor->timer->timHandle = motor->TimHandle;
|
||||||
|
@ -415,10 +417,12 @@ P - High - High -
|
||||||
motor->hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD ;
|
motor->hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD ;
|
||||||
motor->hdma_tim.Init.Mode = DMA_NORMAL;
|
motor->hdma_tim.Init.Mode = DMA_NORMAL;
|
||||||
motor->hdma_tim.Init.Priority = DMA_PRIORITY_HIGH;
|
motor->hdma_tim.Init.Priority = DMA_PRIORITY_HIGH;
|
||||||
|
#if !defined(STM32G4)
|
||||||
motor->hdma_tim.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
motor->hdma_tim.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
motor->hdma_tim.Init.PeriphBurst = DMA_PBURST_SINGLE;
|
motor->hdma_tim.Init.PeriphBurst = DMA_PBURST_SINGLE;
|
||||||
motor->hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE;
|
motor->hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE;
|
||||||
motor->hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
motor->hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
motor->dmaBuffer = &dshotDmaBuffer[motorIndex][0];
|
motor->dmaBuffer = &dshotDmaBuffer[motorIndex][0];
|
||||||
motor->dmaBuffer[DSHOT_DMA_BUFFER_SIZE-2] = 0; // XXX Is this necessary? -> probably.
|
motor->dmaBuffer[DSHOT_DMA_BUFFER_SIZE-2] = 0; // XXX Is this necessary? -> probably.
|
||||||
|
|
Loading…
Reference in New Issue