4545

Dependents:   LSS_Rev_1

Fork of mbed-dev by Umar Naeem

Committer:
<>
Date:
Mon Jan 16 15:03:32 2017 +0000
Revision:
156:95d6b41a828b
Parent:
154:37f96f9d4de2
Child:
160:d5399cc887bb
This updates the lib to the mbed lib v134

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 154:37f96f9d4de2 1 /* mbed Microcontroller Library
<> 154:37f96f9d4de2 2 *******************************************************************************
<> 154:37f96f9d4de2 3 * Copyright (c) 2016, STMicroelectronics
<> 154:37f96f9d4de2 4 * All rights reserved.
<> 154:37f96f9d4de2 5 *
<> 154:37f96f9d4de2 6 * Redistribution and use in source and binary forms, with or without
<> 154:37f96f9d4de2 7 * modification, are permitted provided that the following conditions are met:
<> 154:37f96f9d4de2 8 *
<> 154:37f96f9d4de2 9 * 1. Redistributions of source code must retain the above copyright notice,
<> 154:37f96f9d4de2 10 * this list of conditions and the following disclaimer.
<> 154:37f96f9d4de2 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
<> 154:37f96f9d4de2 12 * this list of conditions and the following disclaimer in the documentation
<> 154:37f96f9d4de2 13 * and/or other materials provided with the distribution.
<> 154:37f96f9d4de2 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
<> 154:37f96f9d4de2 15 * may be used to endorse or promote products derived from this software
<> 154:37f96f9d4de2 16 * without specific prior written permission.
<> 154:37f96f9d4de2 17 *
<> 154:37f96f9d4de2 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
<> 154:37f96f9d4de2 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<> 154:37f96f9d4de2 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 154:37f96f9d4de2 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
<> 154:37f96f9d4de2 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<> 154:37f96f9d4de2 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
<> 154:37f96f9d4de2 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
<> 154:37f96f9d4de2 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
<> 154:37f96f9d4de2 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<> 154:37f96f9d4de2 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 154:37f96f9d4de2 28 *******************************************************************************
<> 154:37f96f9d4de2 29 */
<> 154:37f96f9d4de2 30 #include "sleep_api.h"
<> 154:37f96f9d4de2 31 #include "rtc_api_hal.h"
<> 154:37f96f9d4de2 32
<> 154:37f96f9d4de2 33 #if DEVICE_SLEEP
<> 154:37f96f9d4de2 34
<> 154:37f96f9d4de2 35 #include "cmsis.h"
<> 154:37f96f9d4de2 36
<> 154:37f96f9d4de2 37
<> 154:37f96f9d4de2 38 void sleep(void)
<> 154:37f96f9d4de2 39 {
<> 154:37f96f9d4de2 40 // Stop HAL systick
<> 154:37f96f9d4de2 41 HAL_SuspendTick();
<> 154:37f96f9d4de2 42 // Request to enter SLEEP mode
<> 154:37f96f9d4de2 43 HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
<> 154:37f96f9d4de2 44 // Restart HAL systick
<> 154:37f96f9d4de2 45 HAL_ResumeTick();
<> 154:37f96f9d4de2 46 }
<> 154:37f96f9d4de2 47
<> 154:37f96f9d4de2 48 void deepsleep(void)
<> 154:37f96f9d4de2 49 {
<> 154:37f96f9d4de2 50 // Stop HAL systick
<> 154:37f96f9d4de2 51 HAL_SuspendTick();
<> 154:37f96f9d4de2 52
<> 154:37f96f9d4de2 53 // Request to enter STOP mode with regulator in low power mode
<> 154:37f96f9d4de2 54 #if TARGET_STM32L4
<> 156:95d6b41a828b 55 if (__HAL_RCC_PWR_IS_CLK_ENABLED()) {
<> 156:95d6b41a828b 56 HAL_PWREx_EnableLowPowerRunMode();
<> 156:95d6b41a828b 57 HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
<> 156:95d6b41a828b 58 HAL_PWREx_DisableLowPowerRunMode();
<> 156:95d6b41a828b 59 } else {
<> 156:95d6b41a828b 60 __HAL_RCC_PWR_CLK_ENABLE();
<> 156:95d6b41a828b 61 HAL_PWREx_EnableLowPowerRunMode();
<> 156:95d6b41a828b 62 HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
<> 156:95d6b41a828b 63 HAL_PWREx_DisableLowPowerRunMode();
<> 156:95d6b41a828b 64 __HAL_RCC_PWR_CLK_DISABLE();
<> 156:95d6b41a828b 65 }
<> 154:37f96f9d4de2 66 #else /* TARGET_STM32L4 */
<> 154:37f96f9d4de2 67 HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
<> 154:37f96f9d4de2 68 #endif /* TARGET_STM32L4 */
<> 154:37f96f9d4de2 69
<> 154:37f96f9d4de2 70 // Restart HAL systick
<> 154:37f96f9d4de2 71 HAL_ResumeTick();
<> 154:37f96f9d4de2 72
<> 154:37f96f9d4de2 73 // After wake-up from STOP reconfigure the PLL
<> 154:37f96f9d4de2 74 SetSysClock();
<> 154:37f96f9d4de2 75
<> 154:37f96f9d4de2 76 #if DEVICE_LOWPOWERTIMER
<> 154:37f96f9d4de2 77 rtc_synchronize();
<> 154:37f96f9d4de2 78 #endif
<> 154:37f96f9d4de2 79 }
<> 154:37f96f9d4de2 80
<> 154:37f96f9d4de2 81 #endif