|
fsp_err_t | R_SCI_UART_Open (uart_ctrl_t *const p_api_ctrl, uart_cfg_t const *const p_cfg) |
|
fsp_err_t | R_SCI_UART_Close (uart_ctrl_t *const p_api_ctrl) |
|
fsp_err_t | R_SCI_UART_Read (uart_ctrl_t *const p_api_ctrl, uint8_t *const p_dest, uint32_t const bytes) |
|
fsp_err_t | R_SCI_UART_Write (uart_ctrl_t *const p_api_ctrl, uint8_t const *const p_src, uint32_t const bytes) |
|
fsp_err_t | R_SCI_UART_CallbackSet (uart_ctrl_t *const p_api_ctrl, void(*p_callback)(uart_callback_args_t *), void const *const p_context, uart_callback_args_t *const p_callback_memory) |
|
fsp_err_t | R_SCI_UART_BaudSet (uart_ctrl_t *const p_api_ctrl, void const *const p_baud_setting) |
|
fsp_err_t | R_SCI_UART_InfoGet (uart_ctrl_t *const p_api_ctrl, uart_info_t *const p_info) |
|
fsp_err_t | R_SCI_UART_Abort (uart_ctrl_t *const p_api_ctrl, uart_dir_t communication_to_abort) |
|
fsp_err_t | R_SCI_UART_ReadStop (uart_ctrl_t *const p_api_ctrl, uint32_t *remaining_bytes) |
|
fsp_err_t | R_SCI_UART_BaudCalculate (uint32_t baudrate, bool bitrate_modulation, uint32_t baud_rate_error_x_1000, baud_setting_t *const p_baud_setting) |
|
Driver for the SCI peripheral on RA MCUs. This module implements the UART Interface.
Overview
Features
The SCI UART module supports the following features:
- Full-duplex UART communication
- Interrupt-driven data transmission and reception
- Invoking the user-callback function with an event code (RX/TX complete, TX data empty, RX char, error, etc)
- Baud-rate change at run-time
- Bit rate modulation and noise cancellation
- CTS/RTS hardware flow control (with an associated pin)
- RS-485 Half Duplex driver support with external RS-485 transceiver
- Integration with the DTC transfer module
- Abort in-progress read/write operations
- FIFO support on supported channels
- IrDA is supported on devices that have IrDA interface
Configuration
Build Time Configurations for r_sci_uart
The following build time configurations are defined in fsp_cfg/r_sci_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. |
FIFO Support |
| Disable | Enable FIFO support for the SCI_UART module. |
DTC Support |
| Disable | Enable DTC support for the SCI_UART module. |
Flow Control Support |
| Disable | Enable RS232 and RS-485 flow control support using a user provided pin. |
RS-485 Support |
| Disable | Enable support for controlling the RS-485 DE pin. |
IrDA Support |
| Disabled | Enable support for IrDA pulse encoding/decoding. |
Configurations for Connectivity > UART (r_sci_uart)
This module can be added to the Stacks tab via New Stack > Connectivity > UART (r_sci_uart). Non-secure callable guard functions can be generated for this module by right clicking the module in the RA Configuration tool and checking the "Non-secure Callable" box.
Configuration | Options | Default | Description |
General |
Name | Name must be a valid C symbol | g_uart0 | Module name. |
Channel | Value must be a non-negative integer | 0 | Select the SCI channel. |
Data Bits |
| 8bits | Select the number of bits per word. |
Parity |
| None | Select the parity mode. |
Stop Bits |
| 1bit | Select the number of stop bits. |
Baud |
Baud Rate | Value must be an integer greater than 0 | 115200 | Enter the desired baud rate.
If the requested baud rate cannot be achieved, the settings with the smallest percent error are used. The theoretical calculated baud rate and percent error are printed in a comment in the generated baud_setting_t structure.
For RA4 and RA6 MCUs, refer the datasheet to calculate baud rate considering the SEMR.ABCSE bit restriction. |
Baud Rate Modulation |
| Disabled | Enabling baud rate modulation reduces the percent error of the actual baud rate with respect to the requested baud rate. It does this by modulating the number of cycles per clock, so some bits are slightly longer than others. |
Max Error (%) | Must be a valid non-negative integer with a maximum configurable value of 100 | 5 | Maximum percent error allowed during baud calculation. This is used by the algorithm to determine whether or not to consider using less accurate alternative register settings.
NOTE: The baud calculation does not show an error in the tool if this percent error was not achieved. The calculated percent error is recorded in a comment in the generated baud_setting_t structure. |
Flow Control |
CTS/RTS Selection | MCU Specific Options | | Select either CTS or RTS function on the CTSn_RTSn pin of SCI channel n or select CTS function on CTSn pin and RTS function on CTSn_RTSn pin of SCI channel n (Available on selected MCUs and channels). |
Software RTS Port | Refer to the RA Configuration tool for available options. | Disabled | Specify the flow control pin port for the MCU. |
Software RTS Pin | Refer to the RA Configuration tool for available options. | Disabled | Specify the flow control pin for the MCU. |
Extra |
Extra > IrDA |
Enable |
| Disabled | Enable IrDA on this channel. |
RXD Polarity Switching |
| Normal | IRRXD Pulse polarity (Normal: High Pulse=0) and (Inverted: Low Pulse=0).. |
TXD Polarity Switching |
| Normal | IRTXD Pulse polarity (Normal: High Pulse 0) and (Inverted: Low Pulse=0). |
Extra > RS-485 |
DE Pin |
| Disable | Enable or disable the DE pin for use in RS-485 half-duplex mode. |
DE Pin Polarity |
| Active High | Select the polarity of the DE pin. |
DE Port Number | Refer to the RA Configuration tool for available options. | Disabled | GPIO output port number to use for generating the DE signal. |
DE Pin Number | Refer to the RA Configuration tool for available options. | Disabled | GPIO output pin number to use for generating the DE signal. |
Clock Source |
-
Internal Clock
-
Internal Clock With Output on SCK
-
External Clock 8x baud rate
-
External Clock 16x baud rate
| Internal Clock | Selection of the clock source to be used in the baud-rate clock generator. When internal clock is used the baud rate can be output on the SCK pin. |
Start bit detection |
| Falling Edge | Start bit detected as falling edge or low level. |
Noise Filter |
| Disable | Enable the digital noise filter on RXDn pin. The digital noise filter block in SCI consists of two-stage flipflop circuits. |
Receive FIFO Trigger Level | Refer to the RA Configuration tool for available options. | Max | Unused if the channel has no FIFO or if DTC is used for reception. Set to One to get a callback immediately when each byte is received. Set to Max to get a callback when FIFO is full or after 15 bit times with no data (fewer interrupts). |
Interrupts |
Callback | Name must be a valid C symbol | NULL | A user callback function can be provided. If this callback function is provided, it will be called from the interrupt service routine (ISR). |
Receive Interrupt Priority | MCU Specific Options | | Select the receive interrupt priority. |
Transmit Data Empty Interrupt Priority | MCU Specific Options | | Select the transmit interrupt priority. |
Transmit End Interrupt Priority | MCU Specific Options | | Select the transmit end interrupt priority. |
Error Interrupt Priority | MCU Specific Options | | Select the error interrupt priority. |
Clock Configuration
The clock for this module is derived from the following peripheral clock for each MCU group:
MCU Group | Peripheral Clock |
RA2A1 | PCLKB |
RA2A2 | PCLKB |
RA2E1 | PCLKB |
RA2E2 | PCLKB |
RA2E3 | PCLKB |
RA2L1 | PCLKB |
RA4E1 | PCLKA |
RA4E2 | PCLKA |
RA4M1 | PCLKA |
RA4M2 | PCLKA |
RA4M3 | PCLKA |
RA4T1 | PCLKA |
RA4W1 | PCLKA |
RA6E1 | PCLKA |
RA6E2 | PCLKA |
RA6M1 | PCLKA |
RA6M2 | PCLKA |
RA6M3 | PCLKA |
RA6M4 | PCLKA |
RA6M5 | PCLKA |
RA6T1 | PCLKA |
RA6T3 | PCLKA |
The clock source for the baud-rate clock generator can be selected from the internal clock, the external clock times 8 or the external clock times 16. The external clock is supplied to the SCK pin.
Pin Configuration
This module uses TXD and RXD to communicate to external devices. CTS or RTS or both (CTS and RTS) can be controlled by the hardware. Some MCUs support hardware flow control for both CTS and RTS on some channels. Some MCUs and channels support hardware flow control for either CTS or RTS but not both. If both are desired a GPIO pin can be used for RTS. When the internal clock is the source for the baud-rate generator the SCK pin can be used to output a clock with the same frequency as the bit rate.
Usage Notes
- When configured for Hardware CTS and Software RTS the configured flow control pin will be used for RTS. The pin will be set high inside of the receive ISR while data is being read. It will be set low when all data is read.
- When configured for Hardware CTS and Hardware RTS the CSTn_RTSn pin will be used for RTS function and the CTSn pin will be used for CTS function on channel n.
- The driver will follow correct hardware flow control function when CTSn_RTSn pin is connected to CTSn pin when "Hardware CTS and Hardware RTS" flow control is selected. The data will still be transferred when CTSn_RTSn and CTSn are disconnected as the CTSn pin is internally pulled low on the hardware when CTSn pin is configured as a peripheral pin for SCI module. Do not configure CTSn pin if the hardware flow control is not desired.
Limitations
- Reception is still enabled after uart_api_t::communicationAbort API is called. Any characters received after abort and before the next call to read will arrive via the callback function with event UART_EVENT_RX_CHAR.
- The R_SCI_UART_BaudCalculate() and R_SCI_UART_Open() APIs are used to obtain the baud rate register settings for a specific baudrate. On RA4 and RA6 MCU groups, there is a restriction on SEMR.ABSCE bit for certain channels (refer to 'SEMR : Serial Extended Mode' Register section of MCU User Manual). The API does not enforce this restriction and it may return invalid settings.
DTC Limitations
- DTC support is available for reception, but labeled as [Not recommended]. This is because the UART bytes are received asynchronously. Bytes can be received between calls to R_SCI_UART_Read(). The logic required to combine bytes received through R_SCI_UART_Read() (UART_EVENT_RX_COMPLETE) and bytes received between calls (UART_EVENT_RX_CHAR) is complex. Reception length may also be unknown, and the driver will not issue an interrupt unless the entire DTC buffer is filled.
- Transfer size must be less than or equal to 64K bytes if DTC interface is used for transfer. uart_api_t::infoGet API can be used to get the max transfer size allowed.
- When using 9-bit reception with DTC, clear the upper 7 bits of data before processing the read data. The upper 7 bits contain status flags that are part of the register used to read data in 9-bit mode.
IrDA Limitations
- The IrDA interface works in cooperation with a particular SCI channel based on the IrDA standard 1.0.
- If optics placement yields the echo of transmitted data on the receiver, the application should disable the RX irq during transmission.
R_SCI_UART_BaudCalculate
shall not be called for IrDA baud rate calculation. The correct use is to create the baud rate by using the configurator. If run-time changes to baud rate are required, multiple instances of different baud rates should be created with the configurator.
Examples
SCI UART Example
uint8_t g_dest[TRANSFER_LENGTH];
uint8_t g_src[TRANSFER_LENGTH];
uint8_t g_out_of_band_received[TRANSFER_LENGTH];
uint32_t g_transfer_complete = 0;
uint32_t g_receive_complete = 0;
uint32_t g_out_of_band_index = 0;
void r_sci_uart_basic_example (void)
{
for (uint32_t i = 0; i < TRANSFER_LENGTH; i++)
{
g_src[i] = (uint8_t) ('A' + (i % 26));
}
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
while (!g_transfer_complete)
{
}
while (!g_receive_complete)
{
}
}
{
{
{
if (sizeof(g_out_of_band_received) > g_out_of_band_index)
{
{
g_out_of_band_received[g_out_of_band_index++] = (uint8_t) p_args->
data;
}
else
{
uint16_t * p_dest = (uint16_t *) &g_out_of_band_received[g_out_of_band_index];
*p_dest = (uint16_t) p_args->
data;
g_out_of_band_index += 2;
}
}
break;
}
{
g_receive_complete = 1;
break;
}
{
g_transfer_complete = 1;
break;
}
default:
{
}
}
}
SCI UART Baud Set Example
#define SCI_UART_BAUDRATE_19200 (19200)
#define SCI_UART_BAUDRATE_ERROR_PERCENT_5 (5000)
void r_sci_uart_baud_example (void)
{
uint32_t baud_rate = SCI_UART_BAUDRATE_19200;
bool enable_bitrate_modulation = false;
uint32_t error_rate_x_1000 = SCI_UART_BAUDRATE_ERROR_PERCENT_5;
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
}
◆ sci_uart_instance_ctrl_t
struct sci_uart_instance_ctrl_t |
UART instance control block.
◆ baud_setting_t
Register settings to acheive a desired baud rate and modulation duty.
Data Fields |
union baud_setting_t |
__unnamed__ |
|
uint8_t |
cks: 2 |
CKS value to get divisor (CKS = N) |
uint8_t |
brr |
Bit Rate Register setting. |
uint8_t |
mddr |
Modulation Duty Register setting. |
◆ sci_uart_rs485_setting_t
struct sci_uart_rs485_setting_t |
Configuration settings for controlling the DE signal for RS-485.
◆ sci_uart_irda_setting_t
struct sci_uart_irda_setting_t |
Configuration settings for IrDA interface.
◆ sci_uart_extended_cfg_t
struct sci_uart_extended_cfg_t |
UART on SCI device Configuration
◆ sci_clk_src_t
Enumeration for SCI clock source
Enumerator |
---|
SCI_UART_CLOCK_INT | Use internal clock for baud generation.
|
SCI_UART_CLOCK_INT_WITH_BAUDRATE_OUTPUT | Use internal clock for baud generation and output on SCK.
|
SCI_UART_CLOCK_EXT8X | Use external clock 8x baud rate.
|
SCI_UART_CLOCK_EXT16X | Use external clock 16x baud rate.
|
◆ sci_uart_flow_control_t
UART flow control mode definition
Enumerator |
---|
SCI_UART_FLOW_CONTROL_RTS | Use SCI pin for RTS.
|
SCI_UART_FLOW_CONTROL_CTS | Use SCI pin for CTS.
|
SCI_UART_FLOW_CONTROL_CTSRTS | Use SCI pin for CTS, external pin for RTS.
|
SCI_UART_FLOW_CONTROL_HARDWARE_CTSRTS | Use CTSn_RTSn pin for RTS and CTSn pin for CTS. Available only for some channels on selected MCUs. See hardware manual for channel specific options.
|
◆ 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_2 | Callback when FIFO having 2 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_3 | Callback when FIFO having 3 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_4 | Callback when FIFO having 4 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_5 | Callback when FIFO having 5 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_6 | Callback when FIFO having 6 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_7 | Callback when FIFO having 7 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_8 | Callback when FIFO having 8 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_9 | Callback when FIFO having 9 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_10 | Callback when FIFO having 10 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_11 | Callback when FIFO having 11 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_12 | Callback when FIFO having 12 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_13 | Callback when FIFO having 13 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_14 | Callback when FIFO having 14 bytes.
|
SCI_UART_RX_FIFO_TRIGGER_MAX | Callback when FIFO is full or after 15 bit times with no data (fewer interrupts)
|
◆ sci_uart_start_bit_t
Asynchronous Start Bit Edge Detection configuration.
Enumerator |
---|
SCI_UART_START_BIT_LOW_LEVEL | Detect low level on RXDn pin as start bit.
|
SCI_UART_START_BIT_FALLING_EDGE | Detect falling level on RXDn pin as start bit.
|
◆ sci_uart_noise_cancellation_t
Noise cancellation configuration.
Enumerator |
---|
SCI_UART_NOISE_CANCELLATION_DISABLE | Disable noise cancellation.
|
SCI_UART_NOISE_CANCELLATION_ENABLE | Enable noise cancellation.
|
◆ sci_uart_rs485_enable_t
RS-485 Enable/Disable.
Enumerator |
---|
SCI_UART_RS485_DISABLE | RS-485 disabled.
|
SCI_UART_RS485_ENABLE | RS-485 enabled.
|
◆ sci_uart_rs485_de_polarity_t
The polarity of the RS-485 DE signal.
Enumerator |
---|
SCI_UART_RS485_DE_POLARITY_HIGH | The DE signal is high when a write transfer is in progress.
|
SCI_UART_RS485_DE_POLARITY_LOW | The DE signal is low when a write transfer is in progress.
|
◆ sci_uart_irda_enable_t
IrDA Enable/Disable.
Enumerator |
---|
SCI_UART_IRDA_DISABLED | IrDA disabled.
|
SCI_UART_IRDA_ENABLED | IrDA enabled.
|
◆ sci_uart_irda_polarity_t
IrDA Polarity Switching.
Enumerator |
---|
SCI_UART_IRDA_POLARITY_NORMAL | IrDA Tx/Rx polarity not inverted.
|
SCI_UART_IRDA_POLARITY_INVERTED | IrDA Tx/Rx polarity inverted.
|
◆ R_SCI_UART_Open()
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. Implements uart_api_t::open
- Return values
-
FSP_SUCCESS | Channel opened successfully. |
FSP_ERR_ASSERTION | Pointer to UART control block or configuration structure is NULL. |
FSP_ERR_IP_CHANNEL_NOT_PRESENT | The requested channel does not exist on this MCU. |
FSP_ERR_INVALID_ARGUMENT | Flow control is enabled but flow control pin is not defined or selected channel does not support "Hardware CTS and Hardware RTS" flow control. (or) restricted channel is selected. |
FSP_ERR_ALREADY_OPEN | Control block has already been opened or channel is being used by another instance. Call close() then open() to reconfigure. |
FSP_ERR_INVALID_CHANNEL | IrDA is requested for a channel that does not support IrDA. |
- Returns
- See Common Error Codes or functions called by this function for other possible return codes. This function calls:
◆ R_SCI_UART_Close()
Aborts any in progress transfers. Disables interrupts, receiver, and transmitter. Closes lower level transfer drivers if used. Removes power. Implements uart_api_t::close
- Return values
-
FSP_SUCCESS | Channel successfully closed. |
FSP_ERR_ASSERTION | Pointer to UART control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened |
◆ R_SCI_UART_Read()
fsp_err_t R_SCI_UART_Read |
( |
uart_ctrl_t *const |
p_api_ctrl, |
|
|
uint8_t *const |
p_dest, |
|
|
uint32_t const |
bytes |
|
) |
| |
Receives user specified number of bytes into destination buffer pointer. Implements uart_api_t::read
- Return values
-
FSP_SUCCESS | Data reception successfully ends. |
FSP_ERR_ASSERTION | Pointer to UART control block is NULL. Number of transfers outside the max or min boundary when transfer instance used |
FSP_ERR_INVALID_ARGUMENT | Destination address or data size is not valid for 9-bit mode. |
FSP_ERR_NOT_OPEN | The control block has not been opened |
FSP_ERR_IN_USE | A previous read operation is still in progress. |
FSP_ERR_UNSUPPORTED | SCI_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
- If 9-bit data length is specified at R_SCI_UART_Open call, p_dest must be aligned 16-bit boundary.
◆ R_SCI_UART_Write()
fsp_err_t R_SCI_UART_Write |
( |
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. Implements uart_api_t::write
- Return values
-
FSP_SUCCESS | Data transmission finished successfully. |
FSP_ERR_ASSERTION | Pointer to UART control block is NULL. Number of transfers outside the max or min boundary when transfer instance used |
FSP_ERR_INVALID_ARGUMENT | Source address or data size is not valid for 9-bit mode. |
FSP_ERR_NOT_OPEN | The control block has not been opened |
FSP_ERR_IN_USE | A UART transmission is in progress |
FSP_ERR_UNSUPPORTED | SCI_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
- If 9-bit data length is specified at R_SCI_UART_Open call, p_src must be aligned on a 16-bit boundary.
◆ R_SCI_UART_CallbackSet()
Updates the user callback and has option of providing memory for callback structure. Implements uart_api_t::callbackSet
- Return values
-
FSP_SUCCESS | Callback updated successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |
◆ R_SCI_UART_BaudSet()
Updates the baud rate using the clock selected in Open. p_baud_setting is a pointer to a baud_setting_t structure. Implements uart_api_t::baudSet
- Warning
- This terminates any in-progress transmission.
- Return values
-
FSP_SUCCESS | Baud rate was successfully changed. |
FSP_ERR_ASSERTION | Pointer to UART control block is NULL or the UART is not configured to use the internal clock. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_INVALID_ARGUMENT | Restricted channel is selected. |
◆ R_SCI_UART_InfoGet()
Provides the driver information, including the maximum number of bytes that can be received or transmitted at a time. Implements uart_api_t::infoGet
- Return values
-
FSP_SUCCESS | Information stored in provided p_info. |
FSP_ERR_ASSERTION | Pointer to UART control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened |
◆ R_SCI_UART_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. Implements uart_api_t::communicationAbort
- Return values
-
FSP_SUCCESS | UART transaction aborted successfully. |
FSP_ERR_ASSERTION | Pointer to UART control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_UNSUPPORTED | The 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_UART_ReadStop()
Provides API to abort ongoing read. 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. Implements uart_api_t::readStop
- Return values
-
FSP_SUCCESS | UART transaction aborted successfully. |
FSP_ERR_ASSERTION | Pointer to UART control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_UNSUPPORTED | The 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_UART_BaudCalculate()
fsp_err_t R_SCI_UART_BaudCalculate |
( |
uint32_t |
baudrate, |
|
|
bool |
bitrate_modulation, |
|
|
uint32_t |
baud_rate_error_x_1000, |
|
|
baud_setting_t *const |
p_baud_setting |
|
) |
| |
Calculates baud rate register settings. Evaluates and determines the best possible settings set to the baud rate related registers.
- Note
- For limitations of this API, refer to the 'Limitations' section of r_sci_uart module in FSP User Manual.
- Parameters
-
[in] | baudrate | Baud rate [bps]. For example, 19200, 57600, 115200, etc. |
[in] | bitrate_modulation | Enable bitrate modulation |
[in] | baud_rate_error_x_1000 | Max baud rate error. At most <baud_rate_percent_error> x 1000 required for module to function. Absolute max baud_rate_error is 15000 (15%). |
[out] | p_baud_setting | Baud setting information stored here if successful |
- Return values
-
FSP_SUCCESS | Baud rate is set successfully |
FSP_ERR_ASSERTION | Null pointer |
FSP_ERR_INVALID_ARGUMENT | Baud rate is '0', error in calculated baud rate is larger than requested max error, or requested max error in baud rate is larger than 15%. |