mbed SDK library sources

Fork of mbed-src by mbed official

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Tue Dec 17 08:45:10 2013 +0000
Revision:
60:142c6c6f5949
Child:
70:c1fbde68b492
Synchronized with git revision 572b22395f1ebb513f4fbd423214cb39a18dc58b

Full URL: https://github.com/mbedmicro/mbed/commit/572b22395f1ebb513f4fbd423214cb39a18dc58b/

[NUCLEO_F103RB] InterruptIn, Sleep, RTC added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 60:142c6c6f5949 1 /* mbed Microcontroller Library
mbed_official 60:142c6c6f5949 2 * Copyright (c) 2006-2013 ARM Limited
mbed_official 60:142c6c6f5949 3 *
mbed_official 60:142c6c6f5949 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbed_official 60:142c6c6f5949 5 * you may not use this file except in compliance with the License.
mbed_official 60:142c6c6f5949 6 * You may obtain a copy of the License at
mbed_official 60:142c6c6f5949 7 *
mbed_official 60:142c6c6f5949 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 60:142c6c6f5949 9 *
mbed_official 60:142c6c6f5949 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 60:142c6c6f5949 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 60:142c6c6f5949 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 60:142c6c6f5949 13 * See the License for the specific language governing permissions and
mbed_official 60:142c6c6f5949 14 * limitations under the License.
mbed_official 60:142c6c6f5949 15 */
mbed_official 60:142c6c6f5949 16 #include "sleep_api.h"
mbed_official 60:142c6c6f5949 17 #include "cmsis.h"
mbed_official 60:142c6c6f5949 18
mbed_official 60:142c6c6f5949 19 static void SYSCLKConfig_STOP(void)
mbed_official 60:142c6c6f5949 20 {
mbed_official 60:142c6c6f5949 21 ErrorStatus HSEStartUpStatus;
mbed_official 60:142c6c6f5949 22
mbed_official 60:142c6c6f5949 23 RCC_HSEConfig(RCC_HSE_ON); // Enable HSE
mbed_official 60:142c6c6f5949 24
mbed_official 60:142c6c6f5949 25 HSEStartUpStatus = RCC_WaitForHSEStartUp(); // Wait till HSE is ready
mbed_official 60:142c6c6f5949 26
mbed_official 60:142c6c6f5949 27 if (HSEStartUpStatus == SUCCESS) {
mbed_official 60:142c6c6f5949 28 RCC_PLLCmd(ENABLE); // Enable PLL
mbed_official 60:142c6c6f5949 29 while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {} // Wait till PLL is ready
mbed_official 60:142c6c6f5949 30 RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); // Select PLL as system clock source
mbed_official 60:142c6c6f5949 31 while(RCC_GetSYSCLKSource() != 0x08) {} // Wait till PLL is used as system clock source
mbed_official 60:142c6c6f5949 32 }
mbed_official 60:142c6c6f5949 33 }
mbed_official 60:142c6c6f5949 34
mbed_official 60:142c6c6f5949 35 void sleep(void)
mbed_official 60:142c6c6f5949 36 {
mbed_official 60:142c6c6f5949 37 SCB->SCR = 0; // Normal sleep mode for ARM core
mbed_official 60:142c6c6f5949 38 __WFI();
mbed_official 60:142c6c6f5949 39 }
mbed_official 60:142c6c6f5949 40
mbed_official 60:142c6c6f5949 41 void deepsleep(void)
mbed_official 60:142c6c6f5949 42 {
mbed_official 60:142c6c6f5949 43 // Enable PWR clock
mbed_official 60:142c6c6f5949 44 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
mbed_official 60:142c6c6f5949 45
mbed_official 60:142c6c6f5949 46 // Request to enter STOP mode with regulator in low power mode
mbed_official 60:142c6c6f5949 47 PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
mbed_official 60:142c6c6f5949 48
mbed_official 60:142c6c6f5949 49 // At this stage the system has resumed from STOP mode.
mbed_official 60:142c6c6f5949 50 // Re-configure the system clock: enable HSE, PLL and select
mbed_official 60:142c6c6f5949 51 // PLL as system clock source (because HSE and PLL are disabled in STOP mode).
mbed_official 60:142c6c6f5949 52 SYSCLKConfig_STOP();
mbed_official 60:142c6c6f5949 53 }