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_MAX32655_LP_H_ 28 #define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32655_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 Turn bandgap on 105 */ 106 void MXC_LP_BandgapOn(void); 107 108 /** 109 * @brief Turn bandgap off 110 */ 111 void MXC_LP_BandgapOff(void); 112 113 /** 114 * @brief Is the bandgap on or off 115 * 116 * @return 1 = bandgap on , 0 = bandgap off 117 */ 118 int MXC_LP_BandgapIsOn(void); 119 120 /** 121 * @brief clear all wake up status 122 */ 123 void MXC_LP_ClearWakeStatus(void); 124 125 /** 126 * @brief Enables the selected GPIO port and its selected pins to wake up the device from any low power mode. 127 * Call this function multiple times to enable pins on multiple ports. This function does not configure 128 * the GPIO pins nor does it setup their interrupt functionality. 129 * @param wu_pins The port and pins to configure as wakeup sources. Only the gpio and mask fields of the 130 * structure are used. The func and pad fields are ignored. 131 */ 132 133 void MXC_LP_EnableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 134 135 /** 136 * @brief Disables the selected GPIO port and its selected pins as a wake up source. 137 * Call this function multiple times to disable pins on multiple ports. 138 * @param wu_pins The port and pins to disable as wakeup sources. Only the gpio and mask fields of the 139 * structure are used. The func and pad fields are ignored. 140 */ 141 void MXC_LP_DisableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 142 143 /** 144 * @brief Enables the RTC alarm to wake up the device from any low power mode. 145 */ 146 void MXC_LP_EnableRTCAlarmWakeup(void); 147 148 /** 149 * @brief Disables the RTC alarm from waking up the device. 150 */ 151 void MXC_LP_DisableRTCAlarmWakeup(void); 152 153 /** 154 * @brief Enables Timer to wakeup from any low power mode. 155 * 156 * @param tmr Pointer to timer module. 157 */ 158 void MXC_LP_EnableTimerWakeup(mxc_tmr_regs_t *tmr); 159 160 /** 161 * @brief Disables Timer from waking up device. 162 * 163 * @param tmr Pointer to timer module. 164 */ 165 void MXC_LP_DisableTimerWakeup(mxc_tmr_regs_t *tmr); 166 167 /** 168 * @brief Enables the USB to wake up the device from any low power mode. 169 */ 170 void MXC_LP_EnableUSBWakeup(void); 171 172 /** 173 * @brief Disables the USB from waking up the device. 174 */ 175 void MXC_LP_DisableUSBWakeup(void); 176 177 /** 178 * @brief Enables the WUT alarm to wake up the device from any low power mode. 179 */ 180 void MXC_LP_EnableWUTAlarmWakeup(void); 181 182 /** 183 * @brief Disables the WUT alarm from waking up the device. 184 */ 185 void MXC_LP_DisableWUTAlarmWakeup(void); 186 187 /** 188 * @brief Enables the LPCMP to wake up the device from any low power mode. 189 */ 190 void MXC_LP_EnableLPCMPWakeup(mxc_lpcmp_cmpsel_t cmp); 191 192 /** 193 * @brief Disables the LPCMP from waking up the device. 194 */ 195 void MXC_LP_DisableLPCMPWakeup(mxc_lpcmp_cmpsel_t cmp); 196 197 /** 198 * @brief Enables the HA0 to wake up the device from any low power mode. 199 */ 200 void MXC_LP_EnableHA0Wakeup(void); 201 202 /** 203 * @brief Disables the HA)0 from waking up the device. 204 */ 205 void MXC_LP_DisableHA0Wakeup(void); 206 /** 207 * @brief Enables the HA1 to wake up the device from any low power mode. 208 */ 209 void MXC_LP_EnableHA1Wakeup(void); 210 211 /** 212 * @brief Disables the HA1 from waking up the device. 213 */ 214 void MXC_LP_DisableHA1Wakeup(void); 215 216 /** 217 * @brief Configure which clocks are powered down at deep sleep and which are not affected. 218 * 219 * @note Need to configure all clocks at once any clock not passed in the mask will be unaffected by Deepsleep. This will 220 * always overwrite the previous settings of ALL clocks. 221 * 222 * @param[in] mask The mask of the clocks to power down when part goes into deepsleep 223 * 224 * @return #E_NO_ERROR or error based on /ref MXC_Error_Codes 225 */ 226 int MXC_LP_ConfigDeepSleepClocks(uint32_t mask); 227 228 /** 229 * @brief Enable NFC Oscilator Bypass 230 */ 231 void MXC_LP_NFCOscBypassEnable(void); 232 233 /** 234 * @brief Disable NFC Oscilator Bypass 235 */ 236 void MXC_LP_NFCOscBypassDisable(void); 237 238 /** 239 * @brief Is NFC Oscilator Bypass Enabled 240 * 241 * @return 1 = enabled, 0 = disabled 242 */ 243 int MXC_LP_NFCOscBypassIsEnabled(void); 244 245 /**@} end of group pwrseq */ 246 247 #ifdef __cplusplus 248 } 249 #endif 250 251 #endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32655_LP_H_ 252