diff --git a/boards/holybro/durandal-v1/default.cmake b/boards/holybro/durandal-v1/default.cmake index a48428c6f4..c9056e4075 100644 --- a/boards/holybro/durandal-v1/default.cmake +++ b/boards/holybro/durandal-v1/default.cmake @@ -24,7 +24,7 @@ px4_add_board( camera_trigger differential_pressure # all available differential pressure drivers distance_sensor # all available distance sensor drivers - # dshot -- todo needslooking at + dshot gps heater #imu # all available imu drivers diff --git a/boards/holybro/durandal-v1/nuttx-config/include/board.h b/boards/holybro/durandal-v1/nuttx-config/include/board.h index ed12d2ea75..1ba4cc3ff8 100644 --- a/boards/holybro/durandal-v1/nuttx-config/include/board.h +++ b/boards/holybro/durandal-v1/nuttx-config/include/board.h @@ -374,8 +374,6 @@ /* UART RX DMA configurations */ -#define DMAMAP_USART1_RX DMAMAP_USART1_RX_2 -#define DMAMAP_USART6_RX DMAMAP_USART6_RX_2 #define DMAMAP_UART8_RX DMAMAP_DMA12_UART8RX_0 /* DMA1:81 */ #define DMAMAP_UART8_TX DMAMAP_DMA12_UART8TX_0 /* DMA1:82 */ diff --git a/boards/holybro/durandal-v1/src/board_config.h b/boards/holybro/durandal-v1/src/board_config.h index 2282a09191..3e7aab8488 100644 --- a/boards/holybro/durandal-v1/src/board_config.h +++ b/boards/holybro/durandal-v1/src/board_config.h @@ -340,6 +340,8 @@ #define DIRECT_INPUT_TIMER_CHANNELS 5 +#define BOARD_DSHOT_MOTOR_ASSIGNMENT {3, 2, 1, 0, 4}; + /* User GPIOs * * GPIO0-4 are the PWM servo outputs. diff --git a/boards/holybro/durandal-v1/src/timer_config.c b/boards/holybro/durandal-v1/src/timer_config.c index aaab861e57..92379e4080 100644 --- a/boards/holybro/durandal-v1/src/timer_config.c +++ b/boards/holybro/durandal-v1/src/timer_config.c @@ -60,7 +60,12 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = { .last_channel_index = 3, .handler = io_timer_handler0, .vectorno = STM32_IRQ_TIMCC, - + .dshot = { + .dma_base = STM32_DMA1_BASE, + .dmamap = DMAMAP_DMA12_TIM1UP_0, + .start_ccr_register = TIM_DMABASE_CCR1, + .channels_number = 4u /* CCR1, CCR2, CCR3 and CCR4 */ + } }, { .base = STM32_TIM4_BASE, @@ -71,6 +76,12 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = { .last_channel_index = 4, .handler = io_timer_handler1, .vectorno = STM32_IRQ_TIM4, + .dshot = { + .dma_base = STM32_DMA1_BASE, + .dmamap = DMAMAP_DMA12_TIM4UP_0, + .start_ccr_register = TIM_DMABASE_CCR2, + .channels_number = 1u /* CCR2 */ + } }, }; diff --git a/platforms/nuttx/NuttX/nuttx b/platforms/nuttx/NuttX/nuttx index 66401c8960..2d7920055f 160000 --- a/platforms/nuttx/NuttX/nuttx +++ b/platforms/nuttx/NuttX/nuttx @@ -1 +1 @@ -Subproject commit 66401c8960c5211ded41ae4f60bfb1746a84bd50 +Subproject commit 2d7920055f96f5734d5166e2c58daa16c6dff2f5 diff --git a/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c b/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c index fd14284f34..4f91d9ad74 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c @@ -174,11 +174,11 @@ void up_dshot_trigger(void) first_motor += motors_number; - stm32_dmasetup(dshot_handler[timer].dma_handle, - io_timers[timer].base + STM32_GTIM_DMAR_OFFSET, - (uint32_t)(dshot_burst_buffer[timer]), - dshot_handler[timer].dma_size, - DSHOT_DMA_SCR); + px4_stm32_dmasetup(dshot_handler[timer].dma_handle, + io_timers[timer].base + STM32_GTIM_DMAR_OFFSET, + (uint32_t)(dshot_burst_buffer[timer]), + dshot_handler[timer].dma_size, + DSHOT_DMA_SCR); // Clean UDE flag before DMA is started io_timer_update_dma_req(timer, false); diff --git a/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/dshot.h b/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/dshot.h index 14d7085e4b..7a7f1791bd 100644 --- a/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/dshot.h +++ b/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/dshot.h @@ -32,6 +32,6 @@ ****************************************************************************/ #pragma once - +#define px4_stm32_dmasetup stm32_dmasetup #include "../../../stm32_common/include/px4_arch/dshot.h" diff --git a/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/dshot.h b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/dshot.h index 14d7085e4b..449ca66b96 100644 --- a/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/dshot.h +++ b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/dshot.h @@ -33,5 +33,6 @@ #pragma once +#define px4_stm32_dmasetup stm32_dmasetup #include "../../../stm32_common/include/px4_arch/dshot.h" diff --git a/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/dshot.h b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/dshot.h index 14d7085e4b..449ca66b96 100644 --- a/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/dshot.h +++ b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/dshot.h @@ -33,5 +33,6 @@ #pragma once +#define px4_stm32_dmasetup stm32_dmasetup #include "../../../stm32_common/include/px4_arch/dshot.h" diff --git a/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/dshot.h b/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/dshot.h index 737fd54ee1..57512cee66 100644 --- a/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/dshot.h +++ b/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/dshot.h @@ -32,5 +32,18 @@ ****************************************************************************/ #pragma once +#include + +static inline void px4_stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr, + size_t ntransfers, uint32_t scr) +{ + struct stm32_dma_config_s cfg; + cfg.paddr = paddr; + cfg.maddr = maddr; + cfg.cfg1 = scr; + cfg.cfg2 = 0; + cfg.ndata = ntransfers; + stm32_dmasetup(handle, &cfg); +} #include "../../../stm32_common/include/px4_arch/dshot.h"