File syn_uart.c¶
FileList > drivers > syn_uart.c
Go to the source code of this file
UART driver implementation.
#include "../util/syn_assert.h"#include "syn_uart.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_uart_deinit (SYN_UART * uart) De-initialize a UART instance. |
| SYN_Status | syn_uart_init (SYN_UART * uart, SYN_UARTInstance instance, uint32_t baudrate) Initialize a UART instance with buffered I/O. |
| size_t | syn_uart_read (SYN_UART * uart, uint8_t * data, size_t max_len) Read bytes from the UART RX ring buffer. |
| bool | syn_uart_rx_isr_feed (SYN_UART * uart, uint8_t byte) Feed a received byte into the UART RX ring buffer. |
| SYN_Status | syn_uart_write (const SYN_UART * uart, const uint8_t * data, size_t len, uint32_t timeout_ms) Write a buffer of bytes to the UART (blocking). |
| SYN_Status | syn_uart_write_str (const SYN_UART * uart, const char * str, uint32_t timeout_ms) Write a string to the UART (blocking). |
Public Functions Documentation¶
function syn_uart_deinit¶
De-initialize a UART instance.
Parameters:
uartUART handle to deinitialize.
Returns:
SYN_OK on success.
function syn_uart_init¶
Initialize a UART instance with buffered I/O.
Parameters:
uartPointer to a caller-owned SYN_UART struct.instanceUART peripheral number (0, 1, …).baudrateDesired baud rate.
Returns:
SYN_OK on success.
function syn_uart_read¶
Read bytes from the UART RX ring buffer.
Reads up to max_len bytes that have been received. Non-blocking: returns immediately with however many bytes are available.
Parameters:
uartUART handle.dataBuffer to read into.max_lenMaximum number of bytes to read.
Returns:
Number of bytes actually read.
function syn_uart_rx_isr_feed¶
Feed a received byte into the UART RX ring buffer.
Call this from your UART RX ISR to push incoming data into the driver's buffer.
Parameters:
uartUART handle.byteThe received byte.
Returns:
true if the byte was stored, false if the RX buffer is full.
function syn_uart_write¶
Write a buffer of bytes to the UART (blocking).
SYN_Status syn_uart_write (
const SYN_UART * uart,
const uint8_t * data,
size_t len,
uint32_t timeout_ms
)
Parameters:
uartUART handle.dataData to transmit.lenNumber of bytes.timeout_msTimeout in milliseconds (0 = no timeout).
Returns:
SYN_OK on success.
function syn_uart_write_str¶
Write a string to the UART (blocking).
Parameters:
uartUART handle.strNull-terminated string.timeout_msTimeout in milliseconds (0 = no timeout).
Returns:
SYN_OK on success.
The documentation for this class was generated from the following file src/syntropic/drivers/syn_uart.c