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.
STM32_LowPower.h
00001 /** 00002 ****************************************************************************** 00003 * @file STM32_LowPower.h 00004 * @author Biagio Montaruli, STM32duino team (STMicroelectronics) 00005 * @version V1.0.0 00006 * @date 12-April-2019 00007 * @brief Mbed Library to manage Low Power modes on STM32 boards 00008 * 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2> 00013 * <h2><center>© COPYRIGHT(c) 2019 Biagio Montaruli</center></h2> 00014 * 00015 * Redistribution and use in source and binary forms, with or without modification, 00016 * are permitted provided that the following conditions are met: 00017 * 1. Redistributions of source code must retain the above copyright notice, 00018 * this list of conditions and the following disclaimer. 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00023 * may be used to endorse or promote products derived from this software 00024 * without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00029 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00030 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00031 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00032 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00033 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00034 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00035 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 * 00037 ****************************************************************************** 00038 */ 00039 00040 #ifndef _STM32_LOW_POWER_H_ 00041 #define _STM32_LOW_POWER_H_ 00042 00043 #include "mbed.h" 00044 00045 #define DEBUG 0 00046 00047 /* Check if PWR HAL enable in mbed-os/targets/TARGET_STM/TARGET_STM32YZ/device/stm32yzxx_hal_conf.h */ 00048 #ifndef HAL_PWR_MODULE_ENABLED 00049 #error "PWR configuration is missing. Check flag HAL_PWR_MODULE_ENABLED in " \ 00050 "mbed-os/targets/TARGET_STM/TARGET_STM32YZ/device/stm32yzxx_hal_conf.h" 00051 #endif 00052 00053 typedef void (*voidFuncPtrVoid)(void); 00054 typedef void (*voidFuncPtr)(void *) ; 00055 00056 typedef enum { 00057 STM32_MAIN_REGULATOR = 0, 00058 STM32_LOWPOWER_REGULATOR = 1 00059 } STM32_RegulatorType; 00060 00061 typedef enum { 00062 IT_MODE_RISING = 0, 00063 IT_MODE_FALLING = 1, 00064 IT_MODE_RISING_FALLING = 3 00065 } Interrupt_Mode; 00066 00067 class STM32_LowPower 00068 { 00069 public: 00070 STM32_LowPower(); 00071 00072 void init(void); 00073 00074 void sleep(STM32_RegulatorType reg = STM32_MAIN_REGULATOR, uint32_t timer_s = 0); 00075 00076 void stop(STM32_RegulatorType reg = STM32_MAIN_REGULATOR, uint32_t timer_s = 0); 00077 00078 void standby(uint32_t timer_s = 0); 00079 00080 void attachInterruptWakeup(PinName pin, voidFuncPtrVoid callback, 00081 Interrupt_Mode mode); 00082 void enableWakeupFromRTC(voidFuncPtr callback, void *data = NULL, uint32_t timer_s = 0); 00083 00084 private: 00085 bool _configured; /* Low Power mode initialization status */ 00086 bool _rtc_wakeup; 00087 uint32_t _timer; 00088 InterruptIn *_wakeupPin; 00089 00090 void programRtcWakeUp(uint32_t timer_s); 00091 }; 00092 00093 extern STM32_LowPower LowPower; 00094 00095 #endif // _STM32_LOW_POWER_H_
Generated on Wed Jul 13 2022 07:20:35 by
1.7.2