mbed library sources: Modified to operate FRDM-KL25Z at 48MHz from internal 32kHz oscillator (nothing else changed).

Fork of mbed-src by mbed official

The only file that changed is: mbed-src-FLL48/targets/cmsis/TARGET_Freescale/TARGET_KL25Z/system_MKL25Z4.h

Committer:
bogdanm
Date:
Tue Sep 10 15:14:19 2013 +0300
Revision:
20:4263a77256ae
Child:
27:3315632cc01d
Sync with git revision 171dda705c947bf910926a0b73d6a4797802554d

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 20:4263a77256ae 1 /* mbed Microcontroller Library
bogdanm 20:4263a77256ae 2 * Copyright (c) 2006-2013 ARM Limited
bogdanm 20:4263a77256ae 3 *
bogdanm 20:4263a77256ae 4 * Licensed under the Apache License, Version 2.0 (the "License");
bogdanm 20:4263a77256ae 5 * you may not use this file except in compliance with the License.
bogdanm 20:4263a77256ae 6 * You may obtain a copy of the License at
bogdanm 20:4263a77256ae 7 *
bogdanm 20:4263a77256ae 8 * http://www.apache.org/licenses/LICENSE-2.0
bogdanm 20:4263a77256ae 9 *
bogdanm 20:4263a77256ae 10 * Unless required by applicable law or agreed to in writing, software
bogdanm 20:4263a77256ae 11 * distributed under the License is distributed on an "AS IS" BASIS,
bogdanm 20:4263a77256ae 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bogdanm 20:4263a77256ae 13 * See the License for the specific language governing permissions and
bogdanm 20:4263a77256ae 14 * limitations under the License.
bogdanm 20:4263a77256ae 15 */
bogdanm 20:4263a77256ae 16 #include "sleep_api.h"
bogdanm 20:4263a77256ae 17 #include "cmsis.h"
bogdanm 20:4263a77256ae 18 #include "mbed_interface.h"
bogdanm 20:4263a77256ae 19
bogdanm 20:4263a77256ae 20 void sleep(void) {
bogdanm 20:4263a77256ae 21 // ensure debug is disconnected
bogdanm 20:4263a77256ae 22 mbed_interface_disconnect();
bogdanm 20:4263a77256ae 23
bogdanm 20:4263a77256ae 24 // PCON[DPDEN] set to sleep
bogdanm 20:4263a77256ae 25 LPC_PMU->PCON = 0x0;
bogdanm 20:4263a77256ae 26
bogdanm 20:4263a77256ae 27 // SRC[SLEEPDEEP] set to 0 = sleep
bogdanm 20:4263a77256ae 28 SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
bogdanm 20:4263a77256ae 29
bogdanm 20:4263a77256ae 30 // wait for interrupt
bogdanm 20:4263a77256ae 31 __WFI();
bogdanm 20:4263a77256ae 32 }
bogdanm 20:4263a77256ae 33
bogdanm 20:4263a77256ae 34 /*
bogdanm 20:4263a77256ae 35 * The mbed lpc1768 does not support the deepsleep mode
bogdanm 20:4263a77256ae 36 * as a debugger is connected to it (the mbed interface).
bogdanm 20:4263a77256ae 37 *
bogdanm 20:4263a77256ae 38 * As mentionned in an application note from NXP:
bogdanm 20:4263a77256ae 39 *
bogdanm 20:4263a77256ae 40 * http://www.po-star.com/public/uploads/20120319123122_141.pdf
bogdanm 20:4263a77256ae 41 *
bogdanm 20:4263a77256ae 42 * {{{
bogdanm 20:4263a77256ae 43 * The user should be aware of certain limitations during debugging.
bogdanm 20:4263a77256ae 44 * The most important is that, due to limitations of the Cortex-M3
bogdanm 20:4263a77256ae 45 * integration, the LPC17xx cannot wake up in the usual manner from
bogdanm 20:4263a77256ae 46 * Deep Sleep and Power-down modes. It is recommended not to use these
bogdanm 20:4263a77256ae 47 * modes during debug. Once an application is downloaded via JTAG/SWD
bogdanm 20:4263a77256ae 48 * interface, the USB to SWD/JTAG debug adapter (Keil ULINK2 for example)
bogdanm 20:4263a77256ae 49 * should be removed from the target board, and thereafter, power cycle
bogdanm 20:4263a77256ae 50 * the LPC17xx to allow wake-up from deep sleep and power-down modes
bogdanm 20:4263a77256ae 51 * }}}
bogdanm 20:4263a77256ae 52 *
bogdanm 20:4263a77256ae 53 * As the interface firmware does not reset the target when a
bogdanm 20:4263a77256ae 54 * mbed_interface_disconnect() semihosting call is made, the
bogdanm 20:4263a77256ae 55 * core cannot wake-up from deepsleep.
bogdanm 20:4263a77256ae 56 *
bogdanm 20:4263a77256ae 57 * We treat a deepsleep() as a normal sleep().
bogdanm 20:4263a77256ae 58 */
bogdanm 20:4263a77256ae 59
bogdanm 20:4263a77256ae 60 void deepsleep(void) {
bogdanm 20:4263a77256ae 61 // ensure debug is disconnected
bogdanm 20:4263a77256ae 62 mbed_interface_disconnect();
bogdanm 20:4263a77256ae 63
bogdanm 20:4263a77256ae 64 // PCON[DPDEN] set to deepsleep
bogdanm 20:4263a77256ae 65 LPC_PMU->PCON = 0x2;
bogdanm 20:4263a77256ae 66
bogdanm 20:4263a77256ae 67 // SRC[SLEEPDEEP] set to 1 = deep sleep
bogdanm 20:4263a77256ae 68 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
bogdanm 20:4263a77256ae 69
bogdanm 20:4263a77256ae 70 // Power up everything after powerdown
bogdanm 20:4263a77256ae 71 LPC_SYSCON->PDAWAKECFG &= 0xFFFFF800;
bogdanm 20:4263a77256ae 72
bogdanm 20:4263a77256ae 73 // wait for interrupt
bogdanm 20:4263a77256ae 74 __WFI();
bogdanm 20:4263a77256ae 75 }