5#define TOTAL_NUM_UART 8
8#define USART1_ACTIVE_IDX 0
9#define USART2_ACTIVE_IDX 1
10#define USART3_ACTIVE_IDX 2
11#define UART4_ACTIVE_IDX 3
12#define LPUART1_ACTIVE_IDX 4
13#define USART5_ACTIVE_IDX 5
14#define USART6_ACTIVE_IDX 6
15#define USART7_ACTIVE_IDX 7
18#include "common/phal_G4/phal_G4.h"
20typedef uint32_t ptr_int;
68 bool dma_transfer_error;
69 bool dma_direct_mode_error;
70 bool dma_fifo_overrun;
74 bool dma_transfer_error;
75 bool dma_direct_mode_error;
76 bool dma_fifo_overrun;
91 uint8_t usart_active_num;
96 USART_TypeDef* periph;
185extern void usart_receive_complete_callback(
usart_init_t* handle);
188#define _DEF_USART_RXDMA_CONFIG(rx_addr_, priority_, USARTx, dma_num, channel_num, req_id) \
190 .periph_addr = (uint32_t)&((USARTx)->RDR), \
191 .mem_addr = (uint32_t)(rx_addr_), \
195 .periph_inc = false, \
196 .mem_to_mem = false, \
197 .priority = (priority_), \
199 .mem_size = DMA_SIZE_8BIT, \
200 .periph_size = DMA_SIZE_8BIT, \
202 .mux_request = (req_id), \
203 .channel_idx = (channel_num), \
204 .periph = DMA##dma_num, \
207#define _DEF_USART_TXDMA_CONFIG(tx_addr_, priority_, USARTx, dma_num, channel_num, req_id) \
209 .periph_addr = (uint32_t)&((USARTx)->TDR), \
210 .mem_addr = (uint32_t)(tx_addr_), \
214 .periph_inc = false, \
215 .mem_to_mem = false, \
216 .priority = (priority_), \
218 .mem_size = DMA_SIZE_8BIT, \
219 .periph_size = DMA_SIZE_8BIT, \
221 .mux_request = (req_id), \
222 .channel_idx = (channel_num), \
223 .periph = DMA##dma_num, \
226#define USART1_RXDMA_CONT_CONFIG(a, p) \
227 _DEF_USART_RXDMA_CONFIG(a, p, USART1, 1, 5, DMA_REQUEST_USART1_RX)
228#define USART1_TXDMA_CONT_CONFIG(a, p) \
229 _DEF_USART_TXDMA_CONFIG(a, p, USART1, 1, 7, DMA_REQUEST_USART1_TX)
231#define USART2_RXDMA_CONT_CONFIG(a, p) \
232 _DEF_USART_RXDMA_CONFIG(a, p, USART2, 1, 3, DMA_REQUEST_USART2_RX)
233#define USART2_TXDMA_CONT_CONFIG(a, p) \
234 _DEF_USART_TXDMA_CONFIG(a, p, USART2, 1, 4, DMA_REQUEST_USART2_TX)
236#define USART3_RXDMA_CONT_CONFIG(a, p) \
237 _DEF_USART_RXDMA_CONFIG(a, p, USART3, 1, 1, DMA_REQUEST_USART3_RX)
238#define USART3_TXDMA_CONT_CONFIG(a, p) \
239 _DEF_USART_TXDMA_CONFIG(a, p, USART3, 1, 2, DMA_REQUEST_USART3_TX)
241#define UART4_RXDMA_CONT_CONFIG(a, p) \
242 _DEF_USART_RXDMA_CONFIG(a, p, UART4, 2, 5, DMA_REQUEST_UART4_RX)
243#define UART4_TXDMA_CONT_CONFIG(a, p) \
244 _DEF_USART_TXDMA_CONFIG(a, p, UART4, 2, 3, DMA_REQUEST_UART4_TX)
246#define LPUART1_RXDMA_CONT_CONFIG(a, p) \
247 _DEF_USART_RXDMA_CONFIG(a, p, LPUART1, 2, 6, DMA_REQUEST_LPUART1_RX)
248#define LPUART1_TXDMA_CONT_CONFIG(a, p) \
249 _DEF_USART_TXDMA_CONFIG(a, p, LPUART1, 2, 7, DMA_REQUEST_LPUART1_TX)
void PHAL_usartTxBl(usart_init_t *handle, uint8_t *data, uint32_t len)
TX using no DMA (blocks until complete)
Definition usart.c:150
word_length_t
Definition usart.h:64
@ WORD_8
8-Bit word length
Definition usart.h:65
@ WORD_9
9-Bit word length
Definition usart.h:66
bool PHAL_initUSART(usart_init_t *handle, const uint32_t fck)
Initialize a USART Peripheral with desired settings.
Definition usart.c:34
bool PHAL_disableContinousRxDMA(usart_init_t *handle)
Disables the Continous RX that was previously used.
Definition usart.c:337
bool PHAL_usartRxBusy(usart_init_t *handle)
Returns whether USART peripheral is currently receiving data.
Definition usart.c:396
void PHAL_usartRxBl(usart_init_t *handle, uint8_t *data, uint32_t len)
RX using no DMA (blocks until complete)
Definition usart.c:182
bool PHAL_usartTxBusy(usart_init_t *handle)
Returns whether USART peripheral is currently transmitting data.
Definition usart.c:273
bool PHAL_usartRxDma(usart_init_t *handle, uint16_t *data, uint32_t len, bool cont)
Starts an rx using dma of a specific length.
Definition usart.c:277
hw_flow_ctl_t
Definition usart.h:76
@ CTS_RTS
Enable both CTS and RTS.
Definition usart.h:80
@ HW_DISABLE
Hardware flow control disable.
Definition usart.h:77
@ CTS
Enable Clear to send control.
Definition usart.h:78
@ RTS
Enable Request to send control.
Definition usart.h:79
obsample_t
Definition usart.h:88
@ OB_ENABLE
Enable one bit sampling.
Definition usart.h:90
@ OB_DISABLE
Disable one bit sampling.
Definition usart.h:89
parity_t
Definition usart.h:58
@ PT_ODD
Odd Parity.
Definition usart.h:60
@ PT_EVEN
Even Parity.
Definition usart.h:59
@ PT_NONE
Disable Parity bits.
Definition usart.h:61
stop_bits_t
Definition usart.h:69
@ SB_ONE_HALF
1.5 Stop bits
Definition usart.h:73
@ SB_TWO
Two Stop bits.
Definition usart.h:71
@ SB_HALF
One half stop bit.
Definition usart.h:72
@ SB_ONE
One Stop bit.
Definition usart.h:70
ovsample_t
Definition usart.h:83
@ OV_16
Oversample by 16.
Definition usart.h:84
@ OV_8
Oversample by 8.
Definition usart.h:85
bool PHAL_usartTxDma(usart_init_t *handle, uint16_t *data, uint32_t len)
Starts a tx using dma, use PHAL_usartTxDmaComplete to ensure the previous transmission is complete.
Definition usart.c:207