esp_deepsleep.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 Set the chip to deep-sleep mode.
  27. *
  28. * The device will automatically wake up after the deep-sleep time set
  29. * by the users. Upon waking up, the device boots up from user_init.
  30. *
  31. * @attention The parameter time_in_us to be "uint64" is for further development.
  32. * Only the low 32 bits of parameter time_in_us are avalable now.
  33. *
  34. * @param uint64 time_in_us : deep-sleep time, only the low 32bits are avalable now. unit: microsecond
  35. *
  36. * @return null
  37. */
  38. void system_deep_sleep(uint64_t time_in_us);
  39. /**
  40. * @brief Default stub to run on wake from deep sleep.
  41. *
  42. * Allows for executing code immediately on wake from sleep, before
  43. * the software bootloader or esp-idf app has started up.
  44. *
  45. * This function is weak-linked, so you can implement your own version
  46. * to run code immediately when the chip wakes from
  47. * sleep.
  48. *
  49. * See docs/deep-sleep-stub.rst for details.
  50. */
  51. void esp_wake_deep_sleep(void);
  52. /**
  53. * @brief Function type for stub to run on wake from sleep.
  54. *
  55. */
  56. typedef void (*esp_deep_sleep_wake_stub_fn_t)(void);
  57. /**
  58. * @brief Install a new stub at runtime to run on wake from deep sleep
  59. *
  60. * If implementing esp_wake_deep_sleep() then it is not necessary to
  61. * call this function.
  62. *
  63. * However, it is possible to call this function to substitute a
  64. * different deep sleep stub. Any function used as a deep sleep stub
  65. * must be marked RTC_IRAM_ATTR, and must obey the same rules given
  66. * for esp_wake_deep_sleep().
  67. */
  68. void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub);
  69. /**
  70. * @brief Return current wake from deep sleep stub, or NULL if
  71. * no stub is installed.
  72. */
  73. esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void);
  74. /* The default esp-idf-provided esp_wake_deep_sleep() stub.
  75. See docs/deep-sleep-stub.rst for details.
  76. */
  77. void esp_default_wake_deep_sleep(void);
  78. /**
  79. * @}
  80. */
  81. /**
  82. * @}
  83. */
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #endif /* __ESP_SYSTEM_H__ */