Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_sleep.h Source File

mbed_sleep.h

00001 
00002 /** \addtogroup platform */
00003 /** @{*/
00004 /* mbed Microcontroller Library
00005  * Copyright (c) 2006-2017 ARM Limited
00006  *
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  *
00011  *     http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 #ifndef MBED_SLEEP_H
00020 #define MBED_SLEEP_H
00021 
00022 #include "sleep_api.h"
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /** Send the microcontroller to sleep
00029  *
00030  * @note This function can be a noop if not implemented by the platform.
00031  * @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined).
00032  *
00033  * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
00034  * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
00035  * dynamic power used by the processor, memory systems and buses. The processor, peripheral and
00036  * memory state are maintained, and the peripherals continue to work and can generate interrupts.
00037  *
00038  * The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
00039  *
00040  * @note
00041  *  The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
00042  * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
00043  * able to access the LocalFileSystem
00044  */
00045 __INLINE static void sleep(void)
00046 {
00047 #ifdef NDEBUG
00048 #if DEVICE_SLEEP
00049     hal_sleep();
00050 #endif /* DEVICE_SLEEP */
00051 #endif /* NDEBUG */
00052 }
00053 
00054 /** Send the microcontroller to deep sleep
00055  *
00056  * @note This function can be a noop if not implemented by the platform.
00057  * @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined).
00058  *
00059  * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode
00060  * has the same sleep features as sleep plus it powers down peripherals and clocks. All state
00061  * is still maintained.
00062  *
00063  * The processor can only be woken up by an external interrupt on a pin or a watchdog timer.
00064  *
00065  * @note
00066  *  The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
00067  * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
00068  * able to access the LocalFileSystem
00069  */
00070 __INLINE static void deepsleep(void)
00071 {
00072 #ifdef NDEBUG
00073 #if DEVICE_SLEEP
00074     hal_deepsleep();
00075 #endif /* DEVICE_SLEEP */
00076 #endif /* NDEBUG */
00077 }
00078 
00079 #ifdef __cplusplus
00080 }
00081 #endif
00082 
00083 #endif
00084 
00085 /** @}*/