fix(ulp): fix lp uart keep wakeup triggered

This commit is contained in:
hebinglin
2026-06-05 20:01:15 +08:00
parent a0688c6e32
commit f088b73ea8
12 changed files with 80 additions and 25 deletions

View File

@@ -25,9 +25,19 @@
#include "esp_cpu.h"
#include "ulp_lp_core_cpu_freq_shared.h"
#include "ulp_lp_core_lp_uart_shared.h"
#include "ulp_lp_core_uart.h"
static uint32_t lp_wakeup_cause = 0;
#if SOC_ULP_LP_UART_SUPPORTED
void ulp_lp_core_lp_uart_reset_wakeup_en(void)
{
lp_core_ll_enable_lp_uart_wakeup(false);
lp_core_ll_enable_lp_uart_wakeup(true);
}
#endif
void ulp_lp_core_update_wakeup_cause(void)
{
lp_wakeup_cause = 0;
@@ -42,6 +52,13 @@ void ulp_lp_core_update_wakeup_cause(void)
&& (uart_ll_get_intraw_mask(&LP_UART) & LP_UART_WAKEUP_INT_RAW)) {
lp_wakeup_cause |= LP_CORE_LL_WAKEUP_SOURCE_LP_UART;
uart_ll_clr_intsts_mask(&LP_UART, LP_UART_WAKEUP_INT_CLR);
#if SOC_LP_CORE_LP_UART_WAKEUP_KEEP_TRIGGERED
// In these chips, the LP UART wakeup source is kept triggered, so we need to
// reset the wakeup register and flush the UART buffer manually after waking up.
lp_core_uart_tx_flush(LP_UART_NUM_0);
lp_core_uart_clear_buf();
ulp_lp_core_lp_uart_reset_wakeup_en();
#endif
}
#endif
@@ -133,15 +150,6 @@ void ulp_lp_core_delay_cycles(uint32_t cycles)
}
}
#if SOC_ULP_LP_UART_SUPPORTED
void ulp_lp_core_lp_uart_reset_wakeup_en(void)
{
lp_core_ll_enable_lp_uart_wakeup(false);
lp_core_ll_enable_lp_uart_wakeup(true);
}
#endif
void ulp_lp_core_halt(void)
{
lp_core_ll_request_sleep();

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -18,9 +18,10 @@ extern "C" {
*
* @note This function configures the LP UART wakeup mode. Ensure that the UART has already been initialized
* with the lp_core_uart_init() call.
* Once the LP Core wakes up due to the LP UART, the wakeup feature is disabled.
* To re-enable the wakeup from the LP UART, you must call
* ulp_lp_core_lp_uart_reset_wakeup_en() again before the LP core goes to sleep.
* Once the LP Core wakes up due to the LP UART, the wakeup will be kept triggered in the chips with
* SOC_LP_CORE_LP_UART_WAKEUP_KEEP_TRIGGERED. You need to call ulp_lp_core_lp_uart_reset_wakeup_en()
* to reset the wakeup signal and the UART buffer manually after waking up, which is done in ulp
* startup phase.
* Also be aware of limitations in different modes mentioned in the uart_wakeup_cfg_t struct.
*
*

View File

@@ -1,19 +1,17 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "ulp_lp_core_utils.h"
#include "ulp_lp_core_print.h"
#include "ulp_lp_core_lp_uart_shared.h"
#include "lp_core_uart.h"
#include "ulp_lp_core_uart.h"
int main(void)
{
lp_core_printf("Hello world\r\n");
ulp_lp_core_delay_us(5000);
lp_core_uart_clear_buf();
ulp_lp_core_lp_uart_reset_wakeup_en();
lp_core_uart_tx_flush(LP_UART_NUM_0);
return 0;
}