完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
windows系统,采用esp32,平台:vscode。Code: Select all
#include #include #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 %sn", 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 = %dn ", 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 sleepn"); 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 timern"); break; case ESP_SLEEP_WAKEUP_EXT0: printf("wakeup from EXT0n"); break; case ESP_SLEEP_WAKEUP_GPIO: printf("wakeup from GPIOn"); break; case ESP_SLEEP_WAKEUP_EXT1: printf("wakeup from EXT1n"); break; default: printf("NO REASONn"); } // int64_t start = esp_timer_get_time(); printf("going to sleep. woken up %dn", timesWokenUp++); esp_deep_sleep_start(); printf("wakeup ,wakeupn"); } } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
432浏览 6评论
366浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
345浏览 5评论
350浏览 4评论
328浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-3 16:18 , Processed in 0.800468 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191