SmartSnippets DA1459x SDK
hw_uart.h
Go to the documentation of this file.
1 
41 #ifndef HW_UART_H_
42 #define HW_UART_H_
43 
44 #if dg_configUSE_HW_UART
45 
46 #include <stdbool.h>
47 #include <stdint.h>
48 #include "sdk_defs.h"
49 
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;
54 
69 #define HW_UART_REG_FIELD_MASK(instance, reg, field) \
70  (UART##instance##_UART##instance##_##reg##_REG_##field##_Msk)
71 
86 #define HW_UART_REG_FIELD_POS(instance, reg, field) \
87  (UART##instance##_UART##instance##_##reg##_REG_##field##_Pos)
88 
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))
101 
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))))
114 
121 #define HW_UART_DMA_SUPPORT dg_configUART_DMA_SUPPORT
122 
123 #if (HW_UART_DMA_SUPPORT == 1)
124 #include "hw_dma.h"
125 
133 typedef hw_dma_periph_prio_t hw_uart_dma_prio_t;
134 #endif /* HW_UART_DMA_SUPPORT */
135 
136 /*
137  * ENUMERATION DEFINITIONS
138  *****************************************************************************************
139  */
140 
145 typedef enum {
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,
153 } HW_UART_INT;
154 
161 typedef enum {
182 
195 extern const uint32_t hw_uart_divisor[HW_UART_BAUDRATE_MAX];
196 
201 typedef enum {
202  HW_UART_DATABITS_5 = 0,
203  HW_UART_DATABITS_6 = 1,
204  HW_UART_DATABITS_7 = 2,
205  HW_UART_DATABITS_8 = 3,
207 
212 typedef enum {
213  HW_UART_PARITY_NONE = 0,
214  HW_UART_PARITY_ODD = 1,
215  HW_UART_PARITY_EVEN = 3,
217 
222 typedef enum {
227 
232 typedef enum {
233  HW_UART_ERR_NOERROR = 0,
239 } HW_UART_ERROR;
240 
245 typedef enum {
246  HW_UART_CONFIG_ERR_NOERR = 0,
253 
258 typedef struct {
259  // Baud rate divisor
260  HW_UART_BAUDRATE baud_rate;
261  HW_UART_DATABITS data:2;
262  HW_UART_PARITY parity:2;
263  HW_UART_STOPBITS stop:1;
264  uint8_t auto_flow_control:1;
265  uint8_t use_fifo:1;
266  uint8_t tx_fifo_tr_lvl:2;
267  uint8_t rx_fifo_tr_lvl:2;
268 #if (HW_UART_DMA_SUPPORT == 1)
269  uint8_t use_dma:1;
270  HW_DMA_CHANNEL tx_dma_channel:4;
271  HW_DMA_CHANNEL rx_dma_channel:4;
272  uint8_t tx_dma_burst_lvl:2; /* 0 no burst mode, 1 burst size of 4, 2 burst size of 8 */
273  uint8_t rx_dma_burst_lvl:2; /* 0 no burst mode, 1 burst size of 4, 2 burst size of 8 */
274  hw_uart_dma_prio_t dma_prio;
275 #endif /* HW_UART_DMA_SUPPORT */
276 } uart_config;
277 
278 #ifdef HW_UART_ENABLE_USER_ISR
279 
290 typedef void (*hw_uart_interrupt_isr)(void);
291 
299 void hw_uart_set_isr(HW_UART_ID uart, hw_uart_interrupt_isr isr);
300 #endif
301 
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);
305 
306 //======================= Status functions ====================================
307 
313 __STATIC_INLINE bool hw_uart_is_busy(HW_UART_ID uart)
314 {
315  return HW_UART_REG_GETF(uart, USR, UART_BUSY);
316 }
317 
318 //===================== Read/Write functions ===================================
319 
331 uint8_t hw_uart_read(HW_UART_ID uart);
332 
343 void hw_uart_write(HW_UART_ID uart, uint8_t data);
344 
357 uint16_t hw_uart_abort_receive(HW_UART_ID uart);
358 
359 #if (dg_configUART_RX_CIRCULAR_DMA == 1)
360 
368 uint16_t hw_uart_copy_dma_rx_to_user_buffer(HW_UART_ID uart);
369 #endif
370 
382 uint16_t hw_uart_abort_send(HW_UART_ID uart);
383 
393 uint16_t hw_uart_peek_received(HW_UART_ID uart);
394 
404 uint16_t hw_uart_peek_transmitted(HW_UART_ID uart);
405 
414 __STATIC_INLINE uint8_t hw_uart_rxdata_getf(HW_UART_ID uart)
415 {
416  // Read element from the receive FIFO
417  return UBA(uart)->UART2_RBR_THR_DLL_REG;
418 }
419 
427 __STATIC_INLINE void hw_uart_txdata_setf(HW_UART_ID uart, uint8_t data)
428 {
429  // Write data to the transmit FIFO
430  UBA(uart)->UART2_RBR_THR_DLL_REG = data;
431 }
432 
445 void hw_uart_write_buffer(HW_UART_ID uart, const void *data, uint16_t len);
446 
460 HW_UART_CONFIG_ERR hw_uart_send(HW_UART_ID uart, const void *data, uint16_t len, hw_uart_tx_callback cb,
461  void *user_data);
479 HW_UART_CONFIG_ERR hw_uart_receive(HW_UART_ID uart, void *data, uint16_t len, hw_uart_rx_callback cb,
480  void *user_data);
500 void hw_uart_receive_error_checking(HW_UART_ID uart, void *data, uint16_t len, hw_uart_rx_callback cb,
501  void *user_data, hw_uart_err_callback err_cb, void *error_data);
502 
503 #if (HW_UART_DMA_SUPPORT == 1)
504 
516 void hw_uart_configure_dma_channels(HW_UART_ID uart, const uart_config *uart_init);
517 
518 #endif /* HW_UART_DMA_SUPPORT */
519 
520 //============== Interrupt handling ============================================
521 
529 __STATIC_INLINE void hw_uart_rec_data_int_set(HW_UART_ID uart, uint8_t recdataavail)
530 {
531  // Set ERBFI bit in Interrupt Enable Register
532  HW_UART_REG_SETF(uart, IER_DLH, ERBFI_DLH0, recdataavail);
533 }
541 __STATIC_INLINE void hw_uart_tx_empty_int_set(HW_UART_ID uart, uint8_t txempty)
542 {
543  // Set ETBEI bit in Interrupt Enable Register
544  HW_UART_REG_SETF(uart, IER_DLH, ETBEI_DLH1, txempty);
545 }
546 
554 __STATIC_INLINE void hw_uart_linestat_int_set(HW_UART_ID uart, uint8_t linestat)
555 {
556  // Set ELSI bit in Interrupt Enable Register
557  HW_UART_REG_SETF(uart, IER_DLH, ELSI_DLH2, linestat);
558 }
559 
567 __STATIC_INLINE void hw_uart_pthre_int_set(HW_UART_ID uart, uint8_t pthre)
568 {
569  // Set PTIME bit in Interrupt Enable Register
570  HW_UART_REG_SETF(uart, IER_DLH, PTIME_DLH7, pthre);
571 }
572 
581 __STATIC_INLINE HW_UART_INT hw_uart_get_interrupt_id(HW_UART_ID uart)
582 {
583  return (HW_UART_INT) (UBA(uart)->UART2_IIR_FCR_REG & 0xF);
584 }
585 
595 __STATIC_INLINE void hw_uart_write_scr(const HW_UART_ID uart, uint8_t value)
596 {
597  if (uart == HW_UART2) {
598  REG_SETF(UART2, UART2_CONFIG_REG, ISO7816_SCRATCH_PAD, value);
599  } else {
600  UART->UART_SCR_REG = value;
601  }
602 }
603 
614 __STATIC_INLINE uint8_t hw_uart_read_scr(const HW_UART_ID uart)
615 {
616  uint8_t ret_val = 0;
617  if (uart == HW_UART2) {
618  ret_val = REG_GETF(UART2, UART2_CONFIG_REG, ISO7816_SCRATCH_PAD);
619  } else {
620  ret_val = UART->UART_SCR_REG;
621  }
622  return ret_val;
623 }
624 
625 //==================== Configuration functions =================================
636 void hw_uart_set_sclk(const HW_UART_ID uart, bool sclk);
637 
651 HW_UART_BAUDRATE hw_uart_baudrate_get(HW_UART_ID uart);
652 
672 void hw_uart_baudrate_set(HW_UART_ID uart, HW_UART_BAUDRATE baud_rate);
673 
674 //=========================== FIFO control functions ===========================
675 
684 __STATIC_INLINE bool hw_uart_is_data_ready(HW_UART_ID uart)
685 {
686  return (UBA(uart)->UART2_LSR_REG & 1) != 0;
687 }
688 
697 __STATIC_INLINE bool hw_uart_is_fifo_enabled(HW_UART_ID uart)
698 {
699 
700  return UBA(uart)->UART2_SFE_REG != 0;
701 }
702 
709 __STATIC_INLINE void hw_uart_disable_fifo(HW_UART_ID uart)
710 {
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;
714 }
715 
724 __STATIC_INLINE void hw_uart_enable_fifo(HW_UART_ID uart)
725 {
726 
727  UBA(uart)->UART2_SFE_REG = 1 << HW_UART_REG_FIELD_POS(2, SFE, UART_SHADOW_FIFO_ENABLE);
728 }
729 
738 __STATIC_INLINE bool hw_uart_receive_fifo_not_empty(HW_UART_ID uart)
739 {
740 
741  return HW_UART_REG_GETF(uart, USR, UART_RFNE) != 0;
742 }
743 
752 __STATIC_INLINE bool hw_uart_transmit_fifo_not_full(HW_UART_ID uart)
753 {
754 
755  return HW_UART_REG_GETF(uart, USR, UART_TFNF) != 0;
756 }
757 
766 __STATIC_INLINE bool hw_uart_transmit_fifo_empty(HW_UART_ID uart)
767 {
768  return HW_UART_REG_GETF(uart, USR, UART_TFE) != 0;
769 }
770 
779 __STATIC_INLINE uint16_t hw_uart_receive_fifo_count(HW_UART_ID uart)
780 {
781 
782  return UBA(uart)->UART2_RFL_REG;
783 }
784 
793 __STATIC_INLINE uint16_t hw_uart_transmit_fifo_count(HW_UART_ID uart)
794 {
795 
796  return UBA(uart)->UART2_TFL_REG;
797 }
798 
805 __STATIC_INLINE void hw_uart_enable_loopback(HW_UART_ID uart)
806 {
807  HW_UART_REG_SETF(uart, MCR, UART_LB, 1);
808 }
809 
816 __STATIC_INLINE void hw_uart_disable_loopback(HW_UART_ID uart)
817 {
818  HW_UART_REG_SETF(uart, MCR, UART_LB, 0);
819 }
820 
831 uint8_t hw_uart_fifo_en_getf(HW_UART_ID uart);
832 
840 __STATIC_INLINE void hw_uart_fifo_en_setf(HW_UART_ID uart, uint8_t en)
841 {
842 
843  // Write FIFO Enable (FIFOE) bit in FIFO Control Register
844  uint16_t iir_fcr_reg = UBA(uart)->UART2_IIR_FCR_REG;
845  iir_fcr_reg &= ~0x1;
846  iir_fcr_reg |= (en & 0x1);
847  UBA(uart)->UART2_IIR_FCR_REG = iir_fcr_reg;
848 }
849 
863 __STATIC_INLINE uint8_t hw_uart_rx_fifo_tr_lvl_getf(HW_UART_ID uart)
864 {
865 
866  return UBA(uart)->UART2_SRT_REG & UART2_UART2_SRT_REG_UART_SHADOW_RCVR_TRIGGER_Msk;
867 }
868 
881 __STATIC_INLINE void hw_uart_rx_fifo_tr_lvl_setf(HW_UART_ID uart, uint8_t tr_lvl)
882 {
883 
884  UBA(uart)->UART2_SRT_REG = tr_lvl;
885 }
886 
900 uint8_t hw_uart_tx_fifo_tr_lvl_getf(HW_UART_ID uart);
901 
914 __STATIC_INLINE void hw_uart_tx_fifo_tr_lvl_setf(HW_UART_ID uart, uint8_t tr_lvl)
915 {
916 
917  UBA(uart)->UART2_STET_REG = tr_lvl;
918 }
919 
926 __STATIC_INLINE void hw_uart_tx_fifo_flush(HW_UART_ID uart)
927 {
928  HW_UART_REG_SETF(uart, SRR, UART_XFR, 1);
929 }
930 
937 __STATIC_INLINE void hw_uart_rx_fifo_flush(HW_UART_ID uart)
938 {
939  HW_UART_REG_SETF(uart, SRR, UART_RFR, 1);
940  /* Read also RBR in order to make sure that the character timeout IRQ (if any) is cleared. */
941  hw_uart_rxdata_getf(uart);
942 }
943 
954 __STATIC_INLINE bool hw_uart_read_buf_empty(HW_UART_ID uart)
955 {
956  return !HW_UART_REG_GETF(uart, LSR, UART_DR);
957 }
958 
969 __STATIC_INLINE bool hw_uart_write_buf_full(HW_UART_ID uart)
970 {
971  return !HW_UART_REG_GETF(uart, LSR, UART_THRE);
972 }
973 
987 __STATIC_INLINE bool hw_uart_transmit_empty(HW_UART_ID uart)
988 {
989  return HW_UART_REG_GETF(uart, LSR, UART_TEMT);
990 }
991 
992 #if (dg_configUART_SOFTWARE_FIFO == 1)
993 
1001 void hw_uart_set_soft_fifo(HW_UART_ID uart, uint8_t *buf, uint8_t size);
1002 #endif /* dg_configUART_SOFTWARE_FIFO */
1003 
1004 #if (HW_UART_DMA_SUPPORT == 1)
1005 //=========================== DMA control functions ============================
1006 
1014 __STATIC_INLINE void hw_uart_dma_mode_setf(HW_UART_ID uart, uint8_t dma_mode)
1015 {
1016 
1017  UBA(uart)->UART2_SDMAM_REG = ((dma_mode & 1) << UART2_UART2_SDMAM_REG_UART_SHADOW_DMA_MODE_Pos)
1019 }
1020 
1027 __STATIC_INLINE void hw_uart_clear_dma_request(HW_UART_ID uart)
1028 {
1029  UBA(uart)->UART2_DMASA_REG = 1;
1030 }
1031 #endif /* HW_UART_DMA_SUPPORT */
1032 //=========================== Line control functions ============================
1033 
1054 HW_UART_CONFIG_ERR hw_uart_init(HW_UART_ID uart, const uart_config *cfg);
1055 
1061 void hw_uart_deinit(HW_UART_ID uart);
1062 
1076 void hw_uart_reinit(HW_UART_ID uart, const uart_config *cfg);
1077 
1084 void hw_uart_cfg_get(HW_UART_ID uart, uart_config *cfg);
1085 
1086 //=========================== Modem control functions ==========================
1097 uint8_t hw_uart_afce_getf(HW_UART_ID uart);
1098 
1108 void hw_uart_afce_setf(HW_UART_ID uart, uint8_t afce);
1109 
1118 uint8_t hw_uart_loopback_getf(HW_UART_ID uart);
1119 
1127 void hw_uart_loopback_setf(HW_UART_ID uart, uint8_t lb);
1128 
1137 uint8_t hw_uart_rts_getf(HW_UART_ID uart);
1138 
1146 void hw_uart_rts_setf(HW_UART_ID uart, uint8_t rtsn);
1147 
1148 //=========================== Line status functions ============================
1149 
1159 HW_UART_ERROR hw_uart_error_getf(HW_UART_ID uart);
1160 
1171 uint8_t hw_uart_rx_fifo_err_getf(HW_UART_ID uart);
1172 
1181 uint8_t hw_uart_is_tx_fifo_empty(HW_UART_ID uart);
1182 
1191 uint8_t hw_uart_thr_empty_getf(HW_UART_ID uart);
1192 
1202 uint8_t hw_uart_break_int_getf(HW_UART_ID uart);
1203 
1215 uint8_t hw_uart_frame_err_getf(HW_UART_ID uart);
1216 
1227 uint8_t hw_uart_parity_err_getf(HW_UART_ID uart);
1228 
1239 uint8_t hw_uart_overrun_err_getf(HW_UART_ID uart);
1240 
1241 //=========================== Modem status functions ===========================
1242 
1254 uint8_t hw_uart_cts_getf(HW_UART_ID uart);
1255 
1268 uint8_t hw_uart_delta_cts_getf(HW_UART_ID uart);
1269 
1278 bool hw_uart_tx_in_progress(const HW_UART_ID uart);
1279 
1288 bool hw_uart_rx_in_progress(const HW_UART_ID uart);
1289 
1290 #if (dg_configUART_RX_CIRCULAR_DMA == 1)
1291 
1309 void hw_uart_enable_rx_circular_dma(HW_UART_ID uart);
1310 
1319 void hw_uart_copy_rx_circular_dma_buffer(HW_UART_ID uart, uint8_t *buf, uint16_t len);
1320 
1321 #endif /* dg_configUART_RX_CIRCULAR_DMA */
1322 
1323 #endif /* dg_configUSE_HW_UART */
1324 
1325 
1326 #endif /* HW_UART_H_ */
1327 
hw_uart_rec_data_int_set
__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
hw_uart_peek_transmitted
uint16_t hw_uart_peek_transmitted(HW_UART_ID uart)
Get number of bytes currently sent by asynchronous read.
hw_uart_write_scr
__STATIC_INLINE void hw_uart_write_scr(const HW_UART_ID uart, uint8_t value)
Write Scratch pad register.
Definition: hw_uart.h:595
HW_UART_BAUDRATE_230400
Definition: hw_uart.h:172
HW_UART_PARITY
HW_UART_PARITY
Parity.
Definition: hw_uart.h:212
hw_uart_error_getf
HW_UART_ERROR hw_uart_error_getf(HW_UART_ID uart)
Get the line status register error.
hw_uart_send
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.
hw_dma.h
Definition of API for the DMA Low Level Driver.
hw_uart_disable_fifo
__STATIC_INLINE void hw_uart_disable_fifo(HW_UART_ID uart)
Disable both FIFOs.
Definition: hw_uart.h:709
HW_UART_REG_SETF
#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
REG_SETF
#define REG_SETF(base, reg, field, new_val)
Set the value of a register field.
Definition: sdk_defs.h:738
hw_uart_transmit_fifo_empty
__STATIC_INLINE bool hw_uart_transmit_fifo_empty(HW_UART_ID uart)
Check if transmit FIFO is empty.
Definition: hw_uart.h:766
HW_UART_ERR_PE
Definition: hw_uart.h:235
HW_UART_BAUDRATE_460800
Definition: hw_uart.h:174
hw_uart_transmit_fifo_not_full
__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
hw_uart_is_tx_fifo_empty
uint8_t hw_uart_is_tx_fifo_empty(HW_UART_ID uart)
Get the value of the Transmitter Empty bit.
hw_uart_fifo_en_getf
uint8_t hw_uart_fifo_en_getf(HW_UART_ID uart)
Get the FIFO mode setting.
HW_UART_ERR_BI
Definition: hw_uart.h:237
hw_uart_is_data_ready
__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
HW_UART_ERR_FE
Definition: hw_uart.h:236
HW_UART_BAUDRATE_19200
Definition: hw_uart.h:167
HW_UART_BAUDRATE_256000
Definition: hw_uart.h:173
hw_uart_afce_setf
void hw_uart_afce_setf(HW_UART_ID uart, uint8_t afce)
Enable or disable Auto Flow Control.
hw_uart_write
void hw_uart_write(HW_UART_ID uart, uint8_t data)
Write one byte to UART.
hw_uart_cfg_get
void hw_uart_cfg_get(HW_UART_ID uart, uart_config *cfg)
Get UART line settings.
HW_UART_BAUDRATE_MAX
Definition: hw_uart.h:180
hw_uart_afce_getf
uint8_t hw_uart_afce_getf(HW_UART_ID uart)
Get the Auto Flow Control Enable (AFCE) setting.
uart_config
UART configuration structure definition.
Definition: hw_uart.h:258
hw_uart_reinit
void hw_uart_reinit(HW_UART_ID uart, const uart_config *cfg)
Re-initialize UART registers.
HW_UART_REG_GETF
#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
HW_UART_BAUDRATE
Baud rates.
Definition: hw_uart.h:161
HW_UART_ERROR
HW_UART_ERROR
Uart errors.
Definition: hw_uart.h:232
UART2_UART2_SDMAM_REG_UART_SHADOW_DMA_MODE_Msk
#define UART2_UART2_SDMAM_REG_UART_SHADOW_DMA_MODE_Msk
Definition: DA1459x-00.h:5622
hw_uart_cts_getf
uint8_t hw_uart_cts_getf(HW_UART_ID uart)
Get CTS input status.
HW_UART_BAUDRATE_14400
Definition: hw_uart.h:166
hw_uart_rts_getf
uint8_t hw_uart_rts_getf(HW_UART_ID uart)
Get RTS output value.
sdk_defs.h
Central include header file with platform definitions.
hw_uart_tx_in_progress
bool hw_uart_tx_in_progress(const HW_UART_ID uart)
Check if buffered write is in progress.
hw_dma_periph_prio_t
DMA peripherals priority structure.
Definition: hw_dma.h:275
UART2_UART2_SDMAM_REG_UART_SHADOW_DMA_MODE_Pos
#define UART2_UART2_SDMAM_REG_UART_SHADOW_DMA_MODE_Pos
Definition: DA1459x-00.h:5621
HW_UART_BAUDRATE_4800
Definition: hw_uart.h:164
hw_uart_pthre_int_set
__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
HW_UART_STOPBITS
Stop bits.
Definition: hw_uart.h:222
hw_uart_fifo_en_setf
__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
hw_uart_enable_loopback
__STATIC_INLINE void hw_uart_enable_loopback(HW_UART_ID uart)
Enable loopback.
Definition: hw_uart.h:805
hw_uart_init
HW_UART_CONFIG_ERR hw_uart_init(HW_UART_ID uart, const uart_config *cfg)
Set UART line settings.
HW_UART_BAUDRATE_38400
Definition: hw_uart.h:169
HW_UART_BAUDRATE_57600
Definition: hw_uart.h:170
hw_uart_divisor
const uint32_t hw_uart_divisor[HW_UART_BAUDRATE_MAX]
Baud rates dividers.
hw_uart_receive_fifo_not_empty
__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
HW_UART_INT
Interrupt Identification codes.
Definition: hw_uart.h:145
hw_uart_receive_fifo_count
__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
hw_uart_tx_fifo_flush
__STATIC_INLINE void hw_uart_tx_fifo_flush(HW_UART_ID uart)
Reset UART transmit FIFO.
Definition: hw_uart.h:926
hw_uart_abort_send
uint16_t hw_uart_abort_send(HW_UART_ID uart)
Stop asynchronous transmit from UART.
HW_DMA_CHANNEL
HW_DMA_CHANNEL
DMA channel number.
Definition: hw_dma.h:62
HW_UART_BAUDRATE_921600
Definition: hw_uart.h:176
hw_uart_read
uint8_t hw_uart_read(HW_UART_ID uart)
Read one byte from UART.
HW_UART_BAUDRATE_28800
Definition: hw_uart.h:168
hw_uart_abort_receive
uint16_t hw_uart_abort_receive(HW_UART_ID uart)
Stop asynchronous read from UART.
hw_uart_tx_empty_int_set
__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
hw_uart_is_busy
__STATIC_INLINE bool hw_uart_is_busy(HW_UART_ID uart)
Check if a serial transfer is in progress.
Definition: hw_uart.h:313
HW_UART_ERR_RFE
Definition: hw_uart.h:238
hw_uart_parity_err_getf
uint8_t hw_uart_parity_err_getf(HW_UART_ID uart)
Get the value of the Parity Error bit.
hw_uart_linestat_int_set
__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
hw_uart_set_sclk
void hw_uart_set_sclk(const HW_UART_ID uart, bool sclk)
Configure the serial clock input of the UART (divN or div1)
hw_uart_deinit
void hw_uart_deinit(HW_UART_ID uart)
Disables UART controller.
HW_UART_DATABITS
HW_UART_DATABITS
Character format.
Definition: hw_uart.h:201
hw_uart_delta_cts_getf
uint8_t hw_uart_delta_cts_getf(HW_UART_ID uart)
Get Delta CTS.
hw_uart_break_int_getf
uint8_t hw_uart_break_int_getf(HW_UART_ID uart)
Get the value of the Break Interrupt bit.
HW_UART_BAUDRATE_115200
Definition: hw_uart.h:171
hw_uart_txdata_setf
__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
HW_UART_BAUDRATE_500000
Definition: hw_uart.h:175
hw_uart_receive_error_checking
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.
HW_UART_BAUDRATE_9600
Definition: hw_uart.h:165
hw_uart_tx_fifo_tr_lvl_setf
__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
HW_UART_CONFIG_ERR_RX_SIZE
Definition: hw_uart.h:250
hw_uart_overrun_err_getf
uint8_t hw_uart_overrun_err_getf(HW_UART_ID uart)
Get the value of the Overrun Error bit.
hw_uart_read_scr
__STATIC_INLINE uint8_t hw_uart_read_scr(const HW_UART_ID uart)
Read Scratch pad register.
Definition: hw_uart.h:614
hw_uart_tx_fifo_tr_lvl_getf
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 ...
HW_UART_BAUDRATE_2400
Definition: hw_uart.h:163
HW_UART_STOPBITS_2
Definition: hw_uart.h:225
HW_UART_BAUDRATE_2000000
Definition: hw_uart.h:178
hw_uart_rx_fifo_tr_lvl_getf
__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
hw_uart_rx_fifo_tr_lvl_setf
__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
hw_uart_rxdata_getf
__STATIC_INLINE uint8_t hw_uart_rxdata_getf(HW_UART_ID uart)
Read receive buffer register.
Definition: hw_uart.h:414
hw_uart_get_interrupt_id
__STATIC_INLINE HW_UART_INT hw_uart_get_interrupt_id(HW_UART_ID uart)
Get the Interrupt ID.
Definition: hw_uart.h:581
hw_uart_read_buf_empty
__STATIC_INLINE bool hw_uart_read_buf_empty(HW_UART_ID uart)
Check whether reading buffer is empty.
Definition: hw_uart.h:954
UART2_UART2_SRT_REG_UART_SHADOW_RCVR_TRIGGER_Msk
#define UART2_UART2_SRT_REG_UART_SHADOW_RCVR_TRIGGER_Msk
Definition: DA1459x-00.h:5686
HW_UART_BAUDRATE_1000000
Definition: hw_uart.h:177
hw_uart_rx_fifo_err_getf
uint8_t hw_uart_rx_fifo_err_getf(HW_UART_ID uart)
Get the value of the Receiver FIFO Error bit.
HW_UART_REG_FIELD_POS
#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
HW_UART_CONFIG_ERR_TX_FIFO
Definition: hw_uart.h:248
hw_uart_rx_in_progress
bool hw_uart_rx_in_progress(const HW_UART_ID uart)
Check if buffered read is in progress.
hw_uart_is_fifo_enabled
__STATIC_INLINE bool hw_uart_is_fifo_enabled(HW_UART_ID uart)
Get the FIFO mode setting.
Definition: hw_uart.h:697
hw_uart_frame_err_getf
uint8_t hw_uart_frame_err_getf(HW_UART_ID uart)
Get the value of the Framing Error bit.
HW_UART_STOPBITS_1
Definition: hw_uart.h:223
REG_GETF
#define REG_GETF(base, reg, field)
Return the value of a register field.
Definition: sdk_defs.h:711
HW_UART_ERR_OE
Definition: hw_uart.h:234
hw_uart_transmit_empty
__STATIC_INLINE bool hw_uart_transmit_empty(HW_UART_ID uart)
Check whether transmitter is empty.
Definition: hw_uart.h:987
HW_UART_BAUDRATE_3000000
Definition: hw_uart.h:179
HW_UART_CONFIG_ERR_RX_FIFO
Definition: hw_uart.h:247
HW_UART_CONFIG_ERR_RXTX_FIFO
Definition: hw_uart.h:249
hw_uart_receive
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.
hw_uart_loopback_getf
uint8_t hw_uart_loopback_getf(HW_UART_ID uart)
Get UART diagnostic mode status.
hw_uart_thr_empty_getf
uint8_t hw_uart_thr_empty_getf(HW_UART_ID uart)
Get the value of the Transmit Holding Register Empty bit.
hw_uart_enable_fifo
__STATIC_INLINE void hw_uart_enable_fifo(HW_UART_ID uart)
Enable both FIFOs.
Definition: hw_uart.h:724
hw_uart_disable_loopback
__STATIC_INLINE void hw_uart_disable_loopback(HW_UART_ID uart)
Disable loopback.
Definition: hw_uart.h:816
hw_uart_transmit_fifo_count
__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_get
HW_UART_BAUDRATE hw_uart_baudrate_get(HW_UART_ID uart)
Get the baud rate setting.
hw_uart_loopback_setf
void hw_uart_loopback_setf(HW_UART_ID uart, uint8_t lb)
Set UART in diagnostic mode.
hw_uart_rts_setf
void hw_uart_rts_setf(HW_UART_ID uart, uint8_t rtsn)
Set RTS output value.
hw_uart_write_buf_full
__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
HW_UART_CONFIG_ERR
Configuration errors.
Definition: hw_uart.h:245
HW_UART_BAUDRATE_1200
Definition: hw_uart.h:162
hw_uart_peek_received
uint16_t hw_uart_peek_received(HW_UART_ID uart)
Get number of bytes currently received by asynchronous read.
HW_UART_CONFIG_ERR_TX_SIZE
Definition: hw_uart.h:251
hw_uart_rx_fifo_flush
__STATIC_INLINE void hw_uart_rx_fifo_flush(HW_UART_ID uart)
Reset UART receive FIFO.
Definition: hw_uart.h:937
hw_uart_baudrate_set
void hw_uart_baudrate_set(HW_UART_ID uart, HW_UART_BAUDRATE baud_rate)
Set the baud rate.
hw_uart_write_buffer
void hw_uart_write_buffer(HW_UART_ID uart, const void *data, uint16_t len)
Writes number of bytes to UART synchronously.