esp_deepsleep.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_DEEPSLEEP_H__
  14. #define __ESP_DEEPSLEEP_H_
  15. #include <stdint.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /** \defgroup Deep_Sleep_API Deep Sleep API
  20. * @brief API for putting device into deep sleep
  21. */
  22. /** @addtogroup Deep_Sleep_API
  23. * @{
  24. */
  25. /**
  26. * @brief Enter deep-sleep mode
  27. *
  28. * The device will automatically wake up after the deep-sleep time
  29. * Upon waking up, the device calls deep sleep wake stub, and then proceeds
  30. * to load application.
  31. *
  32. * This function does not return.
  33. *
  34. * @param time_in_us deep-sleep time, unit: microsecond
  35. */
  36. void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn));
  37. /**
  38. * @brief Enter deep-sleep mode
  39. *
  40. * Function has been renamed to esp_deep_sleep.
  41. * This name is deprecated and will be removed in a future version.
  42. *
  43. * @param time_in_us deep-sleep time, unit: microsecond
  44. */
  45. void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated));
  46. /**
  47. * @brief Default stub to run on wake from deep sleep.
  48. *
  49. * Allows for executing code immediately on wake from sleep, before
  50. * the software bootloader or ESP-IDF app has started up.
  51. *
  52. * This function is weak-linked, so you can implement your own version
  53. * to run code immediately when the chip wakes from
  54. * sleep.
  55. *
  56. * See docs/deep-sleep-stub.rst for details.
  57. */
  58. void esp_wake_deep_sleep(void);
  59. /**
  60. * @brief Function type for stub to run on wake from sleep.
  61. *
  62. */
  63. typedef void (*esp_deep_sleep_wake_stub_fn_t)(void);
  64. /**
  65. * @brief Install a new stub at runtime to run on wake from deep sleep
  66. *
  67. * If implementing esp_wake_deep_sleep() then it is not necessary to
  68. * call this function.
  69. *
  70. * However, it is possible to call this function to substitute a
  71. * different deep sleep stub. Any function used as a deep sleep stub
  72. * must be marked RTC_IRAM_ATTR, and must obey the same rules given
  73. * for esp_wake_deep_sleep().
  74. */
  75. void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub);
  76. /**
  77. * @brief Return current wake from deep sleep stub, or NULL if
  78. * no stub is installed.
  79. */
  80. esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void);
  81. /* The default esp-idf-provided esp_wake_deep_sleep() stub.
  82. See docs/deep-sleep-stub.rst for details.
  83. */
  84. void esp_default_wake_deep_sleep(void);
  85. /**
  86. * @}
  87. */
  88. /**
  89. * @}
  90. */
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* __ESP_SYSTEM_H__ */