|
30 | 30 | #include "periph/uart.h" |
31 | 31 |
|
32 | 32 | /* ESP-IDF headers */ |
| 33 | +#include "driver/gpio.h" |
33 | 34 | #include "driver/uart.h" |
34 | 35 | #include "esp_sleep.h" |
35 | 36 | #include "rom/rtc.h" |
@@ -165,13 +166,30 @@ void pm_set(unsigned mode) |
165 | 166 | gpio_pm_sleep_enter(mode); |
166 | 167 |
|
167 | 168 | #if (ESP_PM_WUP_UART0 > 2) |
| 169 | + _Static_assert(UART_NUMOF > 0, "UART_DEV(0) is not defined"); |
| 170 | +#if CPU_FAM_ESP32 |
| 171 | + /* For ESP32, UART RxD has to be configured for direct IO using IOMUX */ |
| 172 | + const uart_periph_sig_t *sig = &uart_periph_signal[UART_DEV(0)].pins[SOC_UART_RX_PIN_IDX]; |
| 173 | + gpio_iomux_out(UART0_RXD, sig->iomux_func, false); |
| 174 | + gpio_iomux_in(UART0_RXD, sig->signal); |
| 175 | +#endif |
168 | 176 | uart_set_wakeup_threshold(UART_DEV(0), ESP_PM_WUP_UART0); |
169 | 177 | esp_sleep_enable_uart_wakeup(0); |
170 | 178 | #endif |
171 | 179 | #if (ESP_PM_WUP_UART1 > 2) |
| 180 | + _Static_assert(UART_NUMOF > 1, "UART_DEV(1) is not defined"); |
| 181 | +#if CPU_FAM_ESP32 |
| 182 | + /* For ESP32, UART RxD has to be configured for direct IO using IOMUX */ |
| 183 | + const uart_periph_sig_t *sig = &uart_periph_signal[UART_DEV(0)].pins[SOC_UART_RX_PIN_IDX]; |
| 184 | + gpio_iomux_out(UART1_RXD, sig->iomux_func, false); |
| 185 | + gpio_iomux_in(UART1_RXD, sig->signal); |
| 186 | +#endif |
172 | 187 | uart_set_wakeup_threshold(UART_DEV(1), ESP_PM_WUP_UART1); |
173 | 188 | esp_sleep_enable_uart_wakeup(1); |
174 | 189 | #endif |
| 190 | +#if MODULE_STDIO_UART |
| 191 | + uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM); |
| 192 | +#endif |
175 | 193 |
|
176 | 194 | if (mode == ESP_PM_DEEP_SLEEP) { |
177 | 195 | esp_deep_sleep_start(); |
|
0 commit comments