mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-03 06:58:11 +00:00
Merge branch 'bugfix/s3_uart_reg_update' into 'master'
uart: S3 7.2.8 bringup Closes IDF-3227 and IDF-3304 See merge request espressif/esp-idf!14009
This commit is contained in:
@@ -509,7 +509,7 @@ esp_err_t uart_enable_pattern_det_baud_intr(uart_port_t uart_num, char pattern_c
|
||||
at_cmd.gap_tout = chr_tout * uart_div;
|
||||
at_cmd.pre_idle = pre_idle * uart_div;
|
||||
at_cmd.post_idle = post_idle * uart_div;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#else
|
||||
at_cmd.gap_tout = chr_tout;
|
||||
at_cmd.pre_idle = pre_idle;
|
||||
at_cmd.post_idle = post_idle;
|
||||
|
@@ -144,8 +144,8 @@ FORCE_INLINE_ATTR void uart_ll_set_baudrate(uart_dev_t *hw, uint32_t baud)
|
||||
uint32_t clk_div = ((sclk_freq) << 4) / (baud * sclk_div);
|
||||
// The baud rate configuration register is divided into
|
||||
// an integer part and a fractional part.
|
||||
hw->clk_div.div_int = clk_div >> 4;
|
||||
hw->clk_div.div_frag = clk_div & 0xf;
|
||||
hw->clkdiv.clkdiv = clk_div >> 4;
|
||||
hw->clkdiv.clkdiv_frag = clk_div & 0xf;
|
||||
hw->clk_conf.sclk_div_num = sclk_div - 1;
|
||||
#undef DIV_UP
|
||||
}
|
||||
@@ -160,8 +160,8 @@ FORCE_INLINE_ATTR void uart_ll_set_baudrate(uart_dev_t *hw, uint32_t baud)
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_baudrate(uart_dev_t *hw)
|
||||
{
|
||||
uint32_t sclk_freq = uart_ll_get_sclk_freq(hw);
|
||||
typeof(hw->clk_div) div_reg = hw->clk_div;
|
||||
return ((sclk_freq << 4)) / (((div_reg.div_int << 4) | div_reg.div_frag) * (hw->clk_conf.sclk_div_num + 1));
|
||||
uart_clkdiv_reg_t div_reg = hw->clkdiv;
|
||||
return ((sclk_freq << 4)) / (((div_reg.clkdiv << 4) | div_reg.clkdiv_frag) * (hw->clk_conf.sclk_div_num + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +239,7 @@ FORCE_INLINE_ATTR uint32_t uart_ll_get_intr_ena_status(uart_dev_t *hw)
|
||||
FORCE_INLINE_ATTR void uart_ll_read_rxfifo(uart_dev_t *hw, uint8_t *buf, uint32_t rd_len)
|
||||
{
|
||||
for (int i = 0; i < (int)rd_len; i++) {
|
||||
buf[i] = hw->ahb_fifo.rw_byte;
|
||||
buf[i] = hw->fifo.rxfifo_rd_byte;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ FORCE_INLINE_ATTR void uart_ll_read_rxfifo(uart_dev_t *hw, uint8_t *buf, uint32_
|
||||
FORCE_INLINE_ATTR void uart_ll_write_txfifo(uart_dev_t *hw, const uint8_t *buf, uint32_t wr_len)
|
||||
{
|
||||
for (int i = 0; i < (int)wr_len; i++) {
|
||||
hw->ahb_fifo.rw_byte = buf[i];
|
||||
hw->fifo.rxfifo_rd_byte = buf[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_set_at_cmd_char(uart_dev_t *hw, uart_at_cmd_t *cmd_char)
|
||||
{
|
||||
hw->at_cmd_char.data = cmd_char->cmd_char;
|
||||
hw->at_cmd_char.at_cmd_char = cmd_char->cmd_char;
|
||||
hw->at_cmd_char.char_num = cmd_char->char_num;
|
||||
hw->at_cmd_postcnt.post_idle_num = cmd_char->post_idle;
|
||||
hw->at_cmd_precnt.pre_idle_num = cmd_char->pre_idle;
|
||||
@@ -593,9 +593,9 @@ FORCE_INLINE_ATTR void uart_ll_set_wakeup_thrd(uart_dev_t *hw, uint32_t wakeup_t
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_set_mode_normal(uart_dev_t *hw)
|
||||
{
|
||||
hw->rs485_conf.en = 0;
|
||||
hw->rs485_conf.tx_rx_en = 0;
|
||||
hw->rs485_conf.rx_busy_tx_en = 0;
|
||||
hw->rs485_conf.rs485_en = 0;
|
||||
hw->rs485_conf.rs485tx_rx_en= 0;
|
||||
hw->rs485_conf.rs485rxby_tx_en = 0;
|
||||
hw->conf0.irda_en = 0;
|
||||
}
|
||||
|
||||
@@ -609,11 +609,11 @@ FORCE_INLINE_ATTR void uart_ll_set_mode_normal(uart_dev_t *hw)
|
||||
FORCE_INLINE_ATTR void uart_ll_set_mode_rs485_app_ctrl(uart_dev_t *hw)
|
||||
{
|
||||
// Application software control, remove echo
|
||||
hw->rs485_conf.rx_busy_tx_en = 1;
|
||||
hw->rs485_conf.rs485rxby_tx_en = 1;
|
||||
hw->conf0.irda_en = 0;
|
||||
hw->conf0.sw_rts = 0;
|
||||
hw->conf0.irda_en = 0;
|
||||
hw->rs485_conf.en = 1;
|
||||
hw->rs485_conf.rs485_en = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -628,11 +628,11 @@ FORCE_INLINE_ATTR void uart_ll_set_mode_rs485_half_duplex(uart_dev_t *hw)
|
||||
// Enable receiver, sw_rts = 1 generates low level on RTS pin
|
||||
hw->conf0.sw_rts = 1;
|
||||
// Must be set to 0 to automatically remove echo
|
||||
hw->rs485_conf.tx_rx_en = 0;
|
||||
hw->rs485_conf.rs485tx_rx_en = 0;
|
||||
// This is to void collision
|
||||
hw->rs485_conf.rx_busy_tx_en = 1;
|
||||
hw->rs485_conf.rs485rxby_tx_en = 1;
|
||||
hw->conf0.irda_en = 0;
|
||||
hw->rs485_conf.en = 1;
|
||||
hw->rs485_conf.rs485_en= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -646,11 +646,11 @@ FORCE_INLINE_ATTR void uart_ll_set_mode_collision_detect(uart_dev_t *hw)
|
||||
{
|
||||
hw->conf0.irda_en = 0;
|
||||
// Transmitters output signal loop back to the receivers input signal
|
||||
hw->rs485_conf.tx_rx_en = 1 ;
|
||||
hw->rs485_conf.rs485tx_rx_en = 1 ;
|
||||
// Transmitter should send data when the receiver is busy
|
||||
hw->rs485_conf.rx_busy_tx_en = 1;
|
||||
hw->rs485_conf.rs485rxby_tx_en = 1;
|
||||
hw->conf0.sw_rts = 0;
|
||||
hw->rs485_conf.en = 1;
|
||||
hw->rs485_conf.rs485_en = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,9 +662,9 @@ FORCE_INLINE_ATTR void uart_ll_set_mode_collision_detect(uart_dev_t *hw)
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_set_mode_irda(uart_dev_t *hw)
|
||||
{
|
||||
hw->rs485_conf.en = 0;
|
||||
hw->rs485_conf.tx_rx_en = 0;
|
||||
hw->rs485_conf.rx_busy_tx_en = 0;
|
||||
hw->rs485_conf.rs485_en = 0;
|
||||
hw->rs485_conf.rs485tx_rx_en = 0;
|
||||
hw->rs485_conf.rs485rxby_tx_en = 0;
|
||||
hw->conf0.sw_rts = 0;
|
||||
hw->conf0.irda_en = 1;
|
||||
}
|
||||
@@ -710,7 +710,7 @@ FORCE_INLINE_ATTR void uart_ll_set_mode(uart_dev_t *hw, uart_mode_t mode)
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_get_at_cmd_char(uart_dev_t *hw, uint8_t *cmd_char, uint8_t *char_num)
|
||||
{
|
||||
*cmd_char = hw->at_cmd_char.data;
|
||||
*cmd_char = hw->at_cmd_char.at_cmd_char;
|
||||
*char_num = hw->at_cmd_char.char_num;
|
||||
}
|
||||
|
||||
@@ -799,7 +799,7 @@ FORCE_INLINE_ATTR void uart_ll_set_loop_back(uart_dev_t *hw, bool loop_back_en)
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_inverse_signal(uart_dev_t *hw, uint32_t inv_mask)
|
||||
{
|
||||
typeof(hw->conf0) conf0_reg = hw->conf0;
|
||||
uart_conf0_reg_t conf0_reg = hw->conf0;
|
||||
conf0_reg.irda_tx_inv = (inv_mask & UART_SIGNAL_IRDA_TX_INV) ? 1 : 0;
|
||||
conf0_reg.irda_rx_inv = (inv_mask & UART_SIGNAL_IRDA_RX_INV) ? 1 : 0;
|
||||
conf0_reg.rxd_inv = (inv_mask & UART_SIGNAL_RXD_INV) ? 1 : 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@
|
||||
#include "driver/uart_select.h"
|
||||
#include "esp_rom_uart.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/uart_ll.h"
|
||||
|
||||
// TODO: make the number of UARTs chip dependent
|
||||
#define UART_NUM SOC_UART_NUM
|
||||
@@ -158,14 +159,13 @@ static int uart_open(const char * path, int flags, int mode)
|
||||
static void uart_tx_char(int fd, int c)
|
||||
{
|
||||
uart_dev_t* uart = s_ctx[fd]->uart;
|
||||
while (uart->status.txfifo_cnt >= 127) {
|
||||
const uint8_t ch = (uint8_t) c;
|
||||
|
||||
while (uart_ll_get_txfifo_len(uart) < 2) {
|
||||
;
|
||||
}
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
uart->fifo.rw_byte = c;
|
||||
#else // CONFIG_IDF_TARGET_ESP32
|
||||
uart->ahb_fifo.rw_byte = c;
|
||||
#endif
|
||||
|
||||
uart_ll_write_txfifo(uart, &ch, 1);
|
||||
}
|
||||
|
||||
static void uart_tx_char_via_driver(int fd, int c)
|
||||
@@ -177,14 +177,13 @@ static void uart_tx_char_via_driver(int fd, int c)
|
||||
static int uart_rx_char(int fd)
|
||||
{
|
||||
uart_dev_t* uart = s_ctx[fd]->uart;
|
||||
if (uart->status.rxfifo_cnt == 0) {
|
||||
uint8_t ch;
|
||||
if (uart_ll_get_rxfifo_len(uart) == 0) {
|
||||
return NONE;
|
||||
}
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
return uart->fifo.rw_byte;
|
||||
#else // CONFIG_IDF_TARGET_ESP32
|
||||
return READ_PERI_REG(UART_FIFO_AHB_REG(fd));
|
||||
#endif
|
||||
uart_ll_read_rxfifo(uart, &ch, 1);
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static int uart_rx_char_via_driver(int fd)
|
||||
|
Reference in New Issue
Block a user