Serial Interface

Serial Overview

Serial interfaces serve as fundamental communication interfaces facilitating the transfer of data between devices one bit at a time. Unlike parallel transmission, where multiple bits are sent simultaneously over multiple channels, serial communication operates sequentially over a single wire or pair of wires. This method of data transfer, widely adopted across embedded systems, computer peripherals, networking devices, and various other applications, owes its popularity to its simplicity, versatility, and ease of implementation.

Supported Communication Modes

The following modes of serial communication are supported:

  • Blocking - Here the read/write function waits(blocked) till the operation is performed or time out

  • Non-Blocking - The read/write function returns immediately and the registered callback is invoked after the completion of operation or time out

Application Interface

The below table captures the functions that are to be called from the application layer.

API Functions

Function

Description

rs_serial_open

To open the serial interface.

rs_serial_set_config

To configure the serial interface.

rs_serial_handle_timeouts

To handle the read/write timeouts for a non-blocking call.

rs_serial_write

To write the data to the serial interface.

rs_serial_read

To read the data from the serial interface.

rs_serial_set_inter_char_timeout

To set the inter character timeout for the serial interface.

rs_serial_set_callbacks

To set the callback function for the serial interface.

rs_serial_close

To close the serial interface.

The below table contains callback functions that are to be performed from the HAL.

Callback Functions

Function

Description

rcb_hal_uart_callback

It is called if a character is received from the serial interface through an interrupt or transmit done.

Error Code

  • Every API’s for the Serial returns some success or failure values. Please refer below section,

Implementation Guide

This section explains how to implement the Serial interface using the RAPIDSEA stack, the steps to be followed are

  • Configure the preferred method of RX or TX communication(FIFO / Direct and Blocking / Non-Blocking).

  • Allocate the RX and TX buffers that are to be used for the FIFO method.

  • Configure the serial interface(Baud rate, Parity, Flow control, Data length, Stop bits and Address).

  • Then call the initialize call of the serial interface.

  • Set the callback function and inter character timeout using the provided serial interface functions.

  • Perform the read and write functions as required and handle the error codes.

  • Close the Serial interface.

Note:

The configurations are done by loading the provided serial structure(rs_serial_config_t) from the application layer.

Documentation from the relevant header as follows:

Warning

doxygenfile: Cannot find file “rs_serial.h