Kévin Redon | ccbed0b | 2019-01-24 18:30:26 +0100 | [diff] [blame] | 1 | The USART Asynchronous Driver |
| 2 | ============================= |
| 3 | |
| 4 | The universal synchronous and asynchronous receiver and transmitter |
| 5 | (USART) is usually used to transfer data from one device to the other. |
| 6 | |
| 7 | The USART driver use a ring buffer to store received data. When the USART |
| 8 | raise the data received interrupt, this data will be stored in the ring buffer |
| 9 | at the next free location. When the ring buffer is full, the next reception |
| 10 | will overwrite the oldest data stored in the ring buffer. There is one |
| 11 | USART_BUFFER_SIZE macro per used hardware instance, e.g. for SERCOM0 the macro |
| 12 | is called SERCOM0_USART_BUFFER_SIZE. |
| 13 | |
| 14 | On the other hand, when sending data over USART, the data is not copied to an |
| 15 | internal buffer, but the data buffer supplied by the user is used. The callback |
| 16 | will only be generated at the end of the buffer and not for each byte. |
| 17 | |
| 18 | User can set action for flow control pins by function usart_set_flow_control, |
| 19 | if the flow control is enabled. All the available states are defined in union |
| 20 | usart_flow_control_state. |
| 21 | |
| 22 | Note that user can set state of flow control pins only if automatic support of |
| 23 | the flow control is not supported by the hardware. |
| 24 | |
| 25 | Features |
| 26 | -------- |
| 27 | |
| 28 | * Initialization/de-initialization |
| 29 | * Enabling/disabling |
| 30 | * Control of the following settings: |
| 31 | |
| 32 | * Baudrate |
| 33 | * UART or USRT communication mode |
| 34 | * Character size |
| 35 | * Data order |
| 36 | * Flow control |
| 37 | * Data transfer: transmission, reception |
| 38 | * Notifications about transfer done or error case via callbacks |
| 39 | * Status information with busy state and transfer count |
| 40 | |
| 41 | Applications |
| 42 | ------------ |
| 43 | |
| 44 | They are commonly used in a terminal application or low-speed communication |
| 45 | between devices. |
| 46 | |
| 47 | Dependencies |
| 48 | ------------ |
| 49 | |
| 50 | USART capable hardware, with interrupt on each character is sent or |
| 51 | received. |
| 52 | |
| 53 | Concurrency |
| 54 | ----------- |
| 55 | |
| 56 | Write buffer should not be changed while data is being sent. |
| 57 | |
| 58 | |
| 59 | Limitations |
| 60 | ----------- |
| 61 | |
| 62 | * The driver does not support 9-bit character size. |
| 63 | * The "USART with ISO7816" mode can be only used in ISO7816 capable devices. |
| 64 | And the SCK pin can't be set directly. Application can use a GCLK output PIN |
| 65 | to generate SCK. For example to communicate with a SMARTCARD with ISO7816 |
| 66 | (F = 372 ; D = 1), and baudrate=9600, the SCK pin output frequency should be |
| 67 | config as 372*9600=3571200Hz. More information can be refer to ISO7816 Specification. |
| 68 | |
| 69 | Known issues and workarounds |
| 70 | ---------------------------- |
| 71 | |
| 72 | N/A |