38#ifndef USART_H_INCLUDED
39#define USART_H_INCLUDED
64#define SPI_CPHA (1 << 0)
67#define SPI_CPOL (1 << 1)
71#define SPI_MODE_1 (SPI_CPHA)
72#define SPI_MODE_2 (SPI_CPOL)
73#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA)
76#if (SAMV71 || SAMV70 || SAME70 || SAMS70)
77#ifndef US_MR_USART_MODE_LIN_MASTER
78#define US_MR_USART_MODE_LIN_MASTER 0x0A
80#ifndef US_MR_USART_MODE_LIN_SLAVE
81#define US_MR_USART_MODE_LIN_SLAVE 0x0B
204 uint32_t baudrate, uint32_t ul_mck);
209#if (SAM3S || SAM4S || SAM3U || SAM4L || SAM4E)
219#if (!SAMG55 && !SAMV71 && !SAMV70 && !SAME70 && !SAMS70)
223#if (!SAMV71 && !SAMV70 && !SAME70 && !SAMS70)
238#if (SAM3XA || SAM4L || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)
239uint32_t usart_init_lin_master(
Usart *p_usart, uint32_t ul_baudrate,
241uint32_t usart_init_lin_slave(
Usart *p_usart, uint32_t ul_baudrate,
243void usart_lin_abort_tx(
Usart *p_usart);
244void usart_lin_send_wakeup_signal(
Usart *p_usart);
245void usart_lin_set_node_action(
Usart *p_usart, uint8_t uc_action);
246void usart_lin_disable_parity(
Usart *p_usart);
247void usart_lin_enable_parity(
Usart *p_usart);
248void usart_lin_disable_checksum(
Usart *p_usart);
249void usart_lin_enable_checksum(
Usart *p_usart);
250void usart_lin_set_checksum_type(
Usart *p_usart, uint8_t uc_type);
251void usart_lin_set_data_len_mode(
Usart *p_usart, uint8_t uc_mode);
252void usart_lin_disable_frame_slot(
Usart *p_usart);
253void usart_lin_enable_frame_slot(
Usart *p_usart);
254void usart_lin_set_wakeup_signal_type(
Usart *p_usart, uint8_t uc_type);
255void usart_lin_set_response_data_len(
Usart *p_usart, uint8_t uc_len);
256void usart_lin_disable_pdc_mode(
Usart *p_usart);
257void usart_lin_enable_pdc_mode(
Usart *p_usart);
258void usart_lin_set_tx_identifier(
Usart *p_usart, uint8_t uc_id);
259uint8_t usart_lin_read_identifier(
Usart *p_usart);
260uint8_t usart_lin_get_data_length(
Usart *usart);
262#if (SAMV71 || SAMV70 || SAME70 || SAMS70)
263uint8_t usart_lin_identifier_send_complete(
Usart *usart);
264uint8_t usart_lin_identifier_reception_complete(
Usart *usart);
265uint8_t usart_lin_tx_complete(
Usart *usart);
266uint32_t usart_init_lon(
Usart *p_usart, uint32_t ul_baudrate, uint32_t ul_mck);
267void usart_lon_set_comm_type(
Usart *p_usart, uint8_t uc_type);
268void usart_lon_disable_coll_detection(
Usart *p_usart);
269void usart_lon_enable_coll_detection(
Usart *p_usart);
270void usart_lon_set_tcol(
Usart *p_usart, uint8_t uc_type);
271void usart_lon_set_cdtail(
Usart *p_usart, uint8_t uc_type);
272void usart_lon_set_dmam(
Usart *p_usart, uint8_t uc_type);
273void usart_lon_set_beta1_tx_len(
Usart *p_usart, uint32_t ul_len);
274void usart_lon_set_beta1_rx_len(
Usart *p_usart, uint32_t ul_len);
275void usart_lon_set_priority(
Usart *p_usart, uint8_t uc_psnb, uint8_t uc_nps);
276void usart_lon_set_tx_idt(
Usart *p_usart, uint32_t ul_time);
277void usart_lon_set_rx_idt(
Usart *p_usart, uint32_t ul_time);
278void usart_lon_set_pre_len(
Usart *p_usart, uint32_t ul_len);
279void usart_lon_set_data_len(
Usart *p_usart, uint8_t uc_len);
280void usart_lon_set_l2hdr(
Usart *p_usart, uint8_t uc_bli, uint8_t uc_altp, uint8_t uc_pb);
281uint32_t usart_lon_is_tx_end(
Usart *p_usart);
282uint32_t usart_lon_is_rx_end(
Usart *p_usart);
302#if (SAM3S || SAM4S || SAM3U || SAM4L || SAM4E)
319uint32_t *usart_get_tx_access(
Usart *p_usart);
320uint32_t *usart_get_rx_access(
Usart *p_usart);
322#if (!SAM4L && !SAMV71 && !SAMV70 && !SAME70 && !SAMS70)
328#if (SAM3S || SAM4S || SAM3U || SAM3XA || SAM4L || SAM4E || SAM4C || SAM4CP || SAM4CM || SAMV70 || SAMV71 || SAMS70 || SAME70)
340uint32_t usart_get_version(
Usart *p_usart);
344void usart_set_sleepwalking(
Usart *p_uart, uint8_t ul_low_value,
345 bool cmpmode,
bool cmppar, uint8_t ul_high_value);
void usart_drive_DTR_pin_low(Usart *p_usart)
Drive the pin DTR to 0.
uint32_t usart_getchar(Usart *p_usart, uint32_t *c)
Read from USART Receive Holding Register.
void usart_reset_tx(Usart *p_usart)
Immediately stop and disable USART transmitter.
void usart_man_set_rx_pre_len(Usart *p_usart, uint8_t uc_len)
Configure the detected receiver preamble length when the Manchester encode/decode is enabled.
Pdc * usart_get_pdc_base(Usart *p_usart)
Get USART PDC base address.
void usart_enable_tx(Usart *p_usart)
Enable USART transmitter.
uint32_t usart_is_rx_buf_full(Usart *p_usart)
Check if both receive buffers are full.
void usart_start_rx_timeout(Usart *p_usart)
Start waiting for a character before clocking the timeout count.
void usart_drive_DTR_pin_high(Usart *p_usart)
Drive the pin DTR to 1.
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.
void usart_enable_interrupt(Usart *p_usart, uint32_t ul_sources)
Enable USART interrupts.
void usart_man_set_rx_pre_pattern(Usart *p_usart, uint8_t uc_pattern)
Configure the detected receiver preamble pattern when the Manchester encode/decode is enabled,...
uint32_t usart_is_tx_buf_end(Usart *p_usart)
Check if one transmit buffer is empty.
void usart_man_set_tx_pre_len(Usart *p_usart, uint8_t uc_len)
Configure the transmitter preamble length when the Manchester encode/decode is enabled.
void usart_man_set_tx_polarity(Usart *p_usart, uint8_t uc_polarity)
Configure the transmitter Manchester polarity when the Manchester encode/decode is enabled.
void usart_reset_status(Usart *p_usart)
Reset status bits (PARE, OVER, MANERR, UNRE and PXBRK in US_CSR).
uint32_t usart_get_writeprotect_status(Usart *p_usart)
Get write protect status.
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.
void usart_restart_rx_timeout(Usart *p_usart)
Restart the receive timeout.
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.
void usart_man_set_tx_pre_pattern(Usart *p_usart, uint8_t uc_pattern)
Configure the transmitter preamble pattern when the Manchester encode/decode is enabled,...
void usart_set_rx_timeout(Usart *p_usart, uint32_t timeout)
Configure the receive timeout register.
void usart_reset(Usart *p_usart)
Reset the USART and disable TX and RX.
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.
void usart_set_tx_timeguard(Usart *p_usart, uint32_t timeguard)
Configure the transmit timeguard register.
void usart_drive_RTS_pin_low(Usart *p_usart)
Drive the pin RTS to 0.
void usart_reset_iterations(Usart *p_usart)
Reset the ITERATION in US_CSR when the ISO7816 mode is enabled.
void usart_enable_rx(Usart *p_usart)
Enable USART receiver.
void usart_reset_rx(Usart *p_usart)
Immediately stop and disable USART receiver.
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.
uint32_t usart_is_tx_buf_empty(Usart *p_usart)
Check if both transmit buffers are empty.
void usart_drive_RTS_pin_high(Usart *p_usart)
Drive the pin RTS to 1.
void usart_man_set_rx_polarity(Usart *p_usart, uint8_t uc_polarity)
Configure the receiver Manchester polarity when the Manchester encode/decode is enabled.
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.
void usart_man_disable_drift_compensation(Usart *p_usart)
Disable drift compensation.
uint32_t usart_is_rx_ready(Usart *p_usart)
Check if the received data are ready.
void usart_disable_interrupt(Usart *p_usart, uint32_t ul_sources)
Disable USART interrupts.
void usart_enable_writeprotect(Usart *p_usart)
Enable write protect of USART registers.
uint32_t usart_write(Usart *p_usart, uint32_t c)
Write to USART Transmit Holding Register.
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...
uint32_t usart_is_rx_buf_end(Usart *p_usart)
Check if one receive buffer is filled.
void usart_spi_release_chip_select(Usart *p_usart)
Drive the slave select line NSS (RTS pin) to 1 in SPI master mode.
void usart_disable_writeprotect(Usart *p_usart)
Disable write protect of USART registers.
uint32_t usart_is_tx_ready(Usart *p_usart)
Check if Transmit is Ready.
uint32_t usart_is_tx_empty(Usart *p_usart)
Check if Transmit Holding Register is empty.
void usart_start_tx_break(Usart *p_usart)
Start transmission of a break.
uint32_t usart_putchar(Usart *p_usart, uint32_t c)
Write to USART Transmit Holding Register.
void usart_reset_nack(Usart *p_usart)
Reset NACK in US_CSR.
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.
void usart_disable_rx(Usart *p_usart)
Disable USART receiver.
uint8_t usart_get_error_number(Usart *p_usart)
Get the total number of errors that occur during an ISO7816 transfer.
uint32_t usart_get_status(Usart *p_usart)
Get current status.
uint32_t usart_read(Usart *p_usart, uint32_t *c)
Read from USART Receive Holding Register.
uint32_t usart_init_modem(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in modem mode.
void usart_man_enable_drift_compensation(Usart *p_usart)
Enable drift compensation.
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.
void usart_disable_tx(Usart *p_usart)
Disable USART transmitter.
void usart_spi_force_chip_select(Usart *p_usart)
Drive the slave select line NSS (RTS pin) to 0 in SPI master mode.
uint32_t usart_get_interrupt_mask(Usart *p_usart)
Read USART interrupt mask.
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.
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.
void usart_stop_tx_break(Usart *p_usart)
Stop transmission of a break.
void usart_write_line(Usart *p_usart, const char *string)
Write one-line string through USART.
Usart hardware registers.
micro definition for LIN mode of SAMV71