UART driver API functions. 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 API functions.
Provides initialization, transmission, and reception functions for UART peripherals. Both generic (UART instance parameter) and specific (UART1/UART2/UART6) functions are provided for flexibility.
int uart1_available | ( | void | ) |
Check if data is available to read from USART1.
void uart1_init | ( | uint32_t | baudrate | ) |
Initialize USART1 peripheral.
baudrate | Desired communication speed in bits per second. |
Configures:
baudrate | Desired communication speed in bits per second |
char uart1_read_char | ( | void | ) |
Read a single character from USART1.
void uart1_write_char | ( | char | c | ) |
Transmit a single character via USART1.
c | Character to transmit |
void uart1_write_float | ( | float | num | ) |
Transmit a floating-point number via USART1.
num | Floating-point number to transmit |
void uart1_write_int | ( | int32_t | num | ) |
Transmit a 32-bit signed integer via USART1.
num | Integer to transmit |
void uart1_write_string | ( | const char * | s | ) |
Transmit a null-terminated string via USART1.
s | Null-terminated string to transmit |
int uart2_available | ( | void | ) |
Check if data is available to read from USART2.
void uart2_init | ( | uint32_t | baudrate | ) |
Initialize USART2 peripheral.
Configures:
baudrate | Desired communication speed in bits per second |
char uart2_read_char | ( | void | ) |
Read a single character from USART2.
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.
Reads characters into the provided buffer until either:
The delimiter character is not included in the buffer. The buffer is always null-terminated.
buffer | Destination buffer for received characters. |
maxlen | Maximum number of characters to read (including null terminator). |
delimiter | Character that terminates the read operation. |
Read characters into a buffer until a delimiter is found or max length is reached.
Reads characters into buffer until:
buffer | Destination buffer |
maxlen | Maximum number of characters to read (including null terminator) |
delimiter | Character that terminates the read |
void uart2_write_char | ( | char | c | ) |
Transmit a single character via USART2.
Blocks until transmit buffer is empty
c | Character to transmit |
void uart2_write_float | ( | float | num | ) |
Transmit a floating-point number via USART2.
Converts float to string representation with 5 decimal places Handles negative numbers
num | Floating-point number to transmit |
void uart2_write_int | ( | int32_t | num | ) |
Transmit a 32-bit signed integer via USART2.
Converts integer to string representation and transmits it Handles negative numbers and zero
num | Integer to transmit |
void uart2_write_string | ( | const char * | s | ) |
Transmit a null-terminated string via USART2.
s | Null-terminated string to transmit |
int uart6_available | ( | void | ) |
Check if data is available to read from USART6.
void uart6_init | ( | uint32_t | baudrate | ) |
Initialize USART6 peripheral.
Configures:
baudrate | Desired communication speed in bits per second |
char uart6_read_char | ( | void | ) |
Read a single character from USART6.
void uart6_write_char | ( | char | c | ) |
Transmit a single character via USART6.
c | Character to transmit |
void uart6_write_float | ( | float | num | ) |
Transmit a floating-point number via USART6.
num | Floating-point number to transmit |
void uart6_write_int | ( | int32_t | num | ) |
Transmit a 32-bit signed integer via USART6.
num | Integer to transmit |
void uart6_write_string | ( | const char * | s | ) |
Transmit a null-terminated string via USART6.
s | Null-terminated string to transmit |
int uart_available | ( | hal_uart_t | uart | ) |
Check if data is available to read.
uart | UART instance to check. |
Check if data is available to read.
uart | UART instance to check |
void uart_init | ( | uint32_t | baudrate, |
hal_uart_t | uart ) |
Initialize the specified UART peripheral.
Configures the UART peripheral with the specified baud rate and enables both transmitter and receiver. Also enables the peripheral clock.
baudrate | Desired communication speed in bits per second. |
uart | UART instance to initialize (UART1, UART2, or UART6). |
Routes initialization to the appropriate UART-specific init function
baudrate | Desired communication speed in bits per second |
uart | UART instance to initialize (UART1, UART2, or UART6) |
char uart_read_char | ( | hal_uart_t | uart | ) |
Read a single character from the specified UART.
Blocks until a character is received.
uart | UART instance to read from. |
Blocks until a character is received
uart | UART instance to read from |
void uart_write_char | ( | char | c, |
hal_uart_t | uart ) |
Transmit a single character via the specified UART.
Blocks until the transmit buffer is empty before sending.
c | Character to transmit. |
uart | UART instance to use. |
c | Character to transmit |
uart | UART instance to use |
void uart_write_float | ( | float | num, |
hal_uart_t | uart ) |
Transmit a floating-point number via UART.
Converts the float to its string representation with default formatting and transmits it.
num | Floating-point number to transmit. |
uart | UART instance to use. |
Converts float to string representation with 5 decimal places
num | Floating-point number to transmit |
uart | UART instance to use |
void uart_write_int | ( | int32_t | num, |
hal_uart_t | uart ) |
Transmit a 32-bit signed integer via UART.
Converts the integer to its string representation and transmits it.
num | Integer to transmit. |
uart | UART instance to use. |
Converts integer to string representation and transmits it
num | Integer to transmit |
uart | UART instance to use |
void uart_write_string | ( | const char * | s, |
hal_uart_t | uart ) |
Transmit a null-terminated string via UART.
Transmits each character of the string until the null terminator.
s | Null-terminated string to transmit. |
uart | UART instance to use. |
s | Null-terminated string to transmit |
uart | UART instance to use |