mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 11:03:11 +00:00
change(example): change uart wakeup mode 0 edge threshold
This commit is contained in:
@@ -273,7 +273,7 @@ static void uart_wakeup_set_get_test(int uart_num)
|
||||
printf("uart wake up set and get test\n");
|
||||
int wake_up_set = 0;
|
||||
int wake_up_get = 0;
|
||||
for (int i = 3; i < 0x3ff; i++) {
|
||||
for (int i = 6; i < 0x3ff; i++) {
|
||||
wake_up_set = i;
|
||||
TEST_ESP_OK(uart_set_wakeup_threshold(uart_num, wake_up_set));
|
||||
TEST_ESP_OK(uart_get_wakeup_threshold(uart_num, &wake_up_get));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -1031,8 +1031,10 @@ FORCE_INLINE_ATTR void uart_ll_set_dtr_active_level(uart_dev_t *hw, int level)
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_set_wakeup_edge_thrd(uart_dev_t *hw, uint32_t wakeup_thrd)
|
||||
{
|
||||
// System would wakeup when the number of positive edges of RxD signal is larger than or equal to (UART_ACTIVE_THRESHOLD+3)
|
||||
hw->sleep_conf2.active_threshold = wakeup_thrd - UART_LL_WAKEUP_EDGE_THRED_MIN;
|
||||
// System would wakeup when the number of positive edges of RxD signal is larger than or equal to (UART_ACTIVE_THRESHOLD+offset)
|
||||
// HP UART: offset is 6, LP UART: offset is 3
|
||||
uint32_t offset = (hw == &LP_UART) ? UART_LL_WAKEUP_EDGE_THRED_MIN : UART_LL_WAKEUP_EDGE_THRED_MIN + 3;
|
||||
hw->sleep_conf2.active_threshold = wakeup_thrd - offset;
|
||||
}
|
||||
|
||||
|
||||
@@ -1338,7 +1340,9 @@ FORCE_INLINE_ATTR void uart_ll_get_at_cmd_char(uart_dev_t *hw, uint8_t *cmd_char
|
||||
*/
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_wakeup_edge_thrd(uart_dev_t *hw)
|
||||
{
|
||||
return hw->sleep_conf2.active_threshold + UART_LL_WAKEUP_EDGE_THRED_MIN;
|
||||
// HP UART: offset is 6, LP UART: offset is 3
|
||||
uint32_t offset = (hw == &LP_UART) ? UART_LL_WAKEUP_EDGE_THRED_MIN : UART_LL_WAKEUP_EDGE_THRED_MIN + 3;
|
||||
return hw->sleep_conf2.active_threshold + offset;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#define EXAMPLE_UART_BAUDRATE 115200
|
||||
#endif
|
||||
|
||||
#define EXAMPLE_UART_WAKEUP_EDGE_THRESHOLD 3
|
||||
/* In ESP32, the min wakeup threshold is 2; in ESP32P4, the min wakeup threshold is 6; in other targets, the min wakeup threshold is 3.*/
|
||||
#define EXAMPLE_UART_WAKEUP_EDGE_THRESHOLD 6
|
||||
#define EXAMPLE_UART_WAKEUP_FIFO_THRESHOLD 8
|
||||
#define EXAMPLE_UART_WAKEUP_CHARS_SEQ "ok"
|
||||
#define EXAMPLE_UART_WAKEUP_CHARS_SEQ_LEN SOC_UART_WAKEUP_CHARS_SEQ_MAX_LEN
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
import logging
|
||||
import time
|
||||
@@ -32,7 +32,7 @@ def test_light_sleep(dut: Dut) -> None:
|
||||
# enter sleep second time
|
||||
dut.expect_exact(ENTERING_SLEEP_STR)
|
||||
match = dut.expect(EXIT_SLEEP_REGEX)
|
||||
logging.info('Got second sleep period, wakeup from {}, slept for {}'.format(match.group(1), match.group(3)))
|
||||
logging.info(f'Got second sleep period, wakeup from {match.group(1)}, slept for {match.group(3)}')
|
||||
# sleep time error should be less than 1ms
|
||||
# TODO: Need to update sleep overhead_out time for esp32c5 (PM-209)
|
||||
assert (
|
||||
@@ -47,7 +47,7 @@ def test_light_sleep(dut: Dut) -> None:
|
||||
dut.serial.proc.setDTR(True)
|
||||
time.sleep(1)
|
||||
match = dut.expect(EXIT_SLEEP_PIN_REGEX)
|
||||
logging.info('Got third sleep period, wakeup from {}, slept for {}'.format(match.group(1), match.group(3)))
|
||||
logging.info(f'Got third sleep period, wakeup from {match.group(1)}, slept for {match.group(3)}')
|
||||
assert int(match.group(3)) < WAKEUP_INTERVAL_MS
|
||||
|
||||
dut.expect(WAITING_FOR_GPIO_STR)
|
||||
@@ -57,11 +57,11 @@ def test_light_sleep(dut: Dut) -> None:
|
||||
dut.expect_exact(ENTERING_SLEEP_STR)
|
||||
logging.info('Went to sleep again')
|
||||
|
||||
# Write 'a' to uart, 'a' in ascii is 0x61 which contains 3 rising edges in total (including the stop bit)
|
||||
dut.write('a')
|
||||
# Write 'tt' to uart, 'tt' in ascii is 0x74 0x74 which contains 6 rising edges in total (including the stop bit)
|
||||
dut.serial.proc.write(b'tt')
|
||||
time.sleep(1)
|
||||
match = dut.expect(EXIT_SLEEP_UART_REGEX)
|
||||
logging.info('Got third sleep period, wakeup from {}, slept for {}'.format(match.group(1), match.group(3)))
|
||||
logging.info(f'Got third sleep period, wakeup from {match.group(1)}, slept for {match.group(3)}')
|
||||
assert int(match.group(3)) < WAKEUP_INTERVAL_MS
|
||||
logging.info('Went to sleep again')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user