Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
sleep.c
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include "sleep_api.h" 00017 00018 #if DEVICE_SLEEP 00019 00020 #include "cmsis.h" 00021 #include "mbed_interface.h" 00022 00023 void sleep(void) { 00024 #if DEVICE_SEMIHOST 00025 // ensure debug is disconnected 00026 mbed_interface_disconnect(); 00027 #endif 00028 00029 // PCON[PD] set to sleep 00030 #if defined(TARGET_LPC11U24) 00031 LPC_PMU->PCON = 0x0; 00032 #elif defined(TARGET_LPC1768) 00033 LPC_SC->PCON = 0x0; 00034 #endif 00035 00036 // SRC[SLEEPDEEP] set to 0 = sleep 00037 SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; 00038 00039 // wait for interrupt 00040 __WFI(); 00041 } 00042 00043 /* 00044 * The mbed lpc1768 does not support the deepsleep mode 00045 * as a debugger is connected to it (the mbed interface). 00046 * 00047 * As mentionned in an application note from NXP: 00048 * 00049 * http://www.po-star.com/public/uploads/20120319123122_141.pdf 00050 * 00051 * {{{ 00052 * The user should be aware of certain limitations during debugging. 00053 * The most important is that, due to limitations of the Cortex-M3 00054 * integration, the LPC17xx cannot wake up in the usual manner from 00055 * Deep Sleep and Power-down modes. It is recommended not to use these 00056 * modes during debug. Once an application is downloaded via JTAG/SWD 00057 * interface, the USB to SWD/JTAG debug adapter (Keil ULINK2 for example) 00058 * should be removed from the target board, and thereafter, power cycle 00059 * the LPC17xx to allow wake-up from deep sleep and power-down modes 00060 * }}} 00061 * 00062 * As the interface firmware does not reset the target when a 00063 * mbed_interface_disconnect() semihosting call is made, the 00064 * core cannot wake-up from deepsleep. 00065 * 00066 * We treat a deepsleep() as a normal sleep(). 00067 */ 00068 00069 void deepsleep(void) { 00070 #if DEVICE_SEMIHOST 00071 // ensure debug is disconnected 00072 mbed_interface_disconnect(); 00073 #endif 00074 00075 // PCON[PD] set to deepsleep 00076 #if defined(TARGET_LPC11U24) 00077 LPC_PMU->PCON = 0x1; 00078 00079 // SRC[SLEEPDEEP] set to 1 = deep sleep 00080 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; 00081 00082 // Power up everything after powerdown 00083 LPC_SYSCON->PDAWAKECFG &= 0xFFFFF800; 00084 00085 // wait for interrupt 00086 __WFI(); 00087 00088 #elif defined(TARGET_LPC1768) 00089 sleep(); 00090 #endif 00091 } 00092 00093 #endif
Generated on Thu Jul 14 2022 07:43:04 by
1.7.2