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