RTOS-integrated Communications Framework UART implementation.
More...
|
| ssp_err_t | SF_UART_COMMS_Open (sf_comms_ctrl_t *const p_api_ctrl, sf_comms_cfg_t const *const p_cfg) |
| | Open the UART for communication. More...
|
| |
| ssp_err_t | SF_UART_COMMS_Close (sf_comms_ctrl_t *const p_api_ctrl) |
| | Close the UART Channel and clean up the resources. More...
|
| |
| ssp_err_t | SF_UART_COMMS_Read (sf_comms_ctrl_t *const p_api_ctrl, uint8_t *const p_dest, uint32_t const bytes, UINT const timeout) |
| | Read user specified number of bytes into destination buffer pointer. More...
|
| |
| ssp_err_t | SF_UART_COMMS_Write (sf_comms_ctrl_t *const p_api_ctrl, uint8_t const *const p_src, uint32_t const bytes, UINT const timeout) |
| | Write user specified number of bytes from the source buffer. More...
|
| |
| ssp_err_t | SF_UART_COMMS_Lock (sf_comms_ctrl_t *const p_api_ctrl, sf_comms_lock_t lock_type, UINT timeout) |
| | Lock the UART resource. More...
|
| |
| ssp_err_t | SF_UART_COMMS_Unlock (sf_comms_ctrl_t *const p_api_ctrl, sf_comms_lock_t lock_type) |
| | UnLock the UART resource. More...
|
| |
| ssp_err_t | SF_UART_COMMS_VersionGet (ssp_version_t *const p_version) |
| |
RTOS-integrated Communications Framework UART implementation.
◆ SF_UART_COMMS_CODE_VERSION_MAJOR
| #define SF_UART_COMMS_CODE_VERSION_MAJOR (2U) |
Version of code that implements the API defined in this file
◆ sf_uart_comms_state_t
Framework UART state
| Enumerator |
|---|
| SF_UART_COMMS_STATE_CLOSED | UART port is closed.
|
| SF_UART_COMMS_STATE_OPENED | UART port is opened.
|
| SF_UART_COMMS_STATE_READING | UART port is on data reception.
|
| SF_UART_COMMS_STATE_WRITING | UART port is on data transmission.
|
◆ SF_UART_COMMS_Close()
Close the UART Channel and clean up the resources.
- Parameters
-
| [in] | p_api_ctrl | Pointer to the UART control block |
- Return values
-
| SSP_SUCCESS | UART channel is successfully closed. |
| SSP_ERR_ASSERTION | Parameter check failed for one of the following:
- Pointer p_api_ctrl is NULL.
- Pointer p_ctrl->p_lower_lvl_uart is NULL
- Pointer p_ctrl->p_lower_lvl_uart->p_api is NULL
- Pointer p_ctrl->p_lower_lvl_uart->p_api->close is NULL
|
| SSP_ERR_NOT_OPEN | Channel is not opened. |
- Note
- This function is reentrant for any channel.
Checks error. Further parameter checking can be done at the driver layer.
Calls close function of UART HAL driver
Release ThreadX resources
◆ SF_UART_COMMS_Lock()
Lock the UART resource.
- Parameters
-
| [in] | p_api_ctrl | Pointer to the UART control block |
| [in] | lock_type | Type of Lock. |
| [in] | timeout | timeout for lock. |
- Return values
-
| SSP_SUCCESS | Locking UART resource successful. |
| SSP_ERR_ASSERTION | Pointer to UART control block is NULL. |
| SSP_ERR_NOT_OPEN | Channel is not opened. |
| SSP_ERR_TIMEOUT | Timeout Error. 'Receive mutex get' timed out 'Transmit mutex get' timed out |
Get both lock if requested, else get the lock type requested
◆ SF_UART_COMMS_Open()
Open the UART for communication.
- Parameters
-
| [in,out] | p_api_ctrl | Pointer to the UART control block |
| [in] | p_cfg | Pointer to the configuration structure |
- Return values
-
| SSP_SUCCESS | Channel opened successfully. |
| SSP_ERR_IN_USE | Channel already in use. |
| SSP_ERR_ASSERTION | Parameter check failed for one of the following:
- Pointer p_api_ctrl is NULL.
- Pointer p_cfg is NULL
- Pointer p_cfg->p_extend is NULL
- Pointer p_cfg_extend->p_lower_lvl_uart is NULL
- Pointer p_cfg_extend->p_lower_lvl_uart->p_api->open is NULL
- Pointer p_cfg_extend->p_lower_lvl_uart->p_cfg is NULL
|
| SSP_ERR_INTERNAL | An internal ThreadX error has occurred. This is typically a failure to create/use thread mutex or failure create/use event flags or queue. |
- Returns
- See Common Error Codes or functions called by this function for other possible codes. This function calls:
- Note
- This function is reentrant for any channel. Handle must be cleared by caller before calling this function.
Checks error. Further parameter checking can be done at the driver layer.
Initialize and start ThreadX resources
Calls open function of UART HAL driver
◆ SF_UART_COMMS_Read()
| ssp_err_t SF_UART_COMMS_Read |
( |
sf_comms_ctrl_t *const |
p_api_ctrl, |
|
|
uint8_t *const |
p_dest, |
|
|
uint32_t const |
bytes, |
|
|
UINT const |
timeout |
|
) |
| |
Read user specified number of bytes into destination buffer pointer.
- Parameters
-
| [in] | p_api_ctrl | Pointer to the UART control block |
| [in] | bytes | No.of bytes to be read |
| [in] | timeout | timeout for read |
| [out] | p_dest | Destination buffer |
- Return values
-
| SSP_SUCCESS | Data reception ends successfully. |
| SSP_ERR_NOT_OPEN | Channel is not opened. |
| SSP_ERR_HW_LOCKED | Channel is locked. |
| SSP_ERR_ASSERTION | Pointer to UART control block/pointer to destination address is NULL. |
| SSP_ERR_INVALID_MODE | Channel is used for non-UART mode. |
| SSP_ERR_INSUFFICIENT_DATA | Not enough data in receive circular buffer. |
| SSP_ERR_OVERFLOW | Hardware overflow. |
| SSP_ERR_FRAMING | Framing error. |
| SSP_ERR_PARITY | Parity error. |
| SSP_ERR_BREAK_DETECT | Break signal detected. |
| SSP_ERR_TIMEOUT | One of the following operation timed out.
- 'Event flags get' timed out
- 'Receive mutex get' timed out
|
| SSP_ERR_INTERNAL | An internal ThreadX error has occurred. This is typically a failure to create/use thread mutex or failure create/use event flags or queue. |
- Returns
- See Common Error Codes or functions called by this function for other possible return codes. This function calls:
Locks the UART reception hardware resource
Unlock the UART reception hardware resource
◆ SF_UART_COMMS_Unlock()
UnLock the UART resource.
- Parameters
-
| [in] | p_api_ctrl | Pointer to the UART control block |
| [in] | lock_type | Type of Lock. |
- Return values
-
| SSP_SUCCESS | Unlocking UART resource successful. |
| SSP_ERR_ASSERTION | Pointer to UART control block is NULL. |
| SSP_ERR_NOT_OPEN | Channel is not opened. |
| SSP_ERR_INTERNAL | Failed to release the mutex. |
◆ SF_UART_COMMS_VersionGet()
- Return values
-
| SSP_SUCCESS | Version number obtained successfully. |
| SSP_ERR_ASSERTION | Pointer to version is NULL |
◆ SF_UART_COMMS_Write()
| ssp_err_t SF_UART_COMMS_Write |
( |
sf_comms_ctrl_t *const |
p_api_ctrl, |
|
|
uint8_t const *const |
p_src, |
|
|
uint32_t const |
bytes, |
|
|
UINT const |
timeout |
|
) |
| |
Write user specified number of bytes from the source buffer.
- Parameters
-
| [in] | p_api_ctrl | Pointer to the UART control block |
| [in] | bytes | Number of bytes to be written. |
| [in] | timeout | Timeout for write. This timeout must be long enough for the write to complete. A timeout of 0 or TX_NO_WAIT results in a return value of SSP_ERR_TIMEOUT. |
| [out] | p_src | Source buffer |
- Return values
-
| SSP_SUCCESS | Data transmission finished successfully. |
| SSP_ERR_ASSERTION | Pointer to UART control block is NULL. Pointer to source buffer is NULL. |
| SSP_ERR_NOT_OPEN | Channel is not opened. |
| SSP_ERR_INVALID_MODE | Channel is used for non-UART mode or illegal mode is set in handle. |
| SSP_ERR_INSUFFICIENT_SPACE | Not enough space in transmission circular buffer. |
| SSP_ERR_HW_LOCKED | Could not lock hardware. |
| SSP_ERR_TIMEOUT | 'Transmit mutex get' timed out |
| SSP_ERR_INTERNAL | An internal ThreadX error has occurred. This is typically a failure to create/use thread mutex or failure create/use event flags or queue. |
- Returns
- See Common Error Codes or functions called by this function for other possible return codes. This function calls:
Locks the UART transmission hardware resource
Clear the event flag.
Calls write function of UART HAL driver
Wait until write operation is completed. Event is signaled in event flag object
Calls communicationAbort function of UART HAL driver to abort write operation.
Unlock the UART transmission hardware resource