File syn_port_stubs.c¶
FileList > port_stubs > syn_port_stubs.c
Go to the source code of this file
Weak default implementations for all port functions. More...
#include "../common/syn_compiler.h"#include "../common/syn_defs.h"#include "../util/syn_assert.h"#include "../port/syn_port_spi.h"#include "../port/syn_port_i2c.h"#include "../port/syn_port_flash.h"#include "../port/syn_port_adc.h"#include "../port/syn_port_pwm.h"#include "../system/syn_sleep.h"#include "../port/syn_port_exti.h"#include "../port/syn_port_can.h"#include "../port/syn_port_dma.h"#include "../port/syn_port_i2c_async.h"#include "../port/syn_port_spi_async.h"#include "../common/syn_barrier.h"#include "../port/syn_port_socket.h"#include "../port/syn_port_serial.h"
Public Functions¶
| Type | Name |
|---|---|
| SYN_WEAK SYN_NORETURN void | syn_assert_failed (const char * file, int line) Called when an assertion fails. |
| SYN_WEAK SYN_Status | syn_port_adc_init (uint8_t channel) Initialize an ADC channel. |
| SYN_WEAK uint16_t | syn_port_adc_read (uint8_t channel) Read a single ADC sample. |
| SYN_WEAK uint16_t | syn_port_adc_reference_mv (void) Get the ADC reference voltage in millivolts. |
| SYN_WEAK uint8_t | syn_port_adc_resolution (void) Get the ADC resolution in bits. |
| SYN_WEAK bool | syn_port_can_init (uint8_t port, uint32_t bitrate) Initialize CAN peripheral. |
| SYN_WEAK bool | syn_port_can_receive (uint8_t port, uint32_t * id, bool * extended, uint8_t * data, uint8_t * dlc) Receive a CAN frame (non-blocking). |
| SYN_WEAK bool | syn_port_can_send (uint8_t port, uint32_t id, bool extended, const uint8_t * data, uint8_t dlc) Send a CAN frame. |
| SYN_WEAK void | syn_port_can_set_filter (uint8_t port, uint32_t id, uint32_t mask) Set hardware acceptance filter. |
| SYN_WEAK void | syn_port_delay_ms (uint32_t ms) Blocking delay for the specified number of milliseconds. |
| SYN_WEAK void | syn_port_enter_critical (void) Enter a critical section (disable interrupts). |
| SYN_WEAK void | syn_port_exit_critical (void) Exit a critical section (re-enable interrupts). |
| SYN_WEAK void | syn_port_exti_clear_pending (SYN_GPIO_Pin pin) Clear pending interrupt flag for a pin. |
| SYN_WEAK SYN_Status | syn_port_exti_configure (SYN_GPIO_Pin pin, SYN_EXTI_Edge edge) Configure a pin for interrupt generation. |
| SYN_WEAK void | syn_port_exti_disable (SYN_GPIO_Pin pin) Disable interrupt on a pin (without deconfiguring). |
| SYN_WEAK void | syn_port_exti_enable (SYN_GPIO_Pin pin) Enable interrupt on a configured pin. |
| SYN_WEAK SYN_Status | syn_port_flash_erase (uint32_t addr) Erase a flash sector. |
| SYN_WEAK SYN_Status | syn_port_flash_read (uint32_t addr, void * buf, size_t len) Read from flash. |
| SYN_WEAK uint32_t | syn_port_flash_sector_size (uint32_t addr) Get the sector size for the given address. |
| SYN_WEAK SYN_Status | syn_port_flash_write (uint32_t addr, const void * buf, size_t len) Write to flash. |
| SYN_WEAK uint32_t | syn_port_get_tick_ms (void) Return the current system tick in milliseconds. |
| SYN_WEAK SYN_Status | syn_port_gpio_deinit (SYN_GPIO_Pin pin) De-initialize a GPIO pin, returning it to its reset state. |
| SYN_WEAK SYN_Status | syn_port_gpio_init (SYN_GPIO_Pin pin, SYN_GPIO_Mode mode) Initialize a GPIO pin with the given mode. |
| SYN_WEAK SYN_GPIO_State | syn_port_gpio_read (SYN_GPIO_Pin pin) Read the current logical state of a pin. |
| SYN_WEAK SYN_Status | syn_port_gpio_toggle (SYN_GPIO_Pin pin) Toggle the state of an output pin. |
| SYN_WEAK SYN_Status | syn_port_gpio_write (SYN_GPIO_Pin pin, SYN_GPIO_State state) Write a logical state to an output pin. |
| SYN_WEAK uint32_t | syn_port_hpclock_freq_hz (void) Return the timer clock frequency in Hz. |
| SYN_WEAK volatile uint32_t * | syn_port_hpclock_lsb_ptr (void) Return a pointer to the hardware timer count register. |
| SYN_WEAK SYN_Status | syn_port_i2c_deinit (uint8_t bus) Deinitialize an I2C bus. |
| SYN_WEAK SYN_Status | syn_port_i2c_init (const SYN_I2C_Config * cfg) Initialize an I2C bus. |
| SYN_WEAK SYN_Status | syn_port_i2c_read (uint8_t bus, uint8_t addr, uint8_t * data, size_t len) Read data from an I2C device. |
| SYN_WEAK SYN_Status | syn_port_i2c_write (uint8_t bus, uint8_t addr, const uint8_t * data, size_t len) Write data to an I2C device. |
| SYN_WEAK SYN_Status | syn_port_i2c_write_read (uint8_t bus, uint8_t addr, const uint8_t * tx_data, size_t tx_len, uint8_t * rx_data, size_t rx_len) Write then read (register access pattern). |
| SYN_WEAK void | syn_port_memory_barrier (void) |
| SYN_WEAK void | syn_port_pwm_enable (uint8_t channel, bool enable) Enable/disable PWM output. |
| SYN_WEAK SYN_Status | syn_port_pwm_init (uint8_t channel, uint32_t freq_hz) Initialize a PWM channel. |
| SYN_WEAK void | syn_port_pwm_set_duty (uint8_t channel, uint8_t duty_pct) Set PWM duty cycle. |
| SYN_WEAK void | syn_port_pwm_set_duty_raw (uint8_t channel, uint16_t duty_u16) Set PWM duty cycle with fine resolution. |
| SYN_WEAK void | syn_port_pwm_set_freq (uint8_t channel, uint32_t freq_hz) Set PWM frequency (runtime change). |
| SYN_WEAK SYN_Status | syn_port_serial_init (uint32_t baudrate) Initialize the console serial port. |
| SYN_WEAK int | syn_port_serial_read (uint8_t * buf, size_t max_len) Read available bytes from the console (non-blocking). |
| SYN_WEAK int | syn_port_serial_write (const uint8_t * data, size_t len) Write bytes to the console. |
| SYN_WEAK void | syn_port_sleep (SYN_SleepMode mode) Enter low-power mode. Implement for your platform. |
| SYN_WEAK void | syn_port_sleep_until (uint32_t wake_tick_ms) |
| SYN_WEAK SYN_Socket | syn_port_sock_accept (SYN_Socket listener, uint32_t timeout_ms) Accept an incoming connection on a listener socket. |
| SYN_WEAK void | syn_port_sock_close (SYN_Socket sock) Close a socket and release resources. |
| SYN_WEAK SYN_Socket | syn_port_sock_connect (const SYN_SockAddr * addr) Connect to a remote host by IP address. |
| SYN_WEAK SYN_Socket | syn_port_sock_connect_host (const char * host, uint16_t port) Connect to a remote host by hostname. |
| SYN_WEAK SYN_Socket | syn_port_sock_listen (uint16_t port, int backlog) Create a listening TCP socket on the given port. |
| SYN_WEAK int | syn_port_sock_recv (SYN_Socket sock, void * buf, size_t max_len, uint32_t timeout_ms) Receive data from a connected socket. |
| SYN_WEAK int | syn_port_sock_send (SYN_Socket sock, const void * data, size_t len) Send data over a connected socket. |
| SYN_WEAK int | syn_port_sock_send_all (SYN_Socket sock, const void * data, size_t len) Send all data over a connected socket. |
| SYN_WEAK SYN_Status | syn_port_spi_cs_assert (uint8_t bus, SYN_GPIO_Pin cs_pin) Assert (pull low) an SPI chip-select pin. |
| SYN_WEAK SYN_Status | syn_port_spi_cs_deassert (uint8_t bus, SYN_GPIO_Pin cs_pin) Deassert (release high) an SPI chip-select pin. |
| SYN_WEAK SYN_Status | syn_port_spi_deinit (uint8_t bus) Deinitialize an SPI bus. |
| SYN_WEAK SYN_Status | syn_port_spi_init (const SYN_SPI_Config * cfg) Initialize an SPI bus. |
| SYN_WEAK SYN_Status | syn_port_spi_transfer (uint8_t bus, const uint8_t * tx_buf, uint8_t * rx_buf, size_t len) Full-duplex SPI transfer. |
| SYN_WEAK SYN_NORETURN void | syn_port_system_reset (void) Perform a system reset. |
| SYN_WEAK SYN_Status | syn_port_uart_deinit (SYN_UARTInstance instance) De-initialize a UART peripheral. |
| SYN_WEAK SYN_Status | syn_port_uart_init (SYN_UARTInstance instance, uint32_t baudrate) Initialize a UART peripheral. |
| SYN_WEAK SYN_Status | syn_port_uart_receive (SYN_UARTInstance instance, uint8_t * data, size_t len, size_t * received, uint32_t timeout_ms) Receive bytes into a buffer (blocking). |
| SYN_WEAK SYN_Status | syn_port_uart_receive_byte (SYN_UARTInstance instance, uint8_t * byte, uint32_t timeout_ms) Receive a single byte (blocking). |
| SYN_WEAK SYN_Status | syn_port_uart_transmit (SYN_UARTInstance instance, const uint8_t * data, size_t len, uint32_t timeout_ms) Transmit a buffer of bytes (blocking). |
| SYN_WEAK SYN_Status | syn_port_uart_transmit_byte (SYN_UARTInstance instance, uint8_t byte) Transmit a single byte (blocking). |
| SYN_WEAK SYN_Status | syn_port_udp_join_multicast (SYN_Socket sock, const char * multicast_ip) Join a multicast group. |
| SYN_WEAK SYN_Socket | syn_port_udp_open (uint16_t port) Open a UDP socket bound to the given port. |
| SYN_WEAK int | syn_port_udp_recvfrom (SYN_Socket sock, void * buf, size_t max_len, SYN_SockAddr * from, uint32_t timeout_ms) Receive a UDP packet. |
| SYN_WEAK int | syn_port_udp_sendto (SYN_Socket sock, const void * data, size_t len, const SYN_SockAddr * to) Send a UDP packet to a destination address. |
Detailed Description¶
Compile this file into your project to catch unimplemented port functions at runtime. Each stub calls syn_assert_failed() with a descriptive message, making it immediately obvious which function you forgot to implement.
If you provide a strong definition of a function in your platform port file, the linker will silently discard the weak stub.
You can also omit this file entirely and rely on the linker to report unresolved symbols at link time — this is a perfectly valid approach.
Public Functions Documentation¶
function syn_assert_failed¶
Called when an assertion fails.
This function is declared weak so you can provide your own implementation. The default (in syn_port_stubs.c) enters an infinite loop.
Parameters:
fileSource file name where the assertion failed.lineLine number where the assertion failed.
function syn_port_adc_init¶
Initialize an ADC channel.
Parameters:
channelADC channel number.
Returns:
SYN_OK on success.
function syn_port_adc_read¶
Read a single ADC sample.
Parameters:
channelADC channel number.
Returns:
Raw ADC value (resolution depends on platform).
function syn_port_adc_reference_mv¶
Get the ADC reference voltage in millivolts.
Returns:
Reference voltage (e.g., 3300 for 3.3V).
function syn_port_adc_resolution¶
Get the ADC resolution in bits.
Returns:
Resolution (e.g., 10, 12, 16).
function syn_port_can_init¶
Initialize CAN peripheral.
Parameters:
portCAN port number (0, 1, ...).bitrateBitrate in bits/sec (e.g. 500000 for 500kbps).
Returns:
true on success.
function syn_port_can_receive¶
Receive a CAN frame (non-blocking).
SYN_WEAK bool syn_port_can_receive (
uint8_t port,
uint32_t * id,
bool * extended,
uint8_t * data,
uint8_t * dlc
)
Parameters:
portCAN port.id[out] CAN identifier.extended[out] true if 29-bit ID.data[out] Frame data buffer (at least 8 bytes).dlc[out] Data length code.
Returns:
true if a frame was received.
function syn_port_can_send¶
Send a CAN frame.
SYN_WEAK bool syn_port_can_send (
uint8_t port,
uint32_t id,
bool extended,
const uint8_t * data,
uint8_t dlc
)
Parameters:
portCAN port.idCAN identifier (11-bit or 29-bit).extendedtrue for 29-bit ID.dataFrame data (up to 8 bytes).dlcData length code (0-8).
Returns:
true if frame was queued for transmission.
function syn_port_can_set_filter¶
Set hardware acceptance filter.
Parameters:
portCAN port.idFilter ID.maskFilter mask (1 = must match, 0 = don't care).
function syn_port_delay_ms¶
Blocking delay for the specified number of milliseconds.
The implementation may busy-wait or yield to an RTOS. The delay must be at least ms milliseconds.
Parameters:
msNumber of milliseconds to delay.
function syn_port_enter_critical¶
Enter a critical section (disable interrupts).
Calls may be nested; the implementation must track nesting depth and only re-enable interrupts when the outermost critical section exits.
function syn_port_exit_critical¶
Exit a critical section (re-enable interrupts).
Must be called once for each corresponding syn_port_enter_critical().
function syn_port_exti_clear_pending¶
Clear pending interrupt flag for a pin.
Parameters:
pinGPIO pin.
function syn_port_exti_configure¶
Configure a pin for interrupt generation.
Parameters:
pinGPIO pin number.edgeTrigger edge.
Returns:
SYN_OK on success.
function syn_port_exti_disable¶
Disable interrupt on a pin (without deconfiguring).
Parameters:
pinGPIO pin.
function syn_port_exti_enable¶
Enable interrupt on a configured pin.
Parameters:
pinGPIO pin.
function syn_port_flash_erase¶
Erase a flash sector.
Parameters:
addrStart address of the sector (must be sector-aligned).
Returns:
SYN_OK on success.
function syn_port_flash_read¶
Read from flash.
Parameters:
addrSource address in flash.bufDestination buffer.lenNumber of bytes to read.
Returns:
SYN_OK on success.
function syn_port_flash_sector_size¶
Get the sector size for the given address.
Parameters:
addrAddress within the sector.
Returns:
Sector size in bytes.
function syn_port_flash_write¶
Write to flash.
Flash must be erased before writing (writes can only clear bits). The implementation should handle any alignment requirements.
Parameters:
addrDestination address in flash.bufSource data.lenNumber of bytes to write.
Returns:
SYN_OK on success.
function syn_port_get_tick_ms¶
Return the current system tick in milliseconds.
This value must be monotonically increasing and should wrap naturally at UINT32_MAX. Typical sources: SysTick, a hardware timer, or an RTOS tick.
Returns:
Milliseconds since system start (or last wrap).
function syn_port_gpio_deinit¶
De-initialize a GPIO pin, returning it to its reset state.
Parameters:
pinPin to de-initialize.
Returns:
SYN_OK on success.
function syn_port_gpio_init¶
Initialize a GPIO pin with the given mode.
Parameters:
pinPlatform-specific pin identifier.modeDesired pin mode (input, output, etc.).
Returns:
SYN_OK on success, or an error code.
function syn_port_gpio_read¶
Read the current logical state of a pin.
Parameters:
pinPin to read.
Returns:
SYN_GPIO_HIGH or SYN_GPIO_LOW.
function syn_port_gpio_toggle¶
Toggle the state of an output pin.
Parameters:
pinPin to toggle.
Returns:
SYN_OK on success.
function syn_port_gpio_write¶
Write a logical state to an output pin.
Parameters:
pinPin to write.stateSYN_GPIO_HIGH or SYN_GPIO_LOW.
Returns:
SYN_OK on success.
function syn_port_hpclock_freq_hz¶
Return the timer clock frequency in Hz.
Used for tick-to-nanosecond conversion. Must be a compile-time constant or a value that does not change after initialization.
Returns:
Timer frequency in Hz (e.g. 16000000 for 16 MHz).
function syn_port_hpclock_lsb_ptr¶
Return a pointer to the hardware timer count register.
The returned pointer must be volatile and point to a memory-mapped register that increments at the rate returned by syn_port_hpclock_freq_hz().
Returns:
Pointer to the timer counter register.
function syn_port_i2c_deinit¶
Deinitialize an I2C bus.
Parameters:
busI2C bus index.
Returns:
SYN_OK on success.
function syn_port_i2c_init¶
Initialize an I2C bus.
Parameters:
cfgI2C configuration.
Returns:
SYN_OK on success.
function syn_port_i2c_read¶
Read data from an I2C device.
Parameters:
busI2C bus index.addr7-bit device address.dataBuffer to receive data.lenNumber of bytes to read.
Returns:
SYN_OK on ACK, SYN_ERROR on NACK/timeout.
function syn_port_i2c_write¶
Write data to an I2C device.
SYN_WEAK SYN_Status syn_port_i2c_write (
uint8_t bus,
uint8_t addr,
const uint8_t * data,
size_t len
)
Parameters:
busI2C bus index.addr7-bit device address.dataData to write.lenNumber of bytes.
Returns:
SYN_OK on ACK, SYN_ERROR on NACK/timeout.
function syn_port_i2c_write_read¶
Write then read (register access pattern).
SYN_WEAK SYN_Status syn_port_i2c_write_read (
uint8_t bus,
uint8_t addr,
const uint8_t * tx_data,
size_t tx_len,
uint8_t * rx_data,
size_t rx_len
)
Sends a write (typically a register address) followed by a repeated start and read. This is the most common I2C transaction pattern.
Parameters:
busI2C bus index.addr7-bit device address.tx_dataData to write (e.g., register address).tx_lenWrite length.rx_dataBuffer for read data.rx_lenRead length.
Returns:
SYN_OK on success.
function syn_port_memory_barrier¶
function syn_port_pwm_enable¶
Enable/disable PWM output.
Parameters:
channelPWM channel index.enabletrue to enable, false to disable.
function syn_port_pwm_init¶
Initialize a PWM channel.
Parameters:
channelPWM channel number.freq_hzPWM frequency in Hz.
Returns:
SYN_OK on success.
function syn_port_pwm_set_duty¶
Set PWM duty cycle.
Parameters:
channelPWM channel number.duty_pctDuty cycle 0–100 (percent).
function syn_port_pwm_set_duty_raw¶
Set PWM duty cycle with fine resolution.
Parameters:
channelPWM channel number.duty_u16Duty cycle 0–65535 (0 = off, 65535 = 100%).
function syn_port_pwm_set_freq¶
Set PWM frequency (runtime change).
Parameters:
channelPWM channel number.freq_hzNew frequency in Hz.
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.
function syn_port_sleep¶
Enter low-power mode. Implement for your platform.
For Cortex-M: SYN_SLEEP_LIGHT → WFI, SYN_SLEEP_DEEP → STOP mode. Must return when an interrupt wakes the MCU.
Parameters:
modeRequested sleep depth.
function syn_port_sleep_until¶
function syn_port_sock_accept¶
Accept an incoming connection on a listener socket.
Blocks until a connection arrives or the timeout expires.
Parameters:
listenerListener socket from syn_port_sock_listen().timeout_msTimeout in milliseconds (0 = block indefinitely).
Returns:
Connected socket handle, or SYN_SOCKET_INVALID on timeout/error.
function syn_port_sock_close¶
Close a socket and release resources.
Parameters:
sockSocket handle to close.
function syn_port_sock_connect¶
Connect to a remote host by IP address.
Opens a TCP connection. Blocking.
Parameters:
addrRemote address (IPv4 + port).
Returns:
Socket handle on success, SYN_SOCKET_INVALID on failure.
function syn_port_sock_connect_host¶
Connect to a remote host by hostname.
Performs DNS resolution and opens a TCP connection. Blocking.
Parameters:
hostHostname or dotted-decimal IP string.portPort number.
Returns:
Socket handle on success, SYN_SOCKET_INVALID on failure.
function syn_port_sock_listen¶
Create a listening TCP socket on the given port.
Binds to all interfaces and begins listening for connections.
Parameters:
portPort number to listen on.backlogMaximum pending connections (typically 1–5).
Returns:
Listener socket handle, or SYN_SOCKET_INVALID on failure.
function syn_port_sock_recv¶
Receive data from a connected socket.
SYN_WEAK int syn_port_sock_recv (
SYN_Socket sock,
void * buf,
size_t max_len,
uint32_t timeout_ms
)
Returns available data up to max_len. Blocks up to timeout_ms.
Parameters:
sockSocket handle.bufReceive buffer.max_lenBuffer capacity.timeout_msTimeout in milliseconds (0 = non-blocking).
Returns:
Number of bytes received, 0 if connection closed, -1 on error/timeout.
function syn_port_sock_send¶
Send data over a connected socket.
May send fewer bytes than requested (partial send).
Parameters:
sockSocket handle.dataData to send.lenNumber of bytes to send.
Returns:
Number of bytes sent, or -1 on error.
function syn_port_sock_send_all¶
Send all data over a connected socket.
Loops internally until all bytes are sent or an error occurs.
Parameters:
sockSocket handle.dataData to send.lenNumber of bytes to send.
Returns:
Number of bytes sent (== len on success), or -1 on error.
function syn_port_spi_cs_assert¶
Assert (pull low) an SPI chip-select pin.
Parameters:
busSPI bus index.cs_pinChip-select GPIO pin.
Returns:
SYN_OK on success.
function syn_port_spi_cs_deassert¶
Deassert (release high) an SPI chip-select pin.
Parameters:
busSPI bus index.cs_pinChip-select GPIO pin.
Returns:
SYN_OK on success.
function syn_port_spi_deinit¶
Deinitialize an SPI bus.
Parameters:
busSPI bus index.
Returns:
SYN_OK on success.
function syn_port_spi_init¶
Initialize an SPI bus.
Parameters:
cfgSPI configuration.
Returns:
SYN_OK on success.
function syn_port_spi_transfer¶
Full-duplex SPI transfer.
SYN_WEAK SYN_Status syn_port_spi_transfer (
uint8_t bus,
const uint8_t * tx_buf,
uint8_t * rx_buf,
size_t len
)
Simultaneously transmits from tx_buf and receives into rx_buf. Either buffer can be NULL for half-duplex operation.
Parameters:
busSPI bus index.tx_bufTransmit buffer (NULL to send 0x00/0xFF).rx_bufReceive buffer (NULL to discard received data).lenNumber of bytes to transfer.
Returns:
SYN_OK on success.
function syn_port_system_reset¶
Perform a system reset.
This function should not return. On Cortex-M, this is typically NVIC_SystemReset().
function syn_port_uart_deinit¶
De-initialize a UART peripheral.
Parameters:
instanceUART instance to de-initialize.
Returns:
SYN_OK on success.
function syn_port_uart_init¶
Initialize a UART peripheral.
Parameters:
instanceUART instance number (0, 1, 2, …).baudrateDesired baud rate.
Returns:
SYN_OK on success.
function syn_port_uart_receive¶
Receive bytes into a buffer (blocking).
SYN_WEAK SYN_Status syn_port_uart_receive (
SYN_UARTInstance instance,
uint8_t * data,
size_t len,
size_t * received,
uint32_t timeout_ms
)
Parameters:
instanceUART instance.dataBuffer to receive into.lenMaximum number of bytes to receive.received[out] Actual number of bytes received.timeout_msTimeout in milliseconds (0 = no timeout).
Returns:
SYN_OK on success, SYN_TIMEOUT if the timeout elapsed.
function syn_port_uart_receive_byte¶
Receive a single byte (blocking).
SYN_WEAK SYN_Status syn_port_uart_receive_byte (
SYN_UARTInstance instance,
uint8_t * byte,
uint32_t timeout_ms
)
Parameters:
instanceUART instance.byte[out] Received byte.timeout_msTimeout in milliseconds (0 = no timeout).
Returns:
SYN_OK if a byte was received, SYN_TIMEOUT otherwise.
function syn_port_uart_transmit¶
Transmit a buffer of bytes (blocking).
SYN_WEAK SYN_Status syn_port_uart_transmit (
SYN_UARTInstance instance,
const uint8_t * data,
size_t len,
uint32_t timeout_ms
)
Parameters:
instanceUART instance.dataPointer to data to transmit.lenNumber of bytes to transmit.timeout_msTimeout in milliseconds (0 = no timeout).
Returns:
SYN_OK on success, SYN_TIMEOUT if the timeout elapsed.
function syn_port_uart_transmit_byte¶
Transmit a single byte (blocking).
Parameters:
instanceUART instance.byteByte to transmit.
Returns:
SYN_OK on success.
function syn_port_udp_join_multicast¶
Join a multicast group.
Parameters:
sockUDP socket handle.multicast_ipMulticast IP string (e.g. "224.0.0.251").
Returns:
SYN_OK on success, SYN_ERROR on failure.
function syn_port_udp_open¶
Open a UDP socket bound to the given port.
Parameters:
portLocal port to bind to, or 0 for ephemeral.
Returns:
Socket handle on success, SYN_SOCKET_INVALID on failure.
function syn_port_udp_recvfrom¶
Receive a UDP packet.
SYN_WEAK int syn_port_udp_recvfrom (
SYN_Socket sock,
void * buf,
size_t max_len,
SYN_SockAddr * from,
uint32_t timeout_ms
)
Parameters:
sockSocket handle.bufReceive buffer.max_lenBuffer capacity.from[out] Source address.timeout_msReceive timeout in milliseconds. If 0, must return immediately (non-blocking poll). Cooperative tasks (protothreads) rely on this to avoid blocking the scheduler. Port implementations MUST NOT treat 0 as "block forever."
Returns:
Number of bytes received, 0 if no data available (non-blocking), or -1 on error.
function syn_port_udp_sendto¶
Send a UDP packet to a destination address.
SYN_WEAK int syn_port_udp_sendto (
SYN_Socket sock,
const void * data,
size_t len,
const SYN_SockAddr * to
)
Parameters:
sockSocket handle.dataPayload to send.lenPayload length.toDestination address (IP + port).
Returns:
Number of bytes sent, or -1 on error.
The documentation for this class was generated from the following file src/syntropic/port_stubs/syn_port_stubs.c