|
SmartSnippets DA1459x SDK
|
Go to the documentation of this file.
44 #if dg_configUSE_HW_UART
50 #define UBA(id) ((UART2_Type *)id)
51 #define HW_UART1 ((uint16_t *)UART_BASE)
52 #define HW_UART2 ((uint16_t *)UART2_BASE)
53 typedef uint16_t * HW_UART_ID;
69 #define HW_UART_REG_FIELD_MASK(instance, reg, field) \
70 (UART##instance##_UART##instance##_##reg##_REG_##field##_Msk)
86 #define HW_UART_REG_FIELD_POS(instance, reg, field) \
87 (UART##instance##_UART##instance##_##reg##_REG_##field##_Pos)
99 #define HW_UART_REG_GETF(id, reg, field) \
100 ((UBA(id)->UART2_##reg##_REG & (UART2_UART2_##reg##_REG_##field##_Msk)) >> (UART2_UART2_##reg##_REG_##field##_Pos))
111 #define HW_UART_REG_SETF(id, reg, field, new_val) \
112 UBA(id)->UART2_##reg##_REG = ((UBA(id)->UART2_##reg##_REG & ~(UART2_UART2_##reg##_REG_##field##_Msk)) | \
113 ((UART2_UART2_##reg##_REG_##field##_Msk) & ((new_val) << (UART2_UART2_##reg##_REG_##field##_Pos))))
121 #define HW_UART_DMA_SUPPORT dg_configUART_DMA_SUPPORT
123 #if (HW_UART_DMA_SUPPORT == 1)
146 HW_UART_INT_MODEM_STAT = 0,
147 HW_UART_INT_NO_INT_PEND = 1,
148 HW_UART_INT_THR_EMPTY = 2,
149 HW_UART_INT_RECEIVED_AVAILABLE = 4,
150 HW_UART_INT_RECEIVE_LINE_STAT = 6,
151 HW_UART_INT_BUSY_DETECTED = 7,
152 HW_UART_INT_TIMEOUT = 12,
202 HW_UART_DATABITS_5 = 0,
203 HW_UART_DATABITS_6 = 1,
204 HW_UART_DATABITS_7 = 2,
205 HW_UART_DATABITS_8 = 3,
213 HW_UART_PARITY_NONE = 0,
214 HW_UART_PARITY_ODD = 1,
215 HW_UART_PARITY_EVEN = 3,
233 HW_UART_ERR_NOERROR = 0,
246 HW_UART_CONFIG_ERR_NOERR = 0,
264 uint8_t auto_flow_control:1;
266 uint8_t tx_fifo_tr_lvl:2;
267 uint8_t rx_fifo_tr_lvl:2;
268 #if (HW_UART_DMA_SUPPORT == 1)
272 uint8_t tx_dma_burst_lvl:2;
273 uint8_t rx_dma_burst_lvl:2;
274 hw_uart_dma_prio_t dma_prio;
278 #ifdef HW_UART_ENABLE_USER_ISR
290 typedef void (*hw_uart_interrupt_isr)(void);
299 void hw_uart_set_isr(HW_UART_ID uart, hw_uart_interrupt_isr isr);
302 typedef void (*hw_uart_tx_callback)(
void *user_data, uint16_t written);
303 typedef void (*hw_uart_rx_callback)(
void *user_data, uint16_t read);
304 typedef void (*hw_uart_err_callback)(
void *user_data,
HW_UART_ERROR error);
359 #if (dg_configUART_RX_CIRCULAR_DMA == 1)
368 uint16_t hw_uart_copy_dma_rx_to_user_buffer(HW_UART_ID uart);
417 return UBA(uart)->UART2_RBR_THR_DLL_REG;
430 UBA(uart)->UART2_RBR_THR_DLL_REG = data;
501 void *user_data, hw_uart_err_callback err_cb,
void *error_data);
503 #if (HW_UART_DMA_SUPPORT == 1)
516 void hw_uart_configure_dma_channels(HW_UART_ID uart,
const uart_config *uart_init);
583 return (
HW_UART_INT) (UBA(uart)->UART2_IIR_FCR_REG & 0xF);
597 if (uart == HW_UART2) {
598 REG_SETF(UART2, UART2_CONFIG_REG, ISO7816_SCRATCH_PAD, value);
600 UART->UART_SCR_REG = value;
617 if (uart == HW_UART2) {
618 ret_val =
REG_GETF(UART2, UART2_CONFIG_REG, ISO7816_SCRATCH_PAD);
620 ret_val = UART->UART_SCR_REG;
686 return (UBA(uart)->UART2_LSR_REG & 1) != 0;
700 return UBA(uart)->UART2_SFE_REG != 0;
711 uint16_t iir_fcr_reg = UBA(uart)->UART2_IIR_FCR_REG;
712 iir_fcr_reg &= 0xfffe;
713 UBA(uart)->UART2_IIR_FCR_REG = iir_fcr_reg;
782 return UBA(uart)->UART2_RFL_REG;
796 return UBA(uart)->UART2_TFL_REG;
844 uint16_t iir_fcr_reg = UBA(uart)->UART2_IIR_FCR_REG;
846 iir_fcr_reg |= (en & 0x1);
847 UBA(uart)->UART2_IIR_FCR_REG = iir_fcr_reg;
884 UBA(uart)->UART2_SRT_REG = tr_lvl;
917 UBA(uart)->UART2_STET_REG = tr_lvl;
992 #if (dg_configUART_SOFTWARE_FIFO == 1)
1001 void hw_uart_set_soft_fifo(HW_UART_ID uart, uint8_t *buf, uint8_t size);
1004 #if (HW_UART_DMA_SUPPORT == 1)
1014 __STATIC_INLINE
void hw_uart_dma_mode_setf(HW_UART_ID uart, uint8_t dma_mode)
1027 __STATIC_INLINE
void hw_uart_clear_dma_request(HW_UART_ID uart)
1029 UBA(uart)->UART2_DMASA_REG = 1;
1290 #if (dg_configUART_RX_CIRCULAR_DMA == 1)
1309 void hw_uart_enable_rx_circular_dma(HW_UART_ID uart);
1319 void hw_uart_copy_rx_circular_dma_buffer(HW_UART_ID uart, uint8_t *buf, uint16_t len);
__STATIC_INLINE void hw_uart_rec_data_int_set(HW_UART_ID uart, uint8_t recdataavail)
Set the Received Data Available interrupt.
Definition: hw_uart.h:529
uint16_t hw_uart_peek_transmitted(HW_UART_ID uart)
Get number of bytes currently sent by asynchronous read.
__STATIC_INLINE void hw_uart_write_scr(const HW_UART_ID uart, uint8_t value)
Write Scratch pad register.
Definition: hw_uart.h:595
Definition: hw_uart.h:172
HW_UART_PARITY
Parity.
Definition: hw_uart.h:212
HW_UART_ERROR hw_uart_error_getf(HW_UART_ID uart)
Get the line status register error.
HW_UART_CONFIG_ERR hw_uart_send(HW_UART_ID uart, const void *data, uint16_t len, hw_uart_tx_callback cb, void *user_data)
Write number of bytes to UART.
Definition of API for the DMA Low Level Driver.
__STATIC_INLINE void hw_uart_disable_fifo(HW_UART_ID uart)
Disable both FIFOs.
Definition: hw_uart.h:709
#define HW_UART_REG_SETF(id, reg, field, new_val)
Set the value of a field of a UART register.
Definition: hw_uart.h:111
#define REG_SETF(base, reg, field, new_val)
Set the value of a register field.
Definition: sdk_defs.h:738
__STATIC_INLINE bool hw_uart_transmit_fifo_empty(HW_UART_ID uart)
Check if transmit FIFO is empty.
Definition: hw_uart.h:766
Definition: hw_uart.h:235
Definition: hw_uart.h:174
__STATIC_INLINE bool hw_uart_transmit_fifo_not_full(HW_UART_ID uart)
Check if transmit FIFO is not full.
Definition: hw_uart.h:752
uint8_t hw_uart_is_tx_fifo_empty(HW_UART_ID uart)
Get the value of the Transmitter Empty bit.
uint8_t hw_uart_fifo_en_getf(HW_UART_ID uart)
Get the FIFO mode setting.
Definition: hw_uart.h:237
__STATIC_INLINE bool hw_uart_is_data_ready(HW_UART_ID uart)
Check if there is data available for read.
Definition: hw_uart.h:684
Definition: hw_uart.h:236
Definition: hw_uart.h:167
Definition: hw_uart.h:173
void hw_uart_afce_setf(HW_UART_ID uart, uint8_t afce)
Enable or disable Auto Flow Control.
void hw_uart_write(HW_UART_ID uart, uint8_t data)
Write one byte to UART.
void hw_uart_cfg_get(HW_UART_ID uart, uart_config *cfg)
Get UART line settings.
Definition: hw_uart.h:180
uint8_t hw_uart_afce_getf(HW_UART_ID uart)
Get the Auto Flow Control Enable (AFCE) setting.
UART configuration structure definition.
Definition: hw_uart.h:258
void hw_uart_reinit(HW_UART_ID uart, const uart_config *cfg)
Re-initialize UART registers.
#define HW_UART_REG_GETF(id, reg, field)
Get the value of a field of a UART register.
Definition: hw_uart.h:99
HW_UART_BAUDRATE
Baud rates.
Definition: hw_uart.h:161
HW_UART_ERROR
Uart errors.
Definition: hw_uart.h:232
#define UART2_UART2_SDMAM_REG_UART_SHADOW_DMA_MODE_Msk
Definition: DA1459x-00.h:5622
uint8_t hw_uart_cts_getf(HW_UART_ID uart)
Get CTS input status.
Definition: hw_uart.h:166
uint8_t hw_uart_rts_getf(HW_UART_ID uart)
Get RTS output value.
Central include header file with platform definitions.
bool hw_uart_tx_in_progress(const HW_UART_ID uart)
Check if buffered write is in progress.
DMA peripherals priority structure.
Definition: hw_dma.h:275
#define UART2_UART2_SDMAM_REG_UART_SHADOW_DMA_MODE_Pos
Definition: DA1459x-00.h:5621
Definition: hw_uart.h:164
__STATIC_INLINE void hw_uart_pthre_int_set(HW_UART_ID uart, uint8_t pthre)
Set the Programmable THRE interrupt.
Definition: hw_uart.h:567
HW_UART_STOPBITS
Stop bits.
Definition: hw_uart.h:222
__STATIC_INLINE void hw_uart_fifo_en_setf(HW_UART_ID uart, uint8_t en)
Enable or disable the UART FIFO mode.
Definition: hw_uart.h:840
__STATIC_INLINE void hw_uart_enable_loopback(HW_UART_ID uart)
Enable loopback.
Definition: hw_uart.h:805
HW_UART_CONFIG_ERR hw_uart_init(HW_UART_ID uart, const uart_config *cfg)
Set UART line settings.
Definition: hw_uart.h:169
Definition: hw_uart.h:170
const uint32_t hw_uart_divisor[HW_UART_BAUDRATE_MAX]
Baud rates dividers.
__STATIC_INLINE bool hw_uart_receive_fifo_not_empty(HW_UART_ID uart)
Check if receive FIFO is not empty.
Definition: hw_uart.h:738
HW_UART_INT
Interrupt Identification codes.
Definition: hw_uart.h:145
__STATIC_INLINE uint16_t hw_uart_receive_fifo_count(HW_UART_ID uart)
Read number of bytes in receive FIFO.
Definition: hw_uart.h:779
__STATIC_INLINE void hw_uart_tx_fifo_flush(HW_UART_ID uart)
Reset UART transmit FIFO.
Definition: hw_uart.h:926
uint16_t hw_uart_abort_send(HW_UART_ID uart)
Stop asynchronous transmit from UART.
HW_DMA_CHANNEL
DMA channel number.
Definition: hw_dma.h:62
Definition: hw_uart.h:176
uint8_t hw_uart_read(HW_UART_ID uart)
Read one byte from UART.
Definition: hw_uart.h:168
uint16_t hw_uart_abort_receive(HW_UART_ID uart)
Stop asynchronous read from UART.
__STATIC_INLINE void hw_uart_tx_empty_int_set(HW_UART_ID uart, uint8_t txempty)
Set the Transmit Holding Register empty interrupt.
Definition: hw_uart.h:541
__STATIC_INLINE bool hw_uart_is_busy(HW_UART_ID uart)
Check if a serial transfer is in progress.
Definition: hw_uart.h:313
Definition: hw_uart.h:238
uint8_t hw_uart_parity_err_getf(HW_UART_ID uart)
Get the value of the Parity Error bit.
__STATIC_INLINE void hw_uart_linestat_int_set(HW_UART_ID uart, uint8_t linestat)
Set the Line Status interrupt.
Definition: hw_uart.h:554
void hw_uart_set_sclk(const HW_UART_ID uart, bool sclk)
Configure the serial clock input of the UART (divN or div1)
void hw_uart_deinit(HW_UART_ID uart)
Disables UART controller.
HW_UART_DATABITS
Character format.
Definition: hw_uart.h:201
uint8_t hw_uart_delta_cts_getf(HW_UART_ID uart)
Get Delta CTS.
uint8_t hw_uart_break_int_getf(HW_UART_ID uart)
Get the value of the Break Interrupt bit.
Definition: hw_uart.h:171
__STATIC_INLINE void hw_uart_txdata_setf(HW_UART_ID uart, uint8_t data)
Write byte to the transmit holding register.
Definition: hw_uart.h:427
Definition: hw_uart.h:175
void hw_uart_receive_error_checking(HW_UART_ID uart, void *data, uint16_t len, hw_uart_rx_callback cb, void *user_data, hw_uart_err_callback err_cb, void *error_data)
Read number of bytes from UART with error checking.
Definition: hw_uart.h:165
__STATIC_INLINE void hw_uart_tx_fifo_tr_lvl_setf(HW_UART_ID uart, uint8_t tr_lvl)
Set the transmit FIFO trigger level at which the Transmit Holding Register Empty (THRE) Interrupt is ...
Definition: hw_uart.h:914
Definition: hw_uart.h:250
uint8_t hw_uart_overrun_err_getf(HW_UART_ID uart)
Get the value of the Overrun Error bit.
__STATIC_INLINE uint8_t hw_uart_read_scr(const HW_UART_ID uart)
Read Scratch pad register.
Definition: hw_uart.h:614
uint8_t hw_uart_tx_fifo_tr_lvl_getf(HW_UART_ID uart)
Get the transmit FIFO trigger level at which the Transmit Holding Register Empty (THRE) Interrupt is ...
Definition: hw_uart.h:163
Definition: hw_uart.h:225
Definition: hw_uart.h:178
__STATIC_INLINE uint8_t hw_uart_rx_fifo_tr_lvl_getf(HW_UART_ID uart)
Get the receive FIFO trigger level at which the Received Data Available Interrupt is generated.
Definition: hw_uart.h:863
__STATIC_INLINE void hw_uart_rx_fifo_tr_lvl_setf(HW_UART_ID uart, uint8_t tr_lvl)
Set the receive FIFO trigger level at which the Received Data Available Interrupt is generated.
Definition: hw_uart.h:881
__STATIC_INLINE uint8_t hw_uart_rxdata_getf(HW_UART_ID uart)
Read receive buffer register.
Definition: hw_uart.h:414
__STATIC_INLINE HW_UART_INT hw_uart_get_interrupt_id(HW_UART_ID uart)
Get the Interrupt ID.
Definition: hw_uart.h:581
__STATIC_INLINE bool hw_uart_read_buf_empty(HW_UART_ID uart)
Check whether reading buffer is empty.
Definition: hw_uart.h:954
#define UART2_UART2_SRT_REG_UART_SHADOW_RCVR_TRIGGER_Msk
Definition: DA1459x-00.h:5686
Definition: hw_uart.h:177
uint8_t hw_uart_rx_fifo_err_getf(HW_UART_ID uart)
Get the value of the Receiver FIFO Error bit.
#define HW_UART_REG_FIELD_POS(instance, reg, field)
Get the bit position of a field of a UART register.
Definition: hw_uart.h:86
Definition: hw_uart.h:248
bool hw_uart_rx_in_progress(const HW_UART_ID uart)
Check if buffered read is in progress.
__STATIC_INLINE bool hw_uart_is_fifo_enabled(HW_UART_ID uart)
Get the FIFO mode setting.
Definition: hw_uart.h:697
uint8_t hw_uart_frame_err_getf(HW_UART_ID uart)
Get the value of the Framing Error bit.
Definition: hw_uart.h:223
#define REG_GETF(base, reg, field)
Return the value of a register field.
Definition: sdk_defs.h:711
Definition: hw_uart.h:234
__STATIC_INLINE bool hw_uart_transmit_empty(HW_UART_ID uart)
Check whether transmitter is empty.
Definition: hw_uart.h:987
Definition: hw_uart.h:179
Definition: hw_uart.h:247
Definition: hw_uart.h:249
HW_UART_CONFIG_ERR hw_uart_receive(HW_UART_ID uart, void *data, uint16_t len, hw_uart_rx_callback cb, void *user_data)
Read number of bytes from UART.
uint8_t hw_uart_loopback_getf(HW_UART_ID uart)
Get UART diagnostic mode status.
uint8_t hw_uart_thr_empty_getf(HW_UART_ID uart)
Get the value of the Transmit Holding Register Empty bit.
__STATIC_INLINE void hw_uart_enable_fifo(HW_UART_ID uart)
Enable both FIFOs.
Definition: hw_uart.h:724
__STATIC_INLINE void hw_uart_disable_loopback(HW_UART_ID uart)
Disable loopback.
Definition: hw_uart.h:816
__STATIC_INLINE uint16_t hw_uart_transmit_fifo_count(HW_UART_ID uart)
Read number of bytes in transmit FIFO.
Definition: hw_uart.h:793
HW_UART_BAUDRATE hw_uart_baudrate_get(HW_UART_ID uart)
Get the baud rate setting.
void hw_uart_loopback_setf(HW_UART_ID uart, uint8_t lb)
Set UART in diagnostic mode.
void hw_uart_rts_setf(HW_UART_ID uart, uint8_t rtsn)
Set RTS output value.
__STATIC_INLINE bool hw_uart_write_buf_full(HW_UART_ID uart)
Check whether writing buffer is full.
Definition: hw_uart.h:969
HW_UART_CONFIG_ERR
Configuration errors.
Definition: hw_uart.h:245
Definition: hw_uart.h:162
uint16_t hw_uart_peek_received(HW_UART_ID uart)
Get number of bytes currently received by asynchronous read.
Definition: hw_uart.h:251
__STATIC_INLINE void hw_uart_rx_fifo_flush(HW_UART_ID uart)
Reset UART receive FIFO.
Definition: hw_uart.h:937
void hw_uart_baudrate_set(HW_UART_ID uart, HW_UART_BAUDRATE baud_rate)
Set the baud rate.
void hw_uart_write_buffer(HW_UART_ID uart, const void *data, uint16_t len)
Writes number of bytes to UART synchronously.