mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu Aug 20 10:45:13 2015 +0100
Revision:
613:bc40b8d2aec4
Parent:
337:6ed01c00b962
Synchronized with git revision 92ca8c7b60a283b6bb60eb65b183dac1599f0ade

Full URL: https://github.com/mbedmicro/mbed/commit/92ca8c7b60a283b6bb60eb65b183dac1599f0ade/

Nordic: update application start address in GCC linker script

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 337:6ed01c00b962 1 /* mbed Microcontroller Library
mbed_official 337:6ed01c00b962 2 * Copyright (c) 2006-2013 ARM Limited
mbed_official 337:6ed01c00b962 3 *
mbed_official 337:6ed01c00b962 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbed_official 337:6ed01c00b962 5 * you may not use this file except in compliance with the License.
mbed_official 337:6ed01c00b962 6 * You may obtain a copy of the License at
mbed_official 337:6ed01c00b962 7 *
mbed_official 337:6ed01c00b962 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 337:6ed01c00b962 9 *
mbed_official 337:6ed01c00b962 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 337:6ed01c00b962 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 337:6ed01c00b962 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 337:6ed01c00b962 13 * See the License for the specific language governing permissions and
mbed_official 337:6ed01c00b962 14 * limitations under the License.
mbed_official 337:6ed01c00b962 15 */
mbed_official 337:6ed01c00b962 16 #include "sleep_api.h"
mbed_official 337:6ed01c00b962 17 #include "cmsis.h"
mbed_official 337:6ed01c00b962 18
mbed_official 337:6ed01c00b962 19
mbed_official 337:6ed01c00b962 20 //#define DEEPSLEEP
mbed_official 337:6ed01c00b962 21 #define POWERDOWN
mbed_official 337:6ed01c00b962 22
mbed_official 337:6ed01c00b962 23 void sleep(void)
mbed_official 337:6ed01c00b962 24 {
mbed_official 337:6ed01c00b962 25 //Normal sleep mode for PCON:
mbed_official 337:6ed01c00b962 26 LPC_PMU->PCON &= ~0x03;
mbed_official 337:6ed01c00b962 27
mbed_official 337:6ed01c00b962 28 //Normal sleep mode for ARM core:
mbed_official 337:6ed01c00b962 29 SCB->SCR = 0;
mbed_official 337:6ed01c00b962 30
mbed_official 337:6ed01c00b962 31 //And go to sleep
mbed_official 337:6ed01c00b962 32 __WFI();
mbed_official 337:6ed01c00b962 33 }
mbed_official 337:6ed01c00b962 34
mbed_official 337:6ed01c00b962 35 // Deepsleep/powerdown modes assume the device is configured to use its internal RC oscillator directly
mbed_official 337:6ed01c00b962 36
mbed_official 337:6ed01c00b962 37 void deepsleep(void)
mbed_official 337:6ed01c00b962 38 {
mbed_official 337:6ed01c00b962 39 //Deep sleep in PCON
mbed_official 337:6ed01c00b962 40 LPC_PMU->PCON &= ~0x03;
mbed_official 337:6ed01c00b962 41
mbed_official 337:6ed01c00b962 42 #if defined(DEEPSLEEP)
mbed_official 337:6ed01c00b962 43 LPC_PMU->PCON |= 0x01;
mbed_official 337:6ed01c00b962 44 #elif defined(POWERDOWN)
mbed_official 337:6ed01c00b962 45 LPC_PMU->PCON |= 0x02;
mbed_official 337:6ed01c00b962 46 #endif
mbed_official 337:6ed01c00b962 47
mbed_official 337:6ed01c00b962 48 //If brownout detection and WDT are enabled, keep them enabled during sleep
mbed_official 337:6ed01c00b962 49 LPC_SYSCON->PDSLEEPCFG = LPC_SYSCON->PDRUNCFG;
mbed_official 337:6ed01c00b962 50
mbed_official 337:6ed01c00b962 51 //After wakeup same stuff as currently enabled:
mbed_official 337:6ed01c00b962 52 LPC_SYSCON->PDAWAKECFG = LPC_SYSCON->PDRUNCFG;
mbed_official 337:6ed01c00b962 53
mbed_official 337:6ed01c00b962 54 //All interrupts may wake up:
mbed_official 337:6ed01c00b962 55 LPC_SYSCON->STARTERP0 = 0xFF;
mbed_official 337:6ed01c00b962 56 LPC_SYSCON->STARTERP1 = 0xFFFF;
mbed_official 337:6ed01c00b962 57
mbed_official 337:6ed01c00b962 58 //Deep sleep for ARM core:
mbed_official 337:6ed01c00b962 59 SCB->SCR = 1<<2;
mbed_official 337:6ed01c00b962 60
mbed_official 337:6ed01c00b962 61 __WFI();
mbed_official 337:6ed01c00b962 62 }