Skip to content

Commit

Permalink
feat(usart): enable DMA periph clock
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Jul 12, 2023
1 parent 47a951c commit d8d4619
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 16 deletions.
1 change: 1 addition & 0 deletions radio/src/targets/common/arm/stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC}
../common/arm/stm32/module_timer_driver.cpp
../common/arm/stm32/stm32_switch_driver.cpp
../common/arm/stm32/stm32_adc.cpp
../common/arm/stm32/stm32_dma.cpp
../common/arm/stm32/stm32_gpio_driver.cpp
../common/arm/stm32/mixer_scheduler_driver.cpp
)
Expand Down
32 changes: 32 additions & 0 deletions radio/src/targets/common/arm/stm32/stm32_dma.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) EdgeTx
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include "stm32_dma.h"
#include "STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h"

void stm32_dma_enable_clock(DMA_TypeDef* DMAx)
{
if (DMAx == DMA1) {
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1);
} else if (DMAx == DMA2) {
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA2);
}
}
2 changes: 2 additions & 0 deletions radio/src/targets/common/arm/stm32/stm32_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ inline static bool stm32_dma_check_tc_flag(DMA_TypeDef* DMAx, uint32_t DMA_Strea

return true;
}

void stm32_dma_enable_clock(DMA_TypeDef* DMAx);
2 changes: 2 additions & 0 deletions radio/src/targets/common/arm/stm32/stm32_usart_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ void stm32_usart_init_rx_dma(const stm32_usart_t* usart, const void* buffer, uin
NVIC_DisableIRQ(usart->IRQn);
}

stm32_dma_enable_clock(usart->rxDMA);
LL_DMA_DeInit(usart->rxDMA, usart->rxDMA_Stream);

LL_DMA_InitTypeDef dmaInit;
Expand Down Expand Up @@ -346,6 +347,7 @@ void stm32_usart_send_buffer(const stm32_usart_t* usart, const uint8_t * data, u
_half_duplex_output(usart);

if (usart->txDMA) {
stm32_dma_enable_clock(usart->txDMA);
LL_DMA_DeInit(usart->txDMA, usart->txDMA_Stream);

LL_DMA_InitTypeDef dmaInit;
Expand Down
6 changes: 0 additions & 6 deletions radio/src/targets/horus/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ void boardInit()
AUDIO_RCC_AHB1Periph |
KEYS_RCC_AHB1Periph |
ADC_RCC_AHB1Periph |
#if defined(RADIO_FAMILY_T16)
FLYSKY_HALL_RCC_AHB1Periph |
#endif
AUX_SERIAL_RCC_AHB1Periph |
AUX2_SERIAL_RCC_AHB1Periph |
TELEMETRY_RCC_AHB1Periph |
Expand All @@ -121,9 +118,6 @@ void boardInit()
ADC_RCC_APB1Periph |
TIMER_2MHz_RCC_APB1Periph |
AUDIO_RCC_APB1Periph |
#if defined(RADIO_FAMILY_T16)
FLYSKY_HALL_RCC_APB1Periph |
#endif
TELEMETRY_RCC_APB1Periph |
AUDIO_RCC_APB1Periph |
MIXER_SCHEDULER_TIMER_RCC_APB1Periph |
Expand Down
4 changes: 0 additions & 4 deletions radio/src/targets/horus/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,10 +854,6 @@
#define FLYSKY_HALL_SERIAL_TX_GPIO_PIN LL_GPIO_PIN_0 // PA.00
#define FLYSKY_HALL_SERIAL_RX_GPIO_PIN LL_GPIO_PIN_1 // PA.01
#define FLYSKY_HALL_SERIAL_GPIO_AF LL_GPIO_AF_8

#define FLYSKY_HALL_RCC_AHB1Periph RCC_AHB1Periph_DMA1
#define FLYSKY_HALL_RCC_APB1Periph RCC_APB1Periph_UART4

#define FLYSKY_HALL_SERIAL_USART_IRQHandler UART4_IRQHandler
#define FLYSKY_HALL_SERIAL_USART_IRQn UART4_IRQn
#define FLYSKY_HALL_SERIAL_DMA DMA1
Expand Down
2 changes: 0 additions & 2 deletions radio/src/targets/nv14/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void delay_self(int count)
AUDIO_RCC_AHB1Periph |\
HAPTIC_RCC_AHB1Periph |\
INTMODULE_RCC_AHB1Periph |\
FLYSKY_HALL_RCC_AHB1Periph |\
EXTMODULE_RCC_AHB1Periph\
)
#define RCC_AHB3PeriphMinimum (SDRAM_RCC_AHB3Periph)
Expand All @@ -136,7 +135,6 @@ void delay_self(int count)
)

#define RCC_APB1PeriphOther (TELEMETRY_RCC_APB1Periph |\
FLYSKY_HALL_RCC_APB1Periph |\
MIXER_SCHEDULER_TIMER_RCC_APB1Periph \
)
#define RCC_APB2PeriphMinimum (LCD_RCC_APB2Periph)
Expand Down
4 changes: 0 additions & 4 deletions radio/src/targets/nv14/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,6 @@
#define FLYSKY_HALL_SERIAL_TX_GPIO_PIN LL_GPIO_PIN_0 // PA.00
#define FLYSKY_HALL_SERIAL_RX_GPIO_PIN LL_GPIO_PIN_1 // PA.01
#define FLYSKY_HALL_SERIAL_GPIO_AF LL_GPIO_AF_8

#define FLYSKY_HALL_RCC_AHB1Periph RCC_AHB1Periph_DMA1
#define FLYSKY_HALL_RCC_APB1Periph RCC_APB1Periph_UART4

#define FLYSKY_HALL_SERIAL_USART_IRQHandler UART4_IRQHandler
#define FLYSKY_HALL_SERIAL_USART_IRQn UART4_IRQn
#define FLYSKY_HALL_SERIAL_DMA DMA1
Expand Down

0 comments on commit d8d4619

Please sign in to comment.