1 | /* DMA'ize TX path */
|
2 | hdma_tx.Instance = DMA1_Stream6;
|
3 | hdma_tx.Init.Channel = DMA_CHANNEL_4;
|
4 | hdma_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
5 | hdma_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
6 | hdma_tx.Init.MemInc = DMA_MINC_ENABLE;
|
7 | hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
8 | hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
9 | hdma_tx.Init.Mode = DMA_NORMAL;
|
10 | hdma_tx.Init.Priority = DMA_PRIORITY_LOW;
|
11 | hdma_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
12 | hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
13 | hdma_tx.Init.MemBurst = DMA_MBURST_INC4;
|
14 | hdma_tx.Init.PeriphBurst = DMA_PBURST_INC4;
|
15 |
|
16 | HAL_DMA_Init(&hdma_tx);
|
17 |
|
18 | /* Link UART TX path to DMA */
|
19 | __HAL_LINKDMA(&uart2Handle, hdmatx, hdma_tx);
|
20 |
|
21 | /* DMA'ize RX path */
|
22 | hdma_rx.Instance = DMA1_Stream5;
|
23 | hdma_rx.Init.Channel = DMA_CHANNEL_4;
|
24 | hdma_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
25 | hdma_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
26 | hdma_rx.Init.MemInc = DMA_MINC_DISABLE;
|
27 | hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
28 | hdma_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
29 | hdma_rx.Init.Mode = DMA_NORMAL;
|
30 | hdma_rx.Init.Priority = DMA_PRIORITY_LOW;
|
31 | hdma_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
32 | hdma_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL;
|
33 | hdma_rx.Init.MemBurst = DMA_MBURST_SINGLE;
|
34 | hdma_rx.Init.PeriphBurst = DMA_PBURST_SINGLE;
|
35 |
|
36 | HAL_DMA_Init(&hdma_rx);
|
37 |
|
38 | /* Link UART RX path to DMA */
|
39 | __HAL_LINKDMA(&uart2Handle, hdmarx, hdma_rx);
|
40 |
|
41 |
|
42 | /* Set priorities */
|
43 | HAL_NVIC_SetPriority(DMA1_Stream6_IRQn, 14, 0);
|
44 | HAL_NVIC_EnableIRQ(DMA1_Stream6_IRQn);
|
45 |
|
46 | HAL_NVIC_SetPriority(DMA1_Stream5_IRQn, 14, 0);
|
47 | HAL_NVIC_EnableIRQ(DMA1_Stream5_IRQn);
|