37 #ifndef UART_H_INCLUDED 38 #define UART_H_INCLUDED 51 #define UART_MCK_DIV 16 53 #define UART_MCK_DIV_MIN_FACTOR 1 55 #define UART_MCK_DIV_MAX_FACTOR 65535 89 #if (!SAMV71 && !SAMV70 && !SAME70 && !SAMS70) 95 #if (SAMG53 || SAMG54 || SAMV71 || SAMV70 || SAME70 || SAMS70) 96 void uart_set_sleepwalking(
Uart *p_uart, uint8_t ul_low_value,
97 bool cmpmode,
bool cmppar, uint8_t ul_high_value);
98 void uart_set_write_protection(
Uart *p_uart,
bool flag);
101 #if (SAM4C || SAM4CP || SAM4CM) 102 enum uart_optical_duty_cycle {
103 UART_MOD_CLK_DUTY_50_00 = UART_MR_OPT_DUTY_DUTY_50,
104 UART_MOD_CLK_DUTY_43_75 = UART_MR_OPT_DUTY_DUTY_43P75,
105 UART_MOD_CLK_DUTY_37_50 = UART_MR_OPT_DUTY_DUTY_37P5,
106 UART_MOD_CLK_DUTY_31_25 = UART_MR_OPT_DUTY_DUTY_31P25,
107 UART_MOD_CLK_DUTY_25_00 = UART_MR_OPT_DUTY_DUTY_25,
108 UART_MOD_CLK_DUTY_18_75 = UART_MR_OPT_DUTY_DUTY_18P75,
109 UART_MOD_CLK_DUTY_12_50 = UART_MR_OPT_DUTY_DUTY_12P5,
110 UART_MOD_CLK_DUTY_06_25 = UART_MR_OPT_DUTY_DUTY_6P25,
113 enum uart_optical_cmp_threshold {
114 UART_RX_CMP_THRESHOLD_VDDIO_DIV_10_0 = UART_MR_OPT_CMPTH_VDDIO_DIV10,
115 UART_RX_CMP_THRESHOLD_VDDIO_DIV_5_0 = UART_MR_OPT_CMPTH_VDDIO_DIV5,
116 UART_RX_CMP_THRESHOLD_VDDIO_DIV_3_3 = UART_MR_OPT_CMPTH_VDDIO_DIV3P3,
117 UART_RX_CMP_THRESHOLD_VDDIO_DIV_2_5 = UART_MR_OPT_CMPTH_VDDIO_DIV2P5,
118 UART_RX_CMP_THRESHOLD_VDDIO_DIV_2_0 = UART_MR_OPT_CMPTH_VDDIO_DIV2,
121 struct uart_config_optical {
131 enum uart_optical_duty_cycle duty;
133 enum uart_optical_cmp_threshold threshold;
136 void uart_enable_optical_interface(
Uart *p_uart);
137 void uart_disable_optical_interface(
Uart *p_uart);
138 void uart_config_optical_interface(
Uart *p_uart,
139 struct uart_config_optical *cfg);
Pdc * uart_get_pdc_base(Uart *p_uart)
Get UART PDC base address.
void uart_reset_rx(Uart *p_uart)
Reset UART receiver.
void uart_disable_tx(Uart *p_uart)
Disable UART transmitter.
uint32_t uart_is_tx_empty(Uart *p_uart)
Check if Transmit Hold Register is empty. Check if the last data written in UART_THR has been loaded ...
void uart_set_clock_divisor(Uart *p_uart, uint16_t us_divisor)
Set UART clock divisor value.
uint32_t uart_is_tx_buf_end(Uart *p_uart)
Check if one transmit buffer is sent out.
uint32_t uart_read(Uart *p_uart, uint8_t *puc_data)
Read from UART Receive Holding Register. Before reading user should check if rx is ready...
uint32_t uart_is_tx_buf_empty(Uart *p_uart)
Check if both transmit buffers are sent out.
void uart_disable(Uart *p_uart)
Disable UART receiver and transmitter.
void uart_enable(Uart *p_uart)
Enable UART receiver and transmitter.
uint32_t uart_init(Uart *p_uart, const sam_uart_opt_t *p_uart_opt)
Configure UART with the specified parameters.
Commonly used includes, types and macros.
void uart_enable_rx(Uart *p_uart)
Enable UART receiver.
void uart_disable_rx(Uart *p_uart)
Disable UART receiver.
void uart_disable_interrupt(Uart *p_uart, uint32_t ul_sources)
Disable UART interrupts.
uint32_t uart_get_interrupt_mask(Uart *p_uart)
Read UART interrupt mask.
uint32_t uart_is_rx_buf_end(Uart *p_uart)
Check if one receive buffer is filled.
uint32_t uart_is_rx_ready(Uart *p_uart)
Check if Received data is ready. Check if data has been received and loaded in UART_RHR.
Option list for UART peripheral initialization.
void uart_reset_status(Uart *p_uart)
Reset status bits.
uint32_t uart_get_status(Uart *p_uart)
Get current status.
uint32_t uart_write(Uart *p_uart, const uint8_t uc_data)
Write to UART Transmit Holding Register Before writing user should check if tx is ready (or empty)...
struct sam_uart_opt sam_uart_opt_t
Option list for UART peripheral initialization.
uint32_t uart_is_rx_buf_full(Uart *p_uart)
Check if both receive buffers are full.
void uart_reset_tx(Uart *p_uart)
Reset UART transmitter.
void uart_enable_tx(Uart *p_uart)
Enable UART transmitter.
uint32_t uart_is_tx_ready(Uart *p_uart)
Check if Transmit is Ready. Check if data has been loaded in UART_THR and is waiting to be loaded in ...
void uart_reset(Uart *p_uart)
Reset UART receiver and transmitter.
void uart_enable_interrupt(Uart *p_uart, uint32_t ul_sources)
Enable UART interrupts.