NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
uart.h File Reference

UART driver interface for STM32F4 (Cortex-M4). More...

#include "core/cortex-m4/uart_reg.h"
#include <stdint.h>
Include dependency graph for uart.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define uart2_write(val)
#define uart1_write(val)
#define uart6_write(val)

Enumerations

enum  hal_uart_t { UART1 = 1 , UART2 = 2 , UART6 = 6 }
 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)
void uart2_write_float (float num)
void uart2_write_string (const char *s)
void uart6_init (uint32_t baudrate)
 Initialize USART6 peripheral.
void uart6_write_char (char c)
void uart6_write_int (int32_t num)
void uart6_write_float (float num)
void uart6_write_string (const char *s)
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.

Detailed Description

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:

  • UART initialization with configurable baud rates
  • Character, integer, float, and string transmission
  • Character reception
  • Data availability checking
  • Type-generic write macros for simplified usage
  • Support for all three available UART peripherals (USART1, USART2, USART6)
Note
Architecture-specific for STM32F401RE. Included through dispatcher based on CORTEX_M4.
All UART functions are blocking (polling mode) implementations.
Author
Ashutosh Vishwakarma
Date
2025-07-23

Enumeration Type Documentation

◆ hal_uart_t

enum hal_uart_t

UART identifier enumeration.

Identifies which UART peripheral to use for operations.

Enumerator
UART1 

USART1 - APB2 peripheral, typically higher speed.

UART2 

USART2 - APB1 peripheral.

UART6 

USART6 - APB2 peripheral.