forked
platform/mbed_sleep.h@167:e84263d55307, 2017-06-21 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Jun 21 17:46:44 2017 +0100
- Revision:
- 167:e84263d55307
- Parent:
- 160:d5399cc887bb
This updates the lib to the mbed lib v 145
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. |
AnnaBridge | 167:e84263d55307 | 31 | * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined). |
AnnaBridge | 167:e84263d55307 | 32 | * @note This function will be a noop while uVisor is in use. |
<> | 160:d5399cc887bb | 33 | * |
<> | 160:d5399cc887bb | 34 | * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the |
<> | 160:d5399cc887bb | 35 | * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates |
<> | 160:d5399cc887bb | 36 | * dynamic power used by the processor, memory systems and buses. The processor, peripheral and |
<> | 160:d5399cc887bb | 37 | * memory state are maintained, and the peripherals continue to work and can generate interrupts. |
<> | 160:d5399cc887bb | 38 | * |
<> | 160:d5399cc887bb | 39 | * The processor can be woken up by any internal peripheral interrupt or external pin interrupt. |
<> | 160:d5399cc887bb | 40 | * |
<> | 160:d5399cc887bb | 41 | * @note |
<> | 160:d5399cc887bb | 42 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. |
<> | 160:d5399cc887bb | 43 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be |
<> | 160:d5399cc887bb | 44 | * able to access the LocalFileSystem |
<> | 160:d5399cc887bb | 45 | */ |
<> | 160:d5399cc887bb | 46 | __INLINE static void sleep(void) |
<> | 160:d5399cc887bb | 47 | { |
AnnaBridge | 167:e84263d55307 | 48 | #if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) |
AnnaBridge | 167:e84263d55307 | 49 | #ifndef MBED_DEBUG |
<> | 160:d5399cc887bb | 50 | #if DEVICE_SLEEP |
<> | 160:d5399cc887bb | 51 | hal_sleep(); |
<> | 160:d5399cc887bb | 52 | #endif /* DEVICE_SLEEP */ |
AnnaBridge | 167:e84263d55307 | 53 | #endif /* MBED_DEBUG */ |
AnnaBridge | 167:e84263d55307 | 54 | #endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */ |
<> | 160:d5399cc887bb | 55 | } |
<> | 160:d5399cc887bb | 56 | |
<> | 160:d5399cc887bb | 57 | /** Send the microcontroller to deep sleep |
<> | 160:d5399cc887bb | 58 | * |
<> | 160:d5399cc887bb | 59 | * @note This function can be a noop if not implemented by the platform. |
AnnaBridge | 167:e84263d55307 | 60 | * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined) |
AnnaBridge | 167:e84263d55307 | 61 | * @note This function will be a noop while uVisor is in use. |
<> | 160:d5399cc887bb | 62 | * |
<> | 160:d5399cc887bb | 63 | * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode |
<> | 160:d5399cc887bb | 64 | * has the same sleep features as sleep plus it powers down peripherals and clocks. All state |
<> | 160:d5399cc887bb | 65 | * is still maintained. |
<> | 160:d5399cc887bb | 66 | * |
<> | 160:d5399cc887bb | 67 | * The processor can only be woken up by an external interrupt on a pin or a watchdog timer. |
<> | 160:d5399cc887bb | 68 | * |
<> | 160:d5399cc887bb | 69 | * @note |
<> | 160:d5399cc887bb | 70 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. |
<> | 160:d5399cc887bb | 71 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be |
<> | 160:d5399cc887bb | 72 | * able to access the LocalFileSystem |
<> | 160:d5399cc887bb | 73 | */ |
<> | 160:d5399cc887bb | 74 | __INLINE static void deepsleep(void) |
<> | 160:d5399cc887bb | 75 | { |
AnnaBridge | 167:e84263d55307 | 76 | #if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) |
AnnaBridge | 167:e84263d55307 | 77 | #ifndef MBED_DEBUG |
<> | 160:d5399cc887bb | 78 | #if DEVICE_SLEEP |
<> | 160:d5399cc887bb | 79 | hal_deepsleep(); |
<> | 160:d5399cc887bb | 80 | #endif /* DEVICE_SLEEP */ |
AnnaBridge | 167:e84263d55307 | 81 | #endif /* MBED_DEBUG */ |
AnnaBridge | 167:e84263d55307 | 82 | #endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */ |
<> | 160:d5399cc887bb | 83 | } |
<> | 160:d5399cc887bb | 84 | |
<> | 160:d5399cc887bb | 85 | #ifdef __cplusplus |
<> | 160:d5399cc887bb | 86 | } |
<> | 160:d5399cc887bb | 87 | #endif |
<> | 160:d5399cc887bb | 88 | |
<> | 160:d5399cc887bb | 89 | #endif |
<> | 160:d5399cc887bb | 90 | |
<> | 160:d5399cc887bb | 91 | /** @}*/ |