Synergy Software Package User's Manual

Driver for the UART on SCI. More...

Data Structures

struct  sci_uart_instance_ctrl_t
 
struct  uart_on_sci_cfg_t
 

Enumerations

enum  sci_clk_src_t { SCI_CLK_SRC_INT, SCI_CLK_SRC_EXT, SCI_CLK_SRC_EXT8X, SCI_CLK_SRC_EXT16X }
 
enum  sci_uart_rx_fifo_trigger_t { SCI_UART_RX_FIFO_TRIGGER_1 = 0x1, SCI_UART_RX_FIFO_TRIGGER_MAX = 0xF }
 

Functions

ssp_err_t R_SCI_UartOpen (uart_ctrl_t *const p_api_ctrl, uart_cfg_t const *const p_cfg)
 
ssp_err_t R_SCI_UartClose (uart_ctrl_t *const p_api_ctrl)
 
ssp_err_t R_SCI_UartRead (uart_ctrl_t *const p_api_ctrl, uint8_t const *const p_dest, uint32_t const bytes)
 
ssp_err_t R_SCI_UartWrite (uart_ctrl_t *const p_api_ctrl, uint8_t const *const p_src, uint32_t const bytes)
 
ssp_err_t R_SCI_UartBaudSet (uart_ctrl_t *const p_api_ctrl, uint32_t const baudrate)
 
ssp_err_t R_SCI_UartInfoGet (uart_ctrl_t *const p_api_ctrl, uart_info_t *const p_info)
 
ssp_err_t R_SCI_UartVersionGet (ssp_version_t *p_version)
 
ssp_err_t R_SCI_UartAbort (uart_ctrl_t *const p_api_ctrl, uart_dir_t communication_to_abort)
 

Detailed Description

Driver for the UART on SCI.

Summary

This module supports the UART on SCI. It implements the UART interface and drives SCI as a full-duplex UART communication port. This module can drive all SCI channels as UART ports.

Extends UART Interface.

Note
This module can use either the 16-stage hardware FIFO or a DTC transfer implementation to write multiple bytes.

Enumeration Type Documentation

◆ sci_clk_src_t

Enumeration for SCI clock source

Enumerator
SCI_CLK_SRC_INT 

Use internal clock for baud generation.

SCI_CLK_SRC_EXT 

Use external clock for baud generation.

SCI_CLK_SRC_EXT8X 

Use external clock 8x baud rate.

SCI_CLK_SRC_EXT16X 

Use external clock 16x baud rate.

◆ sci_uart_rx_fifo_trigger_t

Receive FIFO trigger configuration.

Enumerator
SCI_UART_RX_FIFO_TRIGGER_1 

Callback after each byte is received without buffering.

SCI_UART_RX_FIFO_TRIGGER_MAX 

Callback when FIFO is full or after 15 bit times with no data (fewer interrupts)

Function Documentation

◆ R_SCI_UartAbort()

ssp_err_t R_SCI_UartAbort ( uart_ctrl_t *const  p_api_ctrl,
uart_dir_t  communication_to_abort 
)

Provides API to abort ongoing transfer. Transmission is aborted after the current character is transmitted. Reception is still enabled after abort(). Any characters received after abort() and before the transfer is reset in the next call to read(), will arrive via the callback function with event UART_EVENT_RX_CHAR.

Return values
SSP_SUCCESSUART transaction aborted successfully.
SSP_ERR_ASSERTIONPointer to UART control block is NULL.
SSP_ERR_NOT_OPENThe control block has not been opened.
SSP_ERR_UNSUPPORTEDThe requested Abort direction is unsupported.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

◆ R_SCI_UartBaudSet()

ssp_err_t R_SCI_UartBaudSet ( uart_ctrl_t *const  p_api_ctrl,
uint32_t const  baudrate 
)

Updates the baud rate.

Warning
This terminates any in-progress transmission.
Return values
SSP_SUCCESSBaud rate was successfully changed.
SSP_ERR_ASSERTIONPointer to UART control block is NULL or the UART is not configured to use the internal clock.
SSP_ERR_INVALID_ARGUMENTIllegal baud rate value is specified.
SSP_ERR_NOT_OPENThe control block has not been opened

Calculate new baud rate register settings.

Disables transmitter and receiver. This terminates any in-progress transmission.

Apply new baud rate register settings.

Enable receiver.

If the channel has no FIFO, enable transmitter.

◆ R_SCI_UartClose()

ssp_err_t R_SCI_UartClose ( uart_ctrl_t *const  p_api_ctrl)

Disables interrupts, receiver, and transmitter. Closes lower level transfer drivers if used. Removes power and releases hardware lock.

Return values
SSP_SUCCESSChannel successfully closed.
SSP_ERR_ASSERTIONPointer to UART control block is NULL.
SSP_ERR_NOT_OPENThe control block has not been opened

Mark the channel not open so other APIs cannot use it.

Disable interrupts, receiver, and transmitter.

If reception is enabled at build time, disable reception irqs.

If transmission is enabled at build time, disable transmission irqs.

Disable baud clock output.

Close the lower level transfer instances.

Clear control block parameters.

Remove power to the channel.

Unlock the SCI channel.

◆ R_SCI_UartInfoGet()

ssp_err_t R_SCI_UartInfoGet ( uart_ctrl_t *const  p_api_ctrl,
uart_info_t *const  p_info 
)

Provides the driver information, including the maximum number of bytes that can be received or transmitted at a time.

Return values
SSP_SUCCESSInformation stored in provided p_info.
SSP_ERR_ASSERTIONPointer to UART control block is NULL.
SSP_ERR_NOT_OPENThe control block has not been opened

Store number of bytes that can be read at a time.

Store number of bytes that can be written at a time.

◆ R_SCI_UartOpen()

ssp_err_t R_SCI_UartOpen ( uart_ctrl_t *const  p_api_ctrl,
uart_cfg_t const *const  p_cfg 
)

Configures the UART driver based on the input configurations. If reception is enabled at compile time, reception is enabled at the end of this function.

Return values
SSP_SUCCESSChannel opened successfully.
SSP_ERR_ASSERTIONPointer to UART control block or configuration structure is NULL.
SSP_ERR_INVALID_ARGUMENTInvalid parameter setting found in the configuration structure.
SSP_ERR_IN_USEControl block has already been opened or channel is being used by another instance. Call close() then open() to reconfigure.
SSP_ERR_IRQ_BSP_DISABLEDA required interrupt does not exist in the vector table
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Make sure this channel exists.

Reserve the hardware lock.

Determine if this channel has a FIFO.

Calculate the baud rate register settings.

Configure the interrupts.

Configure the transfer interface for transmission and reception if provided.

Configuration of driver enable pin for rs485 communication mode.

Enable the SCI channel and reset the registers to their initial state.

Set the default level of the TX pin to 1.

Set the baud rate registers.

Set the UART configuration settings provided in uart_cfg_t and uart_on_sci_cfg_t.

If reception is enabled at build time, enable reception.

◆ R_SCI_UartRead()

ssp_err_t R_SCI_UartRead ( uart_ctrl_t *const  p_api_ctrl,
uint8_t const *const  p_dest,
uint32_t const  bytes 
)

Receives user specified number of bytes into destination buffer pointer.

Return values
SSP_SUCCESSData reception successfully ends.
SSP_ERR_ASSERTIONPointer to UART control block is NULL. Number of transfers outside the max or min boundary when transfer instance used
SSP_ERR_INVALID_ARGUMENTDestination address or data size is not valid for 9-bit mode.
SSP_ERR_NOT_OPENThe control block has not been opened
SSP_ERR_IN_USEA previous read operation is still in progress.
SSP_ERR_UNSUPPORTEDSCI_UART_CFG_RX_ENABLE is set to 0
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:
Note
This API is only valid when SCI_UART_CFG_RX_ENABLE is enabled. If 9-bit data length is specified at R_SCI_UartOpen call, p_dest must be aligned 16-bit boundary.

Configure transfer instance to receive the requested number of bytes if transfer is used for reception.

◆ R_SCI_UartVersionGet()

ssp_err_t R_SCI_UartVersionGet ( ssp_version_t p_version)

Provides API and code version in the user provided pointer.

Parameters
[in]p_versionVersion number set here
Return values
SSP_SUCCESSVersion information stored in provided p_version.
SSP_ERR_ASSERTIONp_version is NULL.

◆ R_SCI_UartWrite()

ssp_err_t R_SCI_UartWrite ( uart_ctrl_t *const  p_api_ctrl,
uint8_t const *const  p_src,
uint32_t const  bytes 
)

Transmits user specified number of bytes from the source buffer pointer.

Return values
SSP_SUCCESSData transmission finished successfully.
SSP_ERR_ASSERTIONPointer to UART control block is NULL. Number of transfers outside the max or min boundary when transfer instance used
SSP_ERR_INVALID_ARGUMENTSource address or data size is not valid for 9-bit mode.
SSP_ERR_NOT_OPENThe control block has not been opened
SSP_ERR_IN_USEA UART transmission is in progress
SSP_ERR_UNSUPPORTEDSCI_UART_CFG_TX_ENABLE is set to 0
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:
Note
This API is only valid when SCI_UART_CFG_TX_ENABLE is enabled. If 9-bit data length is specified at R_SCI_UartOpen call, p_src must be aligned on a 16-bit boundary.

Set the Driver Enable pin in RS485 half duplex mode to enable transmission.

Transmit interrupts must be disabled to start with.

Save data to transmit to the control block. It will be transmitted in the TXI ISR.

If a transfer instance is used for transmission, reset the transfer instance to transmit the requested data.

Clear the Driver Enable pin in RS485 half duplex mode to enable reception in error conditions

Trigger a TXI interrupt. This triggers the transfer instance or a TXI interrupt if the transfer instance is not used.