1 /* 2 * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include <stdint.h> 10 #include "esp_err.h" 11 12 #include "hal/touch_sensor_types.h" 13 #include "hal/gpio_types.h" 14 15 #include "soc/soc_caps.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /* 22 Definitions for the deepsleep prepare callbacks 23 */ 24 typedef void (*esp_deep_sleep_cb_t)(void); 25 26 /** 27 * @brief Logic function used for EXT1 wakeup mode. 28 */ 29 typedef enum { 30 ESP_EXT1_WAKEUP_ALL_LOW = 0, //!< Wake the chip when all selected GPIOs go low 31 ESP_EXT1_WAKEUP_ANY_HIGH = 1 //!< Wake the chip when any of the selected GPIOs go high 32 } esp_sleep_ext1_wakeup_mode_t; 33 34 #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP 35 typedef enum { 36 ESP_GPIO_WAKEUP_GPIO_LOW = 0, 37 ESP_GPIO_WAKEUP_GPIO_HIGH = 1 38 } esp_deepsleep_gpio_wake_up_mode_t; 39 #endif 40 41 /** 42 * @brief Power domains which can be powered down in sleep mode 43 */ 44 typedef enum { 45 #if SOC_PM_SUPPORT_RTC_PERIPH_PD 46 ESP_PD_DOMAIN_RTC_PERIPH, //!< RTC IO, sensors and ULP co-processor 47 #endif 48 #if SOC_PM_SUPPORT_RTC_SLOW_MEM_PD 49 ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory 50 #endif 51 #if SOC_PM_SUPPORT_RTC_FAST_MEM_PD 52 ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory 53 #endif 54 ESP_PD_DOMAIN_XTAL, //!< XTAL oscillator 55 #if SOC_PM_SUPPORT_XTAL32K_PD 56 ESP_PD_DOMAIN_XTAL32K, //!< External 32 kHz XTAL oscillator 57 #endif 58 #if SOC_PM_SUPPORT_RC32K_PD 59 ESP_PD_DOMAIN_RC32K, //!< Internal 32 kHz RC oscillator 60 #endif 61 #if SOC_PM_SUPPORT_RC_FAST_PD 62 ESP_PD_DOMAIN_RC_FAST, //!< Internal Fast oscillator 63 #endif 64 #if SOC_PM_SUPPORT_CPU_PD 65 ESP_PD_DOMAIN_CPU, //!< CPU core 66 #endif 67 #if SOC_PM_SUPPORT_VDDSDIO_PD 68 ESP_PD_DOMAIN_VDDSDIO, //!< VDD_SDIO 69 #endif 70 #if SOC_PM_SUPPORT_MODEM_PD 71 ESP_PD_DOMAIN_MODEM, //!< MODEM, includes WiFi, Bluetooth and IEEE802.15.4 72 #endif 73 #if SOC_PM_SUPPORT_TOP_PD 74 ESP_PD_DOMAIN_TOP, //!< SoC TOP 75 #endif 76 ESP_PD_DOMAIN_MAX //!< Number of domains 77 } esp_sleep_pd_domain_t; 78 79 #define ESP_PD_DOMAIN_RTC8M _Pragma("GCC warning \"'ESP_PD_DOMAIN_RTC8M' enum is deprecated\"") ESP_PD_DOMAIN_RC_FAST 80 81 /** 82 * @brief Power down options 83 */ 84 typedef enum { 85 ESP_PD_OPTION_OFF, //!< Power down the power domain in sleep mode 86 ESP_PD_OPTION_ON, //!< Keep power domain enabled during sleep mode 87 ESP_PD_OPTION_AUTO //!< Keep power domain enabled in sleep mode, if it is needed by one of the wakeup options. Otherwise power it down. 88 } esp_sleep_pd_option_t; 89 90 /** 91 * @brief Sleep wakeup cause 92 */ 93 typedef enum { 94 ESP_SLEEP_WAKEUP_UNDEFINED, //!< In case of deep sleep, reset was not caused by exit from deep sleep 95 ESP_SLEEP_WAKEUP_ALL, //!< Not a wakeup cause, used to disable all wakeup sources with esp_sleep_disable_wakeup_source 96 ESP_SLEEP_WAKEUP_EXT0, //!< Wakeup caused by external signal using RTC_IO 97 ESP_SLEEP_WAKEUP_EXT1, //!< Wakeup caused by external signal using RTC_CNTL 98 ESP_SLEEP_WAKEUP_TIMER, //!< Wakeup caused by timer 99 ESP_SLEEP_WAKEUP_TOUCHPAD, //!< Wakeup caused by touchpad 100 ESP_SLEEP_WAKEUP_ULP, //!< Wakeup caused by ULP program 101 ESP_SLEEP_WAKEUP_GPIO, //!< Wakeup caused by GPIO (light sleep only on ESP32, S2 and S3) 102 ESP_SLEEP_WAKEUP_UART, //!< Wakeup caused by UART (light sleep only) 103 ESP_SLEEP_WAKEUP_WIFI, //!< Wakeup caused by WIFI (light sleep only) 104 ESP_SLEEP_WAKEUP_COCPU, //!< Wakeup caused by COCPU int 105 ESP_SLEEP_WAKEUP_COCPU_TRAP_TRIG, //!< Wakeup caused by COCPU crash 106 ESP_SLEEP_WAKEUP_BT, //!< Wakeup caused by BT (light sleep only) 107 } esp_sleep_source_t; 108 109 /** 110 * @brief Sleep mode 111 */ 112 typedef enum { 113 ESP_SLEEP_MODE_LIGHT_SLEEP, //!< light sleep mode 114 ESP_SLEEP_MODE_DEEP_SLEEP //!< deep sleep mode 115 } esp_sleep_mode_t; 116 117 /* Leave this type define for compatibility */ 118 typedef esp_sleep_source_t esp_sleep_wakeup_cause_t; 119 120 enum { 121 ESP_ERR_SLEEP_REJECT = ESP_ERR_INVALID_STATE, 122 ESP_ERR_SLEEP_TOO_SHORT_SLEEP_DURATION = ESP_ERR_INVALID_ARG, 123 }; 124 125 /** 126 * @brief Disable wakeup source 127 * 128 * This function is used to deactivate wake up trigger for source 129 * defined as parameter of the function. 130 * 131 * @note This function does not modify wake up configuration in RTC. 132 * It will be performed in esp_deep_sleep_start/esp_light_sleep_start function. 133 * 134 * See docs/sleep-modes.rst for details. 135 * 136 * @param source - number of source to disable of type esp_sleep_source_t 137 * @return 138 * - ESP_OK on success 139 * - ESP_ERR_INVALID_STATE if trigger was not active 140 */ 141 esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source); 142 143 #if SOC_ULP_SUPPORTED 144 /** 145 * @brief Enable wakeup by ULP coprocessor 146 * @note On ESP32, ULP wakeup source cannot be used when RTC_PERIPH power domain is forced, 147 * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup source is used. 148 * @return 149 * - ESP_OK on success 150 * - ESP_ERR_NOT_SUPPORTED if additional current by touch (CONFIG_RTC_EXT_CRYST_ADDIT_CURRENT) is enabled. 151 * - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled or if wakeup triggers conflict 152 */ 153 esp_err_t esp_sleep_enable_ulp_wakeup(void); 154 155 #endif // SOC_ULP_SUPPORTED 156 157 /** 158 * @brief Enable wakeup by timer 159 * @param time_in_us time before wakeup, in microseconds 160 * @return 161 * - ESP_OK on success 162 * - ESP_ERR_INVALID_ARG if value is out of range (TBD) 163 */ 164 esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us); 165 166 #if SOC_TOUCH_SENSOR_SUPPORTED 167 /** 168 * @brief Enable wakeup by touch sensor 169 * 170 * @note On ESP32, touch wakeup source can not be used when RTC_PERIPH power domain is forced 171 * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup source is used. 172 * 173 * @note The FSM mode of the touch button should be configured 174 * as the timer trigger mode. 175 * 176 * @return 177 * - ESP_OK on success 178 * - ESP_ERR_NOT_SUPPORTED if additional current by touch (CONFIG_RTC_EXT_CRYST_ADDIT_CURRENT) is enabled. 179 * - ESP_ERR_INVALID_STATE if wakeup triggers conflict 180 */ 181 esp_err_t esp_sleep_enable_touchpad_wakeup(void); 182 183 /** 184 * @brief Get the touch pad which caused wakeup 185 * 186 * If wakeup was caused by another source, this function will return TOUCH_PAD_MAX; 187 * 188 * @return touch pad which caused wakeup 189 */ 190 touch_pad_t esp_sleep_get_touchpad_wakeup_status(void); 191 #endif // SOC_TOUCH_SENSOR_SUPPORTED 192 193 /** 194 * @brief Returns true if a GPIO number is valid for use as wakeup source. 195 * 196 * @note For SoCs with RTC IO capability, this can be any valid RTC IO input pin. 197 * 198 * @param gpio_num Number of the GPIO to test for wakeup source capability 199 * 200 * @return True if this GPIO number will be accepted as a sleep wakeup source. 201 */ 202 bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num); 203 204 #if SOC_PM_SUPPORT_EXT0_WAKEUP 205 /** 206 * @brief Enable wakeup using a pin 207 * 208 * This function uses external wakeup feature of RTC_IO peripheral. 209 * It will work only if RTC peripherals are kept on during sleep. 210 * 211 * This feature can monitor any pin which is an RTC IO. Once the pin transitions 212 * into the state given by level argument, the chip will be woken up. 213 * 214 * @note This function does not modify pin configuration. The pin is 215 * configured in esp_deep_sleep_start/esp_light_sleep_start, 216 * immediately before entering sleep mode. 217 * 218 * @note ESP32: ext0 wakeup source can not be used together with touch or ULP wakeup sources. 219 * 220 * @param gpio_num GPIO number used as wakeup source. Only GPIOs with the RTC 221 * functionality can be used. For different SoCs, the related GPIOs are: 222 * - ESP32: 0, 2, 4, 12-15, 25-27, 32-39; 223 * - ESP32-S2: 0-21; 224 * - ESP32-S3: 0-21. 225 * @param level input level which will trigger wakeup (0=low, 1=high) 226 * @return 227 * - ESP_OK on success 228 * - ESP_ERR_INVALID_ARG if the selected GPIO is not an RTC GPIO, 229 * or the mode is invalid 230 * - ESP_ERR_INVALID_STATE if wakeup triggers conflict 231 */ 232 esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level); 233 #endif // SOC_PM_SUPPORT_EXT0_WAKEUP 234 235 #if SOC_PM_SUPPORT_EXT1_WAKEUP 236 /** 237 * @brief Enable wakeup using multiple pins 238 * 239 * This function uses external wakeup feature of RTC controller. 240 * It will work even if RTC peripherals are shut down during sleep. 241 * 242 * This feature can monitor any number of pins which are in RTC IOs. 243 * Once any of the selected pins goes into the state given by mode argument, 244 * the chip will be woken up. 245 * 246 * @note This function does not modify pin configuration. The pins are 247 * configured in esp_deep_sleep_start/esp_light_sleep_start, 248 * immediately before entering sleep mode. 249 * 250 * @note Internal pullups and pulldowns don't work when RTC peripherals are 251 * shut down. In this case, external resistors need to be added. 252 * Alternatively, RTC peripherals (and pullups/pulldowns) may be 253 * kept enabled using esp_sleep_pd_config function. 254 * 255 * @param mask bit mask of GPIO numbers which will cause wakeup. Only GPIOs 256 * which have RTC functionality can be used in this bit map. 257 * For different SoCs, the related GPIOs are: 258 * - ESP32: 0, 2, 4, 12-15, 25-27, 32-39; 259 * - ESP32-S2: 0-21; 260 * - ESP32-S3: 0-21. 261 * - ESP32-C6: 0-7. 262 * @param mode select logic function used to determine wakeup condition: 263 * - ESP_EXT1_WAKEUP_ALL_LOW: wake up when all selected GPIOs are low 264 * - ESP_EXT1_WAKEUP_ANY_HIGH: wake up when any of the selected GPIOs is high 265 * @return 266 * - ESP_OK on success 267 * - ESP_ERR_INVALID_ARG if any of the selected GPIOs is not an RTC GPIO, 268 * or mode is invalid 269 */ 270 esp_err_t esp_sleep_enable_ext1_wakeup(uint64_t mask, esp_sleep_ext1_wakeup_mode_t mode); 271 272 #endif // SOC_PM_SUPPORT_EXT1_WAKEUP 273 274 #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP 275 /** 276 * @brief Enable wakeup using specific gpio pins 277 * 278 * This function enables an IO pin to wake up the chip from deep sleep. 279 * 280 * @note This function does not modify pin configuration. The pins are 281 * configured inside esp_deep_sleep_start, immediately before entering sleep mode. 282 * 283 * @note You don't need to care to pull-up or pull-down before using this 284 * function, because this will be set internally in esp_deep_sleep_start 285 * based on the wakeup mode. BTW, when you use low level to wake up the 286 * chip, we strongly recommend you to add external resistors (pull-up). 287 * 288 * @param gpio_pin_mask Bit mask of GPIO numbers which will cause wakeup. Only GPIOs 289 * which have RTC functionality (pads that powered by VDD3P3_RTC) can be used in this bit map. 290 * @param mode Select logic function used to determine wakeup condition: 291 * - ESP_GPIO_WAKEUP_GPIO_LOW: wake up when the gpio turn to low. 292 * - ESP_GPIO_WAKEUP_GPIO_HIGH: wake up when the gpio turn to high. 293 * @return 294 * - ESP_OK on success 295 * - ESP_ERR_INVALID_ARG if the mask contains any invalid deep sleep wakeup pin or wakeup mode is invalid 296 */ 297 esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepsleep_gpio_wake_up_mode_t mode); 298 #endif 299 300 /** 301 * @brief Enable wakeup from light sleep using GPIOs 302 * 303 * Each GPIO supports wakeup function, which can be triggered on either low level 304 * or high level. Unlike EXT0 and EXT1 wakeup sources, this method can be used 305 * both for all IOs: RTC IOs and digital IOs. It can only be used to wakeup from 306 * light sleep though. 307 * 308 * To enable wakeup, first call gpio_wakeup_enable, specifying gpio number and 309 * wakeup level, for each GPIO which is used for wakeup. 310 * Then call this function to enable wakeup feature. 311 * 312 * @note On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources. 313 * 314 * @return 315 * - ESP_OK on success 316 * - ESP_ERR_INVALID_STATE if wakeup triggers conflict 317 */ 318 esp_err_t esp_sleep_enable_gpio_wakeup(void); 319 320 /** 321 * @brief Enable wakeup from light sleep using UART 322 * 323 * Use uart_set_wakeup_threshold function to configure UART wakeup threshold. 324 * 325 * Wakeup from light sleep takes some time, so not every character sent 326 * to the UART can be received by the application. 327 * 328 * @note ESP32 does not support wakeup from UART2. 329 * 330 * @param uart_num UART port to wake up from 331 * @return 332 * - ESP_OK on success 333 * - ESP_ERR_INVALID_ARG if wakeup from given UART is not supported 334 */ 335 esp_err_t esp_sleep_enable_uart_wakeup(int uart_num); 336 337 /** 338 * @brief Enable wakeup by bluetooth 339 * @return 340 * - ESP_OK on success 341 * - ESP_ERR_NOT_SUPPORTED if wakeup from bluetooth is not supported 342 */ 343 esp_err_t esp_sleep_enable_bt_wakeup(void); 344 345 /** 346 * @brief Disable wakeup by bluetooth 347 * @return 348 * - ESP_OK on success 349 * - ESP_ERR_NOT_SUPPORTED if wakeup from bluetooth is not supported 350 */ 351 esp_err_t esp_sleep_disable_bt_wakeup(void); 352 353 /** 354 * @brief Enable wakeup by WiFi MAC 355 * @return 356 * - ESP_OK on success 357 */ 358 esp_err_t esp_sleep_enable_wifi_wakeup(void); 359 360 /** 361 * @brief Disable wakeup by WiFi MAC 362 * @return 363 * - ESP_OK on success 364 */ 365 esp_err_t esp_sleep_disable_wifi_wakeup(void); 366 367 /** 368 * @brief Enable beacon wakeup by WiFi MAC, it will wake up the system into modem state 369 * @return 370 * - ESP_OK on success 371 */ 372 esp_err_t esp_sleep_enable_wifi_beacon_wakeup(void); 373 374 /** 375 * @brief Disable beacon wakeup by WiFi MAC 376 * @return 377 * - ESP_OK on success 378 */ 379 esp_err_t esp_sleep_disable_wifi_beacon_wakeup(void); 380 381 /** 382 * @brief Get the bit mask of GPIOs which caused wakeup (ext1) 383 * 384 * If wakeup was caused by another source, this function will return 0. 385 * 386 * @return bit mask, if GPIOn caused wakeup, BIT(n) will be set 387 */ 388 uint64_t esp_sleep_get_ext1_wakeup_status(void); 389 390 #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP 391 /** 392 * @brief Get the bit mask of GPIOs which caused wakeup (gpio) 393 * 394 * If wakeup was caused by another source, this function will return 0. 395 * 396 * @return bit mask, if GPIOn caused wakeup, BIT(n) will be set 397 */ 398 uint64_t esp_sleep_get_gpio_wakeup_status(void); 399 #endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP 400 401 /** 402 * @brief Set power down mode for an RTC power domain in sleep mode 403 * 404 * If not set set using this API, all power domains default to ESP_PD_OPTION_AUTO. 405 * 406 * @param domain power domain to configure 407 * @param option power down option (ESP_PD_OPTION_OFF, ESP_PD_OPTION_ON, or ESP_PD_OPTION_AUTO) 408 * @return 409 * - ESP_OK on success 410 * - ESP_ERR_INVALID_ARG if either of the arguments is out of range 411 */ 412 esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, 413 esp_sleep_pd_option_t option); 414 415 /** 416 * @brief Enter deep sleep with the configured wakeup options 417 * 418 * This function does not return. 419 */ 420 void esp_deep_sleep_start(void) __attribute__((__noreturn__)); 421 422 /** 423 * @brief Enter light sleep with the configured wakeup options 424 * 425 * @return 426 * - ESP_OK on success (returned after wakeup) 427 * - ESP_ERR_SLEEP_REJECT sleep request is rejected(wakeup source set before the sleep request) 428 * - ESP_ERR_SLEEP_TOO_SHORT_SLEEP_DURATION after deducting the sleep flow overhead, the final sleep duration 429 * is too short to cover the minimum sleep duration of the chip, when 430 * rtc timer wakeup source enabled 431 */ 432 esp_err_t esp_light_sleep_start(void); 433 434 /** 435 * @brief Enter deep-sleep mode 436 * 437 * The device will automatically wake up after the deep-sleep time 438 * Upon waking up, the device calls deep sleep wake stub, and then proceeds 439 * to load application. 440 * 441 * Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup 442 * followed by a call to esp_deep_sleep_start. 443 * 444 * @param time_in_us deep-sleep time, unit: microsecond 445 */ 446 void esp_deep_sleep(uint64_t time_in_us) __attribute__((__noreturn__)); 447 448 449 /** 450 * @brief Register a callback to be called from the deep sleep prepare 451 * 452 * @warning deepsleep callbacks should without parameters, and MUST NOT, 453 * UNDER ANY CIRCUMSTANCES, CALL A FUNCTION THAT MIGHT BLOCK. 454 * 455 * @param new_dslp_cb Callback to be called 456 * 457 * @return 458 * - ESP_OK: Callback registered to the deepsleep misc_modules_sleep_prepare 459 * - ESP_ERR_NO_MEM: No more hook space for register the callback 460 */ 461 esp_err_t esp_deep_sleep_register_hook(esp_deep_sleep_cb_t new_dslp_cb); 462 463 /** 464 * @brief Unregister an deepsleep callback 465 * 466 * @param old_dslp_cb Callback to be unregistered 467 */ 468 void esp_deep_sleep_deregister_hook(esp_deep_sleep_cb_t old_dslp_cb); 469 470 /** 471 * @brief Get the wakeup source which caused wakeup from sleep 472 * 473 * @return cause of wake up from last sleep (deep sleep or light sleep) 474 */ 475 esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(void); 476 477 478 /** 479 * @brief Default stub to run on wake from deep sleep. 480 * 481 * Allows for executing code immediately on wake from sleep, before 482 * the software bootloader or ESP-IDF app has started up. 483 * 484 * This function is weak-linked, so you can implement your own version 485 * to run code immediately when the chip wakes from 486 * sleep. 487 * 488 * See docs/deep-sleep-stub.rst for details. 489 */ 490 void esp_wake_deep_sleep(void); 491 492 /** 493 * @brief Function type for stub to run on wake from sleep. 494 * 495 */ 496 typedef void (*esp_deep_sleep_wake_stub_fn_t)(void); 497 498 /** 499 * @brief Install a new stub at runtime to run on wake from deep sleep 500 * 501 * If implementing esp_wake_deep_sleep() then it is not necessary to 502 * call this function. 503 * 504 * However, it is possible to call this function to substitute a 505 * different deep sleep stub. Any function used as a deep sleep stub 506 * must be marked RTC_IRAM_ATTR, and must obey the same rules given 507 * for esp_wake_deep_sleep(). 508 */ 509 void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub); 510 511 /** 512 * @brief Set wake stub entry to default `esp_wake_stub_entry` 513 */ 514 void esp_set_deep_sleep_wake_stub_default_entry(void); 515 516 /** 517 * @brief Get current wake from deep sleep stub 518 * @return Return current wake from deep sleep stub, or NULL if 519 * no stub is installed. 520 */ 521 esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void); 522 523 /** 524 * @brief The default esp-idf-provided esp_wake_deep_sleep() stub. 525 * 526 * See docs/deep-sleep-stub.rst for details. 527 */ 528 void esp_default_wake_deep_sleep(void); 529 530 /** 531 * @brief Disable logging from the ROM code after deep sleep. 532 * 533 * Using LSB of RTC_STORE4. 534 */ 535 void esp_deep_sleep_disable_rom_logging(void); 536 537 #ifdef SOC_PM_SUPPORT_CPU_PD 538 539 #if SOC_PM_CPU_RETENTION_BY_RTCCNTL 540 /** 541 * @brief CPU Power down low-level initialize, enable CPU power down during light sleep 542 * @return 543 * - ESP_OK on success 544 * - ESP_ERR_NO_MEM not enough retention memory 545 */ 546 esp_err_t esp_sleep_cpu_pd_low_init(void); 547 548 /** 549 * @brief CPU Power down low-level deinitialize, disable CPU power down during light sleep 550 * @return 551 * - ESP_OK on success 552 * - ESP_ERR_NO_MEM not enough retention memory 553 */ 554 esp_err_t esp_sleep_cpu_pd_low_deinit(void); 555 556 #endif 557 558 /** 559 * @brief CPU Power down initialize 560 * 561 * @return 562 * - ESP_OK on success 563 * - ESP_ERR_NO_MEM not enough retention memory 564 */ 565 esp_err_t esp_sleep_cpu_retention_init(void); 566 567 /** 568 * @brief CPU Power down de-initialize 569 * 570 * @return 571 * - ESP_OK on success 572 * 573 * Release system retention memory. 574 */ 575 esp_err_t esp_sleep_cpu_retention_deinit(void); 576 #endif 577 578 /** 579 * @brief Configure to isolate all GPIO pins in sleep state 580 */ 581 void esp_sleep_config_gpio_isolate(void); 582 583 /** 584 * @brief Enable or disable GPIO pins status switching between slept status and waked status. 585 * @param enable decide whether to switch status or not 586 */ 587 void esp_sleep_enable_gpio_switch(bool enable); 588 589 #if CONFIG_MAC_BB_PD 590 /** 591 * @brief Function type for stub to run mac bb power down. 592 */ 593 typedef void (* mac_bb_power_down_cb_t)(void); 594 595 /** 596 * @brief Function type for stub to run mac bb power up. 597 */ 598 typedef void (* mac_bb_power_up_cb_t)(void); 599 600 /** 601 * @brief Registet mac bb power down callback. 602 * @param cb mac bb power down callback. 603 * @return 604 * - ESP_OK on success 605 */ 606 esp_err_t esp_register_mac_bb_pd_callback(mac_bb_power_down_cb_t cb); 607 608 /** 609 * @brief Unregistet mac bb power down callback. 610 * @param cb mac bb power down callback. 611 * @return 612 * - ESP_OK on success 613 */ 614 esp_err_t esp_unregister_mac_bb_pd_callback(mac_bb_power_down_cb_t cb); 615 616 /** 617 * @brief Registet mac bb power up callback. 618 * @param cb mac bb power up callback. 619 * @return 620 * - ESP_OK on success 621 */ 622 esp_err_t esp_register_mac_bb_pu_callback(mac_bb_power_up_cb_t cb); 623 624 /** 625 * @brief Unregistet mac bb power up callback. 626 * @param cb mac bb power up callback. 627 * @return 628 * - ESP_OK on success 629 */ 630 esp_err_t esp_unregister_mac_bb_pu_callback(mac_bb_power_up_cb_t cb); 631 #endif 632 633 #ifdef __cplusplus 634 } 635 #endif 636