diff --git a/src/usart.c b/src/uart.c copy from src/usart.c copy to src/uart.c --- a/src/usart.c +++ b/src/uart.c @@ -1,6 +1,6 @@ #include "stm32f0xx_hal.h" -#include "usart.h" +#include "uart.h" #include "config.h" #include "gpio.h" @@ -39,36 +39,36 @@ void uart_init(void) huart1.AdvancedInit.DMADisableonRxError = UART_ADVFEATURE_DMA_DISABLEONRXERROR; HAL_UART_Init(&huart1); - - __DMA1_CLK_ENABLE(); - - // Init UART DMA - hdma_usart1_rx.Instance = DMA1_Channel3; - hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_usart1_rx.Init.Mode = DMA_CIRCULAR; - hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW; - HAL_DMA_Init(&hdma_usart1_rx); - - __HAL_LINKDMA(&huart1,hdmarx,hdma_usart1_rx); - - hdma_usart1_tx.Instance = DMA1_Channel2; - hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_usart1_tx.Init.MemInc = DMA_MINC_DISABLE; - hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_usart1_tx.Init.Mode = DMA_NORMAL; - hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW; - HAL_DMA_Init(&hdma_usart1_tx); - - __HAL_LINKDMA(&huart1,hdmatx,hdma_usart1_tx); - -// HAL_NVIC_SetPriority(DMA1_Channel2_3_IRQn, 0, 0); -// HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn); +// +// __DMA1_CLK_ENABLE(); +// +// // Init UART DMA +// hdma_usart1_rx.Instance = DMA1_Channel3; +// hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; +// hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE; +// hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE; +// hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; +// hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; +// hdma_usart1_rx.Init.Mode = DMA_CIRCULAR; +// hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW; +// HAL_DMA_Init(&hdma_usart1_rx); +// +// __HAL_LINKDMA(&huart1,hdmarx,hdma_usart1_rx); +// +// hdma_usart1_tx.Instance = DMA1_Channel2; +// hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; +// hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE; +// hdma_usart1_tx.Init.MemInc = DMA_MINC_DISABLE; +// hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; +// hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; +// hdma_usart1_tx.Init.Mode = DMA_NORMAL; +// hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW; +// HAL_DMA_Init(&hdma_usart1_tx); +// +// __HAL_LINKDMA(&huart1,hdmatx,hdma_usart1_tx); +// +//// HAL_NVIC_SetPriority(DMA1_Channel2_3_IRQn, 0, 0); +//// HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn); HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); //HAL_NVIC_EnableIRQ(USART1_IRQn);