在deepSleep模式下,没有RTC的gpio也能从deepSleep中唤醒,不知道为什么。

esp_wxyao
Posts: 3
Joined: Sun Apr 03, 2022 9:05 am

在deepSleep模式下,没有RTC的gpio也能从deepSleep中唤醒,不知道为什么。

Postby esp_wxyao » Sun Apr 03, 2022 9:10 am

windows系统,采用esp32,平台:vscode。

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/i2c.h"
#include "esp_log.h"
#include "string.h"
#include "driver/rtc_io.h"
#include "esp_sleep.h"
#include "time.h"
#include "sys/time.h"
#include "driver/uart.h"

#define pin GPIO_NUM_15

RTC_DATA_ATTR int timesWokenUp = 0;

void app_main(void)
{
    /* 一般 GPIO config and wakeup enable */

    bool re = esp_sleep_is_valid_wakeup_gpio(pin);
    printf("pin %d is %s\n", pin, re == 1 ? "RTC_GPIO" : "NORMAL_GRIO");

     gpio_pad_select_gpio(pin);
     gpio_pulldown_en(pin);
     gpio_pullup_dis(pin);
     gpio_set_direction(pin, GPIO_MODE_INPUT);
     printf("pin stat = %d\n ", gpio_get_level(pin));
     gpio_wakeup_enable(pin, GPIO_INTR_HIGH_LEVEL);
     esp_sleep_enable_gpio_wakeup();

    /*使timer唤醒睡眠功能用*/
    esp_sleep_enable_timer_wakeup(10000000);
    while (1)
    {
        printf("start to sleep\n");
        uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM); //等待发送缓冲区的数据全部发送完成。

        esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
        switch (cause)
        {
        case ESP_SLEEP_WAKEUP_TIMER:
            printf("wakeup from timer\n");
            break;
        case ESP_SLEEP_WAKEUP_EXT0:
            printf("wakeup from EXT0\n");
            break;
        case ESP_SLEEP_WAKEUP_GPIO:
            printf("wakeup from GPIO\n");
            break;
        case ESP_SLEEP_WAKEUP_EXT1:
            printf("wakeup from EXT1\n");
            break;
        default:
            printf("NO REASON\n");
        }

        // int64_t start = esp_timer_get_time();

        printf("going to sleep. woken up %d\n", timesWokenUp++);

        esp_deep_sleep_start();

        printf("wakeup ,wakeup\n");
    }
}





ESP_Yake
Posts: 109
Joined: Mon Mar 06, 2017 12:23 pm

Re: 在deepSleep模式下,没有RTC的gpio也能从deepSleep中唤醒,不知道为什么。

Postby ESP_Yake » Tue May 10, 2022 1:59 am

请问这个问题解决了么?我们的示例中还包括了定时器唤醒,确定是非RTC管脚导致的么?具体 IO 是哪个,使用的 IDF commit是哪个

Who is online

Users browsing this forum: Bing [Bot] and 55 guests