19#include "esp8266/uart_struct.h"
20#include "esp8266/uart_register.h"
26#define UART_SCLK_DEFAULT 1
28#define UART_LL_FIFO_DEF_LEN (128)
29#define UART_LL_INTR_MASK ((uint32_t)~0)
32typedef unsigned int soc_module_clk_t;
34static inline void uart_ll_set_sclk(uart_dev_t *hw, soc_module_clk_t source)
41static inline void uart_ll_set_baudrate(uart_dev_t *hw, uint32_t baud, uint32_t sclk_freq)
43 hw->clk_div.val = (sclk_freq / baud) & 0xFFFFF;
46static inline void uart_ll_set_stop_bits(uart_dev_t *hw,
uart_stop_bits_t bits)
48 hw->conf0.stop_bit_num = bits;
51static inline void uart_ll_set_data_bit_num(uart_dev_t *hw, uart_word_length_t data_bit)
53 hw->conf0.bit_num = data_bit;
56static inline void uart_ll_set_parity(uart_dev_t *hw,
uart_parity_t parity_mode)
58 hw->conf0.parity = (parity_mode & 0x1);
59 hw->conf0.parity_en = ((parity_mode >> 1) & 0x1);
62static inline uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw)
64 return hw->status.rxfifo_cnt;
67static inline uint32_t uart_ll_get_txfifo_len(uart_dev_t *hw)
69 return UART_LL_FIFO_DEF_LEN - hw->status.txfifo_cnt;
72static inline void uart_ll_read_rxfifo(uart_dev_t *hw, uint8_t *buf, uint32_t rd_len)
74 for (
int i = 0; i < (int)rd_len; i++) {
75 buf[i] = hw->fifo.rw_byte;
79static inline void uart_ll_write_txfifo(uart_dev_t *hw,
const uint8_t *buf, uint32_t wr_len)
81 for (
int i = 0; i < (int)wr_len; i++) {
82 hw->fifo.rw_byte = (int)buf[i];
86static inline void uart_ll_rxfifo_rst(uart_dev_t *hw)
88 hw->conf0.rxfifo_rst = 1;
89 hw->conf0.rxfifo_rst = 0;
92static inline void uart_ll_txfifo_rst(uart_dev_t *hw)
94 hw->conf0.rxfifo_rst = 1;
95 hw->conf0.rxfifo_rst = 0;
98static inline void uart_ll_set_rxfifo_full_thr(uart_dev_t *hw, uint16_t full_thrhd)
100 hw->conf1.rxfifo_full_thrhd = full_thrhd;
103static inline uint32_t uart_ll_get_intsts_mask(uart_dev_t *hw)
105 return hw->int_st.val;
108static inline void uart_ll_ena_intr_mask(uart_dev_t *hw, uint32_t mask)
110 hw->int_ena.val = hw->int_ena.val | mask;
113static inline void uart_ll_clr_intsts_mask(uart_dev_t *hw, uint32_t mask)
115 hw->int_clr.val = mask;
118static inline uint32_t uart_ll_get_intr_ena_status(uart_dev_t *hw)
120 return hw->int_ena.val;
uart_parity_t
Definition of possible parity modes.
uart_stop_bits_t
Definition of possible stop bits lengths.
uart_data_bits_t
Definition of possible data bits lengths in a UART frame.