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) 210 uint32_t usart_init_modem(
Usart *p_usart,
219 #if (!SAMG55 && !SAMV71 && !SAMV70 && !SAME70 && !SAMS70) 223 #if (!SAMV71 && !SAMV70 && !SAME70 && !SAMS70) 238 #if (SAM3XA || SAM4L || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70) 239 uint32_t usart_init_lin_master(
Usart *p_usart, uint32_t ul_baudrate,
241 uint32_t usart_init_lin_slave(
Usart *p_usart, uint32_t ul_baudrate,
243 void usart_lin_abort_tx(
Usart *p_usart);
244 void usart_lin_send_wakeup_signal(
Usart *p_usart);
245 void usart_lin_set_node_action(
Usart *p_usart, uint8_t uc_action);
246 void usart_lin_disable_parity(
Usart *p_usart);
247 void usart_lin_enable_parity(
Usart *p_usart);
248 void usart_lin_disable_checksum(
Usart *p_usart);
249 void usart_lin_enable_checksum(
Usart *p_usart);
250 void usart_lin_set_checksum_type(
Usart *p_usart, uint8_t uc_type);
251 void usart_lin_set_data_len_mode(
Usart *p_usart, uint8_t uc_mode);
252 void usart_lin_disable_frame_slot(
Usart *p_usart);
253 void usart_lin_enable_frame_slot(
Usart *p_usart);
254 void usart_lin_set_wakeup_signal_type(
Usart *p_usart, uint8_t uc_type);
255 void usart_lin_set_response_data_len(
Usart *p_usart, uint8_t uc_len);
256 void usart_lin_disable_pdc_mode(
Usart *p_usart);
257 void usart_lin_enable_pdc_mode(
Usart *p_usart);
258 void usart_lin_set_tx_identifier(
Usart *p_usart, uint8_t uc_id);
259 uint8_t usart_lin_read_identifier(
Usart *p_usart);
260 uint8_t usart_lin_get_data_length(
Usart *usart);
262 #if (SAMV71 || SAMV70 || SAME70 || SAMS70) 263 uint8_t usart_lin_identifier_send_complete(
Usart *usart);
264 uint8_t usart_lin_identifier_reception_complete(
Usart *usart);
265 uint8_t usart_lin_tx_complete(
Usart *usart);
266 uint32_t usart_init_lon(
Usart *p_usart, uint32_t ul_baudrate, uint32_t ul_mck);
267 void usart_lon_set_comm_type(
Usart *p_usart, uint8_t uc_type);
268 void usart_lon_disable_coll_detection(
Usart *p_usart);
269 void usart_lon_enable_coll_detection(
Usart *p_usart);
270 void usart_lon_set_tcol(
Usart *p_usart, uint8_t uc_type);
271 void usart_lon_set_cdtail(
Usart *p_usart, uint8_t uc_type);
272 void usart_lon_set_dmam(
Usart *p_usart, uint8_t uc_type);
273 void usart_lon_set_beta1_tx_len(
Usart *p_usart, uint32_t ul_len);
274 void usart_lon_set_beta1_rx_len(
Usart *p_usart, uint32_t ul_len);
275 void usart_lon_set_priority(
Usart *p_usart, uint8_t uc_psnb, uint8_t uc_nps);
276 void usart_lon_set_tx_idt(
Usart *p_usart, uint32_t ul_time);
277 void usart_lon_set_rx_idt(
Usart *p_usart, uint32_t ul_time);
278 void usart_lon_set_pre_len(
Usart *p_usart, uint32_t ul_len);
279 void usart_lon_set_data_len(
Usart *p_usart, uint8_t uc_len);
280 void usart_lon_set_l2hdr(
Usart *p_usart, uint8_t uc_bli, uint8_t uc_altp, uint8_t uc_pb);
281 uint32_t usart_lon_is_tx_end(
Usart *p_usart);
282 uint32_t usart_lon_is_rx_end(
Usart *p_usart);
302 #if (SAM3S || SAM4S || SAM3U || SAM4L || SAM4E) 303 void usart_drive_DTR_pin_low(
Usart *p_usart);
304 void usart_drive_DTR_pin_high(
Usart *p_usart);
318 #if (SAM3XA || SAM3U) 319 uint32_t *usart_get_tx_access(
Usart *p_usart);
320 uint32_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) 329 void usart_man_set_tx_pre_len(
Usart *p_usart, uint8_t uc_len);
330 void usart_man_set_tx_pre_pattern(
Usart *p_usart, uint8_t uc_pattern);
331 void usart_man_set_tx_polarity(
Usart *p_usart, uint8_t uc_polarity);
332 void usart_man_set_rx_pre_len(
Usart *p_usart, uint8_t uc_len);
333 void usart_man_set_rx_pre_pattern(
Usart *p_usart, uint8_t uc_pattern);
334 void usart_man_set_rx_polarity(
Usart *p_usart, uint8_t uc_polarity);
335 void usart_man_enable_drift_compensation(
Usart *p_usart);
336 void usart_man_disable_drift_compensation(
Usart *p_usart);
340 uint32_t usart_get_version(
Usart *p_usart);
344 void usart_set_sleepwalking(
Usart *p_uart, uint8_t ul_low_value,
345 bool cmpmode,
bool cmppar, uint8_t ul_high_value);
void usart_disable_writeprotect(Usart *p_usart)
Disable write protect of USART registers.
uint8_t usart_get_error_number(Usart *p_usart)
Get the total number of errors that occur during an ISO7816 transfer.
void usart_restart_rx_timeout(Usart *p_usart)
Restart the receive timeout.
uint32_t usart_read(Usart *p_usart, uint32_t *c)
Read from USART Receive Holding Register.
uint32_t usart_is_rx_buf_full(Usart *p_usart)
Check if both receive buffers are full.
void usart_reset_iterations(Usart *p_usart)
Reset the ITERATION in US_CSR when the ISO7816 mode is enabled.
uint32_t usart_is_tx_buf_end(Usart *p_usart)
Check if one transmit buffer is empty.
uint32_t usart_write(Usart *p_usart, uint32_t c)
Write to USART Transmit Holding Register.
void usart_disable_rx(Usart *p_usart)
Disable USART receiver.
Usart hardware registers.
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_disable_interrupt(Usart *p_usart, uint32_t ul_sources)
Disable USART interrupts.
void usart_drive_RTS_pin_high(Usart *p_usart)
Drive the pin RTS to 1.
void usart_write_line(Usart *p_usart, const char *string)
Write one-line string through USART.
void usart_drive_RTS_pin_low(Usart *p_usart)
Drive the pin RTS to 0.
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...
Commonly used includes, types and macros.
void usart_set_tx_timeguard(Usart *p_usart, uint32_t timeguard)
Configure the transmit timeguard register.
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_status(Usart *p_usart)
Get current status.
void usart_enable_writeprotect(Usart *p_usart)
Enable write protect of USART registers.
void usart_reset_rx(Usart *p_usart)
Immediately stop and disable USART receiver.
void usart_enable_tx(Usart *p_usart)
Enable USART transmitter.
void usart_reset_tx(Usart *p_usart)
Immediately stop and disable USART transmitter.
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...
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_start_tx_break(Usart *p_usart)
Start transmission of a break.
void usart_enable_interrupt(Usart *p_usart, uint32_t ul_sources)
Enable USART interrupts.
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_spi_release_chip_select(Usart *p_usart)
Drive the slave select line NSS (RTS pin) to 1 in SPI master mode.
void usart_reset_nack(Usart *p_usart)
Reset NACK in US_CSR.
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.
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.
uint32_t usart_is_tx_buf_empty(Usart *p_usart)
Check if both transmit buffers are empty.
uint32_t usart_putchar(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_init_irda(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in IrDA mode.
uint32_t usart_is_rx_buf_end(Usart *p_usart)
Check if one receive buffer is filled.
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...
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_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_disable_tx(Usart *p_usart)
Disable USART transmitter.
void usart_set_rx_timeout(Usart *p_usart, uint32_t timeout)
Configure the receive timeout register.
uint32_t usart_get_interrupt_mask(Usart *p_usart)
Read USART interrupt mask.
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_init_iso7816(Usart *p_usart, const usart_iso7816_opt_t *p_usart_opt, uint32_t ul_mck)
Configure USART to work in ISO7816 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 ...
void usart_reset(Usart *p_usart)
Reset the USART and disable TX and RX.
Pdc * usart_get_pdc_base(Usart *p_usart)
Get USART PDC base address.
uint32_t usart_get_writeprotect_status(Usart *p_usart)
Get write protect status.
void usart_stop_tx_break(Usart *p_usart)
Stop transmission of a break.
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...
void usart_enable_rx(Usart *p_usart)
Enable USART receiver.
void usart_reset_status(Usart *p_usart)
Reset status bits (PARE, OVER, MANERR, UNRE and PXBRK in US_CSR).