Kashish Haresh Shah
/
HXCClientShield
HXC Client Shield Repository.
Utilities/low_power_manager.h@0:bacc6e701fb4, 2021-03-29 (annotated)
- Committer:
- kashish_mbed
- Date:
- Mon Mar 29 15:37:08 2021 +0000
- Revision:
- 0:bacc6e701fb4
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kashish_mbed | 0:bacc6e701fb4 | 1 | /** |
kashish_mbed | 0:bacc6e701fb4 | 2 | ****************************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 3 | * @file low_power_manager.h |
kashish_mbed | 0:bacc6e701fb4 | 4 | * @author MCD Application Team |
kashish_mbed | 0:bacc6e701fb4 | 5 | * @version V1.1.4 |
kashish_mbed | 0:bacc6e701fb4 | 6 | * @date 08-January-2018 |
kashish_mbed | 0:bacc6e701fb4 | 7 | * @brief Header for stm32xx_lpm.c module |
kashish_mbed | 0:bacc6e701fb4 | 8 | ****************************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 9 | * @attention |
kashish_mbed | 0:bacc6e701fb4 | 10 | * |
kashish_mbed | 0:bacc6e701fb4 | 11 | * <h2><center>© Copyright (c) 2016 STMicroelectronics International N.V. |
kashish_mbed | 0:bacc6e701fb4 | 12 | * All rights reserved.</center></h2> |
kashish_mbed | 0:bacc6e701fb4 | 13 | * |
kashish_mbed | 0:bacc6e701fb4 | 14 | * Redistribution and use in source and binary forms, with or without |
kashish_mbed | 0:bacc6e701fb4 | 15 | * modification, are permitted, provided that the following conditions are met: |
kashish_mbed | 0:bacc6e701fb4 | 16 | * |
kashish_mbed | 0:bacc6e701fb4 | 17 | * 1. Redistribution of source code must retain the above copyright notice, |
kashish_mbed | 0:bacc6e701fb4 | 18 | * this list of conditions and the following disclaimer. |
kashish_mbed | 0:bacc6e701fb4 | 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
kashish_mbed | 0:bacc6e701fb4 | 20 | * this list of conditions and the following disclaimer in the documentation |
kashish_mbed | 0:bacc6e701fb4 | 21 | * and/or other materials provided with the distribution. |
kashish_mbed | 0:bacc6e701fb4 | 22 | * 3. Neither the name of STMicroelectronics nor the names of other |
kashish_mbed | 0:bacc6e701fb4 | 23 | * contributors to this software may be used to endorse or promote products |
kashish_mbed | 0:bacc6e701fb4 | 24 | * derived from this software without specific written permission. |
kashish_mbed | 0:bacc6e701fb4 | 25 | * 4. This software, including modifications and/or derivative works of this |
kashish_mbed | 0:bacc6e701fb4 | 26 | * software, must execute solely and exclusively on microcontroller or |
kashish_mbed | 0:bacc6e701fb4 | 27 | * microprocessor devices manufactured by or for STMicroelectronics. |
kashish_mbed | 0:bacc6e701fb4 | 28 | * 5. Redistribution and use of this software other than as permitted under |
kashish_mbed | 0:bacc6e701fb4 | 29 | * this license is void and will automatically terminate your rights under |
kashish_mbed | 0:bacc6e701fb4 | 30 | * this license. |
kashish_mbed | 0:bacc6e701fb4 | 31 | * |
kashish_mbed | 0:bacc6e701fb4 | 32 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" |
kashish_mbed | 0:bacc6e701fb4 | 33 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT |
kashish_mbed | 0:bacc6e701fb4 | 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
kashish_mbed | 0:bacc6e701fb4 | 35 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
kashish_mbed | 0:bacc6e701fb4 | 36 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT |
kashish_mbed | 0:bacc6e701fb4 | 37 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
kashish_mbed | 0:bacc6e701fb4 | 38 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
kashish_mbed | 0:bacc6e701fb4 | 39 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
kashish_mbed | 0:bacc6e701fb4 | 40 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
kashish_mbed | 0:bacc6e701fb4 | 41 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
kashish_mbed | 0:bacc6e701fb4 | 42 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
kashish_mbed | 0:bacc6e701fb4 | 43 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
kashish_mbed | 0:bacc6e701fb4 | 44 | * |
kashish_mbed | 0:bacc6e701fb4 | 45 | ****************************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 46 | */ |
kashish_mbed | 0:bacc6e701fb4 | 47 | |
kashish_mbed | 0:bacc6e701fb4 | 48 | /* Define to prevent recursive inclusion -------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 49 | #ifndef __STM32_LPM__H |
kashish_mbed | 0:bacc6e701fb4 | 50 | #define __STM32_LPM__H |
kashish_mbed | 0:bacc6e701fb4 | 51 | |
kashish_mbed | 0:bacc6e701fb4 | 52 | #ifdef __cplusplus |
kashish_mbed | 0:bacc6e701fb4 | 53 | extern "C" { |
kashish_mbed | 0:bacc6e701fb4 | 54 | #endif |
kashish_mbed | 0:bacc6e701fb4 | 55 | |
kashish_mbed | 0:bacc6e701fb4 | 56 | /* Includes ------------------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 57 | /*low power manager configuration*/ |
kashish_mbed | 0:bacc6e701fb4 | 58 | typedef enum |
kashish_mbed | 0:bacc6e701fb4 | 59 | { |
kashish_mbed | 0:bacc6e701fb4 | 60 | LPM_APPLI_Id = (1 << 0), |
kashish_mbed | 0:bacc6e701fb4 | 61 | LPM_LIB_Id = (1 << 1), |
kashish_mbed | 0:bacc6e701fb4 | 62 | LPM_RTC_Id = (1 << 2), |
kashish_mbed | 0:bacc6e701fb4 | 63 | LPM_GPS_Id = (1 << 3), |
kashish_mbed | 0:bacc6e701fb4 | 64 | LPM_UART_RX_Id = (1 << 4), |
kashish_mbed | 0:bacc6e701fb4 | 65 | LPM_UART_TX_Id = (1 << 5), |
kashish_mbed | 0:bacc6e701fb4 | 66 | } LPM_Id_t; |
kashish_mbed | 0:bacc6e701fb4 | 67 | |
kashish_mbed | 0:bacc6e701fb4 | 68 | /** |
kashish_mbed | 0:bacc6e701fb4 | 69 | * Low Power Mode selected |
kashish_mbed | 0:bacc6e701fb4 | 70 | */ |
kashish_mbed | 0:bacc6e701fb4 | 71 | typedef enum |
kashish_mbed | 0:bacc6e701fb4 | 72 | { |
kashish_mbed | 0:bacc6e701fb4 | 73 | LPM_Enable=0, |
kashish_mbed | 0:bacc6e701fb4 | 74 | LPM_Disable, |
kashish_mbed | 0:bacc6e701fb4 | 75 | } LPM_SetMode_t; |
kashish_mbed | 0:bacc6e701fb4 | 76 | |
kashish_mbed | 0:bacc6e701fb4 | 77 | typedef enum |
kashish_mbed | 0:bacc6e701fb4 | 78 | { |
kashish_mbed | 0:bacc6e701fb4 | 79 | LPM_SleepMode, |
kashish_mbed | 0:bacc6e701fb4 | 80 | LPM_StopMode, |
kashish_mbed | 0:bacc6e701fb4 | 81 | LPM_OffMode, |
kashish_mbed | 0:bacc6e701fb4 | 82 | } LPM_GetMode_t; |
kashish_mbed | 0:bacc6e701fb4 | 83 | |
kashish_mbed | 0:bacc6e701fb4 | 84 | /* Exported constants --------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 85 | /* External variables --------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 86 | /* Exported macros -----------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 87 | /* Exported functions ------------------------------------------------------- */ |
kashish_mbed | 0:bacc6e701fb4 | 88 | /** |
kashish_mbed | 0:bacc6e701fb4 | 89 | * @brief This API returns the Low Power Mode selected that will be applied when the system will enter low power mode |
kashish_mbed | 0:bacc6e701fb4 | 90 | * if there is no update between the time the mode is read with this API and the time the system enters |
kashish_mbed | 0:bacc6e701fb4 | 91 | * low power mode. |
kashish_mbed | 0:bacc6e701fb4 | 92 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 93 | * @retval LPM_ModeSelected_t |
kashish_mbed | 0:bacc6e701fb4 | 94 | */ |
kashish_mbed | 0:bacc6e701fb4 | 95 | LPM_GetMode_t LPM_GetMode(void); |
kashish_mbed | 0:bacc6e701fb4 | 96 | /** |
kashish_mbed | 0:bacc6e701fb4 | 97 | * @brief This API notifies the low power manager if the specified user allows the Off mode or not. |
kashish_mbed | 0:bacc6e701fb4 | 98 | * When the application does not require the system clock, it enters Stop Mode if at least one user disallow |
kashish_mbed | 0:bacc6e701fb4 | 99 | * Off Mode. Otherwise, it enters Off Mode. |
kashish_mbed | 0:bacc6e701fb4 | 100 | * The default mode selection for all users is Off mode enabled |
kashish_mbed | 0:bacc6e701fb4 | 101 | * @param id: process Id |
kashish_mbed | 0:bacc6e701fb4 | 102 | * @param mode: mode selected |
kashish_mbed | 0:bacc6e701fb4 | 103 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 104 | */ |
kashish_mbed | 0:bacc6e701fb4 | 105 | void LPM_SetStopMode(LPM_Id_t id, LPM_SetMode_t mode); |
kashish_mbed | 0:bacc6e701fb4 | 106 | |
kashish_mbed | 0:bacc6e701fb4 | 107 | void LPM_SetOffMode(LPM_Id_t id, LPM_SetMode_t mode); |
kashish_mbed | 0:bacc6e701fb4 | 108 | /** |
kashish_mbed | 0:bacc6e701fb4 | 109 | * @brief This API shall be used by the application when there is no more code to execute so that the system may |
kashish_mbed | 0:bacc6e701fb4 | 110 | * enter low-power mode. The mode selected depends on the information received from LPM_OffModeSelection() and |
kashish_mbed | 0:bacc6e701fb4 | 111 | * LPM_SysclockRequest() |
kashish_mbed | 0:bacc6e701fb4 | 112 | * This function shall be called in critical section |
kashish_mbed | 0:bacc6e701fb4 | 113 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 114 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 115 | */ |
kashish_mbed | 0:bacc6e701fb4 | 116 | void LPM_EnterLowPower(void); |
kashish_mbed | 0:bacc6e701fb4 | 117 | |
kashish_mbed | 0:bacc6e701fb4 | 118 | /** |
kashish_mbed | 0:bacc6e701fb4 | 119 | * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the |
kashish_mbed | 0:bacc6e701fb4 | 120 | * application to implement dedicated code before entering Sleep Mode |
kashish_mbed | 0:bacc6e701fb4 | 121 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 122 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 123 | */ |
kashish_mbed | 0:bacc6e701fb4 | 124 | void LPM_EnterSleepMode(void); |
kashish_mbed | 0:bacc6e701fb4 | 125 | |
kashish_mbed | 0:bacc6e701fb4 | 126 | /** |
kashish_mbed | 0:bacc6e701fb4 | 127 | * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the |
kashish_mbed | 0:bacc6e701fb4 | 128 | * application to implement dedicated code before getting out from Sleep Mode |
kashish_mbed | 0:bacc6e701fb4 | 129 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 130 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 131 | */ |
kashish_mbed | 0:bacc6e701fb4 | 132 | void LPM_ExitSleepMode(void); |
kashish_mbed | 0:bacc6e701fb4 | 133 | |
kashish_mbed | 0:bacc6e701fb4 | 134 | /** |
kashish_mbed | 0:bacc6e701fb4 | 135 | * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the |
kashish_mbed | 0:bacc6e701fb4 | 136 | * application to implement dedicated code before entering Stop Mode |
kashish_mbed | 0:bacc6e701fb4 | 137 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 138 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 139 | */ |
kashish_mbed | 0:bacc6e701fb4 | 140 | void LPM_EnterStopMode(void); |
kashish_mbed | 0:bacc6e701fb4 | 141 | |
kashish_mbed | 0:bacc6e701fb4 | 142 | /** |
kashish_mbed | 0:bacc6e701fb4 | 143 | * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the |
kashish_mbed | 0:bacc6e701fb4 | 144 | * application to implement dedicated code before getting out from Stop Mode. This is where the application |
kashish_mbed | 0:bacc6e701fb4 | 145 | * should reconfigure the clock tree when needed |
kashish_mbed | 0:bacc6e701fb4 | 146 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 147 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 148 | */ |
kashish_mbed | 0:bacc6e701fb4 | 149 | void LPM_ExitStopMode(void); |
kashish_mbed | 0:bacc6e701fb4 | 150 | |
kashish_mbed | 0:bacc6e701fb4 | 151 | /** |
kashish_mbed | 0:bacc6e701fb4 | 152 | * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the |
kashish_mbed | 0:bacc6e701fb4 | 153 | * application to implement dedicated code before entering Off mode. This is where the application could save |
kashish_mbed | 0:bacc6e701fb4 | 154 | * data in the retention memory as the RAM memory content will be lost |
kashish_mbed | 0:bacc6e701fb4 | 155 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 156 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 157 | */ |
kashish_mbed | 0:bacc6e701fb4 | 158 | void LPM_EnterOffMode(void); |
kashish_mbed | 0:bacc6e701fb4 | 159 | |
kashish_mbed | 0:bacc6e701fb4 | 160 | |
kashish_mbed | 0:bacc6e701fb4 | 161 | /** |
kashish_mbed | 0:bacc6e701fb4 | 162 | * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the |
kashish_mbed | 0:bacc6e701fb4 | 163 | * application to implement dedicated code before getting out from Off mode. This can only happen when the |
kashish_mbed | 0:bacc6e701fb4 | 164 | * Off mode is finally not entered. In that case, the application may reverse some configurations done before |
kashish_mbed | 0:bacc6e701fb4 | 165 | * entering Off mode. When Off mode is successful, the system is reset when getting out from this low-power mode |
kashish_mbed | 0:bacc6e701fb4 | 166 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 167 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 168 | */ |
kashish_mbed | 0:bacc6e701fb4 | 169 | void LPM_ExitOffMode(void); |
kashish_mbed | 0:bacc6e701fb4 | 170 | |
kashish_mbed | 0:bacc6e701fb4 | 171 | #ifdef __cplusplus |
kashish_mbed | 0:bacc6e701fb4 | 172 | } |
kashish_mbed | 0:bacc6e701fb4 | 173 | #endif |
kashish_mbed | 0:bacc6e701fb4 | 174 | |
kashish_mbed | 0:bacc6e701fb4 | 175 | #endif /*__STM32_LPM__H */ |
kashish_mbed | 0:bacc6e701fb4 | 176 | |
kashish_mbed | 0:bacc6e701fb4 | 177 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
kashish_mbed | 0:bacc6e701fb4 | 178 |