UART driver interface for STM32F4 (Cortex-M4). More...
Go to the source code of this file.
Macros | |
#define | uart2_write(val) |
#define | uart1_write(val) |
#define | uart6_write(val) |
#define | PERIPH_BASE 0x40000000UL |
#define | AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) |
#define | APB1PERIPH_BASE (PERIPH_BASE + 0x00000000UL) |
#define | APB2PERIPH_BASE (PERIPH_BASE + 0x7400) |
#define | RCC_BASE (AHB1PERIPH_BASE + 0x3800) |
#define | USART2_BASE (APB1PERIPH_BASE + 0x4400) |
#define | USART1_BASE 0x40011000 |
#define | USART6_BASE 0x40011400 |
#define | RCC_APB1ENR (*(__IO uint32_t *)(RCC_BASE + 0x40)) |
#define | RCC_APB2ENR (*(__IO uint32_t *)(RCC_BASE + 0x44)) |
#define | USART2_SR (*(__IO uint32_t *)(USART2_BASE + 0x00)) |
#define | USART2_DR (*(__IO uint32_t *)(USART2_BASE + 0x04)) |
#define | USART2_BRR (*(__IO uint32_t *)(USART2_BASE + 0x08)) |
#define | USART2_CR1 (*(__IO uint32_t *)(USART2_BASE + 0x0C)) |
#define | USART1_SR (*(__IO uint32_t *)(USART1_BASE + 0x00)) |
#define | USART1_DR (*(__IO uint32_t *)(USART1_BASE + 0x04)) |
#define | USART1_BRR (*(__IO uint32_t *)(USART1_BASE + 0x08)) |
#define | USART1_CR1 (*(__IO uint32_t *)(USART1_BASE + 0x0C)) |
#define | USART6_SR (*(__IO uint32_t *)(USART6_BASE + 0x00)) |
#define | USART6_DR (*(__IO uint32_t *)(USART6_BASE + 0x04)) |
#define | USART6_BRR (*(__IO uint32_t *)(USART6_BASE + 0x08)) |
#define | USART6_CR1 (*(__IO uint32_t *)(USART6_BASE + 0x0C)) |
#define | RCC_APB1ENR_USART2EN (1 << 17) |
#define | RCC_APB2ENR_USART1EN (1 << 4) |
#define | RCC_APB2ENR_USART6EN (1 << 5) |
#define | USART_CR1_UE (1 << 13) |
USART Enable. | |
#define | USART_CR1_TE (1 << 3) |
Transmitter Enable. | |
#define | USART_CR1_RE (1 << 2) |
Receiver Enable. | |
#define | USART_SR_TXE (1 << 7) |
Transmit Data Register Empty. | |
#define | USART_SR_RXNE (1 << 5) |
Read Data Register Not Empty. |
Enumerations | |
enum | hal_uart_t { UART1 , UART2 , UART6 } |
UART identifier enumeration. More... |
Functions | |
void | uart_init (uint32_t baudrate, hal_uart_t uart) |
Initialize the specified UART peripheral. | |
void | uart_write_char (char c, hal_uart_t uart) |
Transmit a single character via the specified UART. | |
void | uart_write_int (int32_t num, hal_uart_t uart) |
Transmit a 32-bit signed integer via UART. | |
void | uart_write_float (float num, hal_uart_t uart) |
Transmit a floating-point number via UART. | |
void | uart_write_string (const char *s, hal_uart_t uart) |
Transmit a null-terminated string via UART. | |
void | uart1_init (uint32_t baudrate) |
Initialize USART1 peripheral. | |
void | uart1_write_char (char c) |
Transmit a single character via USART1. | |
void | uart1_write_int (int32_t num) |
Transmit a 32-bit signed integer via USART1. | |
void | uart1_write_float (float num) |
Transmit a floating-point number via USART1. | |
void | uart1_write_string (const char *s) |
Transmit a null-terminated string via USART1. | |
void | uart2_init (uint32_t baudrate) |
Initialize USART2 peripheral. | |
void | uart2_write_char (char c) |
Transmit a single character via USART2. | |
void | uart2_write_int (int32_t num) |
Transmit a 32-bit signed integer via USART2. | |
void | uart2_write_float (float num) |
Transmit a floating-point number via USART2. | |
void | uart2_write_string (const char *s) |
Transmit a null-terminated string via USART2. | |
void | uart6_init (uint32_t baudrate) |
Initialize USART6 peripheral. | |
void | uart6_write_char (char c) |
Transmit a single character via USART6. | |
void | uart6_write_int (int32_t num) |
Transmit a 32-bit signed integer via USART6. | |
void | uart6_write_float (float num) |
Transmit a floating-point number via USART6. | |
void | uart6_write_string (const char *s) |
Transmit a null-terminated string via USART6. | |
char | uart_read_char (hal_uart_t uart) |
Read a single character from the specified UART. | |
int | uart_available (hal_uart_t uart) |
Check if data is available to read. | |
int | uart1_available (void) |
Check if data is available to read from USART1. | |
char | uart1_read_char (void) |
Read a single character from USART1. | |
int | uart2_available (void) |
Check if data is available to read from USART2. | |
char | uart2_read_char (void) |
Read a single character from USART2. | |
int | uart6_available (void) |
Check if data is available to read from USART6. | |
char | uart6_read_char (void) |
Read a single character from USART6. | |
uint32_t | uart2_read_until (char *buffer, uint32_t maxlen, char delimiter) |
Read characters into a buffer until a delimiter is found or max length is reached. |
UART driver interface for STM32F4 (Cortex-M4).
This header defines memory-mapped registers, macros, and function prototypes for UART (USART1, USART2, USART6) peripheral control on the STM32F401RE MCU.
The implementation provides:
enum hal_uart_t |