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_MAX32572_LP_H_ 28 #define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32572_LP_H_ 29 30 /* **** Includes **** */ 31 #include <stdint.h> 32 #include "pwrseq_regs.h" 33 #include "mcr_regs.h" 34 #include "gpio.h" 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /** 41 * @defgroup pwrseq Low Power (LP) 42 * @ingroup periphlibs 43 * @{ 44 */ 45 46 /** 47 * @brief Enumeration type for voltage selection 48 * 49 */ 50 typedef enum { MXC_LP_V0_9 = 0, MXC_LP_V1_0, MXC_LP_V1_1 } mxc_lp_ovr_t; 51 52 /** 53 * @brief Enumeration type for PM Mode 54 * 55 */ 56 typedef enum { 57 MXC_LP_ISO = MXC_F_GCR_PM_ISO_PD, 58 MXC_LP_IPO = MXC_F_GCR_PM_IPO_PD, 59 MXC_LP_IBRO = MXC_F_GCR_PM_IBRO_PD, 60 MXC_LP_XRFO = MXC_F_GCR_PM_ERFO_PD, 61 } mxc_lp_cfg_ds_pd_t; 62 63 /** 64 * @brief Places the device into SLEEP mode. This function returns once an RTC or external interrupt occur. 65 */ 66 void MXC_LP_EnterSleepMode(void); 67 68 /** 69 * @brief Places the device into DEEPSLEEP mode. This function returns once an RTC or external interrupt occur. 70 */ 71 void MXC_LP_EnterDeepSleepMode(void); 72 73 /** 74 * @brief Places the device into BACKUP mode. CPU state is not maintained in this mode, so this function never returns. 75 * Instead, the device will restart once an RTC or external interrupt occur. 76 */ 77 void MXC_LP_EnterBackupMode(void); 78 79 /** 80 * @brief Places the device into Shutdown mode. CPU state is not maintained in this mode, so this function never returns. 81 * Instead, the device will restart once an RTC, USB wakeup, or external interrupt occur. 82 */ 83 void MXC_LP_EnterShutDownMode(void); 84 85 /** 86 * @brief Set ovr bits to set the voltage the micro will run at. 87 * 88 * @param[in] ovr The ovr options are only 0.9V, 1.0V, and 1.1V use enum mxc_lp_ovr_t 89 */ 90 void MXC_LP_SetOVR(mxc_lp_ovr_t ovr); 91 92 /** 93 * @brief Enable retention regulator 94 */ 95 void MXC_LP_RetentionRegEnable(void); 96 97 /** 98 * @brief Disable retention regulator 99 */ 100 void MXC_LP_RetentionRegDisable(void); 101 102 /** 103 * @brief Is the retention regulator enabled 104 * 105 * @return 1 = enabled 0 = disabled 106 */ 107 int MXC_LP_RetentionRegIsEnabled(void); 108 109 /** 110 * @brief Turn bandgap on 111 */ 112 void MXC_LP_BandgapOn(void); 113 114 /** 115 * @brief Turn bandgap off 116 */ 117 void MXC_LP_BandgapOff(void); 118 119 /** 120 * @brief Is the bandgap on or off 121 * 122 * @return 1 = bandgap on , 0 = bandgap off 123 */ 124 int MXC_LP_BandgapIsOn(void); 125 126 /** 127 * @brief Enable Power on Reset VDD Core Monitor 128 */ 129 void MXC_LP_PORVCOREoreMonitorEnable(void); 130 131 /** 132 * @brief Disable Power on Reset VDD Core Monitor 133 */ 134 void MXC_LP_PORVCOREoreMonitorDisable(void); 135 136 /** 137 * @brief Is Power on Reset VDD Core Monitor enabled 138 * 139 * @return 1 = enabled , 0 = disabled 140 */ 141 int MXC_LP_PORVCOREoreMonitorIsEnabled(void); 142 143 /** 144 * @brief Enable LDO 145 */ 146 void MXC_LP_LDOEnable(void); 147 148 /** 149 * @brief Disable LDO 150 */ 151 void MXC_LP_LDODisable(void); 152 153 /** 154 * @brief Is LDO enabled 155 * 156 * @return 1 = enabled , 0 = disabled 157 */ 158 int MXC_LP_LDOIsEnabled(void); 159 160 /** 161 * @brief Enable Fast wakeup 162 */ 163 void MXC_LP_FastWakeupEnable(void); 164 165 /** 166 * @brief Disable Fast wakeup 167 */ 168 void MXC_LP_FastWakeupDisable(void); 169 170 /** 171 * @brief Is Fast wake up is Enabled 172 * 173 * @return 1 = enabled , 0 = disabled 174 */ 175 int MXC_LP_FastWakeupIsEnabled(void); 176 177 /** 178 * @brief clear all wake up status 179 */ 180 void MXC_LP_ClearWakeStatus(void); 181 182 /** 183 * @brief Enables the selected GPIO port and its selected pins to wake up the device from any low power mode. 184 * Call this function multiple times to enable pins on multiple ports. This function does not configure 185 * the GPIO pins nor does it setup their interrupt functionality. 186 * @param wu_pins The port and pins to configure as wakeup sources. Only the gpio and mask fields of the 187 * structure are used. The func and pad fields are ignored. \ref mxc_gpio_cfg_t 188 */ 189 void MXC_LP_EnableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 190 191 /** 192 * @brief Disables the selected GPIO port and its selected pins as a wake up source. 193 * Call this function multiple times to disable pins on multiple ports. 194 * @param wu_pins The port and pins to disable as wakeup sources. Only the gpio and mask fields of the 195 * structure are used. The func and pad fields are ignored. \ref mxc_gpio_cfg_t 196 */ 197 void MXC_LP_DisableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 198 199 /** 200 * @brief Enables the RTC alarm to wake up the device from any low power mode. 201 */ 202 void MXC_LP_EnableRTCAlarmWakeup(void); 203 204 /** 205 * @brief Disables the RTC alarm from waking up the device. 206 */ 207 void MXC_LP_DisableRTCAlarmWakeup(void); 208 /** 209 * @brief Enables the USB to wake up the device from any low power mode. 210 */ 211 void MXC_LP_EnableUSBWakeup(void); 212 213 /** 214 * @brief Disables the USB from waking up the device. 215 */ 216 void MXC_LP_DisableUSBWakeup(void); 217 218 /** 219 * @brief Configure which clocks are powered down at deep sleep and which are not affected. 220 * 221 * @note Need to configure all clocks at once any clock not passed in the mask will be unaffected by Deepsleep. This will 222 * always overwrite the previous settings of ALL clocks. 223 * 224 * @param[in] mask The mask of the clocks to power down when part goes into deepsleep 225 * 226 * @return #E_NO_ERROR or error based on \ref MXC_Error_Codes 227 */ 228 int MXC_LP_ConfigDeepSleepClocks(uint32_t mask); 229 230 /** 231 * @brief Enable NFC Oscilator Bypass 232 */ 233 void MXC_LP_NFCOscBypassEnable(void); 234 235 /** 236 * @brief Disable NFC Oscilator Bypass 237 */ 238 void MXC_LP_NFCOscBypassDisable(void); 239 240 /** 241 * @brief Is NFC Oscilator Bypass Enabled 242 * 243 * @return 1 = enabled, 0 = disabled 244 */ 245 int MXC_LP_NFCOscBypassIsEnabled(void); 246 247 /** 248 * @brief Enable System Ram 0 in light sleep 249 */ 250 void MXC_LP_SysRam0LightSleepEnable(void); 251 252 /** 253 * @brief Enable System Ram 1 in light sleep 254 */ 255 void MXC_LP_SysRam1LightSleepEnable(void); 256 257 /** 258 * @brief Enable System Ram 2 in light sleep 259 */ 260 void MXC_LP_SysRam2LightSleepEnable(void); 261 262 /** 263 * @brief Enable System Ram 3 in light sleep 264 */ 265 void MXC_LP_SysRam3LightSleepEnable(void); 266 267 /** 268 * @brief Enable System Ram 4 in light sleep 269 */ 270 void MXC_LP_SysRam4LightSleepEnable(void); 271 272 /** 273 * @brief Enable System Ram 5 in light sleep 274 */ 275 void MXC_LP_SysRam5LightSleepEnable(void); 276 277 /** 278 * @brief Enable System Ram 6 in light sleep 279 */ 280 void MXC_LP_SysRam6LightSleepEnable(void); 281 282 /** 283 * @brief Enable Icache XIP in light sleep 284 */ 285 void MXC_LP_ICacheXIPLightSleepEnable(void); 286 287 /** 288 * @brief Enable Crypto in light sleep 289 */ 290 void MXC_LP_CryptoLightSleepEnable(void); 291 292 /** 293 * @brief Enable USB in light sleep 294 */ 295 void MXC_LP_USBFIFOLightSleepEnable(void); 296 297 /** 298 * @brief Enable ROM 0 in light sleep 299 */ 300 void MXC_LP_ROM0LightSleepEnable(void); 301 302 /** 303 * @brief Enable ROM 1 in light sleep 304 */ 305 void MXC_LP_ROM1LightSleepEnable(void); 306 307 /** 308 * @brief Enable MAA in light sleep 309 */ 310 void MXC_LP_MAALightSleepEnable(void); 311 312 /** 313 * @brief Disable System Ram 0 in light sleep 314 */ 315 void MXC_LP_SysRam0LightSleepDisable(void); 316 317 /** 318 * @brief Disable System Ram 1 in light sleep 319 */ 320 void MXC_LP_SysRam1LightSleepDisable(void); 321 322 /** 323 * @brief Disable System Ram 2 in light sleep 324 */ 325 void MXC_LP_SysRam2LightSleepDisable(void); 326 327 /** 328 * @brief Enable System Ram 4 in light sleep 329 */ 330 void MXC_LP_SysRam4LightSleepDisable(void); 331 332 /** 333 * @brief Enable System Ram 5 in light sleep 334 */ 335 void MXC_LP_SysRam5LightSleepDisable(void); 336 337 /** 338 * @brief Enable System Ram 6 in light sleep 339 */ 340 void MXC_LP_SysRam6LightSleepDisable(void); 341 342 /** 343 * @brief Disable System Ram 3 in light sleep 344 */ 345 void MXC_LP_SysRam3LightSleepDisable(void); 346 347 /** 348 * @brief Disable Icache XIP in light sleep 349 */ 350 void MXC_LP_ICacheXIPLightSleepDisable(void); 351 352 /** 353 * @brief Disable Crypto in light sleep 354 */ 355 void MXC_LP_CryptoLightSleepDisable(void); 356 357 /** 358 * @brief Disable USB in light sleep 359 */ 360 void MXC_LP_USBFIFOLightSleepDisable(void); 361 362 /** 363 * @brief Disable ROM 0 in light sleep 364 */ 365 void MXC_LP_ROM0LightSleepDisable(void); 366 367 /** 368 * @brief Disable ROM 1 in light sleep 369 */ 370 void MXC_LP_ROM1LightSleepDisable(void); 371 372 /** 373 * @brief Disable MAA in light sleep 374 */ 375 void MXC_LP_MAALightSleepDisable(void); 376 377 /** 378 * @brief Shutdown System Ram 0 379 */ 380 void MXC_LP_SysRam0Shutdown(void); 381 382 /** 383 * @brief Wakeup System Ram 0 384 */ 385 void MXC_LP_SysRam0PowerUp(void); 386 387 /** 388 * @brief Shutdown System Ram 1 389 */ 390 void MXC_LP_SysRam1Shutdown(void); 391 392 /** 393 * @brief PowerUp System Ram 1 394 */ 395 void MXC_LP_SysRam1PowerUp(void); 396 397 /** 398 * @brief Shutdown System Ram 2 399 */ 400 void MXC_LP_SysRam2Shutdown(void); 401 402 /** 403 * @brief PowerUp System Ram 2 404 */ 405 void MXC_LP_SysRam2PowerUp(void); 406 407 /** 408 * @brief Shutdown System Ram 3 409 */ 410 void MXC_LP_SysRam3Shutdown(void); 411 412 /** 413 * @brief PowerUp System Ram 3 414 */ 415 void MXC_LP_SysRam3PowerUp(void); 416 417 /** 418 * @brief Shutdown System Ram 4 419 */ 420 void MXC_LP_SysRam4Shutdown(void); 421 422 /** 423 * @brief PowerUp System Ram 4 424 */ 425 void MXC_LP_SysRam4PowerUp(void); 426 427 /** 428 * @brief Shutdown System Ram 5 429 */ 430 void MXC_LP_SysRam5Shutdown(void); 431 432 /** 433 * @brief PowerUp System Ram 5 434 */ 435 void MXC_LP_SysRam5PowerUp(void); 436 437 /** 438 * @brief Shutdown System Ram 6 439 */ 440 void MXC_LP_SysRam6Shutdown(void); 441 442 /** 443 * @brief PowerUp System Ram 6 444 */ 445 void MXC_LP_SysRam6PowerUp(void); 446 447 /** 448 * @brief Shutdown Internal Cache XIP 449 */ 450 void MXC_LP_ICacheXIPShutdown(void); 451 452 /** 453 * @brief PowerUp Internal Cache XIP 454 */ 455 void MXC_LP_ICacheXIPPowerUp(void); 456 457 /** 458 * @brief Shutdown Crypto 459 */ 460 void MXC_LP_CryptoShutdown(void); 461 462 /** 463 * @brief PowerUp Crypto 464 */ 465 void MXC_LP_CryptoPowerUp(void); 466 467 /** 468 * @brief Shutdown USB FIFO 469 */ 470 void MXC_LP_USBFIFOShutdown(void); 471 472 /** 473 * @brief PowerUp USB FIFO 474 */ 475 void MXC_LP_USBFIFOPowerUp(void); 476 477 /** 478 * @brief Shutdown ROM0 479 */ 480 void MXC_LP_ROM0Shutdown(void); 481 482 /** 483 * @brief PowerUp ROM0 484 */ 485 void MXC_LP_ROM0PowerUp(void); 486 487 /** 488 * @brief Shutdown ROM1 489 */ 490 void MXC_LP_ROM1Shutdown(void); 491 492 /** 493 * @brief PowerUp ROM1 494 */ 495 void MXC_LP_ROM1PowerUp(void); 496 497 /**@} end of group pwrseq */ 498 499 #ifdef __cplusplus 500 } 501 #endif 502 503 #endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32572_LP_H_ 504