![]() |
Wirepas SDK
|
Go to the source code of this file.
Typedefs | |
| typedef void | usart_multi_instance_t |
| Opaque instance type - driver owns memory, user holds pointer. | |
| typedef void(* | usart_multi_rx_callback_f) (usart_multi_instance_id_t instance_id, const uint8_t *p_data, size_t length) |
| RX data callback - called when data received. | |
| typedef void(* | usart_multi_tx_callback_f) (usart_multi_instance_id_t instance_id) |
| TX complete callback - called when TX finishes. | |
| typedef void(* | usart_multi_error_callback_f) (usart_multi_instance_id_t instance_id, uint32_t error_flags) |
| Error callback - called on UART errors. | |
| typedef void(* | usart_multi_idle_callback_f) (usart_multi_instance_id_t instance_id, const uint8_t *p_data, size_t length) |
| Idle line callback - called when RX line goes idle. | |
Data Structures | |
| struct | usart_multi_data_format_t |
| Data format configuration. More... | |
| struct | usart_multi_init_params_t |
| Initialization parameters for UART instance. More... | |
| struct | usart_multi_error_stats_t |
| Error statistics counters. More... | |
| typedef void(* usart_multi_error_callback_f) (usart_multi_instance_id_t instance_id, uint32_t error_flags) |
Error callback - called on UART errors.
| instance_id | UART instance that triggered callback |
| error_flags | Bitmask of error flags (usart_multi_error_flags_e) |
Definition at line 187 of file usart_multi.h.
| typedef void(* usart_multi_idle_callback_f) (usart_multi_instance_id_t instance_id, const uint8_t *p_data, size_t length) |
Idle line callback - called when RX line goes idle.
| instance_id | UART instance that triggered callback |
| p_data | Pointer to received data (read-only) |
| length | Number of bytes received before idle |
Definition at line 197 of file usart_multi.h.
| typedef void usart_multi_instance_t |
Opaque instance type - driver owns memory, user holds pointer.
Definition at line 49 of file usart_multi.h.
| typedef void(* usart_multi_rx_callback_f) (usart_multi_instance_id_t instance_id, const uint8_t *p_data, size_t length) |
RX data callback - called when data received.
| instance_id | UART instance that triggered callback |
| p_data | Pointer to received data (read-only) |
| length | Number of bytes received |
Definition at line 170 of file usart_multi.h.
| typedef void(* usart_multi_tx_callback_f) (usart_multi_instance_id_t instance_id) |
TX complete callback - called when TX finishes.
| instance_id | UART instance that triggered callback |
Definition at line 179 of file usart_multi.h.
| usart_multi_status_t usart_multi_abort_receive | ( | usart_multi_instance_t * | p_instance | ) |
Abort ongoing RX transfer and stop receiver.
| p_instance | Instance pointer |
| USART_MULTI_SUCCESS | Reception aborted successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| USART_MULTI_ERROR_NOT_SUPPORTED | Abort not supported on this platform |
| USART_MULTI_ERROR_HARDWARE | Hardware abort failed |
| usart_multi_status_t usart_multi_abort_transmit | ( | usart_multi_instance_t * | p_instance | ) |
Abort ongoing TX transfer.
| p_instance | Instance pointer |
| USART_MULTI_SUCCESS | Transmission aborted successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| USART_MULTI_ERROR_NOT_SUPPORTED | Abort not supported on this platform |
| USART_MULTI_ERROR_HARDWARE | Hardware abort failed |
| usart_multi_status_t usart_multi_clear_error_stats | ( | usart_multi_instance_t * | p_instance | ) |
Reset all error counters to zero.
| p_instance | Instance pointer |
| USART_MULTI_SUCCESS | Error counters cleared successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| usart_multi_status_t usart_multi_deinit | ( | usart_multi_instance_t ** | pp_instance | ) |
Deinitialize UART instance.
Stops all transfers, disables peripheral, and sets *pp_instance to NULL
| pp_instance | Pointer to instance pointer |
| USART_MULTI_SUCCESS | Instance deinitialized successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer or *pp_instance is NULL |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| USART_MULTI_ERROR_HARDWARE | Hardware deinitialization failed |
| usart_multi_status_t usart_multi_enable_receiver | ( | usart_multi_instance_t * | p_instance | ) |
Start receiver.
RX callback must be registered first using usart_multi_register_rx_callback()
| p_instance | Instance pointer |
| USART_MULTI_SUCCESS | Receiver started successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| USART_MULTI_ERROR_NOT_ENABLED | UART not enabled |
| USART_MULTI_ERROR_HARDWARE | Hardware RX enable failed |
| usart_multi_status_t usart_multi_flush | ( | usart_multi_instance_t * | p_instance | ) |
Block until all pending TX data transmitted.
| p_instance | Instance pointer |
| USART_MULTI_SUCCESS | All data transmitted successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| USART_MULTI_ERROR_TIMEOUT | Transmission did not complete in time |
| USART_MULTI_ERROR_HARDWARE | Hardware error during transmission |
| usart_multi_status_t usart_multi_get_error_stats | ( | const usart_multi_instance_t * | p_instance, |
| usart_multi_error_stats_t * | p_stats | ||
| ) |
Retrieve accumulated error statistics.
| p_instance | Instance pointer |
| p_stats | Statistics structure to populate |
| USART_MULTI_SUCCESS | Statistics retrieved successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| uint8_t usart_multi_get_instance_count | ( | void | ) |
Get total UART instances available on platform.
| size_t usart_multi_get_max_tx_size | ( | const usart_multi_instance_t * | p_instance | ) |
Get maximum bytes per usart_multi_send_buffer() call.
| p_instance | Instance pointer |
| usart_multi_status_t usart_multi_init | ( | usart_multi_instance_t ** | pp_instance, |
| usart_multi_instance_id_t | instance_id, | ||
| const usart_multi_init_params_t * | p_params | ||
| ) |
Initialize UART instance from driver's static pool.
On success, populates *pp_instance with pointer to instance from driver's memory pool. UART starts disabled - call usart_multi_set_enabled(true) to activate.
| pp_instance | Pointer to instance pointer (populated by driver) |
| instance_id | Instance ID to initialize (USART_MULTI_INSTANCE_0, etc.) |
| p_params | Initialization parameters |
| USART_MULTI_SUCCESS | Instance initialized successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer, invalid instance_id, or invalid parameters |
| USART_MULTI_ERROR_ALREADY_INITIALIZED | Instance already initialized |
| USART_MULTI_ERROR_HARDWARE | Hardware initialization failed |
| usart_multi_status_t usart_multi_register_error_callback | ( | usart_multi_instance_t * | p_instance, |
| usart_multi_error_callback_f | p_callback | ||
| ) |
Register error callback for error notification.
Pass NULL to disable. Callback runs in ISR context.
| p_instance | Instance pointer |
| p_callback | Callback function (NULL to disable) |
| USART_MULTI_SUCCESS | Callback registered successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| usart_multi_status_t usart_multi_register_idle_callback | ( | usart_multi_instance_t * | p_instance, |
| usart_multi_idle_callback_f | p_callback | ||
| ) |
Register idle line detection callback.
Pass NULL to disable. Requires idle_detect_enabled = true during init. Callback runs in ISR context. Used for variable-length packet detection.
| p_instance | Instance pointer |
| p_callback | Callback function (NULL to disable) |
| USART_MULTI_SUCCESS | Callback registered successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| usart_multi_status_t usart_multi_register_rx_callback | ( | usart_multi_instance_t * | p_instance, |
| usart_multi_rx_callback_f | p_callback | ||
| ) |
Register RX data callback.
Callback must be provided (cannot be NULL). Callback runs in ISR context.
| p_instance | Instance pointer |
| p_callback | Callback function |
| USART_MULTI_SUCCESS | Callback registered successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer or NULL callback |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| usart_multi_status_t usart_multi_register_tx_callback | ( | usart_multi_instance_t * | p_instance, |
| usart_multi_tx_callback_f | p_callback | ||
| ) |
Register TX complete callback.
Pass NULL to disable. Callback runs in ISR context.
| p_instance | Instance pointer |
| p_callback | Callback function (NULL to disable) |
| USART_MULTI_SUCCESS | Callback registered successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| usart_multi_status_t usart_multi_send_buffer | ( | usart_multi_instance_t * | p_instance, |
| const void * | p_buf, | ||
| size_t | len | ||
| ) |
Queue data for transmission.
All-or-nothing: either all data queued (returns SUCCESS) or none. Non-blocking operation.
| p_instance | Instance pointer |
| p_buf | Buffer to transmit (read-only) |
| len | Number of bytes to transmit |
| USART_MULTI_SUCCESS | All data queued for transmission |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer or len exceeds max TX size |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| USART_MULTI_ERROR_NOT_ENABLED | UART not enabled |
| USART_MULTI_ERROR_BUFFER_FULL | TX buffer full, no space for this data |
| USART_MULTI_ERROR_HARDWARE | Hardware error during queuing |
| usart_multi_status_t usart_multi_set_enabled | ( | usart_multi_instance_t * | p_instance, |
| bool | enabled | ||
| ) |
Enable or disable UART peripheral.
Uses reference counting - multiple enables require matching disables
| p_instance | Instance pointer |
| enabled | True to enable, false to disable |
| USART_MULTI_SUCCESS | UART enabled/disabled successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| USART_MULTI_ERROR_HARDWARE | Hardware enable/disable failed |
| usart_multi_status_t usart_multi_set_flow_control | ( | usart_multi_instance_t * | p_instance, |
| usart_multi_flow_control_e | flow_control | ||
| ) |
Change flow control mode.
| p_instance | Instance pointer |
| flow_control | Desired flow control mode |
| USART_MULTI_SUCCESS | Flow control configured successfully |
| USART_MULTI_ERROR_INVALID_PARAM | NULL pointer or invalid value |
| USART_MULTI_ERROR_NOT_INITIALIZED | Instance not initialized |
| USART_MULTI_ERROR_NOT_ENABLED | UART is enabled (must disable first) |
| USART_MULTI_ERROR_NOT_SUPPORTED | Flow control not supported on platform |
| USART_MULTI_ERROR_HARDWARE | Hardware configuration failed |
| struct usart_multi_data_format_t |
Data format configuration.
Definition at line 130 of file usart_multi.h.
| Data Fields | ||
|---|---|---|
| uint8_t | data_bits |
7, 8 (default), or 9 data bits |
| usart_multi_parity_e | parity |
Parity mode (0 = NONE, default) |
| usart_multi_stop_bits_e | stop_bits |
Stop bits (0 = 1 bit, default) |
| struct usart_multi_init_params_t |
Initialization parameters for UART instance.
Definition at line 140 of file usart_multi.h.
| Data Fields | ||
|---|---|---|
| uint32_t | baudrate |
Baud rate (9600-3000000) |
| usart_multi_data_format_t | data_format |
Data format (default: 8N1) |
| bool | dma_enabled |
Enable DMA transfers |
| usart_multi_flow_control_e | flow_control |
Flow control (0 = NONE, default) |
| bool | idle_detect_enabled |
Enable idle line detection |
| usart_multi_mode_e | mode |
Communication mode (0 = ASYNC, default) |
| usart_multi_power_mode_e | power_mode |
Power mode (0 = NORMAL, default) |
| bool | wakeup_enabled |
RX wake from sleep (EUSART only) |
| struct usart_multi_error_stats_t |
Error statistics counters.
Definition at line 155 of file usart_multi.h.
Error event flags - can be OR'd together.
Definition at line 101 of file usart_multi.h.
Flow control modes.
| Enumerator | |
|---|---|
| USART_MULTI_FLOW_CONTROL_NONE | No flow control (default) |
| USART_MULTI_FLOW_CONTROL_HW | Hardware RTS/CTS |
Definition at line 54 of file usart_multi.h.
Instance ID - identifies which UART peripheral.
Definition at line 32 of file usart_multi.h.
| enum usart_multi_mode_e |
Communication modes.
Definition at line 63 of file usart_multi.h.
| enum usart_multi_parity_e |
Parity modes.
| Enumerator | |
|---|---|
| USART_MULTI_PARITY_NONE | No parity (default, 8N1) |
| USART_MULTI_PARITY_EVEN | Even parity |
| USART_MULTI_PARITY_ODD | Odd parity |
Definition at line 82 of file usart_multi.h.
Power modes.
| Enumerator | |
|---|---|
| USART_MULTI_POWER_MODE_NORMAL | Normal power (default) |
| USART_MULTI_POWER_MODE_LOW_POWER | Low-power mode (EUSART: EM2) |
Definition at line 73 of file usart_multi.h.
| enum usart_multi_status_t |
Status codes returned by API functions.
Definition at line 113 of file usart_multi.h.
Stop bits.
| Enumerator | |
|---|---|
| USART_MULTI_STOP_BITS_1 | 1 stop bit (default, 8N1) |
| USART_MULTI_STOP_BITS_2 | 2 stop bits |
Definition at line 92 of file usart_multi.h.