|
STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
|
USART1-3/6 and UART4-5. More...
Data Structures | |
| struct | UartRegisters_t |
| USART/UART register block. More... | |
Typedefs | |
| typedef struct UartRegisters_t | UartRegisters_t |
| USART/UART register block. | |
Base addresses | |
| #define | USART1_BASE (0x40011000UL) |
| USART1 (APB2). | |
| #define | USART2_BASE (0x40004400UL) |
| USART2 (APB1), the ST-LINK virtual COM port. | |
| #define | USART3_BASE (0x40004800UL) |
| USART3 (APB1). | |
| #define | UART4_BASE (0x40004C00UL) |
| UART4 (APB1). | |
| #define | UART5_BASE (0x40005000UL) |
| UART5 (APB1). | |
| #define | USART6_BASE (0x40011400UL) |
| USART6 (APB2). | |
Instances | |
| #define | USART1 ((UartRegisters_t *)USART1_BASE) |
| USART1. | |
| #define | USART2 ((UartRegisters_t *)USART2_BASE) |
| USART2. | |
| #define | USART3 ((UartRegisters_t *)USART3_BASE) |
| USART3. | |
| #define | UART4 ((UartRegisters_t *)UART4_BASE) |
| UART4. | |
| #define | UART5 ((UartRegisters_t *)UART5_BASE) |
| UART5. | |
| #define | USART6 ((UartRegisters_t *)USART6_BASE) |
| USART6. | |
SR - status (0x00) | |
PE, FE, NE and ORE clear by reading SR then DR. | |
| #define | USART_SR_PE_Pos (0U) |
| Bit 0. | |
| #define | USART_SR_PE ((uint32_t)1U << USART_SR_PE_Pos) |
| ro Parity error. | |
| #define | USART_SR_FE_Pos (1U) |
| Bit 1. | |
| #define | USART_SR_FE ((uint32_t)1U << USART_SR_FE_Pos) |
| ro Framing error. | |
| #define | USART_SR_NE_Pos (2U) |
| Bit 2. | |
| #define | USART_SR_NE ((uint32_t)1U << USART_SR_NE_Pos) |
| ro Noise detected (RM0390 names it NF). | |
| #define | USART_SR_ORE_Pos (3U) |
| Bit 3. | |
| #define | USART_SR_ORE ((uint32_t)1U << USART_SR_ORE_Pos) |
| ro Overrun error. | |
| #define | USART_SR_IDLE_Pos (4U) |
| Bit 4. | |
| #define | USART_SR_IDLE ((uint32_t)1U << USART_SR_IDLE_Pos) |
| ro Idle line detected. | |
| #define | USART_SR_RXNE_Pos (5U) |
| Bit 5. | |
| #define | USART_SR_RXNE ((uint32_t)1U << USART_SR_RXNE_Pos) |
| rc_w0 Receive data ready; a DR read also clears it. | |
| #define | USART_SR_TC_Pos (6U) |
| Bit 6. | |
| #define | USART_SR_TC ((uint32_t)1U << USART_SR_TC_Pos) |
| rc_w0 Transmission complete: the shift register is empty. | |
| #define | USART_SR_TXE_Pos (7U) |
| Bit 7. | |
| #define | USART_SR_TXE ((uint32_t)1U << USART_SR_TXE_Pos) |
| ro DR can take the next byte; a DR write clears it. | |
BRR - baud rate (0x08) | |
With 16x oversampling, BRR = round(pclk / baud). | |
| #define | USART_BRR_DIV_FRACTION_Pos (0U) |
| Bits 3:0. | |
| #define | USART_BRR_DIV_FRACTION_Msk ((uint32_t)0xFU << USART_BRR_DIV_FRACTION_Pos) |
| rw USARTDIV fraction, in sixteenths. | |
| #define | USART_BRR_DIV_MANTISSA_Pos (4U) |
| Bits 15:4. | |
| #define | USART_BRR_DIV_MANTISSA_Msk ((uint32_t)0xFFFU << USART_BRR_DIV_MANTISSA_Pos) |
| rw USARTDIV mantissa. | |
CR1 - control 1 (0x0C) | |
Every bit is rw. | |
| #define | USART_CR1_SBK_Pos (0U) |
| Bit 0. | |
| #define | USART_CR1_SBK ((uint32_t)1U << USART_CR1_SBK_Pos) |
| Send a break. | |
| #define | USART_CR1_RWU_Pos (1U) |
| Bit 1. | |
| #define | USART_CR1_RWU ((uint32_t)1U << USART_CR1_RWU_Pos) |
| Receiver in mute mode. | |
| #define | USART_CR1_RE_Pos (2U) |
| Bit 2. | |
| #define | USART_CR1_RE ((uint32_t)1U << USART_CR1_RE_Pos) |
| Receiver enable. | |
| #define | USART_CR1_TE_Pos (3U) |
| Bit 3. | |
| #define | USART_CR1_TE ((uint32_t)1U << USART_CR1_TE_Pos) |
| Transmitter enable. | |
| #define | USART_CR1_IDLEIE_Pos (4U) |
| Bit 4. | |
| #define | USART_CR1_IDLEIE ((uint32_t)1U << USART_CR1_IDLEIE_Pos) |
| IDLE interrupt enable. | |
| #define | USART_CR1_RXNEIE_Pos (5U) |
| Bit 5. | |
| #define | USART_CR1_RXNEIE ((uint32_t)1U << USART_CR1_RXNEIE_Pos) |
| RXNE/ORE interrupt enable. | |
| #define | USART_CR1_TCIE_Pos (6U) |
| Bit 6. | |
| #define | USART_CR1_TCIE ((uint32_t)1U << USART_CR1_TCIE_Pos) |
| TC interrupt enable. | |
| #define | USART_CR1_TXEIE_Pos (7U) |
| Bit 7. | |
| #define | USART_CR1_TXEIE ((uint32_t)1U << USART_CR1_TXEIE_Pos) |
| TXE interrupt enable. | |
| #define | USART_CR1_PEIE_Pos (8U) |
| Bit 8. | |
| #define | USART_CR1_PEIE ((uint32_t)1U << USART_CR1_PEIE_Pos) |
| PE interrupt enable. | |
| #define | USART_CR1_PS_Pos (9U) |
| Bit 9. | |
| #define | USART_CR1_PS ((uint32_t)1U << USART_CR1_PS_Pos) |
| Parity: 0 even, 1 odd. | |
| #define | USART_CR1_PCE_Pos (10U) |
| Bit 10. | |
| #define | USART_CR1_PCE ((uint32_t)1U << USART_CR1_PCE_Pos) |
| Parity control enable. | |
| #define | USART_CR1_WAKE_Pos (11U) |
| Bit 11. | |
| #define | USART_CR1_WAKE ((uint32_t)1U << USART_CR1_WAKE_Pos) |
| Wakeup: 0 idle line, 1 address mark. | |
| #define | USART_CR1_M_Pos (12U) |
| Bit 12. | |
| #define | USART_CR1_M ((uint32_t)1U << USART_CR1_M_Pos) |
| Word length: 0 = 8 bits, 1 = 9 bits on the wire (parity included). | |
| #define | USART_CR1_UE_Pos (13U) |
| Bit 13. | |
| #define | USART_CR1_UE ((uint32_t)1U << USART_CR1_UE_Pos) |
| USART enable. | |
| #define | USART_CR1_OVER8_Pos (15U) |
| Bit 15. | |
| #define | USART_CR1_OVER8 ((uint32_t)1U << USART_CR1_OVER8_Pos) |
| Oversampling: 0 = 16x, 1 = 8x. | |
CR2 - control 2 (0x10) | |
| #define | USART_CR2_STOP_Pos (12U) |
| Bits 13:12. | |
| #define | USART_CR2_STOP_Msk ((uint32_t)0x3U << USART_CR2_STOP_Pos) |
| rw Stop bits; values below. | |
CR2.STOP values | |
0.5 and 1.5 stop bits are for smartcard mode, which the driver does not support. | |
| #define | USART_CR2_STOP_1 (0x0U) |
| 1 stop bit | |
| #define | USART_CR2_STOP_0_5 (0x1U) |
| 0.5 stop bit (smartcard) | |
| #define | USART_CR2_STOP_2 (0x2U) |
| 2 stop bits | |
| #define | USART_CR2_STOP_1_5 (0x3U) |
| 1.5 stop bits (smartcard) | |
USART1-3/6 and UART4-5.
| #define USART1_BASE (0x40011000UL) |
USART1 (APB2).
Definition at line 23 of file uart_reg.h.
| #define USART2_BASE (0x40004400UL) |
USART2 (APB1), the ST-LINK virtual COM port.
Definition at line 24 of file uart_reg.h.
| #define USART3_BASE (0x40004800UL) |
USART3 (APB1).
Definition at line 25 of file uart_reg.h.
| #define UART4_BASE (0x40004C00UL) |
UART4 (APB1).
Definition at line 26 of file uart_reg.h.
| #define UART5_BASE (0x40005000UL) |
UART5 (APB1).
Definition at line 27 of file uart_reg.h.
| #define USART6_BASE (0x40011400UL) |
USART6 (APB2).
Definition at line 28 of file uart_reg.h.
| #define USART1 ((UartRegisters_t *)USART1_BASE) |
USART1.
Definition at line 45 of file uart_reg.h.
| #define USART2 ((UartRegisters_t *)USART2_BASE) |
USART2.
Definition at line 46 of file uart_reg.h.
| #define USART3 ((UartRegisters_t *)USART3_BASE) |
USART3.
Definition at line 47 of file uart_reg.h.
| #define UART4 ((UartRegisters_t *)UART4_BASE) |
UART4.
Definition at line 48 of file uart_reg.h.
| #define UART5 ((UartRegisters_t *)UART5_BASE) |
UART5.
Definition at line 49 of file uart_reg.h.
| #define USART6 ((UartRegisters_t *)USART6_BASE) |
USART6.
Definition at line 50 of file uart_reg.h.
| #define USART_SR_PE_Pos (0U) |
Bit 0.
Definition at line 56 of file uart_reg.h.
| #define USART_SR_PE ((uint32_t)1U << USART_SR_PE_Pos) |
| #define USART_SR_FE_Pos (1U) |
Bit 1.
Definition at line 59 of file uart_reg.h.
| #define USART_SR_FE ((uint32_t)1U << USART_SR_FE_Pos) |
| #define USART_SR_NE_Pos (2U) |
Bit 2.
Definition at line 62 of file uart_reg.h.
| #define USART_SR_NE ((uint32_t)1U << USART_SR_NE_Pos) |
ro Noise detected (RM0390 names it NF).
Definition at line 64 of file uart_reg.h.
Referenced by uartReceiveByte().
| #define USART_SR_ORE_Pos (3U) |
Bit 3.
Definition at line 65 of file uart_reg.h.
| #define USART_SR_ORE ((uint32_t)1U << USART_SR_ORE_Pos) |
| #define USART_SR_IDLE_Pos (4U) |
Bit 4.
Definition at line 68 of file uart_reg.h.
| #define USART_SR_IDLE ((uint32_t)1U << USART_SR_IDLE_Pos) |
ro Idle line detected.
Definition at line 70 of file uart_reg.h.
| #define USART_SR_RXNE_Pos (5U) |
Bit 5.
Definition at line 71 of file uart_reg.h.
| #define USART_SR_RXNE ((uint32_t)1U << USART_SR_RXNE_Pos) |
rc_w0 Receive data ready; a DR read also clears it.
Definition at line 73 of file uart_reg.h.
Referenced by uartReceiveByte().
| #define USART_SR_TC_Pos (6U) |
Bit 6.
Definition at line 74 of file uart_reg.h.
| #define USART_SR_TC ((uint32_t)1U << USART_SR_TC_Pos) |
rc_w0 Transmission complete: the shift register is empty.
Definition at line 76 of file uart_reg.h.
Referenced by uartFlush().
| #define USART_SR_TXE_Pos (7U) |
Bit 7.
Definition at line 77 of file uart_reg.h.
| #define USART_SR_TXE ((uint32_t)1U << USART_SR_TXE_Pos) |
ro DR can take the next byte; a DR write clears it.
Definition at line 79 of file uart_reg.h.
Referenced by uartTransmitByte().
| #define USART_BRR_DIV_FRACTION_Pos (0U) |
Bits 3:0.
Definition at line 85 of file uart_reg.h.
| #define USART_BRR_DIV_FRACTION_Msk ((uint32_t)0xFU << USART_BRR_DIV_FRACTION_Pos) |
rw USARTDIV fraction, in sixteenths.
Definition at line 87 of file uart_reg.h.
Referenced by uartComputeBrr().
| #define USART_BRR_DIV_MANTISSA_Pos (4U) |
Bits 15:4.
Definition at line 88 of file uart_reg.h.
| #define USART_BRR_DIV_MANTISSA_Msk ((uint32_t)0xFFFU << USART_BRR_DIV_MANTISSA_Pos) |
| #define USART_CR1_SBK_Pos (0U) |
Bit 0.
Definition at line 96 of file uart_reg.h.
| #define USART_CR1_SBK ((uint32_t)1U << USART_CR1_SBK_Pos) |
Send a break.
Definition at line 97 of file uart_reg.h.
| #define USART_CR1_RWU_Pos (1U) |
Bit 1.
Definition at line 98 of file uart_reg.h.
| #define USART_CR1_RWU ((uint32_t)1U << USART_CR1_RWU_Pos) |
Receiver in mute mode.
Definition at line 99 of file uart_reg.h.
| #define USART_CR1_RE_Pos (2U) |
Bit 2.
Definition at line 100 of file uart_reg.h.
| #define USART_CR1_RE ((uint32_t)1U << USART_CR1_RE_Pos) |
| #define USART_CR1_TE_Pos (3U) |
Bit 3.
Definition at line 102 of file uart_reg.h.
| #define USART_CR1_TE ((uint32_t)1U << USART_CR1_TE_Pos) |
| #define USART_CR1_IDLEIE_Pos (4U) |
Bit 4.
Definition at line 104 of file uart_reg.h.
| #define USART_CR1_IDLEIE ((uint32_t)1U << USART_CR1_IDLEIE_Pos) |
IDLE interrupt enable.
Definition at line 105 of file uart_reg.h.
| #define USART_CR1_RXNEIE_Pos (5U) |
Bit 5.
Definition at line 106 of file uart_reg.h.
| #define USART_CR1_RXNEIE ((uint32_t)1U << USART_CR1_RXNEIE_Pos) |
RXNE/ORE interrupt enable.
Definition at line 107 of file uart_reg.h.
| #define USART_CR1_TCIE_Pos (6U) |
Bit 6.
Definition at line 108 of file uart_reg.h.
| #define USART_CR1_TCIE ((uint32_t)1U << USART_CR1_TCIE_Pos) |
TC interrupt enable.
Definition at line 109 of file uart_reg.h.
| #define USART_CR1_TXEIE_Pos (7U) |
Bit 7.
Definition at line 110 of file uart_reg.h.
| #define USART_CR1_TXEIE ((uint32_t)1U << USART_CR1_TXEIE_Pos) |
TXE interrupt enable.
Definition at line 111 of file uart_reg.h.
| #define USART_CR1_PEIE_Pos (8U) |
Bit 8.
Definition at line 112 of file uart_reg.h.
| #define USART_CR1_PEIE ((uint32_t)1U << USART_CR1_PEIE_Pos) |
PE interrupt enable.
Definition at line 113 of file uart_reg.h.
| #define USART_CR1_PS_Pos (9U) |
Bit 9.
Definition at line 114 of file uart_reg.h.
| #define USART_CR1_PS ((uint32_t)1U << USART_CR1_PS_Pos) |
| #define USART_CR1_PCE_Pos (10U) |
Bit 10.
Definition at line 116 of file uart_reg.h.
| #define USART_CR1_PCE ((uint32_t)1U << USART_CR1_PCE_Pos) |
| #define USART_CR1_WAKE_Pos (11U) |
Bit 11.
Definition at line 118 of file uart_reg.h.
| #define USART_CR1_WAKE ((uint32_t)1U << USART_CR1_WAKE_Pos) |
Wakeup: 0 idle line, 1 address mark.
Definition at line 119 of file uart_reg.h.
| #define USART_CR1_M_Pos (12U) |
Bit 12.
Definition at line 120 of file uart_reg.h.
| #define USART_CR1_M ((uint32_t)1U << USART_CR1_M_Pos) |
Word length: 0 = 8 bits, 1 = 9 bits on the wire (parity included).
Definition at line 122 of file uart_reg.h.
Referenced by uartInit().
| #define USART_CR1_UE_Pos (13U) |
Bit 13.
Definition at line 123 of file uart_reg.h.
| #define USART_CR1_UE ((uint32_t)1U << USART_CR1_UE_Pos) |
| #define USART_CR1_OVER8_Pos (15U) |
Bit 15.
Definition at line 125 of file uart_reg.h.
| #define USART_CR1_OVER8 ((uint32_t)1U << USART_CR1_OVER8_Pos) |
| #define USART_CR2_STOP_Pos (12U) |
| #define USART_CR2_STOP_Msk ((uint32_t)0x3U << USART_CR2_STOP_Pos) |
| #define USART_CR2_STOP_1 (0x0U) |
| #define USART_CR2_STOP_0_5 (0x1U) |
0.5 stop bit (smartcard)
Definition at line 141 of file uart_reg.h.
| #define USART_CR2_STOP_2 (0x2U) |
| #define USART_CR2_STOP_1_5 (0x3U) |
1.5 stop bits (smartcard)
Definition at line 143 of file uart_reg.h.