From 0776c47d88ba9e4804c6c59af29604748b9f153c Mon Sep 17 00:00:00 2001 From: alexklimaj Date: Tue, 24 Jan 2023 11:36:06 -0700 Subject: [PATCH] Enable ARK CANnode pwm outputs 7 and 8 --- .../ark/cannode/nuttx-config/include/board_dma_map.h | 6 ++++++ boards/ark/cannode/src/board_config.h | 3 ++- boards/ark/cannode/src/timer_config.cpp | 10 +++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/boards/ark/cannode/nuttx-config/include/board_dma_map.h b/boards/ark/cannode/nuttx-config/include/board_dma_map.h index 0eb81fc589..e598299d5f 100644 --- a/boards/ark/cannode/nuttx-config/include/board_dma_map.h +++ b/boards/ark/cannode/nuttx-config/include/board_dma_map.h @@ -42,3 +42,9 @@ //--------------------------------------------//---------------------------//---------------- #define DMACHAN_SPI1_RX DMAMAP_SPI1_RX_2 // DMA2, Stream 2, Channel 3 #define DMACHAN_SPI1_TX DMAMAP_SPI1_TX_2 // DMA2, Stream 5, Channel 3 + +// Assigned in timer_config.cpp + +// Timer 2 /* DMA1, Stream 7, Channel 3 DMAMAP_TIM2_UP_2 */ +// Timer 3 /* DMA1, Stream 2, Channel 5 DMAMAP_TIM3_UP */ +// Timer 4 /* DMA1, Stream 6, Channel 2 DMAMAP_TIM4_UP */ diff --git a/boards/ark/cannode/src/board_config.h b/boards/ark/cannode/src/board_config.h index bb820a7b66..03e0137645 100644 --- a/boards/ark/cannode/src/board_config.h +++ b/boards/ark/cannode/src/board_config.h @@ -62,7 +62,8 @@ #define GPIO_TIM1_CH3 /* PA10 */ (GPIO_TIM1_CH3_1|GPIO_OPENDRAIN|GPIO_SPEED_2MHz) /* PWM Outputs */ -#define DIRECT_PWM_OUTPUT_CHANNELS 6 // Actually 8 +#define BOARD_NUM_IO_TIMERS 3 +#define DIRECT_PWM_OUTPUT_CHANNELS 8 #define GPIO_TIM2_CH1_RESET /* PA0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN0) #define GPIO_TIM2_CH2_RESET /* PA1 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN1) diff --git a/boards/ark/cannode/src/timer_config.cpp b/boards/ark/cannode/src/timer_config.cpp index bc69d4b7ea..5f24fea5ad 100644 --- a/boards/ark/cannode/src/timer_config.cpp +++ b/boards/ark/cannode/src/timer_config.cpp @@ -34,9 +34,9 @@ #include constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { - initIOTimer(Timer::Timer2), - initIOTimer(Timer::Timer3), - //initIOTimer(Timer::Timer4), + initIOTimer(Timer::Timer2, DMA{DMA::Index1, DMA::Stream7, DMA::Channel3}), + initIOTimer(Timer::Timer3, DMA{DMA::Index1, DMA::Stream2, DMA::Channel5}), + initIOTimer(Timer::Timer4, DMA{DMA::Index1, DMA::Stream6, DMA::Channel2}), }; constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { @@ -46,8 +46,8 @@ constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel1}, {GPIO::PortB, GPIO::Pin4}), initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel2}, {GPIO::PortB, GPIO::Pin5}), initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel3}, {GPIO::PortB, GPIO::Pin0}), - //initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel4}, {GPIO::PortB, GPIO::Pin1}), - //initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel2}, {GPIO::PortB, GPIO::Pin7}), + initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel4}, {GPIO::PortB, GPIO::Pin1}), + initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel2}, {GPIO::PortB, GPIO::Pin7}), }; constexpr io_timers_channel_mapping_t io_timers_channel_mapping =