1*5fd0122aSMatthias Ringwald /* --COPYRIGHT--,BSD 2*5fd0122aSMatthias Ringwald * Copyright (c) 2017, Texas Instruments Incorporated 3*5fd0122aSMatthias Ringwald * All rights reserved. 4*5fd0122aSMatthias Ringwald * 5*5fd0122aSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 6*5fd0122aSMatthias Ringwald * modification, are permitted provided that the following conditions 7*5fd0122aSMatthias Ringwald * are met: 8*5fd0122aSMatthias Ringwald * 9*5fd0122aSMatthias Ringwald * * Redistributions of source code must retain the above copyright 10*5fd0122aSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 11*5fd0122aSMatthias Ringwald * 12*5fd0122aSMatthias Ringwald * * Redistributions in binary form must reproduce the above copyright 13*5fd0122aSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 14*5fd0122aSMatthias Ringwald * documentation and/or other materials provided with the distribution. 15*5fd0122aSMatthias Ringwald * 16*5fd0122aSMatthias Ringwald * * Neither the name of Texas Instruments Incorporated nor the names of 17*5fd0122aSMatthias Ringwald * its contributors may be used to endorse or promote products derived 18*5fd0122aSMatthias Ringwald * from this software without specific prior written permission. 19*5fd0122aSMatthias Ringwald * 20*5fd0122aSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21*5fd0122aSMatthias Ringwald * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22*5fd0122aSMatthias Ringwald * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23*5fd0122aSMatthias Ringwald * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24*5fd0122aSMatthias Ringwald * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25*5fd0122aSMatthias Ringwald * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26*5fd0122aSMatthias Ringwald * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27*5fd0122aSMatthias Ringwald * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28*5fd0122aSMatthias Ringwald * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29*5fd0122aSMatthias Ringwald * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30*5fd0122aSMatthias Ringwald * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*5fd0122aSMatthias Ringwald * --/COPYRIGHT--*/ 32*5fd0122aSMatthias Ringwald #ifndef __PCM_H__ 33*5fd0122aSMatthias Ringwald #define __PCM_H__ 34*5fd0122aSMatthias Ringwald 35*5fd0122aSMatthias Ringwald //***************************************************************************** 36*5fd0122aSMatthias Ringwald // 37*5fd0122aSMatthias Ringwald //! \addtogroup pcm_api 38*5fd0122aSMatthias Ringwald //! @{ 39*5fd0122aSMatthias Ringwald // 40*5fd0122aSMatthias Ringwald //***************************************************************************** 41*5fd0122aSMatthias Ringwald 42*5fd0122aSMatthias Ringwald //***************************************************************************** 43*5fd0122aSMatthias Ringwald // 44*5fd0122aSMatthias Ringwald // If building with a C++ compiler, make all of the definitions in this header 45*5fd0122aSMatthias Ringwald // have a C binding. 46*5fd0122aSMatthias Ringwald // 47*5fd0122aSMatthias Ringwald //***************************************************************************** 48*5fd0122aSMatthias Ringwald #ifdef __cplusplus 49*5fd0122aSMatthias Ringwald extern "C" 50*5fd0122aSMatthias Ringwald { 51*5fd0122aSMatthias Ringwald #endif 52*5fd0122aSMatthias Ringwald 53*5fd0122aSMatthias Ringwald #include <stdint.h> 54*5fd0122aSMatthias Ringwald #include <stdbool.h> 55*5fd0122aSMatthias Ringwald #include <ti/devices/msp432p4xx/inc/msp.h> 56*5fd0122aSMatthias Ringwald 57*5fd0122aSMatthias Ringwald //***************************************************************************** 58*5fd0122aSMatthias Ringwald // 59*5fd0122aSMatthias Ringwald // Control specific variables 60*5fd0122aSMatthias Ringwald // 61*5fd0122aSMatthias Ringwald //***************************************************************************** 62*5fd0122aSMatthias Ringwald #define PCM_KEY 0x695A0000 63*5fd0122aSMatthias Ringwald 64*5fd0122aSMatthias Ringwald /* Power Modes */ 65*5fd0122aSMatthias Ringwald #define PCM_AM_LDO_VCORE0 0x00 66*5fd0122aSMatthias Ringwald #define PCM_AM_LDO_VCORE1 0x01 67*5fd0122aSMatthias Ringwald #define PCM_AM_DCDC_VCORE0 0x04 68*5fd0122aSMatthias Ringwald #define PCM_AM_DCDC_VCORE1 0x05 69*5fd0122aSMatthias Ringwald #define PCM_AM_LF_VCORE0 0x08 70*5fd0122aSMatthias Ringwald #define PCM_AM_LF_VCORE1 0x09 71*5fd0122aSMatthias Ringwald #define PCM_LPM0_LDO_VCORE0 0x10 72*5fd0122aSMatthias Ringwald #define PCM_LPM0_LDO_VCORE1 0x11 73*5fd0122aSMatthias Ringwald #define PCM_LPM0_DCDC_VCORE0 0x14 74*5fd0122aSMatthias Ringwald #define PCM_LPM0_DCDC_VCORE1 0x15 75*5fd0122aSMatthias Ringwald #define PCM_LPM0_LF_VCORE0 0x18 76*5fd0122aSMatthias Ringwald #define PCM_LPM0_LF_VCORE1 0x19 77*5fd0122aSMatthias Ringwald #define PCM_LPM3 0x20 78*5fd0122aSMatthias Ringwald #define PCM_LPM4 0x21 79*5fd0122aSMatthias Ringwald #define PCM_LPM35_VCORE0 0xC0 80*5fd0122aSMatthias Ringwald #define PCM_LPM45 0xA0 81*5fd0122aSMatthias Ringwald 82*5fd0122aSMatthias Ringwald #define PCM_VCORE0 0x00 83*5fd0122aSMatthias Ringwald #define PCM_VCORE1 0x01 84*5fd0122aSMatthias Ringwald #define PCM_VCORELPM3 0x02 85*5fd0122aSMatthias Ringwald 86*5fd0122aSMatthias Ringwald #define PCM_LDO_MODE 0x00 87*5fd0122aSMatthias Ringwald #define PCM_DCDC_MODE 0x01 88*5fd0122aSMatthias Ringwald #define PCM_LF_MODE 0x02 89*5fd0122aSMatthias Ringwald 90*5fd0122aSMatthias Ringwald #define PCM_SHUTDOWN_PARTIAL PCM_LPM35_VCORE0 91*5fd0122aSMatthias Ringwald #define PCM_SHUTDOWN_COMPLETE PCM_LPM45 92*5fd0122aSMatthias Ringwald 93*5fd0122aSMatthias Ringwald #define PCM_DCDCERROR PCM_IE_DCDC_ERROR_IE 94*5fd0122aSMatthias Ringwald #define PCM_AM_INVALIDTRANSITION PCM_IE_AM_INVALID_TR_IE 95*5fd0122aSMatthias Ringwald #define PCM_SM_INVALIDCLOCK PCM_IE_LPM_INVALID_CLK_IE 96*5fd0122aSMatthias Ringwald #define PCM_SM_INVALIDTRANSITION PCM_IE_LPM_INVALID_TR_IE 97*5fd0122aSMatthias Ringwald 98*5fd0122aSMatthias Ringwald //***************************************************************************** 99*5fd0122aSMatthias Ringwald // 100*5fd0122aSMatthias Ringwald // Prototypes for the APIs. 101*5fd0122aSMatthias Ringwald // 102*5fd0122aSMatthias Ringwald //***************************************************************************** 103*5fd0122aSMatthias Ringwald 104*5fd0122aSMatthias Ringwald //****************************************************************************** 105*5fd0122aSMatthias Ringwald // 106*5fd0122aSMatthias Ringwald //! Sets the core voltage level (Vcore). The function will take care of all 107*5fd0122aSMatthias Ringwald //! power state transitions needed to shift between core voltage levels. 108*5fd0122aSMatthias Ringwald //! Because transitions between voltage levels may require changes power modes, 109*5fd0122aSMatthias Ringwald //! the power mode might temporarily be change. The power mode will be returned 110*5fd0122aSMatthias Ringwald //! to the original state (with the new voltage level) at the end of a 111*5fd0122aSMatthias Ringwald //! successful execution of this function. 112*5fd0122aSMatthias Ringwald //! 113*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about core voltage 114*5fd0122aSMatthias Ringwald //! levels. 115*5fd0122aSMatthias Ringwald //! 116*5fd0122aSMatthias Ringwald //! \param voltageLevel The voltage level to be shifted to. 117*5fd0122aSMatthias Ringwald //! - \b PCM_VCORE0, 118*5fd0122aSMatthias Ringwald //! - \b PCM_VCORE1 119*5fd0122aSMatthias Ringwald //! 120*5fd0122aSMatthias Ringwald //! \return true if voltage level set, false otherwise. 121*5fd0122aSMatthias Ringwald // 122*5fd0122aSMatthias Ringwald //****************************************************************************** 123*5fd0122aSMatthias Ringwald extern bool PCM_setCoreVoltageLevel(uint_fast8_t voltageLevel); 124*5fd0122aSMatthias Ringwald 125*5fd0122aSMatthias Ringwald //****************************************************************************** 126*5fd0122aSMatthias Ringwald // 127*5fd0122aSMatthias Ringwald //! Returns the current powers state of the system see the 128*5fd0122aSMatthias Ringwald //! PCM_setCoreVoltageLevel function for specific information about the modes. 129*5fd0122aSMatthias Ringwald //! 130*5fd0122aSMatthias Ringwald //! \return The current voltage of the system 131*5fd0122aSMatthias Ringwald //! 132*5fd0122aSMatthias Ringwald //! Possible return values include: 133*5fd0122aSMatthias Ringwald //! - \b PCM_VCORE0 134*5fd0122aSMatthias Ringwald //! - \b PCM_VCORE1 135*5fd0122aSMatthias Ringwald //! - \b PCM_VCORELPM3 136*5fd0122aSMatthias Ringwald //! 137*5fd0122aSMatthias Ringwald // 138*5fd0122aSMatthias Ringwald //****************************************************************************** 139*5fd0122aSMatthias Ringwald extern uint8_t PCM_getCoreVoltageLevel(void); 140*5fd0122aSMatthias Ringwald 141*5fd0122aSMatthias Ringwald //****************************************************************************** 142*5fd0122aSMatthias Ringwald // 143*5fd0122aSMatthias Ringwald //! Sets the core voltage level (Vcore). This function will take care of all 144*5fd0122aSMatthias Ringwald //! power state transitions needed to shift between core voltage levels. 145*5fd0122aSMatthias Ringwald //! Because transitions between voltage levels may require changes power modes, 146*5fd0122aSMatthias Ringwald //! the power mode might temporarily be change. The power mode will be returned 147*5fd0122aSMatthias Ringwald //! to the original state (with the new voltage level) at the end of a 148*5fd0122aSMatthias Ringwald //! successful execution of this function. 149*5fd0122aSMatthias Ringwald //! 150*5fd0122aSMatthias Ringwald //! This function is similar to PCMSetCoreVoltageLevel, however a timeout 151*5fd0122aSMatthias Ringwald //! mechanism is used. 152*5fd0122aSMatthias Ringwald //! 153*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about core voltage 154*5fd0122aSMatthias Ringwald //! levels. 155*5fd0122aSMatthias Ringwald //! 156*5fd0122aSMatthias Ringwald //! \param voltageLevel The voltage level to be shifted to. 157*5fd0122aSMatthias Ringwald //! - \b PCM_VCORE0, 158*5fd0122aSMatthias Ringwald //! - \b PCM_VCORE1 159*5fd0122aSMatthias Ringwald //! 160*5fd0122aSMatthias Ringwald //! \param timeOut Number of loop iterations to timeout when checking for 161*5fd0122aSMatthias Ringwald //! power state transitions. This should be used for debugging initial 162*5fd0122aSMatthias Ringwald //! power/hardware configurations. After a stable hardware base is 163*5fd0122aSMatthias Ringwald //! established, the PCMSetCoreVoltageLevel function should be used 164*5fd0122aSMatthias Ringwald //! 165*5fd0122aSMatthias Ringwald //! \return true if voltage level set, false otherwise. 166*5fd0122aSMatthias Ringwald // 167*5fd0122aSMatthias Ringwald //****************************************************************************** 168*5fd0122aSMatthias Ringwald extern bool PCM_setCoreVoltageLevelWithTimeout(uint_fast8_t voltageLevel, 169*5fd0122aSMatthias Ringwald uint32_t timeOut); 170*5fd0122aSMatthias Ringwald 171*5fd0122aSMatthias Ringwald //****************************************************************************** 172*5fd0122aSMatthias Ringwald // 173*5fd0122aSMatthias Ringwald //! Sets the core voltage level (Vcore). This function is similar to 174*5fd0122aSMatthias Ringwald //! PCM_setCoreVoltageLevel, however there are no polling flags to ensure 175*5fd0122aSMatthias Ringwald //! a state has changed. Execution is returned back to the calling program 176*5fd0122aSMatthias Ringwald // and it is up to the user to ensure proper state transitions happen 177*5fd0122aSMatthias Ringwald //! correctly. For MSP432, changing into different power modes/states 178*5fd0122aSMatthias Ringwald //! require very specific logic. This function will initiate only one state 179*5fd0122aSMatthias Ringwald //! transition and then return. It is up to the user to keep calling this 180*5fd0122aSMatthias Ringwald //! function until the correct power state has been achieved. 181*5fd0122aSMatthias Ringwald //! 182*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about core voltage 183*5fd0122aSMatthias Ringwald //! levels. 184*5fd0122aSMatthias Ringwald //! 185*5fd0122aSMatthias Ringwald //! \param voltageLevel The voltage level to be shifted to. 186*5fd0122aSMatthias Ringwald //! - \b PCM_VCORE0, 187*5fd0122aSMatthias Ringwald //! - \b PCM_VCORE1 188*5fd0122aSMatthias Ringwald //! 189*5fd0122aSMatthias Ringwald //! \return true if voltage level set, false otherwise. 190*5fd0122aSMatthias Ringwald // 191*5fd0122aSMatthias Ringwald //****************************************************************************** 192*5fd0122aSMatthias Ringwald extern bool PCM_setCoreVoltageLevelNonBlocking(uint_fast8_t voltageLevel); 193*5fd0122aSMatthias Ringwald 194*5fd0122aSMatthias Ringwald //****************************************************************************** 195*5fd0122aSMatthias Ringwald // 196*5fd0122aSMatthias Ringwald //! Switches between power modes. This function will take care of all 197*5fd0122aSMatthias Ringwald //! power state transitions needed to shift between power modes. Note for 198*5fd0122aSMatthias Ringwald //! changing to DCDC mode, specific hardware considerations are required. 199*5fd0122aSMatthias Ringwald //! 200*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about power modes. 201*5fd0122aSMatthias Ringwald //! 202*5fd0122aSMatthias Ringwald //! \param powerMode The voltage modes to be shifted to. Valid values are: 203*5fd0122aSMatthias Ringwald //! - \b PCM_LDO_MODE, 204*5fd0122aSMatthias Ringwald //! - \b PCM_DCDC_MODE, 205*5fd0122aSMatthias Ringwald //! - \b PCM_LF_MODE 206*5fd0122aSMatthias Ringwald //! 207*5fd0122aSMatthias Ringwald //! \return true if power mode is set, false otherwise. 208*5fd0122aSMatthias Ringwald // 209*5fd0122aSMatthias Ringwald //****************************************************************************** 210*5fd0122aSMatthias Ringwald extern bool PCM_setPowerMode(uint_fast8_t powerMode); 211*5fd0122aSMatthias Ringwald 212*5fd0122aSMatthias Ringwald //****************************************************************************** 213*5fd0122aSMatthias Ringwald // 214*5fd0122aSMatthias Ringwald //! Switches between power modes. This function will take care of all 215*5fd0122aSMatthias Ringwald //! power state transitions needed to shift between power modes. Note for 216*5fd0122aSMatthias Ringwald //! changing to DCDC mode, specific hardware considerations are required. 217*5fd0122aSMatthias Ringwald //! 218*5fd0122aSMatthias Ringwald //! This function is similar to PCMSetPowerMode, however a timeout 219*5fd0122aSMatthias Ringwald //! mechanism is used. 220*5fd0122aSMatthias Ringwald //! 221*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about power modes. 222*5fd0122aSMatthias Ringwald //! 223*5fd0122aSMatthias Ringwald //! \param powerMode The voltage modes to be shifted to. Valid values are: 224*5fd0122aSMatthias Ringwald //! - \b PCM_LDO_MODE, 225*5fd0122aSMatthias Ringwald //! - \b PCM_DCDC_MODE, 226*5fd0122aSMatthias Ringwald //! - \b PCM_LF_MODE 227*5fd0122aSMatthias Ringwald //! 228*5fd0122aSMatthias Ringwald //! \param timeOut Number of loop iterations to timeout when checking for 229*5fd0122aSMatthias Ringwald //! power state transitions. This should be used for debugging initial 230*5fd0122aSMatthias Ringwald //! power/hardware configurations. After a stable hardware base is 231*5fd0122aSMatthias Ringwald //! established, the PCMSetPowerMode function should be used 232*5fd0122aSMatthias Ringwald //! 233*5fd0122aSMatthias Ringwald //! \return true if power mode is set, false otherwise. 234*5fd0122aSMatthias Ringwald // 235*5fd0122aSMatthias Ringwald //****************************************************************************** 236*5fd0122aSMatthias Ringwald extern bool PCM_setPowerModeWithTimeout(uint_fast8_t powerMode, 237*5fd0122aSMatthias Ringwald uint32_t timeOut); 238*5fd0122aSMatthias Ringwald 239*5fd0122aSMatthias Ringwald //****************************************************************************** 240*5fd0122aSMatthias Ringwald // 241*5fd0122aSMatthias Ringwald //! Sets the core voltage level (Vcore). This function is similar to 242*5fd0122aSMatthias Ringwald //! PCM_setPowerMode, however there are no polling flags to ensure 243*5fd0122aSMatthias Ringwald //! a state has changed. Execution is returned back to the calling program 244*5fd0122aSMatthias Ringwald // and it is up to the user to ensure proper state transitions happen 245*5fd0122aSMatthias Ringwald //! correctly. For MSP432, changing into different power modes/states 246*5fd0122aSMatthias Ringwald //! require very specific logic. This function will initiate only one state 247*5fd0122aSMatthias Ringwald //! transition and then return. It is up to the user to keep calling this 248*5fd0122aSMatthias Ringwald //! function until the correct power state has been achieved. 249*5fd0122aSMatthias Ringwald //! 250*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about core voltage 251*5fd0122aSMatthias Ringwald //! levels. 252*5fd0122aSMatthias Ringwald //! 253*5fd0122aSMatthias Ringwald //! \param powerMode The voltage modes to be shifted to. Valid values are: 254*5fd0122aSMatthias Ringwald //! - \b PCM_LDO_MODE, 255*5fd0122aSMatthias Ringwald //! - \b PCM_DCDC_MODE, 256*5fd0122aSMatthias Ringwald //! - \b PCM_LF_MODE 257*5fd0122aSMatthias Ringwald //! 258*5fd0122aSMatthias Ringwald //! \return true if power mode change was initiated, false otherwise 259*5fd0122aSMatthias Ringwald // 260*5fd0122aSMatthias Ringwald //****************************************************************************** 261*5fd0122aSMatthias Ringwald extern bool PCM_setPowerModeNonBlocking(uint_fast8_t powerMode); 262*5fd0122aSMatthias Ringwald 263*5fd0122aSMatthias Ringwald //****************************************************************************** 264*5fd0122aSMatthias Ringwald // 265*5fd0122aSMatthias Ringwald //! Returns the current powers state of the system see the \b PCM_setPowerState 266*5fd0122aSMatthias Ringwald //! function for specific information about the modes. 267*5fd0122aSMatthias Ringwald //! 268*5fd0122aSMatthias Ringwald //! \return The current power mode of the system 269*5fd0122aSMatthias Ringwald //! 270*5fd0122aSMatthias Ringwald // 271*5fd0122aSMatthias Ringwald //****************************************************************************** 272*5fd0122aSMatthias Ringwald extern uint8_t PCM_getPowerMode(void); 273*5fd0122aSMatthias Ringwald 274*5fd0122aSMatthias Ringwald //****************************************************************************** 275*5fd0122aSMatthias Ringwald // 276*5fd0122aSMatthias Ringwald //! Switches between power states. This is a convenience function that combines 277*5fd0122aSMatthias Ringwald //! the functionality of PCM_setPowerMode and PCM_setCoreVoltageLevel as well as 278*5fd0122aSMatthias Ringwald //! the LPM0/LPM3 functions. 279*5fd0122aSMatthias Ringwald //! 280*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about power states. 281*5fd0122aSMatthias Ringwald //! 282*5fd0122aSMatthias Ringwald //! \param powerState The voltage modes to be shifted to. Valid values are: 283*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LDO_VCORE0, [Active Mode, LDO, VCORE0] 284*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LDO_VCORE1, [Active Mode, LDO, VCORE1] 285*5fd0122aSMatthias Ringwald //! - \b PCM_AM_DCDC_VCORE0, [Active Mode, DCDC, VCORE0] 286*5fd0122aSMatthias Ringwald //! - \b PCM_AM_DCDC_VCORE1, [Active Mode, DCDC, VCORE1] 287*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LF_VCORE0, [Active Mode, Low Frequency, VCORE0] 288*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LF_VCORE1, [Active Mode, Low Frequency, VCORE1] 289*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LDO_VCORE0, [LMP0, LDO, VCORE0] 290*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LDO_VCORE1, [LMP0, LDO, VCORE1] 291*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_DCDC_VCORE0, [LMP0, DCDC, VCORE0] 292*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_DCDC_VCORE1, [LMP0, DCDC, VCORE1] 293*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LF_VCORE0, [LMP0, Low Frequency, VCORE0] 294*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LF_VCORE1, [LMP0, Low Frequency, VCORE1] 295*5fd0122aSMatthias Ringwald //! - \b PCM_LPM3, [LPM3] 296*5fd0122aSMatthias Ringwald //! - \b PCM_LPM35_VCORE0, [LPM3.5 VCORE 0] 297*5fd0122aSMatthias Ringwald //! - \b PCM_LPM4, [LPM4] 298*5fd0122aSMatthias Ringwald //! - \b PCM_LPM45, [LPM4.5] 299*5fd0122aSMatthias Ringwald //! 300*5fd0122aSMatthias Ringwald //! \return true if power state is set, false otherwise. 301*5fd0122aSMatthias Ringwald // 302*5fd0122aSMatthias Ringwald //****************************************************************************** 303*5fd0122aSMatthias Ringwald extern bool PCM_setPowerState(uint_fast8_t powerState); 304*5fd0122aSMatthias Ringwald 305*5fd0122aSMatthias Ringwald //****************************************************************************** 306*5fd0122aSMatthias Ringwald // 307*5fd0122aSMatthias Ringwald //! Switches between power states. This is a convenience function that combines 308*5fd0122aSMatthias Ringwald //! the functionality of PCM_setPowerMode and PCM_setCoreVoltageLevel as well as 309*5fd0122aSMatthias Ringwald //! the LPM modes. 310*5fd0122aSMatthias Ringwald //! 311*5fd0122aSMatthias Ringwald //! This function is similar to PCM_setPowerState, however a timeout 312*5fd0122aSMatthias Ringwald //! mechanism is used. 313*5fd0122aSMatthias Ringwald //! 314*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about power states. 315*5fd0122aSMatthias Ringwald //! 316*5fd0122aSMatthias Ringwald //! \param powerState The voltage modes to be shifted to. Valid values are: 317*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LDO_VCORE0, [Active Mode, LDO, VCORE0] 318*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LDO_VCORE1, [Active Mode, LDO, VCORE1] 319*5fd0122aSMatthias Ringwald //! - \b PCM_AM_DCDC_VCORE0, [Active Mode, DCDC, VCORE0] 320*5fd0122aSMatthias Ringwald //! - \b PCM_AM_DCDC_VCORE1, [Active Mode, DCDC, VCORE1] 321*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LF_VCORE0, [Active Mode, Low Frequency, VCORE0] 322*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LF_VCORE1, [Active Mode, Low Frequency, VCORE1] 323*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LDO_VCORE0, [LMP0, LDO, VCORE0] 324*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LDO_VCORE1, [LMP0, LDO, VCORE1] 325*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_DCDC_VCORE0, [LMP0, DCDC, VCORE0] 326*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_DCDC_VCORE1, [LMP0, DCDC, VCORE1] 327*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LF_VCORE0, [LMP0, Low Frequency, VCORE0] 328*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LF_VCORE1, [LMP0, Low Frequency, VCORE1] 329*5fd0122aSMatthias Ringwald //! - \b PCM_LPM3, [LPM3] 330*5fd0122aSMatthias Ringwald //! - \b PCM_LPM35_VCORE0, [LPM3.5 VCORE 0] 331*5fd0122aSMatthias Ringwald //! - \b PCM_LPM4, [LPM4] 332*5fd0122aSMatthias Ringwald //! - \b PCM_LPM45, [LPM4.5] 333*5fd0122aSMatthias Ringwald //! 334*5fd0122aSMatthias Ringwald //! \param timeout Number of loop iterations to timeout when checking for 335*5fd0122aSMatthias Ringwald //! power state transitions. This should be used for debugging initial 336*5fd0122aSMatthias Ringwald //! power/hardware configurations. After a stable hardware base is 337*5fd0122aSMatthias Ringwald //! established, the PCMSetPowerMode function should be used 338*5fd0122aSMatthias Ringwald //! 339*5fd0122aSMatthias Ringwald //! \return true if power state is set, false otherwise. It is important to 340*5fd0122aSMatthias Ringwald //! note that if a timeout occurs, false will be returned, however the 341*5fd0122aSMatthias Ringwald //! power state at this point is not guaranteed to be the same as the 342*5fd0122aSMatthias Ringwald //! state prior to the function call 343*5fd0122aSMatthias Ringwald // 344*5fd0122aSMatthias Ringwald //****************************************************************************** 345*5fd0122aSMatthias Ringwald extern bool PCM_setPowerStateWithTimeout(uint_fast8_t powerState, 346*5fd0122aSMatthias Ringwald uint32_t timeout); 347*5fd0122aSMatthias Ringwald 348*5fd0122aSMatthias Ringwald //****************************************************************************** 349*5fd0122aSMatthias Ringwald // 350*5fd0122aSMatthias Ringwald //! Returns the current powers state of the system see the PCMChangePowerState 351*5fd0122aSMatthias Ringwald //! function for specific information about the states. 352*5fd0122aSMatthias Ringwald //! 353*5fd0122aSMatthias Ringwald //! Refer to \link PCM_setPowerState \endlink for possible return values. 354*5fd0122aSMatthias Ringwald //! 355*5fd0122aSMatthias Ringwald //! \return The current power state of the system 356*5fd0122aSMatthias Ringwald // 357*5fd0122aSMatthias Ringwald //****************************************************************************** 358*5fd0122aSMatthias Ringwald extern uint8_t PCM_getPowerState(void); 359*5fd0122aSMatthias Ringwald 360*5fd0122aSMatthias Ringwald //****************************************************************************** 361*5fd0122aSMatthias Ringwald // 362*5fd0122aSMatthias Ringwald //! Sets the power state of the part. This function is similar to 363*5fd0122aSMatthias Ringwald //! PCM_getPowerState, however there are no polling flags to ensure 364*5fd0122aSMatthias Ringwald //! a state has changed. Execution is returned back to the calling program 365*5fd0122aSMatthias Ringwald // and it is up to the user to ensure proper state transitions happen 366*5fd0122aSMatthias Ringwald //! correctly. For MSP432, changing into different power modes/states 367*5fd0122aSMatthias Ringwald //! require very specific logic. This function will initiate only one state 368*5fd0122aSMatthias Ringwald //! transition and then return. It is up to the user to keep calling this 369*5fd0122aSMatthias Ringwald //! function until the correct power state has been achieved. 370*5fd0122aSMatthias Ringwald //! 371*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about core voltage 372*5fd0122aSMatthias Ringwald //! levels. 373*5fd0122aSMatthias Ringwald //! 374*5fd0122aSMatthias Ringwald //! \param powerState The voltage modes to be shifted to. Valid values are: 375*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LDO_VCORE0, [Active Mode, LDO, VCORE0] 376*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LDO_VCORE1, [Active Mode, LDO, VCORE1] 377*5fd0122aSMatthias Ringwald //! - \b PCM_AM_DCDC_VCORE0, [Active Mode, DCDC, VCORE0] 378*5fd0122aSMatthias Ringwald //! - \b PCM_AM_DCDC_VCORE1, [Active Mode, DCDC, VCORE1] 379*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LF_VCORE0, [Active Mode, Low Frequency, VCORE0] 380*5fd0122aSMatthias Ringwald //! - \b PCM_AM_LF_VCORE1, [Active Mode, Low Frequency, VCORE1] 381*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LDO_VCORE0, [LMP0, LDO, VCORE0] 382*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LDO_VCORE1, [LMP0, LDO, VCORE1] 383*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_DCDC_VCORE0, [LMP0, DCDC, VCORE0] 384*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_DCDC_VCORE1, [LMP0, DCDC, VCORE1] 385*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LF_VCORE0, [LMP0, Low Frequency, VCORE0] 386*5fd0122aSMatthias Ringwald //! - \b PCM_LPM0_LF_VCORE1, [LMP0, Low Frequency, VCORE1] 387*5fd0122aSMatthias Ringwald //! - \b PCM_LPM3, [LPM3] 388*5fd0122aSMatthias Ringwald //! - \b PCM_LPM35_VCORE0, [LPM3.5 VCORE 0] 389*5fd0122aSMatthias Ringwald //! - \b PCM_LPM45, [LPM4.5] 390*5fd0122aSMatthias Ringwald //! 391*5fd0122aSMatthias Ringwald //! \return true if power state change was initiated, false otherwise 392*5fd0122aSMatthias Ringwald // 393*5fd0122aSMatthias Ringwald //****************************************************************************** 394*5fd0122aSMatthias Ringwald extern bool PCM_setPowerStateNonBlocking(uint_fast8_t powerState); 395*5fd0122aSMatthias Ringwald 396*5fd0122aSMatthias Ringwald //****************************************************************************** 397*5fd0122aSMatthias Ringwald // 398*5fd0122aSMatthias Ringwald //! Transitions the device into LPM3.5/LPM4.5 mode. 399*5fd0122aSMatthias Ringwald //! 400*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about shutdown modes. 401*5fd0122aSMatthias Ringwald //! 402*5fd0122aSMatthias Ringwald //! The following events will cause a wake up from LPM3.5 mode: 403*5fd0122aSMatthias Ringwald //! - Device reset 404*5fd0122aSMatthias Ringwald //! - External reset RST 405*5fd0122aSMatthias Ringwald //! - Enabled RTC, WDT, and wake-up I/O only interrupt events 406*5fd0122aSMatthias Ringwald //! 407*5fd0122aSMatthias Ringwald //! The following events will cause a wake up from the LPM4.5 mode: 408*5fd0122aSMatthias Ringwald //! - Device reset 409*5fd0122aSMatthias Ringwald //! - External reset RST 410*5fd0122aSMatthias Ringwald //! - Wake-up I/O only interrupt events 411*5fd0122aSMatthias Ringwald //! 412*5fd0122aSMatthias Ringwald //! \param shutdownMode Specific mode to go to. Valid values are: 413*5fd0122aSMatthias Ringwald //! - \b PCM_LPM35_VCORE0 414*5fd0122aSMatthias Ringwald //! - \b PCM_LPM45 415*5fd0122aSMatthias Ringwald //! 416*5fd0122aSMatthias Ringwald //! 417*5fd0122aSMatthias Ringwald //! \return false if LPM state cannot be entered, true otherwise. 418*5fd0122aSMatthias Ringwald // 419*5fd0122aSMatthias Ringwald //****************************************************************************** 420*5fd0122aSMatthias Ringwald extern bool PCM_shutdownDevice(uint32_t shutdownMode); 421*5fd0122aSMatthias Ringwald 422*5fd0122aSMatthias Ringwald //****************************************************************************** 423*5fd0122aSMatthias Ringwald // 424*5fd0122aSMatthias Ringwald //! Transitions the device into LPM0. 425*5fd0122aSMatthias Ringwald //! 426*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about low power modes. 427*5fd0122aSMatthias Ringwald //! 428*5fd0122aSMatthias Ringwald //! \return false if LPM0 state cannot be entered, true otherwise. 429*5fd0122aSMatthias Ringwald // 430*5fd0122aSMatthias Ringwald //****************************************************************************** 431*5fd0122aSMatthias Ringwald extern bool PCM_gotoLPM0(void); 432*5fd0122aSMatthias Ringwald 433*5fd0122aSMatthias Ringwald //****************************************************************************** 434*5fd0122aSMatthias Ringwald // 435*5fd0122aSMatthias Ringwald //! Transitions the device into LPM3 436*5fd0122aSMatthias Ringwald //! 437*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about low power modes. 438*5fd0122aSMatthias Ringwald //! Note that since LPM3 cannot be entered from a DCDC power modes, the 439*5fd0122aSMatthias Ringwald //! power mode is first switched to LDO operation (if in DCDC mode), 440*5fd0122aSMatthias Ringwald //! LPM3 is entered, and the DCDC mode is restored on wake up. 441*5fd0122aSMatthias Ringwald //! 442*5fd0122aSMatthias Ringwald //! \return false if LPM3 state cannot be entered, true otherwise. 443*5fd0122aSMatthias Ringwald // 444*5fd0122aSMatthias Ringwald //****************************************************************************** 445*5fd0122aSMatthias Ringwald extern bool PCM_gotoLPM3(void); 446*5fd0122aSMatthias Ringwald 447*5fd0122aSMatthias Ringwald //****************************************************************************** 448*5fd0122aSMatthias Ringwald // 449*5fd0122aSMatthias Ringwald //! Transitions the device into LPM0 while maintaining a safe 450*5fd0122aSMatthias Ringwald //! interrupt handling mentality. This function is meant to be used in 451*5fd0122aSMatthias Ringwald //! situations where the user wants to go to LPM0, however does not want 452*5fd0122aSMatthias Ringwald //! to go to "miss" any interrupts due to the fact that going to LPM0 is not 453*5fd0122aSMatthias Ringwald //! an atomic operation. This function will modify the PRIMASK and on exit of 454*5fd0122aSMatthias Ringwald //! the program the master interrupts will be disabled. 455*5fd0122aSMatthias Ringwald //! 456*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about low power modes. 457*5fd0122aSMatthias Ringwald //! 458*5fd0122aSMatthias Ringwald //! \return false if LPM0 state cannot be entered, true otherwise. 459*5fd0122aSMatthias Ringwald // 460*5fd0122aSMatthias Ringwald //****************************************************************************** 461*5fd0122aSMatthias Ringwald extern bool PCM_gotoLPM0InterruptSafe(void); 462*5fd0122aSMatthias Ringwald 463*5fd0122aSMatthias Ringwald //****************************************************************************** 464*5fd0122aSMatthias Ringwald // 465*5fd0122aSMatthias Ringwald //! Transitions the device into LPM3 while maintaining a safe 466*5fd0122aSMatthias Ringwald //! interrupt handling mentality. This function is meant to be used in 467*5fd0122aSMatthias Ringwald //! situations where the user wants to go to LPM3, however does not want 468*5fd0122aSMatthias Ringwald //! to go to "miss" any interrupts due to the fact that going to LPM3 is not 469*5fd0122aSMatthias Ringwald //! an atomic operation. This function will modify the PRIMASK and on exit of 470*5fd0122aSMatthias Ringwald //! the program the master interrupts will be disabled. 471*5fd0122aSMatthias Ringwald //! 472*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about low power modes. 473*5fd0122aSMatthias Ringwald //! Note that since LPM3 cannot be entered from a DCDC power modes, the 474*5fd0122aSMatthias Ringwald //! power mode is first switched to LDO operation (if in DCDC mode), the LPM3 475*5fd0122aSMatthias Ringwald //! is entered, and the DCDC mode is restored on wake up. 476*5fd0122aSMatthias Ringwald //! 477*5fd0122aSMatthias Ringwald //! \return false if LPM3 cannot be entered, true otherwise. 478*5fd0122aSMatthias Ringwald // 479*5fd0122aSMatthias Ringwald //****************************************************************************** 480*5fd0122aSMatthias Ringwald extern bool PCM_gotoLPM3InterruptSafe(void); 481*5fd0122aSMatthias Ringwald 482*5fd0122aSMatthias Ringwald //****************************************************************************** 483*5fd0122aSMatthias Ringwald // 484*5fd0122aSMatthias Ringwald //! Transitions the device into LPM4. LPM4 is the exact same with LPM3, just 485*5fd0122aSMatthias Ringwald //! with RTC_C and WDT_A disabled. When waking up, RTC_C and WDT_A will remain 486*5fd0122aSMatthias Ringwald //! disabled until reconfigured by the user. 487*5fd0122aSMatthias Ringwald //! 488*5fd0122aSMatthias Ringwald //! \return false if LPM4 state cannot be entered, true otherwise. 489*5fd0122aSMatthias Ringwald // 490*5fd0122aSMatthias Ringwald //****************************************************************************** 491*5fd0122aSMatthias Ringwald extern bool PCM_gotoLPM4(void); 492*5fd0122aSMatthias Ringwald 493*5fd0122aSMatthias Ringwald //****************************************************************************** 494*5fd0122aSMatthias Ringwald // 495*5fd0122aSMatthias Ringwald //! Transitions the device into LPM4 while maintaining a safe 496*5fd0122aSMatthias Ringwald //! interrupt handling mentality. This function is meant to be used in 497*5fd0122aSMatthias Ringwald //! situations where the user wants to go to LPM4, however does not want 498*5fd0122aSMatthias Ringwald //! to go to "miss" any interrupts due to the fact that going to LPM4 is not 499*5fd0122aSMatthias Ringwald //! an atomic operation. This function will modify the PRIMASK and on exit of 500*5fd0122aSMatthias Ringwald //! the program the master interrupts will be disabled. 501*5fd0122aSMatthias Ringwald //! 502*5fd0122aSMatthias Ringwald //! Refer to the device specific data sheet for specifics about low power modes. 503*5fd0122aSMatthias Ringwald //! Note that since LPM3 cannot be entered from a DCDC power modes, the 504*5fd0122aSMatthias Ringwald //! power mode is first switched to LDO operation (if in DCDC mode), 505*5fd0122aSMatthias Ringwald //! LPM4 is entered, and the DCDC mode is restored on wake up. 506*5fd0122aSMatthias Ringwald //! 507*5fd0122aSMatthias Ringwald //! \return false if LPM4 state cannot be entered, true otherwise. 508*5fd0122aSMatthias Ringwald // 509*5fd0122aSMatthias Ringwald //****************************************************************************** 510*5fd0122aSMatthias Ringwald extern bool PCM_gotoLPM4InterruptSafe(void); 511*5fd0122aSMatthias Ringwald 512*5fd0122aSMatthias Ringwald //****************************************************************************** 513*5fd0122aSMatthias Ringwald // 514*5fd0122aSMatthias Ringwald //! Enables "rude mode" entry into LPM3 and shutdown modes. With this mode 515*5fd0122aSMatthias Ringwald //! enabled, an entry into shutdown or LPM3 will occur even if there are 516*5fd0122aSMatthias Ringwald //! clock systems active. The system will forcibly turn off all clock/systems 517*5fd0122aSMatthias Ringwald //! when going into these modes. 518*5fd0122aSMatthias Ringwald //! 519*5fd0122aSMatthias Ringwald //! \return None 520*5fd0122aSMatthias Ringwald // 521*5fd0122aSMatthias Ringwald //****************************************************************************** 522*5fd0122aSMatthias Ringwald extern void PCM_enableRudeMode(void); 523*5fd0122aSMatthias Ringwald 524*5fd0122aSMatthias Ringwald //****************************************************************************** 525*5fd0122aSMatthias Ringwald // 526*5fd0122aSMatthias Ringwald //! Disables "rude mode" entry into LPM3 and shutdown modes. With this 527*5fd0122aSMatthias Ringwald //! mode disabled, an entry into shutdown or LPM3 will wait for any 528*5fd0122aSMatthias Ringwald //! active clock requests to free up before going into LPM3 or shutdown. 529*5fd0122aSMatthias Ringwald //! 530*5fd0122aSMatthias Ringwald //! \return None 531*5fd0122aSMatthias Ringwald // 532*5fd0122aSMatthias Ringwald //****************************************************************************** 533*5fd0122aSMatthias Ringwald extern void PCM_disableRudeMode(void); 534*5fd0122aSMatthias Ringwald 535*5fd0122aSMatthias Ringwald //***************************************************************************** 536*5fd0122aSMatthias Ringwald // 537*5fd0122aSMatthias Ringwald //! Enables individual power control interrupt sources. 538*5fd0122aSMatthias Ringwald //! 539*5fd0122aSMatthias Ringwald //! \param flags is a bit mask of the interrupt sources to be enabled. Must 540*5fd0122aSMatthias Ringwald //! be a logical OR of: 541*5fd0122aSMatthias Ringwald //! - \b PCM_DCDCERROR, 542*5fd0122aSMatthias Ringwald //! - \b PCM_AM_INVALIDTRANSITION, 543*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDCLOCK, 544*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDTRANSITION 545*5fd0122aSMatthias Ringwald //! 546*5fd0122aSMatthias Ringwald //! This function enables the indicated power control interrupt sources. Only 547*5fd0122aSMatthias Ringwald //! the sources that are enabled can be reflected to the processor interrupt; 548*5fd0122aSMatthias Ringwald //! disabled sources have no effect on the processor. 549*5fd0122aSMatthias Ringwald //! 550*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 551*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 552*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 553*5fd0122aSMatthias Ringwald //! 554*5fd0122aSMatthias Ringwald //! \return None. 555*5fd0122aSMatthias Ringwald // 556*5fd0122aSMatthias Ringwald //***************************************************************************** 557*5fd0122aSMatthias Ringwald extern void PCM_enableInterrupt(uint32_t flags); 558*5fd0122aSMatthias Ringwald 559*5fd0122aSMatthias Ringwald //***************************************************************************** 560*5fd0122aSMatthias Ringwald // 561*5fd0122aSMatthias Ringwald //! Disables individual power control interrupt sources. 562*5fd0122aSMatthias Ringwald //! 563*5fd0122aSMatthias Ringwald //! \param flags is a bit mask of the interrupt sources to be enabled. Must 564*5fd0122aSMatthias Ringwald //! be a logical OR of: 565*5fd0122aSMatthias Ringwald //! - \b PCM_DCDCERROR, 566*5fd0122aSMatthias Ringwald //! - \b PCM_AM_INVALIDTRANSITION, 567*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDCLOCK, 568*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDTRANSITION 569*5fd0122aSMatthias Ringwald //! 570*5fd0122aSMatthias Ringwald //! This function disables the indicated power control interrupt sources. Only 571*5fd0122aSMatthias Ringwald //! the sources that are enabled can be reflected to the processor interrupt; 572*5fd0122aSMatthias Ringwald //! disabled sources have no effect on the processor. 573*5fd0122aSMatthias Ringwald //! 574*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 575*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 576*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 577*5fd0122aSMatthias Ringwald //! 578*5fd0122aSMatthias Ringwald //! \return None. 579*5fd0122aSMatthias Ringwald // 580*5fd0122aSMatthias Ringwald //***************************************************************************** 581*5fd0122aSMatthias Ringwald extern void PCM_disableInterrupt(uint32_t flags); 582*5fd0122aSMatthias Ringwald 583*5fd0122aSMatthias Ringwald //***************************************************************************** 584*5fd0122aSMatthias Ringwald // 585*5fd0122aSMatthias Ringwald //! Gets the current interrupt status. 586*5fd0122aSMatthias Ringwald //! 587*5fd0122aSMatthias Ringwald //! \return The current interrupt status, enumerated as a bit field of: 588*5fd0122aSMatthias Ringwald //! - \b PCM_DCDCERROR, 589*5fd0122aSMatthias Ringwald //! - \b PCM_AM_INVALIDTRANSITION, 590*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDCLOCK, 591*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDTRANSITION 592*5fd0122aSMatthias Ringwald //! 593*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 594*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 595*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 596*5fd0122aSMatthias Ringwald // 597*5fd0122aSMatthias Ringwald //***************************************************************************** 598*5fd0122aSMatthias Ringwald extern uint32_t PCM_getInterruptStatus(void); 599*5fd0122aSMatthias Ringwald 600*5fd0122aSMatthias Ringwald //***************************************************************************** 601*5fd0122aSMatthias Ringwald // 602*5fd0122aSMatthias Ringwald //! Gets the current interrupt status masked with the enabled interrupts. 603*5fd0122aSMatthias Ringwald //! This function is useful to call in ISRs to get a list of pending 604*5fd0122aSMatthias Ringwald //! interrupts that are actually enabled and could have caused 605*5fd0122aSMatthias Ringwald //! the ISR. 606*5fd0122aSMatthias Ringwald //! 607*5fd0122aSMatthias Ringwald //! \return The current interrupt status, enumerated as a bit field of: 608*5fd0122aSMatthias Ringwald //! - \b PCM_DCDCERROR, 609*5fd0122aSMatthias Ringwald //! - \b PCM_AM_INVALIDTRANSITION, 610*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDCLOCK, 611*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDTRANSITION 612*5fd0122aSMatthias Ringwald //! 613*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 614*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 615*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 616*5fd0122aSMatthias Ringwald // 617*5fd0122aSMatthias Ringwald //***************************************************************************** 618*5fd0122aSMatthias Ringwald extern uint32_t PCM_getEnabledInterruptStatus(void); 619*5fd0122aSMatthias Ringwald 620*5fd0122aSMatthias Ringwald //***************************************************************************** 621*5fd0122aSMatthias Ringwald // 622*5fd0122aSMatthias Ringwald //! Clears power system interrupt sources. 623*5fd0122aSMatthias Ringwald //! 624*5fd0122aSMatthias Ringwald //! The specified power system interrupt sources are cleared, so that they no 625*5fd0122aSMatthias Ringwald //! longer assert. This function must be called in the interrupt handler to 626*5fd0122aSMatthias Ringwald //! keep it from being called again immediately upon exit. 627*5fd0122aSMatthias Ringwald //! 628*5fd0122aSMatthias Ringwald //! \note Because there is a write buffer in the Cortex-M processor, it may 629*5fd0122aSMatthias Ringwald //! take several clock cycles before the interrupt source is actually cleared. 630*5fd0122aSMatthias Ringwald //! Therefore, it is recommended that the interrupt source be cleared early in 631*5fd0122aSMatthias Ringwald //! the interrupt handler (as opposed to the very last action) to avoid 632*5fd0122aSMatthias Ringwald //! returning from the interrupt handler before the interrupt source is 633*5fd0122aSMatthias Ringwald //! actually cleared. Failure to do so may result in the interrupt handler 634*5fd0122aSMatthias Ringwald //! being immediately reentered (because the interrupt controller still sees 635*5fd0122aSMatthias Ringwald //! the interrupt source asserted). 636*5fd0122aSMatthias Ringwald //! 637*5fd0122aSMatthias Ringwald //! \param flags is a bit mask of the interrupt sources to be cleared. Must 638*5fd0122aSMatthias Ringwald //! be a logical OR of 639*5fd0122aSMatthias Ringwald //! - \b PCM_DCDCERROR, 640*5fd0122aSMatthias Ringwald //! - \b PCM_AM_INVALIDTRANSITION, 641*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDCLOCK, 642*5fd0122aSMatthias Ringwald //! - \b PCM_SM_INVALIDTRANSITION 643*5fd0122aSMatthias Ringwald //! 644*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 645*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 646*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 647*5fd0122aSMatthias Ringwald //! 648*5fd0122aSMatthias Ringwald //! \return None. 649*5fd0122aSMatthias Ringwald // 650*5fd0122aSMatthias Ringwald //***************************************************************************** 651*5fd0122aSMatthias Ringwald extern void PCM_clearInterruptFlag(uint32_t flags); 652*5fd0122aSMatthias Ringwald 653*5fd0122aSMatthias Ringwald //***************************************************************************** 654*5fd0122aSMatthias Ringwald // 655*5fd0122aSMatthias Ringwald //! Registers an interrupt handler for the power system interrupt. 656*5fd0122aSMatthias Ringwald //! 657*5fd0122aSMatthias Ringwald //! \param intHandler is a pointer to the function to be called when the power 658*5fd0122aSMatthias Ringwald //! system interrupt occurs. 659*5fd0122aSMatthias Ringwald //! 660*5fd0122aSMatthias Ringwald //! This function registers the handler to be called when a clock system 661*5fd0122aSMatthias Ringwald //! interrupt occurs. This function enables the global interrupt in the 662*5fd0122aSMatthias Ringwald //! interrupt controller; specific PCM interrupts must be enabled 663*5fd0122aSMatthias Ringwald //! via PCM_enableInterrupt(). It is the interrupt handler's responsibility to 664*5fd0122aSMatthias Ringwald //! clear the interrupt source via \link PCM_clearInterruptFlag \endlink . 665*5fd0122aSMatthias Ringwald //! 666*5fd0122aSMatthias Ringwald //! \sa Interrupt_registerInterrupt() for important information about 667*5fd0122aSMatthias Ringwald //! registering interrupt handlers. 668*5fd0122aSMatthias Ringwald //! 669*5fd0122aSMatthias Ringwald //! \return None. 670*5fd0122aSMatthias Ringwald // 671*5fd0122aSMatthias Ringwald //***************************************************************************** 672*5fd0122aSMatthias Ringwald extern void PCM_registerInterrupt(void (*intHandler)(void)); 673*5fd0122aSMatthias Ringwald 674*5fd0122aSMatthias Ringwald //***************************************************************************** 675*5fd0122aSMatthias Ringwald // 676*5fd0122aSMatthias Ringwald //! Unregisters the interrupt handler for the power system. 677*5fd0122aSMatthias Ringwald //! 678*5fd0122aSMatthias Ringwald //! This function unregisters the handler to be called when a power system 679*5fd0122aSMatthias Ringwald //! interrupt occurs. This function also masks off the interrupt in the 680*5fd0122aSMatthias Ringwald //! interrupt controller so that the interrupt handler no longer is called. 681*5fd0122aSMatthias Ringwald //! 682*5fd0122aSMatthias Ringwald //! \sa Interrupt_registerInterrupt() for important information about 683*5fd0122aSMatthias Ringwald //! registering interrupt handlers. 684*5fd0122aSMatthias Ringwald //! 685*5fd0122aSMatthias Ringwald //! \return None. 686*5fd0122aSMatthias Ringwald // 687*5fd0122aSMatthias Ringwald //***************************************************************************** 688*5fd0122aSMatthias Ringwald extern void PCM_unregisterInterrupt(void); 689*5fd0122aSMatthias Ringwald 690*5fd0122aSMatthias Ringwald //***************************************************************************** 691*5fd0122aSMatthias Ringwald // 692*5fd0122aSMatthias Ringwald // Mark the end of the C bindings section for C++ compilers. 693*5fd0122aSMatthias Ringwald // 694*5fd0122aSMatthias Ringwald //***************************************************************************** 695*5fd0122aSMatthias Ringwald #ifdef __cplusplus 696*5fd0122aSMatthias Ringwald } 697*5fd0122aSMatthias Ringwald #endif 698*5fd0122aSMatthias Ringwald 699*5fd0122aSMatthias Ringwald //***************************************************************************** 700*5fd0122aSMatthias Ringwald // 701*5fd0122aSMatthias Ringwald // Close the Doxygen group. 702*5fd0122aSMatthias Ringwald //! @} 703*5fd0122aSMatthias Ringwald // 704*5fd0122aSMatthias Ringwald //***************************************************************************** 705*5fd0122aSMatthias Ringwald 706*5fd0122aSMatthias Ringwald #endif // __PCM_H__ 707