17
17
#define THRESHOLD 0 /* Lower the value, more the sensitivity */
18
18
#endif
19
19
20
- // External wakeup
21
- #define BUTTON_PIN_BITMASK (GPIO ) (1ULL << GPIO) // 2 ^ GPIO_NUMBER in hex
22
-
23
- #if CONFIG_IDF_TARGET_ESP32H2
24
- #define WAKEUP_GPIO GPIO_NUM_7 // Only RTC IO are allowed
25
- #define TARGET_FREQ 32
26
- #else
27
- #define WAKEUP_GPIO GPIO_NUM_4 // Only RTC IO are allowed
28
- #define TARGET_FREQ 40
29
- #endif
20
+ #define TARGET_FREQ CONFIG_XTAL_FREQ
30
21
31
22
RTC_DATA_ATTR int boot_count = 0 ;
32
23
uint32_t orig_freq = 0 ;
@@ -60,30 +51,6 @@ void setup_touchpad() {
60
51
#endif
61
52
}
62
53
63
- void setup_rtc_io () {
64
- #if SOC_RTCIO_WAKE_SUPPORTED && SOC_PM_SUPPORT_EXT0_WAKEUP
65
- esp_sleep_enable_ext0_wakeup (WAKEUP_GPIO, 1 );
66
- rtc_gpio_pullup_en (WAKEUP_GPIO);
67
- rtc_gpio_pulldown_dis (WAKEUP_GPIO);
68
- #endif
69
- }
70
-
71
- void setup_rtc_cntl () {
72
- #if SOC_RTCIO_WAKE_SUPPORTED && SOC_PM_SUPPORT_EXT1_WAKEUP
73
- esp_sleep_enable_ext1_wakeup_io (BUTTON_PIN_BITMASK (WAKEUP_GPIO), ESP_EXT1_WAKEUP_ANY_HIGH);
74
- rtc_gpio_pulldown_dis (WAKEUP_GPIO);
75
- rtc_gpio_pullup_en (WAKEUP_GPIO);
76
- #endif
77
- }
78
-
79
- void setup_gpio () {
80
- esp_sleep_pd_config (ESP_PD_DOMAIN_VDDSDIO, ESP_PD_OPTION_ON);
81
- gpio_pullup_dis (WAKEUP_GPIO);
82
- gpio_pulldown_en (WAKEUP_GPIO);
83
- gpio_wakeup_enable (WAKEUP_GPIO, GPIO_INTR_LOW_LEVEL);
84
- esp_sleep_enable_gpio_wakeup ();
85
- }
86
-
87
54
void setup_uart () {
88
55
uart_set_wakeup_threshold (UART_NUM_0, 9 ); // wake up with "aaa" string (9 positive edges)
89
56
esp_sleep_enable_uart_wakeup (UART_NUM_0);
@@ -126,18 +93,6 @@ void loop() {
126
93
esp_deep_sleep_start ();
127
94
Serial.println (" FAIL" );
128
95
while (1 );
129
- } else if (command == " rtc_io_deep" ) {
130
- // Test external wakeup from deep sleep using RTC IO
131
- setup_rtc_io ();
132
- esp_deep_sleep_start ();
133
- Serial.println (" FAIL" );
134
- while (1 );
135
- } else if (command == " rtc_cntl_deep" ) {
136
- // Test external wakeup from deep sleep using RTC controller
137
- setup_rtc_cntl ();
138
- esp_deep_sleep_start ();
139
- Serial.println (" FAIL" );
140
- while (1 );
141
96
} else if (command == " timer_light" ) {
142
97
// Test timer wakeup from light sleep
143
98
setup_timer ();
@@ -148,15 +103,6 @@ void loop() {
148
103
} else if (command == " touchpad_light" ) {
149
104
// Test touchpad wakeup from light sleep
150
105
setup_touchpad ();
151
- } else if (command == " rtc_io_light" ) {
152
- // Test external wakeup from light sleep using RTC IO
153
- setup_rtc_io ();
154
- } else if (command == " rtc_cntl_light" ) {
155
- // Test external wakeup from light sleep using RTC controller
156
- setup_rtc_cntl ();
157
- } else if (command == " gpio_light" ) {
158
- // Test external wakeup from light sleep using GPIO
159
- setup_gpio ();
160
106
} else if (command == " uart_light" ) {
161
107
// Test external wakeup from light sleep using UART
162
108
setup_uart ();
@@ -169,7 +115,6 @@ void loop() {
169
115
Serial.println (" Woke up from light sleep" );
170
116
print_wakeup_reason ();
171
117
Serial.flush ();
172
- gpio_hold_dis (WAKEUP_GPIO);
173
118
setCpuFrequencyMhz (orig_freq);
174
119
}
175
120
}
0 commit comments