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.
Initialize and deinitialize the driver and associated hardware
Register I/O descriptor
Enable or disable USART
Data transfer: transmission, reception
Set USART baudrate
Select UART or USART communication mode
Select character size
Set Data order
Flow control
Which clock source is used
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.
Write buffer should not be changed while data is being sent
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.
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.
/**
* 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);
}
USART peripheral and its related I/O lines and clocks