USART Synchronous Driver

The universal synchronous and asynchronous receiver and transmitter (USART) is normally used to transfer data from one device to the other.

The user can set the action for flow control pins by the usart_sync_set_flow_control function, if the flow control is enabled. All the available states are defined in the usart_sync_flow_control_status union.

Note that the user can set the state of the flow control pins only if automatic support of the flow control is not supported by the hardware.

Summary of the API's Functional Features

The API provides functions to:
  • Initialize and deinitialize the driver and associated hardware

  • Register I/O descriptor

  • Enable or disable USART

  • Data transfer: transmission, reception

Summary of Configuration Options

Below is a list of the main USART parameters that can be configured in START. Many of these parameters are used by the usart_sync_init function when initializing the driver and underlying hardware. Most of the initial values can be overridden and changed runtime by calling the appropriate API functions.
  • Set USART baudrate

  • Select UART or USART communication mode

  • Select character size

  • Set Data order

  • Flow control

  • Which clock source is used

Driver Implementation Description

After the USART hardware initialization, the usart_sync_get_io_descriptor function is needed to register an I/O descriptor. Then enable USART hardware, and start the read/write operation.

Concurrency

  • Write buffer should not be changed while data is being sent

Limitations

  • The driver does not support 9-bit character size

  • The "USART with ISO7816" mode can be only used in ISO7816 capable devices. And the SCK pin can't be set directly. Application can use a GCLK output PIN to generate SCK. For example to communicate with a SMARTCARD with ISO7816 (F = 372; D = 1), and baudrate=9600, the SCK pin output frequency should be config as 372*9600=3571200Hz. More information can be refer to ISO7816 Specification.

Example of Usage

The following shows a simple example of using the USART. The USART must have been initialized by usart_sync_init. This initialization will configure the operation of the USART.

The example enables USART, and finally starts a writing operation.
/** * Example of using USART_0 to write "Hello World" using the I/O abstraction. */void USART_0_example(void){    struct io_descriptor *io;    usart_sync_get_io_descriptor(&USART_0, &io);    usart_sync_enable(&USART_0);    io_write(io, (uint8_t *)"Hello World!", 12);}

Dependencies

  • USART peripheral and its related I/O lines and clocks