diff --git a/src/main/drivers/dshot_dpwm.h b/src/main/drivers/dshot_dpwm.h index c44a448556..4f1fefe539 100644 --- a/src/main/drivers/dshot_dpwm.h +++ b/src/main/drivers/dshot_dpwm.h @@ -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 #if defined(STM32H7) #define DSHOT_DMA_BUFFER_ATTRIBUTE DMA_RAM +#elif defined(STM32G4) +#define DSHOT_DMA_BUFFER_ATTRIBUTE DMA_RAM_W #elif defined(STM32F7) #define DSHOT_DMA_BUFFER_ATTRIBUTE FAST_RAM_ZERO_INIT #else -#define DSHOT_DMA_BUFFER_ATTRIBUTE +#define DSHOT_DMA_BUFFER_ATTRIBUTE // None #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 #else #define DSHOT_DMA_BUFFER_UNIT uint8_t @@ -93,7 +95,7 @@ typedef struct { #if defined(USE_DSHOT) uint16_t outputPeriod; #if defined(USE_DSHOT_DMAR) -#if defined(STM32F7) || defined(STM32H7) +#if defined(STM32F7) || defined(STM32H7) || defined(STM32G4) TIM_HandleTypeDef timHandle; DMA_HandleTypeDef hdma_tim; #endif @@ -113,7 +115,7 @@ typedef struct motorDmaOutput_s { uint16_t timerDmaSource; uint8_t timerDmaIndex; bool configured; -#ifdef STM32H7 +#if defined(STM32H7) || defined(STM32G4) TIM_HandleTypeDef TimHandle; DMA_HandleTypeDef hdma_tim; IO_t io; diff --git a/src/main/drivers/pwm_output_dshot_hal_hal.c b/src/main/drivers/pwm_output_dshot_hal_hal.c index b9d5d5daa3..f557a7e62a 100644 --- a/src/main/drivers/pwm_output_dshot_hal_hal.c +++ b/src/main/drivers/pwm_output_dshot_hal_hal.c @@ -386,10 +386,12 @@ P - High - High - motor->timer->hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD ; motor->timer->hdma_tim.Init.Mode = DMA_NORMAL; 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.PeriphBurst = DMA_PBURST_SINGLE; motor->timer->hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE; motor->timer->hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; +#endif motor->timer->dmaBurstBuffer = &dshotBurstDmaBuffer[timerIndex][0]; motor->timer->timHandle = motor->TimHandle; @@ -415,10 +417,12 @@ P - High - High - motor->hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD ; motor->hdma_tim.Init.Mode = DMA_NORMAL; motor->hdma_tim.Init.Priority = DMA_PRIORITY_HIGH; +#if !defined(STM32G4) motor->hdma_tim.Init.FIFOMode = DMA_FIFOMODE_DISABLE; motor->hdma_tim.Init.PeriphBurst = DMA_PBURST_SINGLE; motor->hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE; motor->hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; +#endif motor->dmaBuffer = &dshotDmaBuffer[motorIndex][0]; motor->dmaBuffer[DSHOT_DMA_BUFFER_SIZE-2] = 0; // XXX Is this necessary? -> probably.