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_MAX32690_LP_H_ 28 #define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32690_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 "lpcmp.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 Places the device into SLEEP mode. This function returns once an RTC or external interrupt occur. 57 */ 58 void MXC_LP_EnterSleepMode(void); 59 60 /** 61 * @brief Places the device into Low Power mode. This function returns once an RTC or external interrupt occur. 62 */ 63 void MXC_LP_EnterLowPowerMode(void); 64 65 /** 66 * @brief Places the device into Micro Power mode. This function returns once an RTC or external interrupt occur. 67 */ 68 void MXC_LP_EnterMicroPowerMode(void); 69 70 /** 71 * @brief Places the device into Standby mode. This function returns once an RTC or external interrupt occur. 72 */ 73 void MXC_LP_EnterStandbyMode(void); 74 75 /** 76 * @brief Places the device into BACKUP mode. CPU state is not maintained in this mode, so this function never returns. 77 * Instead, the device will restart once an RTC or external interrupt occur. 78 */ 79 void MXC_LP_EnterBackupMode(void); 80 81 /** 82 * @brief Places the device into Shutdown mode. CPU state is not maintained in this mode, so this function never returns. 83 * Instead, the device will restart once an RTC, USB wakeup, or external interrupt occur. 84 */ 85 void MXC_LP_EnterPowerDownMode(void); 86 87 /** 88 * @brief Set ovr bits to set the voltage the micro will run at. 89 * 90 * @param[in] ovr The ovr options are only 0.9V, 1.0V, and 1.1V use enum mxc_lp_ovr_t 91 */ 92 void MXC_LP_SetOVR(mxc_lp_ovr_t ovr); 93 94 /** 95 * @brief Turn bandgap on 96 */ 97 void MXC_LP_BandgapOn(void); 98 99 /** 100 * @brief Turn bandgap off 101 */ 102 void MXC_LP_BandgapOff(void); 103 104 /** 105 * @brief Is the bandgap on or off 106 * 107 * @return 1 = bandgap on , 0 = bandgap off 108 */ 109 int MXC_LP_BandgapIsOn(void); 110 111 /** 112 * @brief clear all wake up status 113 */ 114 void MXC_LP_ClearWakeStatus(void); 115 116 /** 117 * @brief Enables the selected GPIO port and its selected pins to wake up the device from any low power mode. 118 * Call this function multiple times to enable pins on multiple ports. This function does not configure 119 * the GPIO pins nor does it setup their interrupt functionality. 120 * @param wu_pins The port and pins to configure as wakeup sources. Only the gpio and mask fields of the 121 * structure are used. The func and pad fields are ignored. 122 */ 123 124 void MXC_LP_EnableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 125 126 /** 127 * @brief Disables the selected GPIO port and its selected pins as a wake up source. 128 * Call this function multiple times to disable pins on multiple ports. 129 * @param wu_pins The port and pins to disable as wakeup sources. Only the gpio and mask fields of the 130 * structure are used. The func and pad fields are ignored. 131 */ 132 void MXC_LP_DisableGPIOWakeup(mxc_gpio_cfg_t *wu_pins); 133 134 /** 135 * @brief Enables the RTC alarm to wake up the device from any low power mode. 136 */ 137 void MXC_LP_EnableRTCAlarmWakeup(void); 138 139 /** 140 * @brief Disables the RTC alarm from waking up the device. 141 */ 142 void MXC_LP_DisableRTCAlarmWakeup(void); 143 144 /** 145 * @brief Enables Timer to wakeup from any low power mode. 146 * 147 * @param tmr Pointer to timer module. 148 */ 149 void MXC_LP_EnableTimerWakeup(mxc_tmr_regs_t *tmr); 150 151 /** 152 * @brief Disables Timer from waking up device. 153 * 154 * @param tmr Pointer to timer module. 155 */ 156 void MXC_LP_DisableTimerWakeup(mxc_tmr_regs_t *tmr); 157 158 /** 159 * @brief Enables the WUT alarm to wake up the device from any low power mode. 160 */ 161 void MXC_LP_EnableWUTAlarmWakeup(void); 162 163 /** 164 * @brief Disables the WUT alarm from waking up the device. 165 */ 166 void MXC_LP_DisableWUTAlarmWakeup(void); 167 168 /** 169 * @brief Enables the comparators to wake up the device from any low power mode. 170 * 171 * @param cmp Selects the comparator to enable wakeup events for 172 */ 173 void MXC_LP_EnableLPCMPWakeup(mxc_lpcmp_cmpsel_t cmp); 174 175 /** 176 * @brief Disables the comparators from waking up the device. 177 * 178 * @param cmp Selects the comparator to disable wakeup events for 179 */ 180 void MXC_LP_DisableLPCMPWakeup(mxc_lpcmp_cmpsel_t cmp); 181 182 /** 183 * @brief Enables CAN to wake up the device from any low power mode. 184 * 185 * @param can_idx Selects which CAN instance to enable wakeup events for 186 */ 187 void MXC_LP_EnableCANWakeup(uint32_t can_idx); 188 189 /** 190 * @brief Disables CAN from waking up the device. 191 * 192 * @param can_idx Selects which CAN instance to disable wakeup events for 193 */ 194 void MXC_LP_DisableCANWakeup(uint32_t can_idx); 195 196 /** 197 * @brief Configure which clocks are powered down at deep sleep and which are not affected. 198 * 199 * @note Need to configure all clocks at once any clock not passed in the mask will be unaffected by Deepsleep. This will 200 * always overwrite the previous settings of ALL clocks. 201 * 202 * @param[in] mask The mask of the clocks to power down when part goes into deepsleep 203 * 204 * @return #E_NO_ERROR or error based on /ref MXC_Error_Codes 205 */ 206 int MXC_LP_ConfigDeepSleepClocks(uint32_t mask); 207 208 /**@} end of group pwrseq */ 209 210 #ifdef __cplusplus 211 } 212 #endif 213 214 #endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32690_LP_H_ 215