mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
platform/mbed_sleep.h@160:d5399cc887bb, 2017-03-14 (annotated)
- Committer:
- <>
- Date:
- Tue Mar 14 16:40:56 2017 +0000
- Revision:
- 160:d5399cc887bb
This updates the lib to the mbed lib v138
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 160:d5399cc887bb | 1 | |
<> | 160:d5399cc887bb | 2 | /** \addtogroup platform */ |
<> | 160:d5399cc887bb | 3 | /** @{*/ |
<> | 160:d5399cc887bb | 4 | /* mbed Microcontroller Library |
<> | 160:d5399cc887bb | 5 | * Copyright (c) 2006-2017 ARM Limited |
<> | 160:d5399cc887bb | 6 | * |
<> | 160:d5399cc887bb | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 160:d5399cc887bb | 8 | * you may not use this file except in compliance with the License. |
<> | 160:d5399cc887bb | 9 | * You may obtain a copy of the License at |
<> | 160:d5399cc887bb | 10 | * |
<> | 160:d5399cc887bb | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 160:d5399cc887bb | 12 | * |
<> | 160:d5399cc887bb | 13 | * Unless required by applicable law or agreed to in writing, software |
<> | 160:d5399cc887bb | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 160:d5399cc887bb | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 160:d5399cc887bb | 16 | * See the License for the specific language governing permissions and |
<> | 160:d5399cc887bb | 17 | * limitations under the License. |
<> | 160:d5399cc887bb | 18 | */ |
<> | 160:d5399cc887bb | 19 | #ifndef MBED_SLEEP_H |
<> | 160:d5399cc887bb | 20 | #define MBED_SLEEP_H |
<> | 160:d5399cc887bb | 21 | |
<> | 160:d5399cc887bb | 22 | #include "sleep_api.h" |
<> | 160:d5399cc887bb | 23 | |
<> | 160:d5399cc887bb | 24 | #ifdef __cplusplus |
<> | 160:d5399cc887bb | 25 | extern "C" { |
<> | 160:d5399cc887bb | 26 | #endif |
<> | 160:d5399cc887bb | 27 | |
<> | 160:d5399cc887bb | 28 | /** Send the microcontroller to sleep |
<> | 160:d5399cc887bb | 29 | * |
<> | 160:d5399cc887bb | 30 | * @note This function can be a noop if not implemented by the platform. |
<> | 160:d5399cc887bb | 31 | * @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined). |
<> | 160:d5399cc887bb | 32 | * |
<> | 160:d5399cc887bb | 33 | * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the |
<> | 160:d5399cc887bb | 34 | * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates |
<> | 160:d5399cc887bb | 35 | * dynamic power used by the processor, memory systems and buses. The processor, peripheral and |
<> | 160:d5399cc887bb | 36 | * memory state are maintained, and the peripherals continue to work and can generate interrupts. |
<> | 160:d5399cc887bb | 37 | * |
<> | 160:d5399cc887bb | 38 | * The processor can be woken up by any internal peripheral interrupt or external pin interrupt. |
<> | 160:d5399cc887bb | 39 | * |
<> | 160:d5399cc887bb | 40 | * @note |
<> | 160:d5399cc887bb | 41 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. |
<> | 160:d5399cc887bb | 42 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be |
<> | 160:d5399cc887bb | 43 | * able to access the LocalFileSystem |
<> | 160:d5399cc887bb | 44 | */ |
<> | 160:d5399cc887bb | 45 | __INLINE static void sleep(void) |
<> | 160:d5399cc887bb | 46 | { |
<> | 160:d5399cc887bb | 47 | #ifdef NDEBUG |
<> | 160:d5399cc887bb | 48 | #if DEVICE_SLEEP |
<> | 160:d5399cc887bb | 49 | hal_sleep(); |
<> | 160:d5399cc887bb | 50 | #endif /* DEVICE_SLEEP */ |
<> | 160:d5399cc887bb | 51 | #endif /* NDEBUG */ |
<> | 160:d5399cc887bb | 52 | } |
<> | 160:d5399cc887bb | 53 | |
<> | 160:d5399cc887bb | 54 | /** Send the microcontroller to deep sleep |
<> | 160:d5399cc887bb | 55 | * |
<> | 160:d5399cc887bb | 56 | * @note This function can be a noop if not implemented by the platform. |
<> | 160:d5399cc887bb | 57 | * @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined). |
<> | 160:d5399cc887bb | 58 | * |
<> | 160:d5399cc887bb | 59 | * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode |
<> | 160:d5399cc887bb | 60 | * has the same sleep features as sleep plus it powers down peripherals and clocks. All state |
<> | 160:d5399cc887bb | 61 | * is still maintained. |
<> | 160:d5399cc887bb | 62 | * |
<> | 160:d5399cc887bb | 63 | * The processor can only be woken up by an external interrupt on a pin or a watchdog timer. |
<> | 160:d5399cc887bb | 64 | * |
<> | 160:d5399cc887bb | 65 | * @note |
<> | 160:d5399cc887bb | 66 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. |
<> | 160:d5399cc887bb | 67 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be |
<> | 160:d5399cc887bb | 68 | * able to access the LocalFileSystem |
<> | 160:d5399cc887bb | 69 | */ |
<> | 160:d5399cc887bb | 70 | __INLINE static void deepsleep(void) |
<> | 160:d5399cc887bb | 71 | { |
<> | 160:d5399cc887bb | 72 | #ifdef NDEBUG |
<> | 160:d5399cc887bb | 73 | #if DEVICE_SLEEP |
<> | 160:d5399cc887bb | 74 | hal_deepsleep(); |
<> | 160:d5399cc887bb | 75 | #endif /* DEVICE_SLEEP */ |
<> | 160:d5399cc887bb | 76 | #endif /* NDEBUG */ |
<> | 160:d5399cc887bb | 77 | } |
<> | 160:d5399cc887bb | 78 | |
<> | 160:d5399cc887bb | 79 | #ifdef __cplusplus |
<> | 160:d5399cc887bb | 80 | } |
<> | 160:d5399cc887bb | 81 | #endif |
<> | 160:d5399cc887bb | 82 | |
<> | 160:d5399cc887bb | 83 | #endif |
<> | 160:d5399cc887bb | 84 | |
<> | 160:d5399cc887bb | 85 | /** @}*/ |