33#define USART_CR1(usart_base) MMIO32((usart_base) + 0x00)
34#define USART1_CR1 USART_CR1(USART1_BASE)
35#define USART2_CR1 USART_CR1(USART2_BASE)
36#define USART3_CR1 USART_CR1(USART3_BASE)
37#if defined(USART4_BASE)
38#define USART4_CR1 USART_CR1(USART4_BASE)
40#if defined(UART4_BASE)
41#define UART4_CR1 USART_CR1(UART4_BASE)
43#if defined(UART5_BASE)
44#define UART5_CR1 USART_CR1(UART5_BASE)
48#define USART_CR2(usart_base) MMIO32((usart_base) + 0x04)
49#define USART1_CR2 USART_CR2(USART1_BASE)
50#define USART2_CR2 USART_CR2(USART2_BASE)
51#define USART3_CR2 USART_CR2(USART3_BASE)
52#if defined(USART4_BASE)
53#define USART4_CR2 USART_CR2(USART4_BASE)
55#if defined(UART4_BASE)
56#define UART4_CR2 USART_CR2(UART4_BASE)
58#if defined(UART5_BASE)
59#define UART5_CR2 USART_CR2(UART5_BASE)
63#define USART_CR3(usart_base) MMIO32((usart_base) + 0x08)
64#define USART1_CR3 USART_CR3(USART1_BASE)
65#define USART2_CR3 USART_CR3(USART2_BASE)
66#define USART3_CR3 USART_CR3(USART3_BASE)
67#if defined(USART4_BASE)
68#define USART4_CR3 USART_CR3(USART4_BASE)
70#if defined(UART4_BASE)
71#define UART4_CR3 USART_CR3(UART4_BASE)
73#if defined(UART5_BASE)
74#define UART5_CR3 USART_CR3(UART5_BASE)
78#define USART_BRR(usart_base) MMIO32((usart_base) + 0x0C)
79#define USART1_BRR USART_BRR(USART1_BASE)
80#define USART2_BRR USART_BRR(USART2_BASE)
81#define USART3_BRR USART_BRR(USART3_BASE)
82#if defined(USART4_BASE)
83#define USART4_BRR USART_BRR(USART4_BASE)
85#if defined(UART4_BASE)
86#define UART4_BRR USART_BRR(UART4_BASE)
88#if defined(UART5_BASE)
89#define UART5_BRR USART_BRR(UART5_BASE)
93#define USART_GTPR(usart_base) MMIO32((usart_base) + 0x10)
94#define USART1_GTPR USART_GTPR(USART1_BASE)
95#define USART2_GTPR USART_GTPR(USART2_BASE)
96#define USART3_GTPR USART_GTPR(USART3_BASE)
97#if defined(USART4_BASE)
98#define USART4_GTPR USART_GTPR(USART4_BASE)
100#if defined(UART4_BASE)
101#define UART4_GTPR USART_GTPR(UART4_BASE)
103#if defined(UART5_BASE)
104#define UART5_GTPR USART_GTPR(UART5_BASE)
108#define USART_RTOR(usart_base) MMIO32((usart_base) + 0x14)
109#define USART1_RTOR USART_RTOR(USART1_BASE)
110#define USART2_RTOR USART_RTOR(USART2_BASE)
111#define USART3_RTOR USART_RTOR(USART3_BASE)
112#if defined(USART4_BASE)
113#define USART4_RTOR USART_RTOR(USART4_BASE)
115#if defined(UART4_BASE)
116#define UART4_RTOR USART_RTOR(UART4_BASE)
118#if defined(UART5_BASE)
119#define UART5_RTOR USART_RTOR(UART5_BASE)
123#define USART_RQR(usart_base) MMIO32((usart_base) + 0x18)
124#define USART1_RQR USART_RQR(USART1_BASE)
125#define USART2_RQR USART_RQR(USART2_BASE)
126#define USART3_RQR USART_RQR(USART3_BASE)
127#if defined(USART4_BASE)
128#define USART4_RQR USART_RQR(USART4_BASE)
130#if defined(UART4_BASE)
131#define UART4_RQR USART_RQR(UART4_BASE)
133#if defined(UART5_BASE)
134#define UART5_RQR USART_RQR(UART5_BASE)
138#define USART_ISR(usart_base) MMIO32((usart_base) + 0x1C)
139#define USART1_ISR USART_ISR(USART1_BASE)
140#define USART2_ISR USART_ISR(USART2_BASE)
141#define USART3_ISR USART_ISR(USART3_BASE)
142#if defined(USART4_BASE)
143#define USART4_ISR USART_ISR(USART4_BASE)
145#if defined(UART4_BASE)
146#define UART4_ISR USART_ISR(UART4_BASE)
148#if defined(UART5_BASE)
149#define UART5_ISR USART_ISR(UART5_BASE)
153#define USART_ICR(usart_base) MMIO32((usart_base) + 0x20)
154#define USART1_ICR USART_ICR(USART1_BASE)
155#define USART2_ICR USART_ICR(USART2_BASE)
156#define USART3_ICR USART_ICR(USART3_BASE)
157#if defined(USART4_BASE)
158#define USART4_ICR USART_ICR(USART4_BASE)
160#if defined(UART4_BASE)
161#define UART4_ICR USART_ICR(UART4_BASE)
163#if defined(UART5_BASE)
164#define UART5_ICR USART_ICR(UART5_BASE)
168#define USART_RDR(usart_base) MMIO32((usart_base) + 0x24)
169#define USART1_RDR USART_RDR(USART1_BASE)
170#define USART2_RDR USART_RDR(USART2_BASE)
171#define USART3_RDR USART_RDR(USART3_BASE)
172#if defined(USART4_BASE)
173#define USART4_RDR USART_RDR(USART4_BASE)
175#if defined(UART4_BASE)
176#define UART4_RDR USART_RDR(UART4_BASE)
178#if defined(UART5_BASE)
179#define UART5_RDR USART_RDR(UART5_BASE)
183#define USART_TDR(usart_base) MMIO32((usart_base) + 0x28)
184#define USART1_TDR USART_TDR(USART1_BASE)
185#define USART2_TDR USART_TDR(USART2_BASE)
186#define USART3_TDR USART_TDR(USART3_BASE)
187#if defined(USART4_BASE)
188#define USART4_TDR USART_TDR(USART4_BASE)
190#if defined(UART4_BASE)
191#define UART4_TDR USART_TDR(UART4_BASE)
193#if defined(UART5_BASE)
194#define UART5_TDR USART_TDR(UART5_BASE)
206#define USART_FLAG_PE USART_ISR_PE
207#define USART_FLAG_FE USART_ISR_FE
208#define USART_FLAG_NF USART_ISR_NF
209#define USART_FLAG_ORE USART_ISR_ORE
210#define USART_FLAG_IDLE USART_ISR_IDLE
211#define USART_FLAG_RXNE USART_ISR_RXNE
212#define USART_FLAG_TC USART_ISR_TC
213#define USART_FLAG_TXE USART_ISR_TXE
226#define USART_CR1_M1 (1 << 28)
229#define USART_CR1_EOBIE (1 << 27)
232#define USART_CR1_RTOIE (1 << 26)
234#define USART_CR1_DEAT_SHIFT 21
235#define USART_CR1_DEAT (0x1F << USART_CR1_DEAT_SHIFT)
237#define USART_CR1_DEAT_VAL(x) ((x) << USART_CR1_DEAT_SHIFT)
239#define USART_CR1_DEDT_SHIFT 16
240#define USART_CR1_DEDT (0x1F << USART_CR1_DEDT_SHIFT)
242#define USART_CR1_DEDT_VAL(x) ((x) << USART_CR1_DEDT_SHIFT)
245#define USART_CR1_OVER8 (1 << 15)
248#define USART_CR1_CMIE (1 << 14)
251#define USART_CR1_MME (1 << 13)
254#define USART_CR1_M0 (1 << 12)
256#define USART_CR1_M USART_CR1_M0
259#define USART_CR1_WAKE (1 << 11)
262#define USART_CR1_PCE (1 << 10)
265#define USART_CR1_PS (1 << 9)
268#define USART_CR1_PEIE (1 << 8)
271#define USART_CR1_TXEIE (1 << 7)
274#define USART_CR1_TCIE (1 << 6)
277#define USART_CR1_RXNEIE (1 << 5)
280#define USART_CR1_IDLEIE (1 << 4)
283#define USART_CR1_TE (1 << 3)
286#define USART_CR1_RE (1 << 2)
289#define USART_CR1_UESM (1 << 1)
292#define USART_CR1_UE (1 << 0)
301#define USART_CR2_ADD_SHIFT 24
302#define USART_CR2_ADD (0xFF << USART_CR2_ADD_SHIFT)
303#define USART_CR2_ADD_VAL(x) ((x) << USART_CR2_ADD_SHIFT)
305#define USART_CR2_ABRMOD_MASK 3
306#define USART_CR2_ABRMOD_SHIFT 21
312#define USART_CR2_ABRMOD_STARTBIT (0x0 << USART_CR2_ABRMOD_SHIFT)
313#define USART_CR2_ABRMOD_FALL_EDGE (0x1 << USART_CR2_ABRMOD_SHIFT)
314#define USART_CR2_ABRMOD_FRAME_0x7F (0x2 << USART_CR2_ABRMOD_SHIFT)
315#define USART_CR2_ABRMOD_FRAME_0x55 (0x3 << USART_CR2_ABRMOD_SHIFT)
319#define USART_CR2_RTOEN (1 << 23)
322#define USART_CR2_ABREN (1 << 20)
325#define USART_CR2_MSBFIRST (1 << 19)
328#define USART_CR2_DATAINV (1 << 18)
331#define USART_CR2_TXINV (1 << 17)
334#define USART_CR2_RXINV (1 << 16)
337#define USART_CR2_SWAP (1 << 15)
340#define USART_CR2_LINEN (1 << 14)
343#define USART_CR2_CLKEN (1 << 11)
346#define USART_CR2_CPOL (1 << 10)
349#define USART_CR2_CPHA (1 << 9)
352#define USART_CR2_LBCL (1 << 8)
355#define USART_CR2_LBDIE (1 << 6)
358#define USART_CR2_LBDL (1 << 5)
361#define USART_CR2_ADDM7 (1 << 4)
370#define USART_CR3_WUFIE (1 << 22)
373#define USART_CR3_WUS_ADDRMATCH (0x0 << 20)
374#define USART_CR3_WUS_START_BIT (0x2 << 20)
375#define USART_CR3_WUS_RXNE (0x3 << 20)
377#define USART_CR3_SCARCNT_SHIFT 17
378#define USART_CR3_SCARCNT_MASK 0x7
380#define USART_CR3_SCARCNT_DISABLE (0 << USART_CR3_SCARCNT_SHIFT)
381#define USART_CR3_SCARCNT_VAL(x) ((x) << USART_CR3_SCARCNT_SHIFT)
384#define USART_CR3_DEP (1 << 15)
387#define USART_CR3_DEM (1 << 14)
390#define USART_CR3_DDRE (1 << 13)
393#define USART_CR3_OVRDIS (1 << 12)
396#define USART_CR3_ONEBIT (1 << 11)
399#define USART_CR3_CTSIE (1 << 10)
402#define USART_CR3_CTSE (1 << 9)
405#define USART_CR3_RTSE (1 << 8)
408#define USART_CR3_DMAT (1 << 7)
411#define USART_CR3_DMAR (1 << 6)
414#define USART_CR3_SCEN (1 << 5)
417#define USART_CR3_NACK (1 << 4)
420#define USART_CR3_HDSEL (1 << 3)
423#define USART_CR3_IRLP (1 << 2)
426#define USART_CR3_IREN (1 << 1)
429#define USART_CR3_EIE (1 << 0)
437#define USART_GTPR_GT_SHIFT 8
438#define USART_GTPR_GT (0xFF << USART_GTPR_GT_SHIFT)
439#define USART_GTPR_GT_VAL(x) ((x) << USART_GTPR_GT_SHIFT)
441#define USART_GTPR_PSC_SHIFT 0
442#define USART_GTPR_PSC (0xFF << USART_GTPR_PSC_SHIFT)
443#define USART_GTPR_PSC_VAL(x) ((x) << USART_GTPR_PSC_SHIFT)
452#define USART_RTOR_BLEN_SHIFT 24
453#define USART_RTOR_BLEN_MASK (0xFF << USART_RTOR_BLEN_SHIFT)
454#define USART_RTOR_BLEN_VAL(x) ((x) << USART_RTOR_BLEN_SHIFT)
457#define USART_RTOR_RTO_SHIFT 0
458#define USART_RTOR_RTO_MASK (0xFFFFF << USART_RTOR_RTO_SHIFT)
459#define USART_RTOR_RTO_VAL(x) ((x) << USART_RTOR_RTO_SHIFT)
469#define USART_RQR_TXFRQ (1 << 4)
472#define USART_RQR_RXFRQ (1 << 3)
475#define USART_RQR_MMRQ (1 << 2)
478#define USART_RQR_SBKRQ (1 << 1)
481#define USART_RQR_ABRRQ (1 << 0)
492#define USART_ISR_REACK (1 << 22)
495#define USART_ISR_TEACK (1 << 21)
498#define USART_ISR_WUF (1 << 20)
501#define USART_ISR_RWU (1 << 19)
504#define USART_ISR_SBKF (1 << 18)
507#define USART_ISR_CMF (1 << 17)
510#define USART_ISR_BUSY (1 << 16)
513#define USART_ISR_ABRF (1 << 15)
516#define USART_ISR_ABRE (1 << 14)
519#define USART_ISR_EOBF (1 << 12)
522#define USART_ISR_RTOF (1 << 11)
525#define USART_ISR_CTS (1 << 10)
528#define USART_ISR_CTSIF (1 << 9)
531#define USART_ISR_LBDF (1 << 8)
534#define USART_ISR_TXE (1 << 7)
537#define USART_ISR_TC (1 << 6)
540#define USART_ISR_RXNE (1 << 5)
543#define USART_ISR_IDLE (1 << 4)
546#define USART_ISR_ORE (1 << 3)
549#define USART_ISR_NF (1 << 2)
552#define USART_ISR_FE (1 << 1)
555#define USART_ISR_PE (1 << 0)
566#define USART_ICR_WUCF (1 << 20)
569#define USART_ICR_CMCF (1 << 17)
572#define USART_ICR_EOBCF (1 << 12)
575#define USART_ICR_RTOCF (1 << 11)
578#define USART_ICR_CTSCF (1 << 9)
581#define USART_ICR_LBDCF (1 << 8)
584#define USART_ICR_TCCF (1 << 6)
587#define USART_ICR_IDLECF (1 << 4)
590#define USART_ICR_ORECF (1 << 3)
593#define USART_ICR_NCF (1 << 2)
596#define USART_ICR_FECF (1 << 1)
599#define USART_ICR_PECF (1 << 0)
608#define USART_RDR_MASK (0x1FF << 0)
610#define USART_TDR_MASK (0x1FF << 0)
void usart_enable_data_inversion(uint32_t usart)
USART enable data inversion.
void usart_disable_halfduplex(uint32_t usart)
USART Disable Half-duplex.
void usart_enable_rx_timeout(uint32_t usart)
USART enable receive timeout function.
void usart_set_rx_timeout_value(uint32_t usart, uint32_t value)
USART Set receiver timeout value.
void usart_enable_halfduplex(uint32_t usart)
USART Enable Half-duplex.
void usart_disable_rx_timeout_interrupt(uint32_t usart)
USART disable receive timeout interrupt.
void usart_disable_tx_inversion(uint32_t usart)
USART Disable TX pin active level inversion.
void usart_disable_rx_timeout(uint32_t usart)
USART disable receive timeout function.
void usart_disable_rx_inversion(uint32_t usart)
USART Disable RX pin active level inversion.
void usart_enable_rx_timeout_interrupt(uint32_t usart)
USART enable receive timeout interrupt.
void usart_enable_rx_inversion(uint32_t usart)
USART Enable RX pin active level inversion.
void usart_disable_data_inversion(uint32_t usart)
USART disable data inversion.
void usart_enable_tx_inversion(uint32_t usart)
USART Enable TX pin active level inversion.