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.
Fork of mbed-dev by
targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/api/sleep.c@121:7f86b4238bec, 2016-05-03 (annotated)
- Committer:
- mbed_official
- Date:
- Tue May 03 00:15:16 2016 +0100
- Revision:
- 121:7f86b4238bec
Synchronized with git revision 9cef243de23875778f461bbe9a8c1bc47e65212b
Full URL: https://github.com/mbedmicro/mbed/commit/9cef243de23875778f461bbe9a8c1bc47e65212b/
Switch to KSDK 2.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 121:7f86b4238bec | 1 | /* mbed Microcontroller Library |
mbed_official | 121:7f86b4238bec | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 121:7f86b4238bec | 3 | * |
mbed_official | 121:7f86b4238bec | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 121:7f86b4238bec | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 121:7f86b4238bec | 6 | * You may obtain a copy of the License at |
mbed_official | 121:7f86b4238bec | 7 | * |
mbed_official | 121:7f86b4238bec | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 121:7f86b4238bec | 9 | * |
mbed_official | 121:7f86b4238bec | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 121:7f86b4238bec | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 121:7f86b4238bec | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 121:7f86b4238bec | 13 | * See the License for the specific language governing permissions and |
mbed_official | 121:7f86b4238bec | 14 | * limitations under the License. |
mbed_official | 121:7f86b4238bec | 15 | */ |
mbed_official | 121:7f86b4238bec | 16 | #include "sleep_api.h" |
mbed_official | 121:7f86b4238bec | 17 | #include "cmsis.h" |
mbed_official | 121:7f86b4238bec | 18 | #include "fsl_smc.h" |
mbed_official | 121:7f86b4238bec | 19 | |
mbed_official | 121:7f86b4238bec | 20 | void sleep(void) { |
mbed_official | 121:7f86b4238bec | 21 | SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll); |
mbed_official | 121:7f86b4238bec | 22 | |
mbed_official | 121:7f86b4238bec | 23 | SMC_SetPowerModeWait(SMC); |
mbed_official | 121:7f86b4238bec | 24 | } |
mbed_official | 121:7f86b4238bec | 25 | |
mbed_official | 121:7f86b4238bec | 26 | void deepsleep(void) { |
mbed_official | 121:7f86b4238bec | 27 | #if (defined(FSL_FEATURE_SOC_MCG_COUNT) && FSL_FEATURE_SOC_MCG_COUNT) |
mbed_official | 121:7f86b4238bec | 28 | mcg_mode_t mode = CLOCK_GetMode(); |
mbed_official | 121:7f86b4238bec | 29 | #endif |
mbed_official | 121:7f86b4238bec | 30 | SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll); |
mbed_official | 121:7f86b4238bec | 31 | |
mbed_official | 121:7f86b4238bec | 32 | SMC_SetPowerModeVlps(SMC); |
mbed_official | 121:7f86b4238bec | 33 | |
mbed_official | 121:7f86b4238bec | 34 | #if (defined(FSL_FEATURE_SOC_MCG_COUNT) && FSL_FEATURE_SOC_MCG_COUNT) |
mbed_official | 121:7f86b4238bec | 35 | /* |
mbed_official | 121:7f86b4238bec | 36 | * If enter stop modes when MCG in PEE mode, then after wakeup, the MCG is in PBE mode, |
mbed_official | 121:7f86b4238bec | 37 | * need to enter PEE mode manually. |
mbed_official | 121:7f86b4238bec | 38 | */ |
mbed_official | 121:7f86b4238bec | 39 | if (mode == kMCG_ModePEE) { |
mbed_official | 121:7f86b4238bec | 40 | /* Wait for PLL lock. */ |
mbed_official | 121:7f86b4238bec | 41 | while (!(MCG_S_LOCK0_MASK & MCG->S)) |
mbed_official | 121:7f86b4238bec | 42 | { |
mbed_official | 121:7f86b4238bec | 43 | } |
mbed_official | 121:7f86b4238bec | 44 | CLOCK_SetPeeMode(); |
mbed_official | 121:7f86b4238bec | 45 | } |
mbed_official | 121:7f86b4238bec | 46 | #endif |
mbed_official | 121:7f86b4238bec | 47 | } |