2094 #define US_MR_USART_MODE_Msk
(US_MR) USART Mode of Operation
#define US_CR_RETTO
(US_CR) Start Time-out Immediately
#define US_LONB1TX_BETA1TX(value)
__IO uint32_t US_IDTRX
(Usart Offset: 0x0084) LON IDT Rx Register
void usart_enable_rx(Usart *p_usart)
Enable USART receiver.
__IO uint32_t US_BRGR
(Usart Offset: 0x0020) Baud Rate Generator Register
static uint32_t usart_set_iso7816_clock(Usart *p_usart, uint32_t clock, uint32_t ul_mck)
Calculate a clock divider (CD) for the USART ISO7816 mode to generate an ISO7816 clock as close as po...
#define US_MAN_RX_PL(value)
#define US_MR_CLKO
(US_MR) Clock Output Select
void usart_start_rx_timeout(Usart *p_usart)
Start waiting for a character before clocking the timeout count. Reset the status bit TIMEOUT in US_C...
#define US_LINIR_IDCHR(value)
__IO uint32_t US_LINMR
(Usart Offset: 0x0054) LIN Mode Register
#define US_LONPRIO_NPS(value)
void usart_drive_RTS_pin_low(Usart *p_usart)
Drive the pin RTS to 0.
#define US_LONL2HDR_BLI(value)
uint8_t usart_get_error_number(Usart *p_usart)
Get the total number of errors that occur during an ISO7816 transfer.
#define US_LINMR_CHKDIS
(US_LINMR) Checksum Disable
uint32_t usart_init_rs485(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in RS485 mode.
#define US_MR_USART_MODE_LIN_MASTER
(US_MR) LIN Master mode
#define US_MR_USCLKS_Msk
(US_MR) Clock Selection
#define US_CR_LINWKUP
(US_CR) Send LIN Wakeup Signal
#define US_THR_TXCHR(value)
#define US_MAN_RX_MPOL
(US_MAN) Receiver Manchester Polarity
void usart_restart_rx_timeout(Usart *p_usart)
Restart the receive timeout.
#define US_CR_STTTO
(US_CR) Clear TIMEOUT Flag and Start Time-out After Next Character Received
__IO uint32_t US_LINIR
(Usart Offset: 0x0058) LIN Identifier Register
#define US_MAN_TX_MPOL
(US_MAN) Transmitter Manchester Polarity
#define US_LINMR_FSDIS
(US_LINMR) Frame Slot Mode Disable
#define US_MR_PAR_MULTIDROP
(US_MR) Multidrop mode
#define US_MR_USART_MODE_RS485
(US_MR) RS485
#define US_MR_PAR_EVEN
(US_MR) Even parity
#define US_MR_NBSTOP_1_BIT
(US_MR) 1 stop bit
#define US_LONMR_COLDET
(US_LONMR) LON Collision Detection Feature
void usart_set_tx_timeguard(Usart *p_usart, uint32_t timeguard)
Configure the transmit timeguard register.
#define US_CR_RSTRX
(US_CR) Reset Receiver
void usart_write_line(Usart *p_usart, const char *string)
Write one-line string through USART.
static void usart_set_spi_slave_baudrate(Usart *p_usart)
Select the SCK pin as the source of baudrate for the USART SPI slave mode.
uint32_t usart_is_rx_buf_full(Usart *p_usart)
Check if both receive buffers are full.
#define US_MAN_RX_PL_Msk
(US_MAN) Receiver Preamble Length
uint32_t usart_get_interrupt_mask(Usart *p_usart)
Read USART interrupt mask.
#define US_CR_STPBRK
(US_CR) Stop Break
#define LOW_FRQ_SAMPLE_DIV
void usart_disable_interrupt(Usart *p_usart, uint32_t ul_sources)
Disable USART interrupts.
uint32_t usart_init_spi_slave(Usart *p_usart, const usart_spi_opt_t *p_usart_opt)
Configure USART to work in SPI mode and act as a slave.
__I uint32_t US_VERSION
(Usart Offset: 0x00FC) Version Register
Usart hardware registers.
void usart_enable_interrupt(Usart *p_usart, uint32_t ul_sources)
Enable USART interrupts.
void usart_drive_RTS_pin_high(Usart *p_usart)
Drive the pin RTS to 1.
#define US_CSR_LTXD
(US_CSR) LON Transmission End Flag (cleared by writing a one to bit US_CR.RSTSTA) ...
#define US_LONPRIO_PSNB(value)
#define US_MR_USART_MODE_HW_HANDSHAKING
(US_MR) Hardware Handshaking
#define US_WPSR_WPVSRC_Msk
(US_WPSR) Write Protection Violation Source
void usart_set_rx_timeout(Usart *p_usart, uint32_t timeout)
Configure the receive timeout register.
static uint32_t usart_set_spi_master_baudrate(Usart *p_usart, uint32_t baudrate, uint32_t ul_mck)
Calculate a clock divider (CD) for the USART SPI master mode to generate a baud rate as close as poss...
#define US_LONMR_DMAM
(US_LONMR) LON DMA Mode
#define US_WPSR_WPVS
(US_WPSR) Write Protection Violation Status
Pdc * usart_get_pdc_base(Usart *p_usart)
Get USART PDC base address.
uint32_t usart_send_address(Usart *p_usart, uint32_t ul_addr)
In Multidrop mode only, the next character written to the US_THR is sent with the address bit set...
static void usart_set_sync_slave_baudrate(Usart *p_usart)
Select the SCK pin as the source of baud rate for the USART synchronous slave modes.
#define US_LONDL_LONDL(value)
#define US_MR_USART_MODE_LON
(US_MR) LON
void usart_disable_writeprotect(Usart *p_usart)
Disable write protect of USART registers.
#define US_MR_DSNACK
(US_MR) Disable Successive NACK
Universal Synchronous Asynchronous Receiver Transmitter (USART) driver for SAM.
#define US_LONB1RX_BETA1RX(value)
uint32_t usart_is_rx_buf_end(Usart *p_usart)
Check if one receive buffer is filled.
#define US_LINMR_DLM
(US_LINMR) Data Length Mode
#define US_MR_USCLKS_MCK
(US_MR) Peripheral clock is selected
#define US_CSR_TXEMPTY
(US_CSR) Transmitter Empty (cleared by writing US_THR)
#define US_MR_CPHA
(US_MR) SPI Clock Phase
#define SPI_MODE_1
SPI mode 1.
#define US_CR_DTRDIS
(US_CR) Data Terminal Ready Disable
#define USART0
(USART0) Base Address
#define US_MAN_TX_PL_Msk
(US_MAN) Transmitter Preamble Length
#define US_CR_LINABT
(US_CR) Abort LIN Transmission
void usart_reset_iterations(Usart *p_usart)
Reset the ITERATION in US_CSR when the ISO7816 mode is enabled.
#define USART1
(USART1) Base Address
uint32_t usart_get_status(Usart *p_usart)
Get current status.
#define US_MR_OVER
(US_MR) Oversampling Mode
#define US_MR_USART_MODE_IRDA
(US_MR) IrDA
__IO uint32_t US_RTOR
(Usart Offset: 0x0024) Receiver Time-out Register
__IO uint32_t US_TTGR
(Usart Offset: 0x0028) Transmitter Timeguard Register
uint32_t usart_is_tx_buf_end(Usart *p_usart)
Check if one transmit buffer is empty.
#define US_LINMR_DLC_Msk
(US_LINMR) Data Length Control
void usart_spi_release_chip_select(Usart *p_usart)
Drive the slave select line NSS (RTS pin) to 1 in SPI master mode.
uint32_t usart_is_tx_ready(Usart *p_usart)
Check if Transmit is Ready. Check if data have been loaded in USART_THR and are waiting to be loaded ...
__IO uint32_t US_LONPR
(Usart Offset: 0x0064) LON Preamble Register
#define US_MR_USART_MODE_SPI_SLAVE
(US_MR) SPI Slave mode
#define US_LINMR_CHKTYP
(US_LINMR) Checksum Type
#define US_MR_NBSTOP_2_BIT
(US_MR) 2 stop bits
void usart_reset_rx(Usart *p_usart)
Immediately stop and disable USART receiver.
#define US_LINMR_NACT_Pos
uint32_t usart_read(Usart *p_usart, uint32_t *c)
Read from USART Receive Holding Register.
#define US_LONMR_CDTAIL
(US_LONMR) LON Collision Detection on Frame Tail
#define US_CR_FCS
(US_CR) Force SPI Chip Select
#define US_LONMR_COMMT
(US_LONMR) LON comm_type Parameter Value
#define US_CR_RCS
(US_CR) Release SPI Chip Select
#define US_LINMR_WKUPTYP
(US_LINMR) Wakeup Signal Type
#define US_WPMR_WPKEY_PASSWD
#define US_LONMR_TCOL
(US_LONMR) Terminate Frame upon Collision Notification
#define US_MR_CPOL
(US_MR) SPI Clock Polarity
__IO uint32_t US_LONB1TX
(Usart Offset: 0x0074) LON Beta1 Tx Register
uint32_t usart_is_rx_ready(Usart *p_usart)
Check if the received data are ready. Check if Data have been received and loaded into USART_RHR...
#define US_MAN_TX_PL(value)
uint32_t usart_init_rs232(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in RS232 mode.
#define US_LINMR_PDCM
(US_LINMR) DMAC Mode
#define US_MR_USART_MODE_IS07816_T_0
(US_MR) IS07816 Protocol: T = 0
uint32_t usart_set_async_baudrate(Usart *p_usart, uint32_t baudrate, uint32_t ul_mck)
Calculate a clock divider(CD) and a fractional part (FP) for the USART asynchronous modes to generate...
void usart_enable_writeprotect(Usart *p_usart)
Enable write protect of USART registers.
#define US_CR_DTREN
(US_CR) Data Terminal Ready Enable
#define US_MAN_DRIFT
(US_MAN) Drift Compensation
void usart_reset_status(Usart *p_usart)
Reset status bits (PARE, OVER, MANERR, UNRE and PXBRK in US_CSR).
#define US_MR_USART_MODE_MODEM
(US_MR) Modem
#define US_CSR_LINID
(US_CSR) LIN Identifier Sent or LIN Identifier Received (cleared by writing a one to bit US_CR...
#define US_CR_SENDA
(US_CR) Send Address
uint32_t usart_init_spi_master(Usart *p_usart, const usart_spi_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in SPI mode and act as a master.
void usart_reset(Usart *p_usart)
Reset the USART and disable TX and RX.
uint32_t usart_init_sync_master(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in SYNC mode and act as a master.
__IO uint32_t US_MAN
(Usart Offset: 0x0050) Manchester Configuration Register
__IO uint32_t US_LONL2HDR
(Usart Offset: 0x006C) LON L2HDR Register
uint32_t usart_init_iso7816(Usart *p_usart, const usart_iso7816_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in ISO7816 mode.
#define US_MR_PAR_ODD
(US_MR) Odd parity
#define US_WPSR_WPVSRC_Pos
#define US_MR_MSBF
(US_MR) Bit Order
#define US_CR_RSTTX
(US_CR) Reset Transmitter
__I uint32_t US_CSR
(Usart Offset: 0x0014) Channel Status Register
uint32_t usart_init_sync_slave(Usart *p_usart, const sam_usart_opt_t *p_usart_opt)
Configure USART to work in SYNC mode and act as a slave.
#define US_CSR_LRXD
(US_CSR) LON Reception End Flag (cleared by writing a one to bit US_CR.RSTSTA)
uint32_t usart_init_hw_handshaking(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in hardware handshaking mode.
#define US_CSR_RXRDY
(US_CSR) Receiver Ready (cleared by reading US_RHR)
#define US_CR_RTSDIS
(US_CR) Request to Send Pin Control
void usart_reset_nack(Usart *p_usart)
Reset NACK in US_CSR.
#define US_MAN_TX_PP_Msk
(US_MAN) Transmitter Preamble Pattern
uint32_t usart_getchar(Usart *p_usart, uint32_t *c)
Read from USART Receive Holding Register. Before reading user should check if rx is ready...
__I uint32_t US_IMR
(Usart Offset: 0x0010) Interrupt Mask Register
#define US_RHR_RXCHR_Msk
(US_RHR) Received Character
void usart_disable_rx(Usart *p_usart)
Disable USART receiver.
__O uint32_t US_CR
(Usart Offset: 0x0000) Control Register
#define US_LINIR_IDCHR_Msk
(US_LINIR) Identifier Character
__O uint32_t US_IDR
(Usart Offset: 0x000C) Interrupt Disable Register
#define US_MR_USART_MODE_IS07816_T_1
(US_MR) IS07816 Protocol: T = 1
#define US_CR_TXEN
(US_CR) Transmitter Enable
void usart_stop_tx_break(Usart *p_usart)
Stop transmission of a break.
#define US_LINMR_NACT_Msk
(US_LINMR) LIN Node Action
__O uint32_t US_IER
(Usart Offset: 0x0008) Interrupt Enable Register
#define US_MR_USART_MODE_NORMAL
(US_MR) Normal mode
#define US_MR_SYNC
(US_MR) Synchronous Mode Select
#define SPI_MODE_3
SPI mode 3.
#define US_MR_USART_MODE_SPI_MASTER
(US_MR) SPI master mode (CLKO must be written to 1 and USCLKS = 0, 1 or 2)
__IO uint32_t US_IF
(Usart Offset: 0x004C) IrDA Filter Register
uint32_t usart_putchar(Usart *p_usart, uint32_t c)
Write to USART Transmit Holding Register.
#define US_CSR_TXRDY
(US_CSR) Transmitter Ready (cleared by writing US_THR)
#define US_LINIR_IDCHR_Pos
__I uint32_t US_RHR
(Usart Offset: 0x0018) Receive Holding Register
#define US_CSR_LINTC
(US_CSR) LIN Transfer Completed (cleared by writing a one to bit US_CR.RSTSTA)
#define US_CR_RTSEN
(US_CR) Request to Send Pin Control
__I uint32_t US_WPSR
(Usart Offset: 0x00E8) Write Protection Status Register
#define HIGH_FRQ_SAMPLE_DIV
#define US_WPMR_WPEN
(US_WPMR) Write Protection Enable
#define US_MR_INACK
(US_MR) Inhibit Non Acknowledge
#define SPI_MODE_0
SPI mode 0.
void usart_disable_tx(Usart *p_usart)
Disable USART transmitter.
#define US_MR_USCLKS_SCK
(US_MR) Serial clock (SCK) is selected
#define SPI_MODE_2
SPI mode 2.
#define US_CR_STTBRK
(US_CR) Start Break
void usart_start_tx_break(Usart *p_usart)
Start transmission of a break.
__IO uint32_t US_MR
(Usart Offset: 0x0004) Mode Register
__IO uint32_t US_LONMR
(Usart Offset: 0x0060) LON Mode Register
uint32_t usart_init_irda(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in IrDA mode.
static uint32_t usart_set_sync_master_baudrate(Usart *p_usart, uint32_t baudrate, uint32_t ul_mck)
Calculate a clock divider for the USART synchronous master modes to generate a baudrate as close as p...
#define US_CR_RSTNACK
(US_CR) Reset Non Acknowledge
#define US_NER_NB_ERRORS_Msk
(US_NER) Number of Errors
__IO uint32_t US_LONPRIO
(Usart Offset: 0x007C) LON Priority Register
#define US_CR_RXEN
(US_CR) Receiver Enable
__IO uint32_t US_LONDL
(Usart Offset: 0x0068) LON Data Length Register
__O uint32_t US_THR
(Usart Offset: 0x001C) Transmit Holding Register
void usart_spi_force_chip_select(Usart *p_usart)
Drive the slave select line NSS (RTS pin) to 0 in SPI master mode.
#define US_CR_TXDIS
(US_CR) Transmitter Disable
#define US_LONPR_LONPL(value)
void usart_enable_tx(Usart *p_usart)
Enable USART transmitter.
#define US_MR_USART_MODE_LIN_SLAVE
(US_MR) LIN Slave mode
__IO uint32_t US_IDTTX
(Usart Offset: 0x0080) LON IDT Tx Register
__IO uint32_t US_WPMR
(Usart Offset: 0x00E4) Write Protection Mode Register
#define US_MR_MAX_ITERATION_Pos
#define US_MAN_RX_PP_Msk
(US_MAN) Receiver Preamble Pattern detected
#define USART2
(USART2) Base Address
#define US_LINMR_PARDIS
(US_LINMR) Parity Disable
#define US_IDTTX_IDTTX(value)
#define US_IDTRX_IDTRX(value)
uint32_t usart_write(Usart *p_usart, uint32_t c)
Write to USART Transmit Holding Register.
uint32_t usart_is_tx_empty(Usart *p_usart)
Check if Transmit Holding Register is empty. Check if the last data written in USART_THR have been lo...
#define Assert(expr)
This macro is used to test fatal errors.
__IO uint32_t US_LONB1RX
(Usart Offset: 0x0078) LON Beta1 Rx Register
uint32_t usart_get_writeprotect_status(Usart *p_usart)
Get write protect status.
#define US_CR_RSTIT
(US_CR) Reset Iterations
#define US_CR_RXDIS
(US_CR) Receiver Disable
#define US_CR_RSTSTA
(US_CR) Reset Status Bits
__IO uint32_t US_FIDI
(Usart Offset: 0x0040) FI DI Ratio Register
void usart_reset_tx(Usart *p_usart)
Immediately stop and disable USART transmitter.
__I uint32_t US_NER
(Usart Offset: 0x0044) Number of Errors Register
uint32_t usart_is_tx_buf_empty(Usart *p_usart)
Check if both transmit buffers are empty.