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-STM32F030F4 by
targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/sleep.c@12:6f07dd7cbe47, 2018-02-01 (annotated)
- Committer:
- acosinwork
- Date:
- Thu Feb 01 10:37:10 2018 +0000
- Revision:
- 12:6f07dd7cbe47
- Parent:
- 9:64dafd1db1ec
Change pin mapping and set internall oscillator as default. Fork to support Troyka GPIO expander (I2C I/O); http://amperka.ru/product/troyka-gpio-expander
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mega64 | 0:38ccae254a29 | 1 | /* mbed Microcontroller Library |
mega64 | 0:38ccae254a29 | 2 | ******************************************************************************* |
mega64 | 0:38ccae254a29 | 3 | * Copyright (c) 2014, STMicroelectronics |
mega64 | 0:38ccae254a29 | 4 | * All rights reserved. |
mega64 | 0:38ccae254a29 | 5 | * |
mega64 | 0:38ccae254a29 | 6 | * Redistribution and use in source and binary forms, with or without |
mega64 | 0:38ccae254a29 | 7 | * modification, are permitted provided that the following conditions are met: |
mega64 | 0:38ccae254a29 | 8 | * |
mega64 | 0:38ccae254a29 | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
mega64 | 0:38ccae254a29 | 10 | * this list of conditions and the following disclaimer. |
mega64 | 0:38ccae254a29 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mega64 | 0:38ccae254a29 | 12 | * this list of conditions and the following disclaimer in the documentation |
mega64 | 0:38ccae254a29 | 13 | * and/or other materials provided with the distribution. |
mega64 | 0:38ccae254a29 | 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mega64 | 0:38ccae254a29 | 15 | * may be used to endorse or promote products derived from this software |
mega64 | 0:38ccae254a29 | 16 | * without specific prior written permission. |
mega64 | 0:38ccae254a29 | 17 | * |
mega64 | 0:38ccae254a29 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mega64 | 0:38ccae254a29 | 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mega64 | 0:38ccae254a29 | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mega64 | 0:38ccae254a29 | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mega64 | 0:38ccae254a29 | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mega64 | 0:38ccae254a29 | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mega64 | 0:38ccae254a29 | 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mega64 | 0:38ccae254a29 | 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mega64 | 0:38ccae254a29 | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mega64 | 0:38ccae254a29 | 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mega64 | 0:38ccae254a29 | 28 | ******************************************************************************* |
mega64 | 0:38ccae254a29 | 29 | */ |
mega64 | 0:38ccae254a29 | 30 | #include "sleep_api.h" |
mega64 | 9:64dafd1db1ec | 31 | #include "us_ticker_api.h" |
mega64 | 0:38ccae254a29 | 32 | |
mega64 | 0:38ccae254a29 | 33 | #if DEVICE_SLEEP |
mega64 | 0:38ccae254a29 | 34 | |
mega64 | 0:38ccae254a29 | 35 | #include "cmsis.h" |
mega64 | 0:38ccae254a29 | 36 | |
mega64 | 9:64dafd1db1ec | 37 | |
mega64 | 9:64dafd1db1ec | 38 | void sleep(void) |
mega64 | 9:64dafd1db1ec | 39 | { |
mega64 | 9:64dafd1db1ec | 40 | |
mega64 | 9:64dafd1db1ec | 41 | TIM_HandleTypeDef TimTickerHandle; |
mega64 | 9:64dafd1db1ec | 42 | TimTickerHandle.Instance = TIM1; //same timer as TIM_MST in us_ticker.c |
mega64 | 9:64dafd1db1ec | 43 | |
mega64 | 9:64dafd1db1ec | 44 | // Disable us_ticker update interrupt |
mega64 | 9:64dafd1db1ec | 45 | __HAL_TIM_DISABLE_IT(&TimTickerHandle, TIM_IT_UPDATE); |
mega64 | 9:64dafd1db1ec | 46 | |
mega64 | 9:64dafd1db1ec | 47 | // Stop HAL systick |
mega64 | 0:38ccae254a29 | 48 | HAL_SuspendTick(); |
mega64 | 9:64dafd1db1ec | 49 | |
mega64 | 9:64dafd1db1ec | 50 | |
mega64 | 0:38ccae254a29 | 51 | // Request to enter SLEEP mode |
mega64 | 0:38ccae254a29 | 52 | HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); |
mega64 | 9:64dafd1db1ec | 53 | |
mega64 | 9:64dafd1db1ec | 54 | // Re-enable us_ticker update interrupt |
mega64 | 9:64dafd1db1ec | 55 | __HAL_TIM_ENABLE_IT(&TimTickerHandle, TIM_IT_UPDATE); |
mega64 | 9:64dafd1db1ec | 56 | |
mega64 | 9:64dafd1db1ec | 57 | // Restart HAL systick |
mega64 | 0:38ccae254a29 | 58 | HAL_ResumeTick(); |
mega64 | 9:64dafd1db1ec | 59 | |
mega64 | 0:38ccae254a29 | 60 | } |
mega64 | 0:38ccae254a29 | 61 | |
mega64 | 9:64dafd1db1ec | 62 | void deepsleep(void) |
mega64 | 9:64dafd1db1ec | 63 | { |
mega64 | 0:38ccae254a29 | 64 | // Request to enter STOP mode with regulator in low power mode |
mega64 | 0:38ccae254a29 | 65 | HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); |
mega64 | 0:38ccae254a29 | 66 | |
mega64 | 9:64dafd1db1ec | 67 | HAL_InitTick(TICK_INT_PRIORITY); |
mega64 | 9:64dafd1db1ec | 68 | |
mega64 | 0:38ccae254a29 | 69 | // After wake-up from STOP reconfigure the PLL |
mega64 | 0:38ccae254a29 | 70 | SetSysClock(); |
mega64 | 9:64dafd1db1ec | 71 | |
mega64 | 9:64dafd1db1ec | 72 | HAL_InitTick(TICK_INT_PRIORITY); |
mega64 | 0:38ccae254a29 | 73 | } |
mega64 | 0:38ccae254a29 | 74 | |
mega64 | 0:38ccae254a29 | 75 | #endif |