From 543a057f80f705e0139e6762d3164b6235942c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Mi=C5=A1i=C4=87?= Date: Sat, 31 Aug 2019 12:03:08 +0200 Subject: [PATCH] fmu-v4: add dshot timer config --- boards/px4/fmu-v4/default.cmake | 1 + boards/px4/fmu-v4/nuttx-config/include/board.h | 4 ++-- boards/px4/fmu-v4/nuttx-config/nsh/defconfig | 1 - .../px4/fmu-v4/nuttx-config/stackcheck/defconfig | 1 - boards/px4/fmu-v4/src/board_config.h | 3 +++ boards/px4/fmu-v4/src/timer_config.c | 14 ++++++++++++++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/boards/px4/fmu-v4/default.cmake b/boards/px4/fmu-v4/default.cmake index ba4dafbb2b..d189b479fd 100644 --- a/boards/px4/fmu-v4/default.cmake +++ b/boards/px4/fmu-v4/default.cmake @@ -23,6 +23,7 @@ px4_add_board( camera_trigger differential_pressure # all available differential pressure drivers distance_sensor # all available distance sensor drivers + dshot gps heater imu # all available imu drivers diff --git a/boards/px4/fmu-v4/nuttx-config/include/board.h b/boards/px4/fmu-v4/nuttx-config/include/board.h index 3c1a239dc4..cb68f6e3fa 100644 --- a/boards/px4/fmu-v4/nuttx-config/include/board.h +++ b/boards/px4/fmu-v4/nuttx-config/include/board.h @@ -236,8 +236,8 @@ /* UART8 has no alternate pin config */ /* UART RX DMA configurations */ -#define DMAMAP_USART1_RX DMAMAP_USART1_RX_2 -#define DMAMAP_USART6_RX DMAMAP_USART6_RX_2 +#define DMAMAP_USART1_RX DMAMAP_USART1_RX_1 /*DMA2 Stream 2*/ +#define DMAMAP_USART6_RX DMAMAP_USART6_RX_1 /*DMA2 Stream 1*/ /* * CAN diff --git a/boards/px4/fmu-v4/nuttx-config/nsh/defconfig b/boards/px4/fmu-v4/nuttx-config/nsh/defconfig index 7a93c4c594..9f876c0803 100644 --- a/boards/px4/fmu-v4/nuttx-config/nsh/defconfig +++ b/boards/px4/fmu-v4/nuttx-config/nsh/defconfig @@ -217,7 +217,6 @@ CONFIG_UART7_SERIAL_CONSOLE=y CONFIG_UART7_TXBUFSIZE=300 CONFIG_UART8_BAUD=57600 CONFIG_UART8_RXBUFSIZE=300 -CONFIG_UART8_RXDMA=y CONFIG_UART8_TXBUFSIZE=300 CONFIG_USART1_RXBUFSIZE=600 CONFIG_USART1_RXDMA=y diff --git a/boards/px4/fmu-v4/nuttx-config/stackcheck/defconfig b/boards/px4/fmu-v4/nuttx-config/stackcheck/defconfig index 7afa549107..8e01a66342 100644 --- a/boards/px4/fmu-v4/nuttx-config/stackcheck/defconfig +++ b/boards/px4/fmu-v4/nuttx-config/stackcheck/defconfig @@ -211,7 +211,6 @@ CONFIG_UART7_SERIAL_CONSOLE=y CONFIG_UART7_TXBUFSIZE=300 CONFIG_UART8_BAUD=57600 CONFIG_UART8_RXBUFSIZE=300 -CONFIG_UART8_RXDMA=y CONFIG_UART8_TXBUFSIZE=300 CONFIG_USART1_RXBUFSIZE=600 CONFIG_USART1_RXDMA=y diff --git a/boards/px4/fmu-v4/src/board_config.h b/boards/px4/fmu-v4/src/board_config.h index a6fe9ee29c..26d75ee013 100644 --- a/boards/px4/fmu-v4/src/board_config.h +++ b/boards/px4/fmu-v4/src/board_config.h @@ -355,6 +355,9 @@ #define BOARD_DMA_ALLOC_POOL_SIZE 5120 #define BOARD_HAS_ON_RESET 1 + +#define BOARD_DSHOT_MOTOR_ASSIGNMENT {3, 2, 1, 0, 4, 5}; + __BEGIN_DECLS /**************************************************************************************************** diff --git a/boards/px4/fmu-v4/src/timer_config.c b/boards/px4/fmu-v4/src/timer_config.c index 57cd33ec7c..97988c3434 100644 --- a/boards/px4/fmu-v4/src/timer_config.c +++ b/boards/px4/fmu-v4/src/timer_config.c @@ -60,6 +60,13 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = { .last_channel_index = 3, .handler = io_timer_handler0, .vectorno = STM32_IRQ_TIM1CC, + .dshot = { + .dma_base = DSHOT_DMA2_BASE, + .channel = DShot_Channel6, + .stream = DShot_Stream5, + .start_ccr_register = TIM_DMABASE_CCR1, + .channels_number = 4u /* CCR1, CCR2, CCR3 and CCR4 */ + } }, { @@ -71,6 +78,13 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = { .last_channel_index = 5, .handler = io_timer_handler1, .vectorno = STM32_IRQ_TIM4, + .dshot = { + .dma_base = DSHOT_DMA1_BASE, + .channel = DShot_Channel2, + .stream = DShot_Stream6, + .start_ccr_register = TIM_DMABASE_CCR2, + .channels_number = 2u /* CCR2 and CCR3 */ + } } };