STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
uart.h
Go to the documentation of this file.
1
29#ifndef UART_H
30#define UART_H
31
32#include "driver_status.h"
33#include "uart_reg.h"
34
35#include <stddef.h>
36#include <stdint.h>
37
42
64DRIVER_MUST_CHECK DriverStatus_e uartInit(UartRegisters_t *uart, uint32_t pclk_hz, uint32_t baud,
65 uint32_t stop_bits, uint32_t parity_enable,
66 uint32_t parity_select, uint32_t direction);
67
73void uartDeinit(UartRegisters_t *uart);
74
88DRIVER_MUST_CHECK DriverStatus_e uartFlush(const UartRegisters_t *uart, uint32_t timeout);
89
100 uint32_t timeout);
101
118 size_t length, uint32_t timeout);
119
138 uint32_t timeout);
139
151DRIVER_MUST_CHECK DriverStatus_e uartReceive(UartRegisters_t *uart, uint8_t *data, size_t length,
152 uint32_t timeout);
153
155
156#endif /* UART_H */
The status every fallible driver function returns.
DriverStatus_e
Outcome of a driver call: a category for control flow, not a diagnosis.
#define DRIVER_MUST_CHECK
Make ignoring a function's result a compile error (with -Werror).
DRIVER_MUST_CHECK DriverStatus_e uartTransmit(UartRegisters_t *uart, const uint8_t *data, size_t length, uint32_t timeout)
Send a buffer and wait until the line is idle.
Definition uart.c:184
DRIVER_MUST_CHECK DriverStatus_e uartFlush(const UartRegisters_t *uart, uint32_t timeout)
Wait until the last byte has left the shift register (SR.TC).
Definition uart.c:167
DRIVER_MUST_CHECK DriverStatus_e uartInit(UartRegisters_t *uart, uint32_t pclk_hz, uint32_t baud, uint32_t stop_bits, uint32_t parity_enable, uint32_t parity_select, uint32_t direction)
Configure an instance for asynchronous 8-bit operation and enable it.
Definition uart.c:60
DRIVER_MUST_CHECK DriverStatus_e uartReceive(UartRegisters_t *uart, uint8_t *data, size_t length, uint32_t timeout)
Receive a buffer, one byte at a time.
Definition uart.c:240
void uartDeinit(UartRegisters_t *uart)
Return CR1, CR2, CR3, BRR and GTPR to their reset values (disabled).
Definition uart.c:128
DRIVER_MUST_CHECK DriverStatus_e uartReceiveByte(UartRegisters_t *uart, uint8_t *byte, uint32_t timeout)
Receive one byte once SR.RXNE sets.
Definition uart.c:212
DRIVER_MUST_CHECK DriverStatus_e uartTransmitByte(UartRegisters_t *uart, uint8_t byte, uint32_t timeout)
Send one byte once DR is free (SR.TXE).
Definition uart.c:172
USART/UART register block.
Definition uart_reg.h:33
USART/UART registers (RM0390 section 25.6).