mbed-src updated for BMD-200 evaluation board. Just pin numbers are updated.
Dependents: mbed_blinky-bmd-200 bmd-200_accel_demo firstRig
Fork of mbed-src by
Replacement for the "mbed" or "mbed-src" library when using the BMD-200 Evaluation kit. This library only remaps the pin names (i.e. LED1 points to p0.01 instead of p0.18, etc) as used by the BMD-200 Evaluation board (select the nRF51822_mkit platform). All other code is untouched.
targets/hal/TARGET_NXP/TARGET_LPC11U6X/sleep.c@592:5e2eb8beba71, 2015-07-10 (annotated)
- Committer:
- dcnichols
- Date:
- Fri Jul 10 17:36:27 2015 +0000
- Revision:
- 592:5e2eb8beba71
- Parent:
- 513:bb3effbb3493
updating to latest mbed-src
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 513:bb3effbb3493 | 1 | /* mbed Microcontroller Library |
mbed_official | 513:bb3effbb3493 | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 513:bb3effbb3493 | 3 | * |
mbed_official | 513:bb3effbb3493 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 513:bb3effbb3493 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 513:bb3effbb3493 | 6 | * You may obtain a copy of the License at |
mbed_official | 513:bb3effbb3493 | 7 | * |
mbed_official | 513:bb3effbb3493 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 513:bb3effbb3493 | 9 | * |
mbed_official | 513:bb3effbb3493 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 513:bb3effbb3493 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 513:bb3effbb3493 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 513:bb3effbb3493 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 513:bb3effbb3493 | 14 | * limitations under the License. |
mbed_official | 513:bb3effbb3493 | 15 | */ |
mbed_official | 513:bb3effbb3493 | 16 | #include "sleep_api.h" |
mbed_official | 513:bb3effbb3493 | 17 | #include "cmsis.h" |
mbed_official | 513:bb3effbb3493 | 18 | #include "mbed_interface.h" |
mbed_official | 513:bb3effbb3493 | 19 | |
mbed_official | 513:bb3effbb3493 | 20 | #if DEVICE_SLEEP |
mbed_official | 513:bb3effbb3493 | 21 | |
mbed_official | 513:bb3effbb3493 | 22 | void sleep(void) { |
mbed_official | 513:bb3effbb3493 | 23 | |
mbed_official | 513:bb3effbb3493 | 24 | #if (DEVICE_SEMIHOST == 1) |
mbed_official | 513:bb3effbb3493 | 25 | // ensure debug is disconnected |
mbed_official | 513:bb3effbb3493 | 26 | mbed_interface_disconnect(); |
mbed_official | 513:bb3effbb3493 | 27 | #endif |
mbed_official | 513:bb3effbb3493 | 28 | |
mbed_official | 513:bb3effbb3493 | 29 | // PCON[PM] (bits 2:0) set to 0 |
mbed_official | 513:bb3effbb3493 | 30 | LPC_PMU->PCON &= ~0x03; |
mbed_official | 513:bb3effbb3493 | 31 | |
mbed_official | 513:bb3effbb3493 | 32 | // SRC[SLEEPDEEP] set to 0 = sleep |
mbed_official | 513:bb3effbb3493 | 33 | SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; |
mbed_official | 513:bb3effbb3493 | 34 | |
mbed_official | 513:bb3effbb3493 | 35 | // wait for interrupt |
mbed_official | 513:bb3effbb3493 | 36 | __WFI(); |
mbed_official | 513:bb3effbb3493 | 37 | } |
mbed_official | 513:bb3effbb3493 | 38 | |
mbed_official | 513:bb3effbb3493 | 39 | |
mbed_official | 513:bb3effbb3493 | 40 | void deepsleep(void) { |
mbed_official | 513:bb3effbb3493 | 41 | |
mbed_official | 513:bb3effbb3493 | 42 | #if (DEVICE_SEMIHOST == 1) |
mbed_official | 513:bb3effbb3493 | 43 | // ensure debug is disconnected |
mbed_official | 513:bb3effbb3493 | 44 | mbed_interface_disconnect(); |
mbed_official | 513:bb3effbb3493 | 45 | #endif |
mbed_official | 513:bb3effbb3493 | 46 | |
mbed_official | 513:bb3effbb3493 | 47 | // PCON[PM] (bits 2:0) set to 1 |
mbed_official | 513:bb3effbb3493 | 48 | LPC_PMU->PCON &= ~0x03; |
mbed_official | 513:bb3effbb3493 | 49 | LPC_PMU->PCON |= 0x01; |
mbed_official | 513:bb3effbb3493 | 50 | |
mbed_official | 513:bb3effbb3493 | 51 | //According to user manual it is kinda picky about reserved bits, so we follow that nicely |
mbed_official | 513:bb3effbb3493 | 52 | //Keep WDOSC and BOD in same state as they are now during deepsleep |
mbed_official | 513:bb3effbb3493 | 53 | LPC_SYSCON->PDSLEEPCFG = 0x00000037 | (LPC_SYSCON->PDRUNCFG & (0x00000048)); |
mbed_official | 513:bb3effbb3493 | 54 | |
mbed_official | 513:bb3effbb3493 | 55 | // Power up same as before powerdown |
mbed_official | 513:bb3effbb3493 | 56 | LPC_SYSCON->PDAWAKECFG = LPC_SYSCON->PDRUNCFG; |
mbed_official | 513:bb3effbb3493 | 57 | |
mbed_official | 513:bb3effbb3493 | 58 | // All interrupts can wake |
mbed_official | 513:bb3effbb3493 | 59 | LPC_SYSCON->STARTERP0 = 0xFF; |
mbed_official | 513:bb3effbb3493 | 60 | LPC_SYSCON->STARTERP1 = 0xFFFFFFFF; |
mbed_official | 513:bb3effbb3493 | 61 | |
mbed_official | 513:bb3effbb3493 | 62 | // SRC[SLEEPDEEP] set to 1 = deep sleep |
mbed_official | 513:bb3effbb3493 | 63 | SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; |
mbed_official | 513:bb3effbb3493 | 64 | |
mbed_official | 513:bb3effbb3493 | 65 | // wait for interrupt |
mbed_official | 513:bb3effbb3493 | 66 | __WFI(); |
mbed_official | 513:bb3effbb3493 | 67 | } |
mbed_official | 513:bb3effbb3493 | 68 | |
mbed_official | 513:bb3effbb3493 | 69 | #endif |