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