rik te winkel / mbed-dev

Dependents:   Numitron_clock

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Fri Oct 28 11:17:30 2016 +0100
Revision:
149:156823d33999
Parent:
targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/api/sleep.c@121:7f86b4238bec
Child:
150:02e0a0aed4ec
This updates the lib to the mbed lib v128

NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.

Who changed what in which revision?

UserRevisionLine numberNew 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 }