View detail for Atmel AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART)

APPLICATION NOTE
AT08220: Universal Synchronous Asynchronous
Receiver Transceiver (USART) for SAM4L
ASF PROGRAMMERS MANUAL
Universal Synchronous Asynchronous Receiver
Transceiver (USART) for SAM4L
The Universal Synchronous Asynchronous Receiver Transceiver (USART) provides
a full duplex synchronous or asynchronous serial link.
The outline of this documentation is as follows:
●
Prerequisites
●
Module Overview
●
Special Considerations
●
Extra Information
●
Examples
●
API Overview
42318A-MCU-05/2014
Table of Contents
Universal Synchronous Asynchronous Receiver Transceiver
(USART) for SAM4L ........................................................................... 1
Software License ................................................................................ 5
1. Prerequisites ................................................................................. 6
2. Module Overview .......................................................................... 7
3. Special Considerations ................................................................. 8
4. Extra Information .......................................................................... 9
5. Examples .................................................................................... 10
6. API Overview .............................................................................. 11
6.1.
6.2.
6.3.
Structure Definitions ................................................................... 11
6.1.1.
Struct sam_usart_opt_t .................................................. 11
6.1.2.
Struct usart_iso7816_opt_t .............................................. 11
6.1.3.
Struct usart_spi_opt_t .................................................... 12
Macro Definitions ...................................................................... 13
6.2.1.
Macro SPI_CPHA ........................................................ 13
6.2.2.
Macro SPI_CPOL ........................................................ 13
6.2.3.
Macro SPI_MODE_0 .................................................... 13
6.2.4.
Macro SPI_MODE_1 .................................................... 13
6.2.5.
Macro SPI_MODE_2 .................................................... 13
6.2.6.
Macro SPI_MODE_3 .................................................... 13
Function Definitions ................................................................... 14
6.3.1.
Function usart_disable_interrupt() .................................... 14
6.3.2.
Function usart_disable_rx() ............................................ 14
6.3.3.
Function usart_disable_tx() ............................................ 14
6.3.4.
Function usart_disable_writeprotect() ............................... 14
6.3.5.
Function usart_drive_DTR_pin_high() .............................. 15
6.3.6.
Function usart_drive_DTR_pin_low() ................................ 15
6.3.7.
Function usart_drive_RTS_pin_high() ............................... 15
6.3.8.
Function usart_drive_RTS_pin_low() ................................ 15
6.3.9.
Function usart_enable_interrupt() .................................... 16
6.3.10. Function usart_enable_rx() ............................................. 16
6.3.11. Function usart_enable_tx() ............................................. 16
6.3.12. Function usart_enable_writeprotect() ................................ 16
6.3.13. Function usart_get_error_number() .................................. 17
6.3.14. Function usart_get_interrupt_mask() ................................ 17
6.3.15. Function usart_get_pdc_base() ....................................... 17
6.3.16. Function usart_get_rx_access() ...................................... 18
6.3.17. Function usart_get_status() ............................................ 18
6.3.18. Function usart_get_tx_access() ....................................... 18
6.3.19. Function usart_get_version() .......................................... 19
6.3.20. Function usart_get_writeprotect_status() ........................... 19
6.3.21. Function usart_getchar() ................................................ 19
6.3.22. Function usart_init_hw_handshaking() .............................. 20
6.3.23. Function usart_init_irda() ............................................... 20
6.3.24. Function usart_init_iso7816() .......................................... 21
6.3.25. Function usart_init_lin_master() ...................................... 22
6.3.26. Function usart_init_lin_slave() ......................................... 22
6.3.27. Function usart_init_modem() .......................................... 23
6.3.28. Function usart_init_rs232() ............................................. 23
6.3.29. Function usart_init_rs485() ............................................. 24
6.3.30. Function usart_init_spi_master() ...................................... 25
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
2
6.3.31.
6.3.32.
6.3.33.
6.3.34.
6.3.35.
6.3.36.
6.3.37.
6.3.38.
6.3.39.
6.3.40.
6.3.41.
6.3.42.
6.3.43.
6.3.44.
6.3.45.
6.3.46.
6.3.47.
6.3.48.
6.3.49.
6.3.50.
6.3.51.
6.3.52.
6.3.53.
6.3.54.
6.3.55.
6.3.56.
6.3.57.
6.3.58.
6.3.59.
6.3.60.
6.3.61.
6.3.62.
6.3.63.
6.3.64.
6.3.65.
6.3.66.
6.3.67.
6.3.68.
6.3.69.
6.3.70.
6.3.71.
6.3.72.
6.3.73.
6.3.74.
6.3.75.
6.3.76.
6.3.77.
6.3.78.
6.3.79.
6.3.80.
6.3.81.
6.3.82.
6.3.83.
6.3.84.
6.3.85.
Function usart_init_spi_slave() ........................................
Function usart_init_sync_master() ...................................
Function usart_init_sync_slave() .....................................
Function usart_is_rx_buf_end() .......................................
Function usart_is_rx_buf_full() ........................................
Function usart_is_rx_ready() ..........................................
Function usart_is_tx_buf_empty() ....................................
Function usart_is_tx_buf_end() .......................................
Function usart_is_tx_empty() ..........................................
Function usart_is_tx_ready() ..........................................
Function usart_lin_abort_tx() ..........................................
Function usart_lin_disable_checksum() .............................
Function usart_lin_disable_frame_slot() ............................
Function usart_lin_disable_parity() ...................................
Function usart_lin_disable_pdc_mode() ............................
Function usart_lin_enable_checksum() .............................
Function usart_lin_enable_frame_slot() .............................
Function usart_lin_enable_parity() ...................................
Function usart_lin_enable_pdc_mode() .............................
Function usart_lin_get_data_length() ................................
Function usart_lin_read_identifier() ..................................
Function usart_lin_send_wakeup_signal() .........................
Function usart_lin_set_checksum_type() ...........................
Function usart_lin_set_data_len_mode() ...........................
Function usart_lin_set_node_action() ...............................
Function usart_lin_set_response_data_len() ......................
Function usart_lin_set_tx_identifier() ................................
Function usart_lin_set_wakeup_signal_type() ....................
Function usart_man_disable_drift_compensation() ..............
Function usart_man_enable_drift_compensation() ..............
Function usart_man_set_rx_polarity() ...............................
Function usart_man_set_rx_pre_len() ..............................
Function usart_man_set_rx_pre_pattern() .........................
Function usart_man_set_tx_polarity() ...............................
Function usart_man_set_tx_pre_len() ...............................
Function usart_man_set_tx_pre_pattern() .........................
Function usart_putchar() ................................................
Function usart_read() ....................................................
Function usart_reset() ...................................................
Function usart_reset_iterations() .....................................
Function usart_reset_nack() ...........................................
Function usart_reset_rx() ...............................................
Function usart_reset_status() .........................................
Function usart_reset_tx() ...............................................
Function usart_restart_rx_timeout() ..................................
Function usart_send_address() .......................................
Function usart_set_rx_timeout() ......................................
Function usart_set_tx_timeguard() ...................................
Function usart_spi_force_chip_select() .............................
Function usart_spi_release_chip_select() ..........................
Function usart_start_rx_timeout() ....................................
Function usart_start_tx_break() .......................................
Function usart_stop_tx_break() .......................................
Function usart_write() ...................................................
Function usart_write_line() .............................................
25
26
26
27
27
28
28
28
29
29
29
30
30
30
30
31
31
31
31
31
32
32
32
33
33
33
34
34
34
34
35
35
35
36
36
36
37
37
38
38
38
38
39
39
39
39
40
40
40
41
41
41
41
42
42
7. Extra Information for USART ...................................................... 43
7.1.
7.2.
7.3.
7.4.
Acronyms ................................................................................
Dependencies ...........................................................................
Errata ......................................................................................
Module History .........................................................................
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
3
43
43
43
43
8. Examples for USART ................................................................. 44
8.1.
8.2.
8.3.
8.4.
8.5.
8.6.
8.7.
USART
8.1.1.
8.1.2.
8.1.3.
8.1.4.
USART
8.2.1.
8.2.2.
8.2.3.
8.2.4.
USART
8.3.1.
8.3.2.
8.3.3.
8.3.4.
USART
8.4.1.
8.4.2.
8.4.3.
8.4.4.
USART
8.5.1.
8.5.2.
8.5.3.
8.5.4.
USART
8.6.1.
8.6.2.
8.6.3.
8.6.4.
USART
8.7.1.
8.7.2.
8.7.3.
8.7.4.
DMAC Example .............................................................
Purpose ......................................................................
Requirements ...............................................................
Description ...................................................................
Usage .........................................................................
Hardware Handshaking Example ......................................
Purpose ......................................................................
Requirements ...............................................................
Description ...................................................................
Usage .........................................................................
IrDA Example ................................................................
Purpose ......................................................................
Requirements ...............................................................
Description ...................................................................
Usage .........................................................................
ISO7816 Example ..........................................................
Purpose ......................................................................
Requirements ...............................................................
Description ...................................................................
Usage .........................................................................
RS485 Example with PDC ...............................................
Purpose ......................................................................
Requirements ...............................................................
Description ...................................................................
Usage .........................................................................
Serial Example ..............................................................
Purpose ......................................................................
Requirements ...............................................................
Description ...................................................................
Usage .........................................................................
Synchronous Mode Example ............................................
Purpose ......................................................................
Requirements ...............................................................
Description ...................................................................
Usage .........................................................................
44
44
44
44
44
45
45
45
45
45
46
46
46
46
46
47
47
47
47
48
48
48
48
48
48
49
49
49
49
50
50
50
50
50
50
Index ................................................................................................. 52
Document Revision History .............................................................. 53
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
4
Software License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of Atmel may not be used to endorse or promote products derived from this software without specific
prior written permission.
4. This software may only be redistributed and used in connection with an Atmel microcontroller product.
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN
NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
5
1.
Prerequisites
There are no prerequisites for this module.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
6
2.
Module Overview
Provides access to full duplex synchronous or asynchronous serial links. Data frame format is flexibly
programmable (data length, parity, number of stop bits) to support a maximum of standards. The receiver
implements parity error, framing error and overrun error detection. The receiver time-out enables handling variablelength frames and the transmitter timeguard facilitates communications with slow remote devices. Multidrop
communications are also supported through address bit handling in reception and transmission. The driver
supports the following modes: RS232, RS485, SPI, IrDA, ISO7816, MODEM, hardware handshaking and LIN.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
7
3.
Special Considerations
None.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
8
4.
Extra Information
For extra information, see Extra Information for USART. This includes:
●
Acronyms
●
Dependencies
●
Errata
●
Module History
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
9
5.
Examples
For a list of examples related to this driver, see Examples for USART.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
10
6.
API Overview
6.1
Structure Definitions
6.1.1
Struct sam_usart_opt_t
Table 6-1. Members
Type
Name
Description
uint32_t
baudrate
Set baud rate of the USART
(unused in slave modes).
uint32_t
channel_mode
Run the channel in test mode,
which should be one of following:
US_MR_CHMODE_NORMAL,
US_MR_CHMODE_AUTOMATIC,
US_MR_CHMODE_LOCAL_LOOPBACK,
US_MR_CHMODE_REMOTE_LOOPBACK.
uint32_t
char_length
Number of bits, which should
be one of the following:
US_MR_CHRL_5_BIT,
US_MR_CHRL_6_BIT,
US_MR_CHRL_7_BIT,
US_MR_CHRL_8_BIT or
US_MR_MODE9.
uint32_t
irda_filter
Filter of IrDA mode, useless in
other modes.
uint32_t
parity_type
Parity type, which should
be one of the following:
US_MR_PAR_EVEN,
US_MR_PAR_ODD,
US_MR_PAR_SPACE,
US_MR_PAR_MARK,
US_MR_PAR_NO or
US_MR_PAR_MULTIDROP.
uint32_t
stop_bits
Number of stop bits
between two characters:
US_MR_NBSTOP_1_BIT,
US_MR_NBSTOP_1_5_BIT,
1
US_MR_NBSTOP_2_BIT.
1
Notes:
6.1.2
US_MR_NBSTOP_1_5_BIT is supported in asynchronous modes only.
Struct usart_iso7816_opt_t
Table 6-2. Members
Type
Name
Description
uint32_t
bit_order
Bit order in transmitted characters:
0: LSB first;1: MSB first.
uint32_t
dis_suc_nack
Disable successive NACKs. 0:
NACK is sent on the ISO line as
soon as a parity error occurs in
the received character (unless
INACK is set).1: Successive parity
errors are counted up to the value
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
11
Type
Name
Description
specified in the MAX_ITERATION
field. These parity errors generate
a NACK on the ISO line. As
soon as this value is reached, no
additional NACK is sent on the
ISO line. The flag ITERATION is
asserted.
uint32_t
fidi_ratio
The number of ISO7816 clock ticks
in every bit period (1 to 2047, 0
= disable clock). Baudrate rate =
iso7816_hz / fidi_ratio.
uint32_t
inhibit_nack
Inhibit Non Acknowledge: 0: the
NACK is generated;1: the NACK is
1
not generated.
uint32_t
iso7816_hz
Set the frequency of the ISO7816
clock.
uint32_t
max_iterations
Max number of repetitions (0 to 7).
uint32_t
parity_type
How to calculate the parity bit:
US_MR_PAR_EVEN for normal
mode or US_MR_PAR_ODD for
inverse mode.
uint32_t
protocol_type
Which protocol is used: 0: T = 0;1:
T = 1.
1
Notes:
6.1.3
This bit will be used only in ISO7816 mode, protocol T = 0 receiver.
Struct usart_spi_opt_t
Table 6-3. Members
Type
Name
Description
uint32_t
baudrate
Set the frequency of the SPI clock
(unused in slave mode).
uint32_t
channel_mode
Run the channel in test mode,
which should be one of following:
US_MR_CHMODE_NORMAL,
US_MR_CHMODE_AUTOMATIC,
US_MR_CHMODE_LOCAL_LOOPBACK,
US_MR_CHMODE_REMOTE_LOOPBACK.
uint32_t
char_length
Number of bits, which should
be one of the following:
US_MR_CHRL_5_BIT,
US_MR_CHRL_6_BIT,
US_MR_CHRL_7_BIT,
US_MR_CHRL_8_BIT or
US_MR_MODE9.
uint32_t
spi_mode
Which SPI mode to use, which
should be one of the following:
SPI_MODE_0, SPI_MODE_1,
SPI_MODE_2, SPI_MODE_3.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
12
6.2
Macro Definitions
6.2.1
Macro SPI_CPHA
#define SPI_CPHA
Clock phase.
6.2.2
Macro SPI_CPOL
#define SPI_CPOL
Clock polarity.
6.2.3
Macro SPI_MODE_0
#define SPI_MODE_0
SPI mode 0 definition.
The inactive state value of SPCK is logic level zero. Data is changed on the leading edge of SPCK and captured on
the following edge of SPCK.
6.2.4
Macro SPI_MODE_1
#define SPI_MODE_1
SPI mode 1 definition.
The inactive state value of SPCK is logic level zero. Data is captured on the leading edge of SPCK and changed on
the following edge of SPCK.
6.2.5
Macro SPI_MODE_2
#define SPI_MODE_2
SPI mode 2 definition.
The inactive state value of SPCK is logic level one. Data is changed on the leading edge of SPCK and captured on
the following edge of SPCK.
6.2.6
Macro SPI_MODE_3
#define SPI_MODE_3
SPI mode 3 definition.
The inactive state value of SPCK is logic level one. Data is captured on the leading edge of SPCK and changed on
the following edge of SPCK.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
13
6.3
Function Definitions
6.3.1
Function usart_disable_interrupt()
Disable a USART's interrupts.
void usart_disable_interrupt(
Usart * p_usart,
uint32_t ul_sources)
Table 6-4. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART peripheral
[in]
ul_sources
Interrupt sources bit mask
Note
6.3.2
This writes to the USART Interrupt Disable Register (IDR) The meaning of the bit positions of the
register is dependent upon the USARTs current mode. For more informations see the USART section
of the appropriate device datasheet.
Function usart_disable_rx()
Disable a USART receiver.
void usart_disable_rx(
Usart * p_usart)
Table 6-5. Parameters
6.3.3
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_disable_tx()
Disable a USART transmitter.
void usart_disable_tx(
Usart * p_usart)
Table 6-6. Parameters
6.3.4
Function usart_disable_writeprotect()
Disable write protect of a USART registers.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
14
void usart_disable_writeprotect(
Usart * p_usart)
Table 6-7. Parameters
6.3.5
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_drive_DTR_pin_high()
De-assert (drive high) the DTR pin.
void usart_drive_DTR_pin_high(
Usart * p_usart)
Table 6-8. Parameters
6.3.6
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_drive_DTR_pin_low()
Assert (drive low) the DTR pin.
void usart_drive_DTR_pin_low(
Usart * p_usart)
Table 6-9. Parameters
6.3.7
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_drive_RTS_pin_high()
De-assert (drive high) the RTS pin.
void usart_drive_RTS_pin_high(
Usart * p_usart)
Table 6-10. Parameters
6.3.8
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_drive_RTS_pin_low()
Assert (drive low) the RTS pin.
void usart_drive_RTS_pin_low(
Usart * p_usart)
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
15
Table 6-11. Parameters
6.3.9
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART peripheral
[in]
ul_sources
Interrupt sources bit mask
Function usart_enable_interrupt()
Enable a USART's interrupts.
void usart_enable_interrupt(
Usart * p_usart,
uint32_t ul_sources)
Table 6-12. Parameters
Note
6.3.10
This writes to the USART Interrupt Enable Register (IER) The meaning of the bit positions of the
register is dependent upon the USARTs current mode. For more informations see the USART section
of the appropriate device datasheet.
Function usart_enable_rx()
Enable a USART receiver.
void usart_enable_rx(
Usart * p_usart)
Table 6-13. Parameters
6.3.11
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_enable_tx()
Enable a USART transmitter.
void usart_enable_tx(
Usart * p_usart)
Table 6-14. Parameters
6.3.12
Function usart_enable_writeprotect()
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
16
Enable write protect of a USART registers.
void usart_enable_writeprotect(
Usart * p_usart)
Table 6-15. Parameters
6.3.13
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_get_error_number()
Get the total number of errors that occur during an ISO7816 transfer.
uint8_t usart_get_error_number(
Usart * p_usart)
Table 6-16. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Returns
6.3.14
The number of errors that occurred.
Function usart_get_interrupt_mask()
Read a USART interrupt mask.
uint32_t usart_get_interrupt_mask(
Usart * p_usart)
Table 6-17. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART peripheral
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a UART instance
Returns
6.3.15
The interrupt mask value.
Function usart_get_pdc_base()
Get a USART PDC base address.
Pdc * usart_get_pdc_base(
Usart * p_usart)
Table 6-18. Parameters
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
17
Returns
USART PDC registers base for PDC driver to access.
Note
Only available on SAM4L devices.
6.3.16
Function usart_get_rx_access()
Get Receive address for DMA operation.
uint32_t * usart_get_rx_access(
Usart * p_usart)
Table 6-19. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Returns
6.3.17
Receive address for DMA access.
Function usart_get_status()
Get current status.
uint32_t usart_get_status(
Usart * p_usart)
Table 6-20. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Returns
6.3.18
The current USART status.
Function usart_get_tx_access()
Get Transmit address for DMA operation.
uint32_t * usart_get_tx_access(
Usart * p_usart)
Table 6-21. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
18
Returns
Transmit address for DMA access.
Note
Only available on SAM3XA and SAM3U devices.
6.3.19
Function usart_get_version()
Return the version of a USART device.
uint32_t usart_get_version(
Usart * p_usart)
Table 6-22. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Returns
Version identifier.
Note
The version number is held in the least significant 12 bits of the returned value.
This function is only available on the SAM4L family of devices.
6.3.20
Function usart_get_writeprotect_status()
Get write protect status.
uint32_t usart_get_writeprotect_status(
Usart * p_usart)
Table 6-23. Parameters
Returns
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
0 if the peripheral is not protected.
16-bit Write Protect Violation Status otherwise.
6.3.21
Function usart_getchar()
Read from a USART Receive Holding Register. This will block until a character is available to read.
uint32_t usart_getchar(
Usart * p_usart,
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
19
uint32_t * c)
Table 6-24. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[out]
c
Pointer where the one-byte
received data will be stored
Table 6-25. Return Values
6.3.22
Return value
Description
0
Data has been received
1
Failure
Function usart_init_hw_handshaking()
Configure a USART to work in hardware handshaking mode.
uint32_t usart_init_hw_handshaking(
Usart * p_usart,
const sam_usart_opt_t * p_usart_opt,
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-26. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-27. Return Values
6.3.23
Return value
Description
0
Hardware handshakining enabled
1
Failure
Function usart_init_irda()
Configure USART to work in IrDA mode.
uint32_t usart_init_irda(
Usart * p_usart,
const sam_usart_opt_t * p_usart_opt,
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
20
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-28. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-29. Return Values
6.3.24
Return value
Description
0
USART IrDA mode configured successfully
1
Failure
Function usart_init_iso7816()
Configure USART to work in ISO7816 mode.
uint32_t usart_init_iso7816(
Usart * p_usart,
const usart_iso7816_opt_t * p_usart_opt,
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-30. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-31. Return Values
Return value
Description
0
USART ISO7816 mode configured successfully
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
21
6.3.25
Return value
Description
1
Failure
Function usart_init_lin_master()
Configure USART to work in LIN mode and act as a LIN master.
uint32_t usart_init_lin_master(
Usart * p_usart,
uint32_t ul_baudrate,
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-32. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
ul_baudrate
Baudrate to be used
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-33. Return Values
6.3.26
Return value
Description
0
USART LIN master mode configured successfully
1
Operation failed
Function usart_init_lin_slave()
Configure USART to work in LIN mode and act as a LIN slave.
uint32_t usart_init_lin_slave(
Usart * p_usart,
uint32_t ul_baudrate,
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-34. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
ul_baudrate
Baudrate to be used
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
22
Data direction
Parameter name
Description
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-35. Return Values
6.3.27
Return value
Description
0
USART LIN slave mode configured successfully
1
Operation failed
Function usart_init_modem()
Configure a USART to work in modem mode.
uint32_t usart_init_modem(
Usart * p_usart,
const sam_usart_opt_t * p_usart_opt,
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-36. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-37. Return Values
6.3.28
Return value
Description
0
Modem mode configured
1
Failure
Function usart_init_rs232()
Configure a USART to work in RS232 mode.
uint32_t usart_init_rs232(
Usart * p_usart,
const sam_usart_opt_t * p_usart_opt,
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
23
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-38. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-39. Return Values
6.3.29
Return value
Description
0
Successfully set to RS232 mode
1
Failure
Function usart_init_rs485()
Configure a USART to work in RS485 mode.
uint32_t usart_init_rs485(
Usart * p_usart,
const sam_usart_opt_t * p_usart_opt,
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-40. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to a sam_usart_opt_t
instance
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-41. Return Values
Return value
Description
0
USART RS485 mode configured successfully
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
24
6.3.30
Return value
Description
1
Failure
Function usart_init_spi_master()
Configure USART to work in SPI mode and act as a master.
uint32_t usart_init_spi_master(
Usart * p_usart,
const usart_spi_opt_t * p_usart_opt,
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-42. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-43. Return Values
6.3.31
Return value
Description
0
USART SPI master mode configured successfully
1
Failure
Function usart_init_spi_slave()
Configure USART to work in SPI mode and act as a slave.
uint32_t usart_init_spi_slave(
Usart * p_usart,
const usart_spi_opt_t * p_usart_opt)
Note
By default, the transmitter and receiver are not enabled.
Table 6-44. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
25
Data direction
Parameter name
Description
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-45. Return Values
6.3.32
Return value
Description
0
USART SPI slave mode configured successfully
1
Failure
Function usart_init_sync_master()
Configure a USART to work in SYNC mode and act as a master.
uint32_t usart_init_sync_master(
Usart * p_usart,
const sam_usart_opt_t * p_usart_opt,
uint32_t ul_mck)
Note
By default, the transmitter and receiver are not enabled.
Table 6-46. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
[in]
ul_mck
USART module input clock
frequency
Note
For a description of the values to use for ul_mck, see usart_set_async_baudrate.
Table 6-47. Return Values
6.3.33
Return value
Description
0
Configured
1
Failure
Function usart_init_sync_slave()
Configure a USART to work in SYNC mode and act as a slave.
uint32_t usart_init_sync_slave(
Usart * p_usart,
const sam_usart_opt_t * p_usart_opt)
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
26
Note
By default, the transmitter and receiver are not enabled.
Table 6-48. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
p_usart_opt
Pointer to sam_usart_opt_t
instance
Table 6-49. Return Values
6.3.34
Return value
Description
0
Configured
1
Failure
Function usart_is_rx_buf_end()
Check whether the USART has received the number of bytes defined by the Peripheral DMA Controller (PDC) for a
transfer.
uint32_t usart_is_rx_buf_end(
Usart * p_usart)
Table 6-50. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Table 6-51. Return Values
6.3.35
Return value
Description
1
Receive is complete
0
Receive is still pending
Function usart_is_rx_buf_full()
Check if both receive buffers are full.
uint32_t usart_is_rx_buf_full(
Usart * p_usart)
Table 6-52. Parameters
Data direction
Parameter name
Description
?
p_usart
Pointer to a USART instance
Table 6-53. Return Values
Return value
Description
1
Receive buffers are full
0
Receive buffers are not full
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
27
6.3.36
Function usart_is_rx_ready()
Check if the received data is ready.
uint32_t usart_is_rx_ready(
Usart * p_usart)
Table 6-54. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Table 6-55. Return Values
Return value
Description
1
Some data has been received
0
No data has been received
Check if data has been received.
6.3.37
Function usart_is_tx_buf_empty()
Check if both transmit buffers are empty.
uint32_t usart_is_tx_buf_empty(
Usart * p_usart)
Table 6-56. Parameters
Data direction
Parameter name
Description
?
p_usart
Pointer to a USART instance
Table 6-57. Return Values
6.3.38
Return value
Description
1
Transmit buffers are empty
0
Transmit buffers are not empty
Function usart_is_tx_buf_end()
Check If the number of bytes defined by the Peripheral DMA Controller (PDC) in a transfer has been transmitted.
uint32_t usart_is_tx_buf_end(
Usart * p_usart)
Table 6-58. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Table 6-59. Return Values
Return value
Description
1
Transmit is complete
0
Transmit is still pending
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
28
6.3.39
Function usart_is_tx_empty()
Check if Transmit Holding Register is empty.
uint32_t usart_is_tx_empty(
Usart * p_usart)
Check if the last data written in USART_THR have been loaded into the Transmit Shift Register(TSR) and the last
data loaded in TSR has been transmitted.
Table 6-60. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Table 6-61. Return Values
6.3.40
Return value
Description
1
Transmitter is empty
0
Transmitter is not empty
Function usart_is_tx_ready()
Check if Transmit is Ready.
uint32_t usart_is_tx_ready(
Usart * p_usart)
Table 6-62. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Table 6-63. Return Values
Return value
Description
1
No data is in the Transmit Holding Register
0
There is data in the Transmit Holding Register
Check if data has been loaded in the Transmit Holding Register(USART_THR) and is waiting to be loaded into the
Transmit Shift Register (TSR).
6.3.41
Function usart_lin_abort_tx()
Abort the current LIN transmission.
void usart_lin_abort_tx(
Usart * p_usart)
Table 6-64. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
29
6.3.42
Function usart_lin_disable_checksum()
Disable the checksum during the LIN communication.
void usart_lin_disable_checksum(
Usart * p_usart)
Table 6-65. Parameters
6.3.43
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_lin_disable_frame_slot()
Disable the frame slot mode during the LIN communication.
void usart_lin_disable_frame_slot(
Usart * p_usart)
Table 6-66. Parameters
6.3.44
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_lin_disable_parity()
Disable the parity check during the LIN communication.
void usart_lin_disable_parity(
Usart * p_usart)
Table 6-67. Parameters
6.3.45
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_lin_disable_pdc_mode()
The LIN mode register is not written by the PDC.
void usart_lin_disable_pdc_mode(
Usart * p_usart)
Table 6-68. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
30
6.3.46
Function usart_lin_enable_checksum()
Enable the checksum during the LIN communication.
void usart_lin_enable_checksum(
Usart * p_usart)
Table 6-69. Parameters
6.3.47
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_lin_enable_frame_slot()
Enable the frame slot mode during the LIN communication.
void usart_lin_enable_frame_slot(
Usart * p_usart)
Table 6-70. Parameters
6.3.48
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_lin_enable_parity()
Enable the parity check during the LIN communication.
void usart_lin_enable_parity(
Usart * p_usart)
Table 6-71. Parameters
6.3.49
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_lin_enable_pdc_mode()
The LIN mode register (except this flag) is written by the PDC.
void usart_lin_enable_pdc_mode(
Usart * p_usart)
Table 6-72. Parameters
6.3.50
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_lin_get_data_length()
Get data length, in bytes.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
31
uint8_t usart_lin_get_data_length(
Usart * usart)
Table 6-73. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Returns
6.3.51
Data length.
Function usart_lin_read_identifier()
Read the identifier when a USART works in LIN mode.
uint8_t usart_lin_read_identifier(
Usart * p_usart)
Table 6-74. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Returns
6.3.52
The last identifier received in LIN slave mode or the last identifier transmitted in LIN master mode.
Function usart_lin_send_wakeup_signal()
Send a wake-up signal on the LIN bus.
void usart_lin_send_wakeup_signal(
Usart * p_usart)
Table 6-75. Parameters
6.3.53
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_lin_set_checksum_type()
Configure the checksum type during the LIN communication.
void usart_lin_set_checksum_type(
Usart * p_usart,
uint8_t uc_type)
Table 6-76. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
32
6.3.54
Data direction
Parameter name
Description
[in]
uc_type
0 for LIN 2.0 Enhanced checksum
or 1 for LIN 1.3 Classic checksum.
Function usart_lin_set_data_len_mode()
Configure the data length mode during the LIN communication.
void usart_lin_set_data_len_mode(
Usart * p_usart,
uint8_t uc_mode)
Table 6-77. Parameters
6.3.55
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_mode
Indicate the data length type: 0 if
the data length is defined by the
DLC of LIN mode register or 1 if
the data length is defined by bits 5
and 6 of the identifier.
Function usart_lin_set_node_action()
Configure the LIN node action, which should be one of PUBLISH, SUBSCRIBE, or IGNORE.
void usart_lin_set_node_action(
Usart * p_usart,
uint8_t uc_action)
Table 6-78. Parameters
6.3.56
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_action
0 for PUBLISH, 1 for SUBSCRIBE,
2 for IGNORE
Function usart_lin_set_response_data_len()
Configure the response data length if the data length is defined by the DLC field during the LIN communication.
void usart_lin_set_response_data_len(
Usart * p_usart,
uint8_t uc_len)
Table 6-79. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_len
Indicate the response data length
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
33
6.3.57
Function usart_lin_set_tx_identifier()
Configure the LIN identifier when a USART works in LIN master mode.
void usart_lin_set_tx_identifier(
Usart * p_usart,
uint8_t uc_id)
Table 6-80. Parameters
6.3.58
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_id
The identifier to be transmitted
Function usart_lin_set_wakeup_signal_type()
Configure the wake-up signal type during the LIN communication.
void usart_lin_set_wakeup_signal_type(
Usart * p_usart,
uint8_t uc_type)
Table 6-81. Parameters
6.3.59
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_type
Indicate the checksum type: 0 if the
wake-up signal is a LIN 2.0 wakeup signal; 1 if the wake-up signal is
a LIN 1.3 wake-up signal.
Function usart_man_disable_drift_compensation()
Disable drift compensation.
void usart_man_disable_drift_compensation(
Usart * p_usart)
Table 6-82. Parameters
6.3.60
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_man_enable_drift_compensation()
Enable drift compensation.
void usart_man_enable_drift_compensation(
Usart * p_usart)
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
34
Note
The 16X clock mode must be enabled.
Table 6-83. Parameters
6.3.61
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_man_set_rx_polarity()
Configure the receiver Manchester polarity when the Manchester encode/decode is enabled.
void usart_man_set_rx_polarity(
Usart * p_usart,
uint8_t uc_polarity)
Table 6-84. Parameters
6.3.62
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_polarity
Indicate the receiver Manchester
polarity, which should be 0 or 1.
Function usart_man_set_rx_pre_len()
Configure the detected receiver preamble length when Manchester encoding/decoding is enabled.
void usart_man_set_rx_pre_len(
Usart * p_usart,
uint8_t uc_len)
Table 6-85. Parameters
6.3.63
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_len
The detected receiver preamble
length, which should be 0-15
Function usart_man_set_rx_pre_pattern()
Configure the detected receiver preamble pattern when the Manchester encode/decode is enabled, which should
be, in the range 0-3.
void usart_man_set_rx_pre_pattern(
Usart * p_usart,
uint8_t uc_pattern)
Table 6-86. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
35
Data direction
Parameter name
Description
[in]
uc_pattern
See definitions table below
Definition of uc_pattern values.
6.3.64
Value
Description
0
Preamble is composed of '1's
1
Preamble is composed of '0's
2
Preamble is composed of '01's
3
Preamble is composed of '10's
Function usart_man_set_tx_polarity()
Configure the transmitter Manchester polarity when Manchester encoding/decoding is enabled.
void usart_man_set_tx_polarity(
Usart * p_usart,
uint8_t uc_polarity)
Table 6-87. Parameters
6.3.65
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_polarity
Indicate the transmitter Manchester
polarity, which should be 0 or 1.
Function usart_man_set_tx_pre_len()
Configure the transmitter preamble length when Manchester encoding/decoding is enabled.
void usart_man_set_tx_pre_len(
Usart * p_usart,
uint8_t uc_len)
Table 6-88. Parameters
Note
6.3.66
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_len
The transmitter preamble length,
which should be 0 ~ 15
Only available on SAM3S, SAM4S, SAM3U, SAM3XA, SAM4L, SAM4E, and SAM4 devices.
Function usart_man_set_tx_pre_pattern()
Configure the transmitter preamble pattern when Manchester encoding/decoding is enabled, which should be 0-3.
void usart_man_set_tx_pre_pattern(
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
36
Usart * p_usart,
uint8_t uc_pattern)
Table 6-89. Parameters
6.3.67
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
uc_pattern
0 if the preamble is composed of
'1's; 0 if the preamble is composed
of '1's; 1 if the preamble is
composed of '0's; 2 if the preamble
is composed of '01's; 3 if the
preamble is composed of '10's.
Function usart_putchar()
Write to a USART Transmit Holding Register.
uint32_t usart_putchar(
Usart * p_usart,
uint32_t c)
Table 6-90. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
c
Data to be sent
Table 6-91. Return Values
6.3.68
Return value
Description
0
Data written successfully
1
Data write failed
Function usart_read()
Read from a USART Receive Holding Register.
uint32_t usart_read(
Usart * p_usart,
uint32_t * c)
Note
Before reading, user should check if rx is ready.
Table 6-92. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
c
Pointer where the one-byte
received data will be stored
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
37
Table 6-93. Return Values
6.3.69
Return value
Description
0
Data read successfully
1
If no data is available or errors
Function usart_reset()
Reset a USART and disable TX and RX.
void usart_reset(
Usart * p_usart)
Table 6-94. Parameters
6.3.70
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_reset_iterations()
Reset the ITERATION in US_CSR when the ISO7816 mode is enabled.
void usart_reset_iterations(
Usart * p_usart)
Table 6-95. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Writes a one to the reset Iterations (RSTIT) bit of the USART Configuration Register. This has the effect of clearing
the iterations (ITER) bit in the Channel Status Register (CSR).
6.3.71
Function usart_reset_nack()
Reset NACK in the Channel Status Register (US_CSR).
void usart_reset_nack(
Usart * p_usart)
Table 6-96. Parameters
6.3.72
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_reset_rx()
Immediately stop and disable a USART receiver.
void usart_reset_rx(
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
38
Usart * p_usart)
Table 6-97. Parameters
6.3.73
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_reset_status()
Reset status bits (PARE, OVER, MANERR, UNRE, and PXBRK in US_CSR).
void usart_reset_status(
Usart * p_usart)
Table 6-98. Parameters
6.3.74
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_reset_tx()
Immediately stop and disable a USART transmitter.
void usart_reset_tx(
Usart * p_usart)
Table 6-99. Parameters
6.3.75
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_restart_rx_timeout()
Restart the receive timeout.
void usart_restart_rx_timeout(
Usart * p_usart)
Table 6-100. Parameters
6.3.76
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_send_address()
In Multidrop mode only, the next character written to the US_THR is sent with the address bit set.
uint32_t usart_send_address(
Usart * p_usart,
uint32_t ul_addr)
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
39
Table 6-101. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
ul_addr
The address to be sent out
Table 6-102. Return Values
6.3.77
Return value
Description
0
Character written successfully
1
Failure
Function usart_set_rx_timeout()
Configure the receive timeout register.
void usart_set_rx_timeout(
Usart * p_usart,
uint32_t timeout)
Table 6-103. Parameters
6.3.78
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
timeout
The value of receive timeout
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
timeguard
The value of transmit timeguard
Function usart_set_tx_timeguard()
Configure a transmit timeguard register.
void usart_set_tx_timeguard(
Usart * p_usart,
uint32_t timeguard)
Table 6-104. Parameters
6.3.79
Function usart_spi_force_chip_select()
Assert (drive low) the slave select line NSS (RTS pin) in SPI master mode.
void usart_spi_force_chip_select(
Usart * p_usart)
Table 6-105. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
40
6.3.80
Function usart_spi_release_chip_select()
De-assert (drive low) the slave select line NSS (RTS pin) in SPI master mode.
void usart_spi_release_chip_select(
Usart * p_usart)
Table 6-106. Parameters
6.3.81
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_start_rx_timeout()
Start waiting for a character before clocking the timeout count. Reset the status bit TIMEOUT in US_CSR.
void usart_start_rx_timeout(
Usart * p_usart)
Table 6-107. Parameters
6.3.82
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
Function usart_start_tx_break()
Start transmission of a break.
void usart_start_tx_break(
Usart * p_usart)
Table 6-108. Parameters
Commence the transmission of a break when the Transmit Holding Register (THR) and Transmit register are both
empty.
6.3.83
Function usart_stop_tx_break()
Stop transmission of a break.
void usart_stop_tx_break(
Usart * p_usart)
Table 6-109. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
41
Cancel the transmission of a break. If the transmission of a break has already commenced it will stop generation
and send ones for at least 12 bit periods.
6.3.84
Function usart_write()
Write to a USART Transmit Holding Register (THR).
uint32_t usart_write(
Usart * p_usart,
uint32_t c)
Note
Before writing, user should check if tx is ready (or empty).
Table 6-110. Parameters
Data direction
Parameter name
Description
?
p_usart
Pointer to a USART instance
?
c
Data to be sent
Table 6-111. Return Values
6.3.85
Return value
Description
0
THR witten to
1
Failure
Function usart_write_line()
Write a string to a USART.
void usart_write_line(
Usart * p_usart,
const char * string)
Table 6-112. Parameters
Data direction
Parameter name
Description
[in]
p_usart
Pointer to a USART instance
[in]
string
Pointer to the string to be sent
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
42
7.
Extra Information for USART
7.1
Acronyms
Below is a table listing the acronyms used in this module, along with their intended meanings.
7.2
Acronym
Definition
DMAC
Direct Memeory Addressing Controller
DTR
Data Terminal Ready
LIN
Local Interconnect Network
IrDA
Infra Red Data Associoation
PDC
Periperal DMAC
RTS
Ring To Send
QSG
Quick Start Guide
SPI
Serial Peripheral Interface
USART
Universal Synchronous Asynchronous Receiver
Transmitter
Dependencies
This driver has the following dependencies:
●
7.3
None
Errata
There are no errata related to this driver.
7.4
Module History
An overview of the module history is presented in the table below, with details on the enhancements and fixes
made to the module since its first release. The current version of this corresponds to the newest version in the
table.
Changelog
Initial document release
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
43
8.
Examples for USART
This is a list of the available Quick Start guides (QSGs) and example applications for Universal Synchronous
Asynchronous Receiver Transceiver (USART) for SAM4L. QSGs are simple examples with step-by-step
instructions to configure and use this driver in a selection of use cases. Note that QSGs can be compiled as a
standalone application or be added to the user application.
The various examples below can be found in the ASF software under sam/driver/usart.
●
USART DMAC Example
●
USART Hardware Handshaking Example
●
USART IrDA Example
●
USART ISO7816 Example
●
USART RS485 Example with PDC
●
USART Serial Example
●
USART Synchronous Mode Example
8.1
USART DMAC Example
8.1.1
Purpose
This example demonstrates how to use DMAC to implement USART peripherals function in serial mode.
8.1.2
Requirements
This package can be used with all SAM-EK with UART/USART and DMAC.
8.1.3
Description
On start up, the debug information is dumped to the on-board UART port. A terminal application, such as
HyperTerminal, is used to monitor this debug information. Open another HyperTerminal to connect with the onboard USART port. Then the program works in ECHO mode, so the USART will send back anything it receives
from the HyperTerminal. You can send a text file from the HyperTerminal connected with the USART port to the
device (without any protocol such as X-modem).
Note
8.1.4
The text file size must be equal to BUFFER_SIZE (32 bytes in this example).
Usage
1.
Build the program and download it into the evaluation boards.
2.
Connect a serial cable to the UART port for the evaluation kit.
3.
On the computer, open and configure a terminal application HyperTerminal on Microsoft Windows ) with
these settings:
4.
®
●
115200 baud
●
8 bits of data
●
No parity
●
1 stop bit
●
No flow control
®
In the terminal window, the following text should appear:
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
44
-- USART DMAC Example --- xxxxxx-xx
-- Compiled: xxx xx xxxx xx:xx:xx --
5.
Send a file in text format from the HyperTerminal connected with the USART port to the device. On
HyperTerminal, this is done by selecting "Transfer -> Send Text File"(this does not prevent you from sending
binary files). The transfer will start and then you could read the file in the HyperTerminal.
8.2
USART Hardware Handshaking Example
8.2.1
Purpose
This example demonstrates the hardware handshaking mode (i.e., RTS/CTS) provided by the USART peripherals
on SAM microcontrollers. The practical use of hardware handshaking is that it allow transfers to stop on the USART
without losing any data in the process. This is very useful for applications that need to program slow memories, for
example.
8.2.2
Requirements
This example can be used with SAM evaluation kits, such as SAM4C-EK, SAM4S-EK, and others. Refer to the list
of available kits at http://www.atmel.com
It requires a serial line with hardware control support (TXD and RXD cross over, RTS, and CTS cross over) to
connect the board and PC.
8.2.3
Description
The provided program uses hardware handshaking mode to regulate the data rate of an incoming file transfer. A
terminal application, such as HyperTerminal, is used to send a text file to the device (without any protocol such as
X-modem). The device will enforce the configured bytes per second (bps) rate with its Request To Send (RTS) line.
Whenever the data rate meets or exceeds the configurable threshold, the device stops receiving data on the
USART. Since no buffer is provided to the PDC, this will set the RTS line, telling the computer to stop sending data.
Each second, the current data rate and total number of bytes received are displayed; the transfer is also restarted.
Note that the device may receive slightly fewer bytes than the actual file size, depending on the nature of the file.
This does NOT mean that bytes have been lost: this is simply an issue with how line breaks are transmitted by the
terminal.
8.2.4
Usage
1.
Build the program and download it into the evaluation board.
2.
Connect a serial cable to the USART port on the evaluation kit.
3.
On the computer, open and configure a terminal application (e.g. HyperTerminal on Microsoft Windows) with
these settings:
Note
●
115200 baud
●
8 data bits
●
No parity
●
1 stop bit
●
Hardware flow control (RTS/CTS)
Configure your terminal emulator to perform no translation of carriage return/line feed sequences.
1.
Start the application. The following traces shall appear on the terminal:
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
45
-- USART Hardware Handshaking Example --- xxxxxx-xx
-- Compiled: xxx xx xxxx xx:xx:xx -Bps:
0; Tot:
0
2.
Send a file in text format to the device. On HyperTerminal, this is done by selecting "Transfer -> Send Text
File" (this does not prevent you from sending binary files). The transfer will start and the device will update the
bps and total counts on the terminal.
3.
Whenever the transfer is complete, the total number of bytes received should match the size of the sent file
(unless it is a text file, see explanation in description section).
8.3
USART IrDA Example
8.3.1
Purpose
This example demonstrates the IrDA (Infrared Data Association) on SAM.
8.3.2
Requirements
This example can be used on all SAM EK boards with external IrDA transceiver component. Connect the board and
external components with the following paired pins.
SAM4E-EK IrDA transceiver
●
3V3 VCC
●
TXD(PA22) TXD
●
RXD(PA21) RXD
●
CTS(PA25) SD
●
GND GND
Note
8.3.3
Refer to the user guide for your specific board for more information.
Description
The provided program uses the USART in IrDA mode for transmitting and receiving several octets. This example
can be used with two SAM-EK boards. The program receives or transmits a series of octets according to its state of
either receiver or transmitter.
Note
8.3.4
To receive IrDA signals, the following needs to be done:
1.
Disable TX and Enable RX.
2.
Configure the TXD pin as PIO and set it as an output at 0 (to avoid LED emission). Disable the
internal pull-up (better for power consumption).
3.
Receive data.
Usage
1.
Build the program and download it into the two evaluation boards.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
46
2.
Connect a serial cable to the UART port for each evaluation kit.
3.
On the computer, open and configure a terminal application (e.g. HyperTerminal on Microsoft Windows) with
these settings:
●
115200 baud
●
8 data bits
●
No parity
●
1 stop bit
●
No flow control
4.
Start the application.
5.
The following traces shall appear on the terminal:
-- USART IrDA Example --- xxxxxx-xx
-- Compiled: xxx xx xxxx xx:xx:xx --I- Press t to transmit, press r to receive
6.
Enable one board as transmitter and another as receiver to start the communication. On success the receiver
will send its data to the terminal.
8.4
USART ISO7816 Example
8.4.1
Purpose
This example sends ISO7816 commands to a smartcard connected to a SAM evaluation kit.
8.4.2
Requirements
This example can be used with many SAM evaluation kits. Connect the smartcard contacts with following pins.
●
SAM3N-EK, SAM3U-EK, SAM3X-EK, and SAM4N-Xplained-Pro use USART0 TXD0 and SCK0
●
SAM3S-EK, SAM3S-EK2, SAM4S-EK, and SAM4E-EK use USART1 TXD1 and SCK1
●
SAM4C-EK uses USART2 TXD2 and SCK2
Example Connections
8.4.3
Sam-Ek
Smartcard
PA15
RST
TXD*
I/O
SCK
CLK
VCC
VCC
GND
GND
Description
The iso7816 software provided in this example is used to transform APDU commands to TPDU commands for a
smart card.
The iso7816 implementation provided here is for the T=0 protocol only. Sending and receiving of characters is done
by polling.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
47
Note
8.4.4
The driver is compliant with CASE 1, 2, 3 of the ISO7816-4 specification.
Usage
1.
Build the program and download it to the evaluation board.
2.
On the computer, open and configure a terminal application (e.g. HyperTerminal on Microsoft Windows) with
these settings:
●
115200 baud
●
8 data bits
●
No parity
●
1 stop bit
●
No flow control
3.
Connect the card reader to SAM EK board as described previousley.
4.
Start the application. The following traces shall appear on the terminal:
-- USART ISO7816 Example --- xxxxxx-xx
-- Compiled: xxx xx xxxx xx:xx:xx --
8.5
USART RS485 Example with PDC
8.5.1
Purpose
The USART RS485 example with PDC demonstrates how to use USART in RS485 mode.
8.5.2
Requirements
This package can be used with all SAM-EK boards. Before running, make sure to connect two boards with RS485
lines. Match each paired pins of two boards with A to A, B to B and FGND to FGND.
Refer to the board user guide for the details of rs485 jumper settings.
8.5.3
Description
This example connects two boards through an RS485 interface. One board acts as the transmitter and the other
one as the receiver. The role is determined by the sequence that the two applications started.
The application sends a sync character at running to seek a receiver. If the acknowledgement is received in a short
time, it will act as the transmitter and then send a full frame text to the receiver.
The earlier started board will act automatically as the receiver due to no acknowledgement received. The receiver
will wait until sync character is received. Then it sends the acknowledgement and waits for the full frame sent by
the transmitter. At the end of reception, the reciever prints out a message through the UART interface to indicate
that the whole process succeeded.
8.5.4
Usage
●
Build the program and download it into the two evaluation boards
●
Connect a serial cable to the UART port for each evaluation kit
●
On the computer, open and configure a terminal application for each board (e.g., HyperTerminal on Microsoft
Windows) with these settings:
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
48
●
115200 baud
●
8 bits of data
●
No parity
●
1 stop bit
●
No flow control
●
Start the application from the two boards in sequence Make sure that the application is NOT started on the
second board until the first board reports that it is waiting for a synchronization character.
●
In the terminal window, the following text should appear:
-- USART RS485 Example --- xxxxxx-xx
-- Compiled: xxx xx xxxx xx:xx:xx --
●
The consequent messages will indicate the boards' behavior
●
The earlier started board will output the message below to indicate it is waiting for a synchronization
character:
-I- Receiving sync character
●
If it receives a sync character and is ready to receive a frame, it will print out the message below:
-I- Start receiving!
●
After successfully receiving a frame, the board will output the following message to indicate that the whole
process succeeded.
-I- Received successfully!
●
The board that was started later will act as transmitter and if it receives an acknowledgement character
successfully, it will output the following message and start transmitting:
-I- Start transmitting!
8.6
USART Serial Example
8.6.1
Purpose
This example demonstrates the normal (serial) mode provided by the USART peripherals.
8.6.2
Requirements
This package can be used with all SAM-EK with a UART/USART and a PDC.
8.6.3
Description
On start up, the debug information is dumped to the on-board USART port. A terminal application, such as
HyperTerminal, is used to monitor this debug information. Open another HyperTerminal to connect with the onboard USART port. Then the program works in ECHO mode, so the USART will send back anything it receives
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
49
from the HyperTerminal. You can send a text file from the HyperTerminal connected with the USART port to the
device (without any protocol such as X-modem).
8.6.4
Usage
1.
Build the program and download it into the evaluation boards.
2.
Connect a serial cable to the UART port for the evaluation kit.
3.
On the computer, open and configure a terminal application (e.g., HyperTerminal on Microsoft Windows) with
these settings:
4.
●
115200 baud
●
8 bits of data
●
No parity
●
1 stop bit
●
No flow control
In the terminal window, the following text should appear:
-------
5.
USART Serial Example -xxxxxx-xx
Compiled: xxx xx xxxx xx:xx:xx -Start to echo serial inputs --I- Default Transfer with PDC --I- Press 's' to switch transfer mode
Send a file in text format from the HyperTerminal connected with the USART port to the device. On
HyperTerminal, this is done by selecting "Transfer -> Send Text File"(this does not prevent you from sending
binary files). The transfer will start and then you could read the file in the HyperTerminal.
8.7
USART Synchronous Mode Example
8.7.1
Purpose
This example demonstrates the Synchronous mode provided by the USART peripherals on SAM.
8.7.2
Requirements
This example can be used on all SAM EK boards and requires two boards to be connected directly through
populated USART pins.
8.7.3
Description
This application gives an example of how to use the USART in synchronous mode. Synchronous operations
provide a high speed transfer capability. The transfer under this mode needs a pair of master and slave, which is
determined by which one offers the clock source.
The example initializes the USART as master by default. To enable communication between the two sides of
the connection, the user should change the mode of one side to slave through the user interface. If correctly
configured, transfer can be started by typing 'r' and 'w' from the terminal applications. This example also leaves the
interface to select the clock frequency.
The meaning of each input character could be found in items of the main menu.
8.7.4
Usage
1.
Build the program and download it into the two evaluation boards.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
50
2.
Connect a serial cable to the UART port for each evaluation kit.
3.
On the computer, open and configure a terminal application (e.g. HyperTerminal on Microsoft Windows) with
these settings:
4.
●
115200 baud
●
8 data bits
●
No parity
●
1 stop bit
●
No flow control
Start the application. The following traces shall appear on the terminal:
-- USART Synchronous Mode Example --- xxxxxx-xx
-- Compiled: xxx xx xxxx xx:xx:xx --- Menu Choices for this example --- [0-3]:Select clock freq of master --- i: Display configuration info
-- w: Write data block .--- r: Read data block.--- s: Switch between master and slave mode.--- m: Display this menu again.---USART in MASTER mode--
5.
The main menu will guide the user to configure the device and conduct operations.
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
51
Index
usart_lin_set_data_len_mode, 33
usart_lin_set_node_action, 33
usart_lin_set_response_data_len, 33
usart_lin_set_tx_identifier, 34
usart_lin_set_wakeup_signal_type, 34
usart_man_disable_drift_compensation, 34
usart_man_enable_drift_compensation, 34
usart_man_set_rx_polarity, 35
usart_man_set_rx_pre_len, 35
usart_man_set_rx_pre_pattern, 35
usart_man_set_tx_polarity, 36
usart_man_set_tx_pre_len, 36
usart_man_set_tx_pre_pattern, 36
usart_putchar, 37
usart_read, 37
usart_reset, 38
usart_reset_iterations, 38
usart_reset_nack, 38
usart_reset_rx, 38
usart_reset_status, 39
usart_reset_tx, 39
usart_restart_rx_timeout, 39
usart_send_address, 39
usart_set_rx_timeout, 40
usart_set_tx_timeguard, 40
usart_spi_force_chip_select, 40
usart_spi_release_chip_select, 41
usart_start_rx_timeout, 41
usart_start_tx_break, 41
usart_stop_tx_break, 41
usart_write, 42
usart_write_line, 42
F
Function Definitions
usart_disable_interrupt, 14
usart_disable_rx, 14
usart_disable_tx, 14
usart_disable_writeprotect, 14
usart_drive_DTR_pin_high, 15
usart_drive_DTR_pin_low, 15
usart_drive_RTS_pin_high, 15
usart_drive_RTS_pin_low, 15
usart_enable_interrupt, 16
usart_enable_rx, 16
usart_enable_tx, 16
usart_enable_writeprotect, 16
usart_getchar, 19
usart_get_error_number, 17
usart_get_interrupt_mask, 17
usart_get_pdc_base, 17
usart_get_rx_access, 18
usart_get_status, 18
usart_get_tx_access, 18
usart_get_version, 19
usart_get_writeprotect_status, 19
usart_init_hw_handshaking, 20
usart_init_irda, 20
usart_init_iso7816, 21
usart_init_lin_master, 22
usart_init_lin_slave, 22
usart_init_modem, 23
usart_init_rs232, 23
usart_init_rs485, 24
usart_init_spi_master, 25
usart_init_spi_slave, 25
usart_init_sync_master, 26
usart_init_sync_slave, 26
usart_is_rx_buf_end, 27
usart_is_rx_buf_full, 27
usart_is_rx_ready, 28
usart_is_tx_buf_empty, 28
usart_is_tx_buf_end, 28
usart_is_tx_empty, 29
usart_is_tx_ready, 29
usart_lin_abort_tx, 29
usart_lin_disable_checksum, 30
usart_lin_disable_frame_slot, 30
usart_lin_disable_parity, 30
usart_lin_disable_pdc_mode, 30
usart_lin_enable_checksum, 31
usart_lin_enable_frame_slot, 31
usart_lin_enable_parity, 31
usart_lin_enable_pdc_mode, 31
usart_lin_get_data_length, 31
usart_lin_read_identifier, 32
usart_lin_send_wakeup_signal, 32
usart_lin_set_checksum_type, 32
M
Macro Definitions
SPI_CPHA, 13
SPI_CPOL, 13
SPI_MODE_0, 13
SPI_MODE_1, 13
SPI_MODE_2, 13
SPI_MODE_3, 13
S
Structure Definitions
sam_usart_opt_t, 11
usart_iso7816_opt_t, 11
usart_spi_opt_t, 12
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
52
Document Revision History
Doc. Rev.
Date
Comments
42318A
05/2014
Initial document release
AT08220: Universal Synchronous Asynchronous Receiver Transceiver (USART) for SAM4L
[APPLICATION NOTE]
42318A-MCU-05/2014
53
Atmel Corporation
1600 Technology Drive, San Jose, CA 95110 USA
T: (+1)(408) 441.0311
F: (+1)(408) 436.4200
|
www.atmel.com
© 2014 Atmel Corporation. All rights reserved. / Rev.: 42318A-MCU-05/2014
®
®
Atmel , Atmel logo and combinations thereof, Enabling Unlimited Possibilities , and others are registered trademarks or trademarks of Atmel Corporation or its
®
subsidiaries. Windows is a registered trademark of Microsoft Corporation in U.S. and or other countries. Other terms and product names may be trademarks
of others.
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by
this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL
ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF
INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at
any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be
used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.