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_MAX32675_LP_H_ 28 #define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32675_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 "gpio.h" 36 #include "tmr.h" 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /** 43 * @defgroup pwrseq Low Power (LP) 44 * @ingroup periphlibs 45 * @{ 46 */ 47 48 /** 49 * @brief Enumeration type for voltage selection 50 */ 51 typedef enum { 52 MXC_LP_OVR_0_9 = MXC_S_PWRSEQ_LPCN_OVR_0_9V, /**< OVR 0.9V */ 53 MXC_LP_OVR_1_0 = MXC_S_PWRSEQ_LPCN_OVR_1_0V, /**< OVR 1.0V */ 54 MXC_LP_OVR_1_1 = MXC_S_PWRSEQ_LPCN_OVR_1_1V, /**< OVR 1.1V */ 55 } mxc_lp_ovr_t; 56 57 /** 58 * @brief Enumeration type for PM Mode 59 * 60 */ 61 typedef enum { 62 MXC_LP_IPO = MXC_F_GCR_PM_IPO_PD, 63 MXC_LP_IBRO = MXC_F_GCR_PM_IBRO_PD, 64 MXC_LP_XRFO = MXC_F_GCR_PM_ERFO_PD 65 } mxc_lp_cfg_ds_pd_t; 66 67 /** 68 * @brief Places the device into SLEEP mode. This function returns once an RTC or external interrupt occur. 69 */ 70 void MXC_LP_EnterSleepMode(void); 71 72 /** 73 * @brief Places the device into DEEPSLEEP mode. This function returns once an RTC or external interrupt occur. 74 */ 75 void MXC_LP_EnterDeepSleepMode(void); 76 77 /** 78 * @brief Places the device into BACKUP mode. CPU state is not maintained in this mode, so this function never returns. 79 * Instead, the device will restart once an RTC or external interrupt occur. 80 */ 81 void MXC_LP_EnterBackupMode(void); 82 83 /** 84 * @brief Places the device into Storage mode. CPU state is not maintained in this mode, so this function never returns. 85 * Instead, the device will restart once an RTC or external interrupt occur. 86 */ 87 void MXC_LP_EnterStorageMode(void); 88 89 /** 90 * @brief Places the device into Shutdown mode. CPU state is not maintained in this mode, so this function never returns. 91 * Instead, the device will restart once an RTC, USB wakeup, or external interrupt occur. 92 */ 93 void MXC_LP_EnterShutDownMode(void); 94 95 /** 96 * @brief Sets the operating voltage for the device. The caller must perform the peripheral reset after 97 * calling this function. 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 * @return Success/Fail, see \ref MXC_Error_Codes for a list of return codes. 102 */ 103 int MXC_LP_SetOVR(mxc_lp_ovr_t ovr); 104 105 /** 106 * @brief Enable retention regulator 107 */ 108 void MXC_LP_RetentionRegEnable(void); 109 110 /** 111 * @brief Disable retention regulator 112 */ 113 void MXC_LP_RetentionRegDisable(void); 114 115 /** 116 * @brief Is the retention regulator enabled 117 * 118 * @return 1 = enabled 0 = disabled 119 */ 120 int MXC_LP_RetentionRegIsEnabled(void); 121 122 /** 123 * @brief Turn bandgap on 124 */ 125 void MXC_LP_BandgapOn(void); 126 127 /** 128 * @brief Turn bandgap off 129 */ 130 void MXC_LP_BandgapOff(void); 131 132 /** 133 * @brief Is the bandgap on or off 134 * 135 * @return 1 = bandgap on , 0 = bandgap off 136 */ 137 int MXC_LP_BandgapIsOn(void); 138 139 /** 140 * @brief Enable Power on Reset VDD Core Monitor 141 */ 142 void MXC_LP_PORVCOREoreMonitorEnable(void); 143 144 /** 145 * @brief Disable Power on Reset VDD Core Monitor 146 */ 147 void MXC_LP_PORVCOREoreMonitorDisable(void); 148 149 /** 150 * @brief Is Power on Reset VDD Core Monitor enabled 151 * 152 * @return 1 = enabled , 0 = disabled 153 */ 154 int MXC_LP_PORVCOREoreMonitorIsEnabled(void); 155 156 /** 157 * @brief Enable LDO 158 */ 159 void MXC_LP_LDOEnable(void); 160 161 /** 162 * @brief Disable LDO 163 */ 164 void MXC_LP_LDODisable(void); 165 166 /** 167 * @brief Is LDO enabled 168 * 169 * @return 1 = enabled , 0 = disabled 170 */ 171 int MXC_LP_LDOIsEnabled(void); 172 173 /** 174 * @brief Enable Fast wakeup 175 */ 176 void MXC_LP_FastWakeupEnable(void); 177 178 /** 179 * @brief Disable Fast wakeup 180 */ 181 void MXC_LP_FastWakeupDisable(void); 182 183 /** 184 * @brief Is Fast wake up is Enabled 185 * 186 * @return 1 = enabled , 0 = disabled 187 */ 188 int MXC_LP_FastWakeupIsEnabled(void); 189 190 /** 191 * @brief clear all wake up status 192 */ 193 void MXC_LP_ClearWakeStatus(void); 194 195 /** 196 * @brief Enables the selected GPIO port and its selected pins to wake up the device from any low power mode. 197 * Call this function multiple times to enable pins on multiple ports. This function does not configure 198 * the GPIO pins nor does it setup their interrupt functionality. 199 * @param wu_pins The port and pins to configure as wakeup sources. Only the gpio and mask fields of the 200 * structure are used. The func and pad fields are ignored. \ref mxc_gpio_cfg_t 201 */ 202 void MXC_LP_EnableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 203 204 /** 205 * @brief Disables the selected GPIO port and its selected pins as a wake up source. 206 * Call this function multiple times to disable pins on multiple ports. 207 * @param wu_pins The port and pins to disable as wakeup sources. Only the gpio and mask fields of the 208 * structure are used. The func and pad fields are ignored. \ref mxc_gpio_cfg_t 209 */ 210 void MXC_LP_DisableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 211 212 /** 213 * @brief Enables the RTC alarm to wake up the device from any low power mode. 214 */ 215 void MXC_LP_EnableRTCAlarmWakeup(void); 216 217 /** 218 * @brief Disables the RTC alarm from waking up the device. 219 */ 220 void MXC_LP_DisableRTCAlarmWakeup(void); 221 222 /** 223 * @brief Enables Timer to wakeup from any low power mode. 224 * 225 * @param tmr Pointer to timer module. 226 */ 227 void MXC_LP_EnableTimerWakeup(mxc_tmr_regs_t *tmr); 228 229 /** 230 * @brief Disables Timer from waking up device. 231 * 232 * @param tmr Pointer to timer module. 233 */ 234 void MXC_LP_DisableTimerWakeup(mxc_tmr_regs_t *tmr); 235 236 /** 237 * @brief Enables the USB to wake up the device from any low power mode. 238 */ 239 void MXC_LP_EnableUSBWakeup(void); 240 241 /** 242 * @brief Disables the USB from waking up the device. 243 */ 244 void MXC_LP_DisableUSBWakeup(void); 245 246 /** 247 * @brief Enables the HA0 to wake up the device from any low power mode. 248 */ 249 void MXC_LP_EnableHA0Wakeup(void); 250 251 /** 252 * @brief Disables the HA)0 from waking up the device. 253 */ 254 void MXC_LP_DisableHA0Wakeup(void); 255 /** 256 * @brief Enables the HA1 to wake up the device from any low power mode. 257 */ 258 void MXC_LP_EnableHA1Wakeup(void); 259 260 /** 261 * @brief Disables the HA1 from waking up the device. 262 */ 263 void MXC_LP_DisableHA1Wakeup(void); 264 265 /** 266 * @brief Configure which clocks are powered down at deep sleep and which are not affected. 267 * 268 * @note Need to configure all clocks at once any clock not passed in the mask will be unaffected by Deepsleep. This will 269 * always overwrite the previous settings of ALL clocks. 270 * 271 * @param[in] mask The mask of the clocks to power down when part goes into deepsleep 272 * 273 * @return #E_NO_ERROR or error based on \ref MXC_Error_Codes 274 */ 275 int MXC_LP_ConfigDeepSleepClocks(uint32_t mask); 276 277 /** 278 * @brief Enable NFC Oscilator Bypass 279 */ 280 void MXC_LP_NFCOscBypassEnable(void); 281 282 /** 283 * @brief Disable NFC Oscilator Bypass 284 */ 285 void MXC_LP_NFCOscBypassDisable(void); 286 287 /** 288 * @brief Is NFC Oscilator Bypass Enabled 289 * 290 * @return 1 = enabled, 0 = disabled 291 */ 292 int MXC_LP_NFCOscBypassIsEnabled(void); 293 294 /** 295 * @brief Enable System Ram 0 in light sleep 296 */ 297 void MXC_LP_SysRam0LightSleepEnable(void); 298 299 /** 300 * @brief Enable System Ram 1 in light sleep 301 */ 302 void MXC_LP_SysRam1LightSleepEnable(void); 303 304 /** 305 * @brief Enable System Ram 2 in light sleep 306 */ 307 void MXC_LP_SysRam2LightSleepEnable(void); 308 309 /** 310 * @brief Enable System Ram 3 in light sleep 311 */ 312 void MXC_LP_SysRam3LightSleepEnable(void); 313 314 /** 315 * @brief Enable Icache 0 in light sleep 316 */ 317 void MXC_LP_ICache0LightSleepEnable(void); 318 319 /** 320 * @brief Enable ROM 0 in light sleep 321 */ 322 void MXC_LP_ROMLightSleepEnable(void); 323 324 /** 325 * @brief Disable System Ram 0 in light sleep 326 */ 327 void MXC_LP_SysRam0LightSleepDisable(void); 328 329 /** 330 * @brief Disable System Ram 1 in light sleep 331 */ 332 void MXC_LP_SysRam1LightSleepDisable(void); 333 334 /** 335 * @brief Disable System Ram 2 in light sleep 336 */ 337 void MXC_LP_SysRam2LightSleepDisable(void); 338 339 /** 340 * @brief Disable System Ram 3 in light sleep 341 */ 342 void MXC_LP_SysRam3LightSleepDisable(void); 343 344 /** 345 * @brief Disable Icache 0 in light sleep 346 */ 347 void MXC_LP_ICache0LightSleepDisable(void); 348 349 /** 350 * @brief Disable ROM 0 in light sleep 351 */ 352 void MXC_LP_ROMLightSleepDisable(void); 353 354 /** 355 * @brief Shutdown System Ram 0 356 */ 357 void MXC_LP_SysRam0Shutdown(void); 358 359 /** 360 * @brief Wakeup System Ram 0 361 */ 362 void MXC_LP_SysRam0PowerUp(void); 363 364 /** 365 * @brief Shutdown System Ram 1 366 */ 367 void MXC_LP_SysRam1Shutdown(void); 368 369 /** 370 * @brief PowerUp System Ram 1 371 */ 372 void MXC_LP_SysRam1PowerUp(void); 373 374 /** 375 * @brief Shutdown System Ram 2 376 */ 377 void MXC_LP_SysRam2Shutdown(void); 378 379 /** 380 * @brief PowerUp System Ram 2 381 */ 382 void MXC_LP_SysRam2PowerUp(void); 383 384 /** 385 * @brief Shutdown System Ram 3 386 */ 387 void MXC_LP_SysRam3Shutdown(void); 388 389 /** 390 * @brief PowerUp System Ram 3 391 */ 392 void MXC_LP_SysRam3PowerUp(void); 393 394 /**@} end of group pwrseq */ 395 396 #ifdef __cplusplus 397 } 398 #endif 399 400 #endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32675_LP_H_ 401