Synergy Software Package User's Manual

RTOS-integrated Communications Framework UART implementation. More...

Data Structures

struct  sf_uart_comms_instance_ctrl_t
 
struct  sf_uart_comms_cfg_t
 

Macros

#define SF_UART_COMMS_CODE_VERSION_MAJOR   (2U)
 

Enumerations

enum  sf_uart_comms_state_t { SF_UART_COMMS_STATE_CLOSED = 0, SF_UART_COMMS_STATE_OPENED, SF_UART_COMMS_STATE_READING, SF_UART_COMMS_STATE_WRITING }
 

Functions

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)
 

Detailed Description

RTOS-integrated Communications Framework UART implementation.

Macro Definition Documentation

◆ 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

Enumeration Type Documentation

◆ 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.

Function Documentation

◆ SF_UART_COMMS_Close()

ssp_err_t SF_UART_COMMS_Close ( sf_comms_ctrl_t *const  p_api_ctrl)

Close the UART Channel and clean up the resources.

Parameters
[in]p_api_ctrlPointer to the UART control block
Return values
SSP_SUCCESSUART channel is successfully closed.
SSP_ERR_ASSERTIONParameter 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_OPENChannel 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()

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.

Parameters
[in]p_api_ctrlPointer to the UART control block
[in]lock_typeType of Lock.
[in]timeouttimeout for lock.
Return values
SSP_SUCCESSLocking UART resource successful.
SSP_ERR_ASSERTIONPointer to UART control block is NULL.
SSP_ERR_NOT_OPENChannel is not opened.
SSP_ERR_TIMEOUTTimeout 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()

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.

Parameters
[in,out]p_api_ctrlPointer to the UART control block
[in]p_cfgPointer to the configuration structure
Return values
SSP_SUCCESSChannel opened successfully.
SSP_ERR_IN_USEChannel already in use.
SSP_ERR_ASSERTIONParameter 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_INTERNALAn 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_ctrlPointer to the UART control block
[in]bytesNo.of bytes to be read
[in]timeouttimeout for read
[out]p_destDestination buffer
Return values
SSP_SUCCESSData reception ends successfully.
SSP_ERR_NOT_OPENChannel is not opened.
SSP_ERR_HW_LOCKEDChannel is locked.
SSP_ERR_ASSERTIONPointer to UART control block/pointer to destination address is NULL.
SSP_ERR_INVALID_MODEChannel is used for non-UART mode.
SSP_ERR_INSUFFICIENT_DATANot enough data in receive circular buffer.
SSP_ERR_OVERFLOWHardware overflow.
SSP_ERR_FRAMINGFraming error.
SSP_ERR_PARITYParity error.
SSP_ERR_BREAK_DETECTBreak signal detected.
SSP_ERR_TIMEOUTOne of the following operation timed out.
  • 'Event flags get' timed out
  • 'Receive mutex get' timed out
SSP_ERR_INTERNALAn 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()

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.

Parameters
[in]p_api_ctrlPointer to the UART control block
[in]lock_typeType of Lock.
Return values
SSP_SUCCESSUnlocking UART resource successful.
SSP_ERR_ASSERTIONPointer to UART control block is NULL.
SSP_ERR_NOT_OPENChannel is not opened.
SSP_ERR_INTERNALFailed to release the mutex.

◆ SF_UART_COMMS_VersionGet()

ssp_err_t SF_UART_COMMS_VersionGet ( ssp_version_t *const  p_version)
Return values
SSP_SUCCESSVersion number obtained successfully.
SSP_ERR_ASSERTIONPointer 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_ctrlPointer to the UART control block
[in]bytesNumber of bytes to be written.
[in]timeoutTimeout 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_srcSource buffer
Return values
SSP_SUCCESSData transmission finished successfully.
SSP_ERR_ASSERTIONPointer to UART control block is NULL. Pointer to source buffer is NULL.
SSP_ERR_NOT_OPENChannel is not opened.
SSP_ERR_INVALID_MODEChannel is used for non-UART mode or illegal mode is set in handle.
SSP_ERR_INSUFFICIENT_SPACENot enough space in transmission circular buffer.
SSP_ERR_HW_LOCKEDCould not lock hardware.
SSP_ERR_TIMEOUT'Transmit mutex get' timed out
SSP_ERR_INTERNALAn 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