Middleware to implement a generic communications interface over UART. This module implements the Communicatons Middleware Interface.
Overview
The RM_COMMS_UART module implements COMMS API for UART interface.
Features
The implementation of the UART communications interfacehas the following key features:
- Non-blocking API for bare metal
- Non-blocking and blocking API for RTOS
Configuration
Build Time Configurations for rm_comms_uart
The following build time configurations are defined in fsp_cfg/rm_comms_uart_cfg.h:
Configuration | Options | Default | Description |
Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configurations for Connectivity > UART Communication Device (rm_comms_uart)
This module can be added to the Stacks tab via New Stack > Connectivity > UART Communication Device (rm_comms_uart).
Configuration | Options | Default | Description |
RTOS > Write Mutex |
| Use | Lock device for writing in using RTOS. |
RTOS > Read Mutex |
| Use | Lock device for reading in using RTOS. |
RTOS > Mutex Timeout | Value must be a non-negative integer | 0xFFFFFFFF | Timeout for recursive mutex operation in using RTOS. |
RTOS > Write Semaphore |
| Use | Block writing in using RTOS. |
RTOS > Read Semaphore |
| Use | Block reading in using RTOS. |
RTOS > Semaphore Timeout | Value must be a non-negative integer | 0xFFFFFFFF | Timeout for semaphore operation in using RTOS. |
Name | Name must be a valid C symbol | g_comms_uart0 | Module name. |
Callback | Name must be a valid C symbol | NULL | A user callback function can be provided. |
Usage Notes
Limitations
Examples
Basic Example
This is a basic example of minimal use of UART communications implementation in an application.
void rm_comms_uart_basic_example (void)
{
if (FSP_SUCCESS != err)
{
}
while (true)
{
g_err_flag = 0;
g_tx_flag = 0;
if (FSP_SUCCESS != err)
{
}
while ((0 == g_tx_flag) && (0 == g_err_flag))
{
}
g_err_flag = 0;
g_rx_flag = 0;
if (FSP_SUCCESS != err)
{
}
while ((0 == g_rx_flag) && (0 == g_err_flag))
{
}
}
}
{
if (p_args->event == RM_COMMS_EVENT_TX_OPERATION_COMPLETE)
{
g_tx_flag = 1;
}
else if (p_args->event == RM_COMMS_EVENT_RX_OPERATION_COMPLETE)
{
g_rx_flag = 1;
}
else
{
g_err_flag = 1;
}
}
◆ rm_comms_uart_instance_ctrl_t
struct rm_comms_uart_instance_ctrl_t |
Communications middleware control structure.
Data Fields |
uint32_t | open |
| Open flag.
|
|
rm_comms_cfg_t const * | p_cfg |
| Middleware configuration.
|
|
rm_comms_uart_extended_cfg_t const * | p_extend |
| Pointer to extended configuration structure.
|
|
void(* | p_callback )(rm_comms_callback_args_t *p_args) |
| Pointer to callback that is called when a uart_event_t occurs.
|
|
void const * | p_context |
| Pointer to context passed into callback function.
|
|
◆ RM_COMMS_UART_Open()
Opens and configures the UART Comms module. Implements rm_comms_api_t::open.
- Return values
-
FSP_SUCCESS | UART Comms module successfully configured. |
FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
FSP_ERR_ALREADY_OPEN | Module is already open. This module can only be opened once. |
- Returns
- See Common Error Codes or functions called by this function for other possible return codes.
◆ RM_COMMS_UART_Close()
Disables specified UART Comms module. Implements rm_comms_api_t::close.
- Return values
-
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
- Returns
- See Common Error Codes or functions called by this function for other possible return codes.
◆ RM_COMMS_UART_Read()
Performs a read from the UART device. Implements rm_comms_api_t::read.
- Return values
-
FSP_SUCCESS | Successfully data decoded. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
- Returns
- See Common Error Codes or functions called by this function for other possible return codes.
◆ RM_COMMS_UART_Write()
Performs a write to the UART device. Implements rm_comms_api_t::write.
- Return values
-
FSP_SUCCESS | Successfully writing data . |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
- Returns
- See Common Error Codes or functions called by this function for other possible return codes.
◆ RM_COMMS_UART_WriteRead()
Performs a write to, then a read from the UART device. Implements rm_comms_api_t::writeRead.
- Return values
-
FSP_ERR_UNSUPPORTED | Not supported. |
◆ RM_COMMS_UART_CallbackSet()
Updates the UART Comms callback. Implements rm_comms_api_t::callbackSet.
- Return values
-
FSP_SUCCESS | Successfully set. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |