File syn_port_serial.h¶
FileList > port > syn_port_serial.h
Go to the source code of this file
Console serial port interface. More...
#include "../common/syn_defs.h"#include <stddef.h>#include <stdint.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_port_serial_init (uint32_t baudrate) Initialize the console serial port. |
| int | syn_port_serial_read (uint8_t * buf, size_t max_len) Read available bytes from the console (non-blocking). |
| int | syn_port_serial_write (const uint8_t * data, size_t len) Write bytes to the console. |
Public Static Functions¶
| Type | Name |
|---|---|
| int | syn_port_serial_read_byte (uint8_t * byte) Read a single byte from the console (non-blocking). |
| int | syn_port_serial_write_byte (uint8_t byte) Write a single byte to the console. |
Detailed Description¶
Provides the low-level byte I/O primitives for the system console. The console is a singleton — there is exactly one per project. It may be backed by a hardware UART, USB CDC, or any other byte stream.
The CLI and logging system use this interface directly — no callback wiring is needed in application code.
** **
writemay briefly block for buffer space but must not spin indefinitely.readis strictly non-blocking: returns 0 if nothing is available.
** **
For non-console UARTs (Modbus, GPS, sensors), use syn_port_uart.h which provides instance-based access to hardware UART peripherals.
Public Functions Documentation¶
function syn_port_serial_init¶
Initialize the console serial port.
Parameters:
baudrateDesired baud rate. Pass 0 for default (or if the underlying transport ignores baud rate, e.g. USB CDC).
Returns:
SYN_OK on success.
function syn_port_serial_read¶
Read available bytes from the console (non-blocking).
Returns immediately with however many bytes are available, up to max_len. Returns 0 if no data is available. Never blocks.
Parameters:
bufBuffer to read into.max_lenMaximum bytes to read.
Returns:
Number of bytes read (0 if nothing available), or -1 on error.
function syn_port_serial_write¶
Write bytes to the console.
Writes up to len bytes. May briefly block if the transmit buffer is full, but must not spin indefinitely.
Parameters:
dataData to write.lenNumber of bytes.
Returns:
Number of bytes actually written, or -1 on error.
Public Static Functions Documentation¶
function syn_port_serial_read_byte¶
Read a single byte from the console (non-blocking).
Parameters:
byte[out] Received byte.
Returns:
1 if a byte was read, 0 if nothing available.
function syn_port_serial_write_byte¶
Write a single byte to the console.
Parameters:
byteByte to write.
Returns:
1 on success, -1 on error.
The documentation for this class was generated from the following file src/syntropic/port/syn_port_serial.h