feat(uart): support HP/LP uart on ESP32S31

This commit is contained in:
gaoxu
2026-04-15 10:57:26 +08:00
parent 668dfb7e33
commit 0068fb1507
24 changed files with 1374 additions and 125 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -61,6 +61,10 @@ typedef enum {
UART_INTR_WAKEUP = (0x1 << 19),
} uart_intr_t;
typedef enum {
UART_LL_MEM_LP_MODE_SHUT_DOWN, // force memory low power
} uart_ll_mem_lp_mode_t;
/**
* @brief Check if UART is enabled or disabled.
*
@@ -197,6 +201,62 @@ FORCE_INLINE_ATTR void uart_ll_get_sclk(uart_dev_t *hw, soc_module_clk_t *source
}
}
/**
* @brief Force UART memory block powered on by software.
*
* @param hw Beginning address of the peripheral registers.
*
* @return None.
*/
FORCE_INLINE_ATTR void uart_ll_mem_force_power_on(uart_port_t uart_num)
{
uart_dev_t *hw = UART_LL_GET_HW(uart_num);
hw->mem_conf.force_pd = 0;
hw->mem_conf.force_pu = 1;
}
/**
* @brief Force UART memory block in low power by software.
*
* @param hw Beginning address of the peripheral registers.
*
* @return None.
*/
FORCE_INLINE_ATTR void uart_ll_mem_force_low_power(uart_port_t uart_num)
{
uart_dev_t *hw = UART_LL_GET_HW(uart_num);
hw->mem_conf.force_pu = 0;
hw->mem_conf.force_pd = 1;
}
/**
* @brief Control UART memory block by PMU logic.
*
* @param hw Beginning address of the peripheral registers.
*
* @return None.
*/
FORCE_INLINE_ATTR void uart_ll_mem_power_by_pmu(uart_port_t uart_num)
{
uart_dev_t *hw = UART_LL_GET_HW(uart_num);
hw->mem_conf.force_pd = 0;
hw->mem_conf.force_pu = 0;
}
/**
* @brief Set UART memory low power mode in low power stage.
*
* @param hw Beginning address of the peripheral registers.
* @param mode UART memory low power mode.
*
* @return None.
*/
FORCE_INLINE_ATTR void uart_ll_mem_set_low_power_mode(uart_port_t uart_num, uart_ll_mem_lp_mode_t mode)
{
HAL_ASSERT(mode == UART_LL_MEM_LP_MODE_SHUT_DOWN);
(void)uart_num;
}
/**
* @brief Configure the baud-rate.
*