sleep_api.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /** \addtogroup hal */
  2. /** @{*/
  3. /* mbed Microcontroller Library
  4. * Copyright (c) 2006-2013 ARM Limited
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef MBED_SLEEP_API_H
  19. #define MBED_SLEEP_API_H
  20. #include "device.h"
  21. #if DEVICE_SLEEP
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /**
  26. * \defgroup hal_sleep sleep hal requirements
  27. * Low level interface to the sleep mode of a target.
  28. *
  29. * # Defined behaviour
  30. *
  31. * * Sleep mode
  32. * * wake-up time should be less than 10 us - Verified by sleep_usticker_test().
  33. * * the processor can be woken up by any internal peripheral interrupt - Verified by sleep_usticker_test().
  34. * * all peripherals operate as in run mode - not verified.
  35. * * the processor can be woken up by external pin interrupt - not verified.
  36. * * Deep sleep
  37. * * the wake-up time should be less than 10 ms - Verified by deepsleep_lpticker_test().
  38. * * lp ticker should wake up a target from this mode - Verified by deepsleep_lpticker_test().
  39. * * RTC should wake up a target from this mode - not verified.
  40. * * an external interrupt on a pin should wake up a target from this mode - not verified.
  41. * * a watchdog timer should wake up a target from this mode - not verified.
  42. * * High-speed clocks are turned off - Verified by deepsleep_high_speed_clocks_turned_off_test().
  43. * * RTC keeps time - Verified by rtc_sleep_test().
  44. *
  45. * # Undefined behaviour
  46. *
  47. * * peripherals aside from RTC, GPIO and lp ticker result in undefined behaviour in deep sleep.
  48. * @{
  49. */
  50. /**
  51. * \defgroup hal_sleep_tests sleep hal tests
  52. * The sleep HAL tests ensure driver conformance to defined behaviour.
  53. *
  54. * To run the sleep hal tests use the command:
  55. *
  56. * mbed test -t <toolchain> -m <target> -n tests-mbed_hal-sleep*
  57. *
  58. */
  59. /** Send the microcontroller to sleep
  60. *
  61. * The processor is setup ready for sleep, and sent to sleep. In this mode, the
  62. * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
  63. * dynamic power used by the processor, memory systems and buses. The processor, peripheral and
  64. * memory state are maintained, and the peripherals continue to work and can generate interrupts.
  65. *
  66. * The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
  67. *
  68. * The wake-up time shall be less than 10 us.
  69. *
  70. */
  71. void hal_sleep(void);
  72. /** Send the microcontroller to deep sleep
  73. *
  74. * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode
  75. * has the same sleep features as sleep plus it powers down peripherals and high frequency clocks.
  76. * All state is still maintained.
  77. *
  78. * The processor can only be woken up by low power ticker, RTC, an external interrupt on a pin or a watchdog timer.
  79. *
  80. * The wake-up time shall be less than 10 ms.
  81. */
  82. void hal_deepsleep(void);
  83. /**@}*/
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #endif
  88. #endif
  89. /**@}*/