1 /** 2 * @file lp.h 3 * @brief Low Power(LP) function prototypes and data types. 4 */ 5 6 /****************************************************************************** 7 * 8 * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by 9 * Analog Devices, Inc.), 10 * Copyright (C) 2023-2024 Analog Devices, Inc. 11 * 12 * Licensed under the Apache License, Version 2.0 (the "License"); 13 * you may not use this file except in compliance with the License. 14 * You may obtain a copy of the License at 15 * 16 * http://www.apache.org/licenses/LICENSE-2.0 17 * 18 * Unless required by applicable law or agreed to in writing, software 19 * distributed under the License is distributed on an "AS IS" BASIS, 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 * See the License for the specific language governing permissions and 22 * limitations under the License. 23 * 24 ******************************************************************************/ 25 26 /* Define to prevent redundant inclusion */ 27 #ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX78002_LP_H_ 28 #define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX78002_LP_H_ 29 30 /* **** Includes **** */ 31 #include <stdint.h> 32 #include "pwrseq_regs.h" 33 #include "mcr_regs.h" 34 #include "gcr_regs.h" 35 #include "lpcmp.h" 36 #include "gpio.h" 37 #include "tmr.h" 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 /** 44 * @defgroup pwrseq Low Power (LP) 45 * @ingroup periphlibs 46 * @{ 47 */ 48 49 /** 50 * @brief Enumeration type for voltage selection 51 * 52 */ 53 typedef enum { MXC_LP_V0_9 = 0, MXC_LP_V1_0, MXC_LP_V1_1 } mxc_lp_ovr_t; 54 55 /** 56 * @brief Enumeration type for PM Mode 57 * 58 */ 59 typedef enum { 60 MXC_LP_IPO = MXC_F_GCR_PM_IPO_PD, 61 MXC_LP_IBRO = MXC_F_GCR_PM_IBRO_PD, 62 } mxc_lp_cfg_ds_pd_t; 63 64 /** 65 * @brief Places the device into SLEEP mode. This function returns once an RTC or external interrupt occur. 66 */ 67 void MXC_LP_EnterSleepMode(void); 68 69 /** 70 * @brief Places the device into Low Power mode. This function returns once an RTC or external interrupt occur. 71 */ 72 void MXC_LP_EnterLowPowerMode(void); 73 74 /** 75 * @brief Places the device into Micro Power mode. This function returns once an RTC or external interrupt occur. 76 */ 77 void MXC_LP_EnterMicroPowerMode(void); 78 79 /** 80 * @brief Places the device into Standby mode. This function returns once an RTC or external interrupt occur. 81 */ 82 void MXC_LP_EnterStandbyMode(void); 83 84 /** 85 * @brief Places the device into BACKUP mode. CPU state is not maintained in this mode, so this function never returns. 86 * Instead, the device will restart once an RTC or external interrupt occur. 87 */ 88 void MXC_LP_EnterBackupMode(void); 89 90 /** 91 * @brief Places the device into Shutdown mode. CPU state is not maintained in this mode, so this function never returns. 92 * Instead, the device will restart once an RTC, USB wakeup, or external interrupt occur. 93 */ 94 void MXC_LP_EnterPowerDownMode(void); 95 96 /** 97 * @brief Set ovr bits to set the voltage the micro will run at. 98 * 99 * @param[in] ovr The ovr options are only 0.9V, 1.0V, and 1.1V use enum mxc_lp_ovr_t 100 */ 101 void MXC_LP_SetOVR(mxc_lp_ovr_t ovr); 102 103 /** 104 * @brief Enable retention regulator 105 */ 106 void MXC_LP_RetentionRegEnable(void); 107 108 /** 109 * @brief Disable retention regulator 110 */ 111 void MXC_LP_RetentionRegDisable(void); 112 113 /** 114 * @brief Is the retention regulator enabled 115 * 116 * @return 1 = enabled 0 = disabled 117 */ 118 int MXC_LP_RetentionRegIsEnabled(void); 119 120 /** 121 * @brief Turn bandgap on 122 */ 123 void MXC_LP_BandgapOn(void); 124 125 /** 126 * @brief Turn bandgap off 127 */ 128 void MXC_LP_BandgapOff(void); 129 130 /** 131 * @brief Is the bandgap on or off 132 * 133 * @return 1 = bandgap on , 0 = bandgap off 134 */ 135 int MXC_LP_BandgapIsOn(void); 136 137 /** 138 * @brief Enable Power on Reset VDD Core Monitor 139 */ 140 void MXC_LP_PORVCOREoreMonitorEnable(void); 141 142 /** 143 * @brief Disable Power on Reset VDD Core Monitor 144 */ 145 void MXC_LP_PORVCOREoreMonitorDisable(void); 146 147 /** 148 * @brief Is Power on Reset VDD Core Monitor enabled 149 * 150 * @return 1 = enabled , 0 = disabled 151 */ 152 int MXC_LP_PORVCOREoreMonitorIsEnabled(void); 153 154 /** 155 * @brief Enable LDO 156 */ 157 void MXC_LP_LDOEnable(void); 158 159 /** 160 * @brief Disable LDO 161 */ 162 void MXC_LP_LDODisable(void); 163 164 /** 165 * @brief Is LDO enabled 166 * 167 * @return 1 = enabled , 0 = disabled 168 */ 169 int MXC_LP_LDOIsEnabled(void); 170 171 /** 172 * @brief Enable Fast wakeup 173 */ 174 void MXC_LP_FastWakeupEnable(void); 175 176 /** 177 * @brief Disable Fast wakeup 178 */ 179 void MXC_LP_FastWakeupDisable(void); 180 181 /** 182 * @brief Is Fast wake up is Enabled 183 * 184 * @return 1 = enabled , 0 = disabled 185 */ 186 int MXC_LP_FastWakeupIsEnabled(void); 187 188 /** 189 * @brief clear all wake up status 190 */ 191 void MXC_LP_ClearWakeStatus(void); 192 193 /** 194 * @brief Enables the selected GPIO port and its selected pins to wake up the device from any low power mode. 195 * Call this function multiple times to enable pins on multiple ports. This function does not configure 196 * the GPIO pins nor does it setup their interrupt functionality. 197 * @param wu_pins The port and pins to configure as wakeup sources. Only the gpio and mask fields of the 198 * structure are used. The func and pad fields are ignored. 199 */ 200 201 void MXC_LP_EnableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 202 203 /** 204 * @brief Disables the selected GPIO port and its selected pins as a wake up source. 205 * Call this function multiple times to disable pins on multiple ports. 206 * @param wu_pins The port and pins to disable as wakeup sources. Only the gpio and mask fields of the 207 * structure are used. The func and pad fields are ignored. 208 */ 209 void MXC_LP_DisableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 210 211 /** 212 * @brief Enables the RTC alarm to wake up the device from any low power mode. 213 */ 214 void MXC_LP_EnableRTCAlarmWakeup(void); 215 216 /** 217 * @brief Disables the RTC alarm from waking up the device. 218 */ 219 void MXC_LP_DisableRTCAlarmWakeup(void); 220 221 /** 222 * @brief Enables Timer to wakeup from any low power mode. 223 * 224 * @param tmr Pointer to timer module. 225 */ 226 void MXC_LP_EnableTimerWakeup(mxc_tmr_regs_t *tmr); 227 228 /** 229 * @brief Disables Timer from waking up device. 230 * 231 * @param tmr Pointer to timer module. 232 */ 233 void MXC_LP_DisableTimerWakeup(mxc_tmr_regs_t *tmr); 234 235 /** 236 * @brief Enables the WUT alarm to wake up the device from any low power mode. 237 */ 238 void MXC_LP_EnableWUTAlarmWakeup(void); 239 240 /** 241 * @brief Disables the WUT alarm from waking up the device. 242 */ 243 void MXC_LP_DisableWUTAlarmWakeup(void); 244 245 /** 246 * @brief Enables the LPCMP to wake up the device from any low power mode. 247 */ 248 void MXC_LP_EnableLPCMPWakeup(mxc_lpcmp_cmpsel_t cmp); 249 250 /** 251 * @brief Disables the LPCMP from waking up the device. 252 */ 253 void MXC_LP_DisableLPCMPWakeup(mxc_lpcmp_cmpsel_t cmp); 254 255 /** 256 * @brief Configure which clocks are powered down at deep sleep and which are not affected. 257 * 258 * @note Need to configure all clocks at once any clock not passed in the mask will be unaffected by Deepsleep. This will 259 * always overwrite the previous settings of ALL clocks. 260 * 261 * @param[in] mask The mask of the clocks to power down when part goes into deepsleep 262 * 263 * @return #E_NO_ERROR or error based on /ref MXC_Error_Codes 264 */ 265 int MXC_LP_ConfigDeepSleepClocks(uint32_t mask); 266 267 /** 268 * @brief Shutdown System Ram 0 269 */ 270 void MXC_LP_SysRam0Shutdown(void); 271 272 /** 273 * @brief Wakeup System Ram 0 274 */ 275 void MXC_LP_SysRam0PowerUp(void); 276 277 /** 278 * @brief Shutdown System Ram 1 279 */ 280 void MXC_LP_SysRam1Shutdown(void); 281 282 /** 283 * @brief PowerUp System Ram 1 284 */ 285 void MXC_LP_SysRam1PowerUp(void); 286 287 /** 288 * @brief Shutdown System Ram 2 289 */ 290 void MXC_LP_SysRam2Shutdown(void); 291 292 /** 293 * @brief PowerUp System Ram 2 294 */ 295 void MXC_LP_SysRam2PowerUp(void); 296 297 /** 298 * @brief Shutdown System Ram 3 299 */ 300 void MXC_LP_SysRam3Shutdown(void); 301 302 /** 303 * @brief PowerUp System Ram 3 304 */ 305 void MXC_LP_SysRam3PowerUp(void); 306 307 /**@} end of group pwrseq */ 308 309 #ifdef __cplusplus 310 } 311 #endif 312 313 #endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX78002_LP_H_ 314