EZR32 Leopard Gecko Software Documentation  ezr32lg-doc-4.2.1

Energy Management Unit (EMU) Peripheral API

. More...

Data Structures

struct  EMU_EM23Init_TypeDef
 
struct  EMU_EM4Init_TypeDef
 
struct  EMU_BUPDInit_TypeDef
 

Macros

#define EMU_EM23INIT_DEFAULT   { false } /* Reduced voltage regulator drive strength in EM2 and EM3 */
 
#define EMU_EM4INIT_DEFAULT
 
#define EMU_BUPDINIT_DEFAULT
 

Enumerations

enum  EMU_EM4Osc_TypeDef {
  emuEM4Osc_ULFRCO = EMU_EM4CONF_OSC_ULFRCO,
  emuEM4Osc_LFXO = EMU_EM4CONF_OSC_LFXO,
  emuEM4Osc_LFRCO = EMU_EM4CONF_OSC_LFRCO
}
 
enum  EMU_Probe_TypeDef {
  emuProbe_Disable = EMU_BUCTRL_PROBE_DISABLE,
  emuProbe_VDDDReg = EMU_BUCTRL_PROBE_VDDDREG,
  emuProbe_BUIN = EMU_BUCTRL_PROBE_BUIN,
  emuProbe_BUOUT = EMU_BUCTRL_PROBE_BUOUT
}
 
enum  EMU_Resistor_TypeDef {
  emuRes_Res0 = EMU_PWRCONF_PWRRES_RES0,
  emuRes_Res1 = EMU_PWRCONF_PWRRES_RES1,
  emuRes_Res2 = EMU_PWRCONF_PWRRES_RES2,
  emuRes_Res3 = EMU_PWRCONF_PWRRES_RES3
}
 
enum  EMU_Power_TypeDef {
  emuPower_None = EMU_BUINACT_PWRCON_NONE,
  emuPower_BUMain = EMU_BUINACT_PWRCON_BUMAIN,
  emuPower_MainBU = EMU_BUINACT_PWRCON_MAINBU,
  emuPower_NoDiode = EMU_BUINACT_PWRCON_NODIODE
}
 
enum  EMU_BODMode_TypeDef {
  emuBODMode_Active,
  emuBODMode_Inactive
}
 

Functions

__STATIC_INLINE void EMU_EnterEM1 (void)
 Enter energy mode 1 (EM1).
 
void EMU_EM23Init (EMU_EM23Init_TypeDef *em23Init)
 Update EMU module with Energy Mode 2 and 3 configuration. More...
 
void EMU_EM4Init (EMU_EM4Init_TypeDef *em4Init)
 Update EMU module with Energy Mode 4 configuration. More...
 
void EMU_EnterEM2 (bool restore)
 Enter energy mode 2 (EM2). More...
 
void EMU_EnterEM3 (bool restore)
 Enter energy mode 3 (EM3). More...
 
void EMU_EnterEM4 (void)
 Enter energy mode 4 (EM4). More...
 
void EMU_MemPwrDown (uint32_t blocks)
 Power down memory block. More...
 
void EMU_UpdateOscConfig (void)
 Update EMU module with CMU oscillator selection/enable status. More...
 
void EMU_BUPDInit (EMU_BUPDInit_TypeDef *bupdInit)
 Configure Backup Power Domain settings. More...
 
void EMU_BUThresholdSet (EMU_BODMode_TypeDef mode, uint32_t value)
 Configure Backup Power Domain BOD Threshold value. More...
 
void EMU_BUThresRangeSet (EMU_BODMode_TypeDef mode, uint32_t value)
 Configure Backup Power Domain BOD Threshold Range. More...
 
__STATIC_INLINE void EMU_IntClear (uint32_t flags)
 Clear one or more pending EMU interrupts. More...
 
__STATIC_INLINE void EMU_IntDisable (uint32_t flags)
 Disable one or more EMU interrupts. More...
 
__STATIC_INLINE void EMU_IntEnable (uint32_t flags)
 Enable one or more EMU interrupts. More...
 
__STATIC_INLINE uint32_t EMU_IntGet (void)
 Get pending EMU interrupt flags. More...
 
__STATIC_INLINE uint32_t EMU_IntGetEnabled (void)
 Get enabled and pending EMU interrupt flags. Useful for handling more interrupt sources in the same interrupt handler. More...
 
__STATIC_INLINE void EMU_IntSet (uint32_t flags)
 Set one or more pending EMU interrupts. More...
 
__STATIC_INLINE void EMU_EM4Lock (bool enable)
 Enable or disable EM4 lock configuration. More...
 
__STATIC_INLINE void EMU_BUReady (void)
 Halts until backup power functionality is ready.
 
__STATIC_INLINE void EMU_BUPinEnable (bool enable)
 Disable BU_VIN support. More...
 
__STATIC_INLINE void EMU_Lock (void)
 Lock the EMU in order to protect its registers against unintended modification. More...
 
__STATIC_INLINE void EMU_Unlock (void)
 Unlock the EMU so that writing to locked registers again is possible.
 
__STATIC_INLINE void EMU_EM2Block (void)
 Block entering EM2 or higher number energy modes.
 
__STATIC_INLINE void EMU_EM2UnBlock (void)
 Unblock entering EM2 or higher number energy modes.
 

Detailed Description

Macro Definition Documentation

#define EMU_EM23INIT_DEFAULT   { false } /* Reduced voltage regulator drive strength in EM2 and EM3 */

Default initialization of EM2 and 3 configuration

Definition at line 245 of file em_emu.h.

#define EMU_EM4INIT_DEFAULT
Value:
{ \
false, /* Dont't lock configuration after it's been set */ \
false, /* No reset will be asserted due to Brownout when in EM4 */ \
emuEM4Osc_ULFRCO, /* Use default ULFRCO oscillator */ \
true, /* Wake up on EM4 BURTC interrupt */ \
true, /* Enable VREG */ \
}

Default initialization of EM4 configuration

Definition at line 274 of file em_emu.h.

#define EMU_BUPDINIT_DEFAULT
Value:
{ \
emuProbe_Disable, /* Do not enable voltage probe */ \
false, /* Disable BOD calibration mode */ \
false, /* Disable BU_STAT pin for backup mode indication */ \
\
emuRes_Res0, /* RES0 series resistance between main and backup power */ \
false, /* Don't enable strong switch */ \
false, /* Don't enable medium switch */ \
false, /* Don't enable weak switch */ \
\
emuPower_None, /* No connection between main and backup power (inactive mode) */ \
emuPower_None, /* No connection between main and backup power (active mode) */ \
true /* Enable BUPD enter on BOD, enable BU_VIN pin, release BU reset */ \
}

Default Backup Power Domain configuration

Definition at line 325 of file em_emu.h.

Enumeration Type Documentation

EM4 duty oscillator

Enumerator
emuEM4Osc_ULFRCO 

Select ULFRCO as duty oscillator in EM4

emuEM4Osc_LFXO 

Select LFXO as duty oscillator in EM4

emuEM4Osc_LFRCO 

Select LFRCO as duty oscillator in EM4

Definition at line 62 of file em_emu.h.

Backup Power Voltage Probe types

Enumerator
emuProbe_Disable 

Disable voltage probe

emuProbe_VDDDReg 

Connect probe to VDD_DREG

emuProbe_BUIN 

Connect probe to BU_IN

emuProbe_BUOUT 

Connect probe to BU_OUT

Definition at line 75 of file em_emu.h.

Backup Power Domain resistor selection

Enumerator
emuRes_Res0 

Main power and backup power connected with RES0 series resistance

emuRes_Res1 

Main power and backup power connected with RES1 series resistance

emuRes_Res2 

Main power and backup power connected with RES2 series resistance

emuRes_Res3 

Main power and backup power connected with RES3 series resistance

Definition at line 90 of file em_emu.h.

Backup Power Domain power connection

Enumerator
emuPower_None 

No connection between main and backup power

emuPower_BUMain 

Main power and backup power connected through diode, allowing current from backup to main only

emuPower_MainBU 

Main power and backup power connected through diode, allowing current from main to backup only

emuPower_NoDiode 

Main power and backup power connected without diode

Definition at line 105 of file em_emu.h.

BOD threshold setting selector, active or inactive mode

Enumerator
emuBODMode_Active 

Configure BOD threshold for active mode

emuBODMode_Inactive 

Configure BOD threshold for inactive mode

Definition at line 121 of file em_emu.h.

Function Documentation

void EMU_EM23Init ( EMU_EM23Init_TypeDef em23Init)
Parameters
[in]em23InitEnergy Mode 2 and 3 configuration structure

Definition at line 753 of file em_emu.c.

References EMU_EM23Init_TypeDef::em23VregFullEn, EMU, and EMU_CTRL_EMVREG.

void EMU_EnterEM2 ( bool  restore)

When entering EM2, the high frequency clocks are disabled, ie HFXO, HFRCO and AUXHFRCO (for AUXHFRCO, see exception note below). When re-entering EM0, HFRCO is re-enabled and the core will be clocked by the configured HFRCO band. This ensures a quick wakeup from EM2.

However, prior to entering EM2, the core may have been using another oscillator than HFRCO. The restore parameter gives the user the option to restore all HF oscillators according to state prior to entering EM2, as well as the clock used to clock the core. This restore procedure is handled by SW. However, since handled by SW, it will not be restored before completing the interrupt function(s) waking up the core!

Note
If restoring core clock to use the HFXO oscillator, which has been disabled during EM2 mode, this function will stall until the oscillator has stabilized. Stalling time can be reduced by adding interrupt support detecting stable oscillator, and an asynchronous switch to the original oscillator. See CMU documentation. Such a feature is however outside the scope of the implementation in this function.
If HFXO is re-enabled by this function, and NOT used to clock the core, this function will not wait for HFXO to stabilize. This must be considered by the application if trying to use features relying on that oscillator upon return.
If a debugger is attached, the AUXHFRCO will not be disabled if enabled upon entering EM2. It will thus remain enabled when returning to EM0 regardless of the restore parameter.
If HFXO autostart and select is enabled by using CMU_HFXOAutostartEnable(), the starting and selecting of the core clocks will be identical to the user independently of the value of the restore parameter when waking up on the wakeup sources corresponding to the autostart and select setting.
Parameters
[in]restore
  • true - restore oscillators and clocks, see function details.
  • false - do not restore oscillators and clocks, see function details.
The restore option should only be used if all clock control is done via the CMU API.

Definition at line 413 of file em_emu.c.

References CMU, CMU_STATUS_HFRCOSEL, and SystemCoreClockUpdate().

Referenced by CAPLESENSE_Sleep().

void EMU_EnterEM3 ( bool  restore)

When entering EM3, the high frequency clocks are disabled by HW, ie HFXO, HFRCO and AUXHFRCO (for AUXHFRCO, see exception note below). In addition, the low frequency clocks, ie LFXO and LFRCO are disabled by SW. When re-entering EM0, HFRCO is re-enabled and the core will be clocked by the configured HFRCO band. This ensures a quick wakeup from EM3.

However, prior to entering EM3, the core may have been using another oscillator than HFRCO. The restore parameter gives the user the option to restore all HF/LF oscillators according to state prior to entering EM3, as well as the clock used to clock the core. This restore procedure is handled by SW. However, since handled by SW, it will not be restored before completing the interrupt function(s) waking up the core!

Note
If restoring core clock to use an oscillator other than HFRCO, this function will stall until the oscillator has stabilized. Stalling time can be reduced by adding interrupt support detecting stable oscillator, and an asynchronous switch to the original oscillator. See CMU documentation. Such a feature is however outside the scope of the implementation in this function.
If HFXO/LFXO/LFRCO are re-enabled by this function, and NOT used to clock the core, this function will not wait for those oscillators to stabilize. This must be considered by the application if trying to use features relying on those oscillators upon return.
If a debugger is attached, the AUXHFRCO will not be disabled if enabled upon entering EM3. It will thus remain enabled when returning to EM0 regardless of the restore parameter.
Parameters
[in]restore
  • true - restore oscillators and clocks, see function details.
  • false - do not restore oscillators and clocks, see function details.
The restore option should only be used if all clock control is done via the CMU API.

Definition at line 529 of file em_emu.c.

References CMU, CMU_Lock(), CMU_LOCK_LOCKKEY_LOCKED, CMU_OSCENCMD_LFRCODIS, CMU_OSCENCMD_LFXODIS, CMU_STATUS_HFRCOSEL, CMU_Unlock(), and SystemCoreClockUpdate().

void EMU_EnterEM4 ( void  )
Note
Only a power on reset or external reset pin can wake the device from EM4.

Definition at line 626 of file em_emu.c.

References _EMU_CTRL_EM4CTRL_MASK, _EMU_CTRL_EM4CTRL_SHIFT, EMU, and EMU_Unlock().

void EMU_MemPwrDown ( uint32_t  blocks)
Parameters
[in]blocksSpecifies a logical OR of bits indicating memory blocks to power down. Bit 0 selects block 1, bit 1 selects block 2, etc. Memory block 0 cannot be disabled. Please refer to the reference manual for available memory blocks for a device.
Note
Only a reset can make the specified memory block(s) available for use after having been powered down. Function will be void for devices not supporting this feature.

Definition at line 687 of file em_emu.c.

References EMU.

void EMU_UpdateOscConfig ( void  )

When entering EM2 and EM3, the HW may change the core clock oscillator used, as well as disabling some oscillators. The user may optionally select to restore the oscillators after waking up from EM2 and EM3 through the SW API.

However, in order to support this in a safe way, the EMU module must be kept up-to-date on the actual selected configuration. The CMU module must keep the EMU module up-to-date.

This function is mainly intended for internal use by the CMU module, but if the applications changes oscillator configurations without using the CMU API, this function can be used to keep the EMU module up-to-date.

Definition at line 736 of file em_emu.c.

References CMU.

Referenced by CMU_ClockSelectSet(), and CMU_OscillatorEnable().

void EMU_BUThresholdSet ( EMU_BODMode_TypeDef  mode,
uint32_t  value 
)
Note
These values are precalibrated
Parameters
[in]modeActive or Inactive mode
[in]value

Definition at line 886 of file em_emu.c.

References _EMU_BUACT_BUEXTHRES_MASK, _EMU_BUACT_BUEXTHRES_SHIFT, _EMU_BUINACT_BUENTHRES_MASK, _EMU_BUINACT_BUENTHRES_SHIFT, EMU, emuBODMode_Active, and emuBODMode_Inactive.

void EMU_BUThresRangeSet ( EMU_BODMode_TypeDef  mode,
uint32_t  value 
)
Note
These values are precalibrated
Parameters
[in]modeActive or Inactive mode
[in]value

Definition at line 913 of file em_emu.c.

References _EMU_BUACT_BUEXRANGE_MASK, _EMU_BUACT_BUEXRANGE_SHIFT, _EMU_BUINACT_BUENRANGE_MASK, _EMU_BUINACT_BUENRANGE_SHIFT, EMU, emuBODMode_Active, and emuBODMode_Inactive.

__STATIC_INLINE void EMU_IntClear ( uint32_t  flags)
Parameters
[in]flagsPending EMU interrupt sources to clear. Use one or more valid interrupt flags for the EMU module (EMU_IFC_nnn).

Definition at line 506 of file em_emu.h.

References EMU.

__STATIC_INLINE void EMU_IntDisable ( uint32_t  flags)
Parameters
[in]flagsEMU interrupt sources to disable. Use one or more valid interrupt flags for the EMU module (EMU_IEN_nnn).

Definition at line 520 of file em_emu.h.

References EMU.

__STATIC_INLINE void EMU_IntEnable ( uint32_t  flags)
Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. Consider using EMU_IntClear() prior to enabling if such a pending interrupt should be ignored.
Parameters
[in]flagsEMU interrupt sources to enable. Use one or more valid interrupt flags for the EMU module (EMU_IEN_nnn).

Definition at line 539 of file em_emu.h.

References EMU.

__STATIC_INLINE uint32_t EMU_IntGet ( void  )
Note
The event bits are not cleared by the use of this function.
Returns
EMU interrupt sources pending. Returns one or more valid interrupt flags for the EMU module (EMU_IF_nnn).

Definition at line 556 of file em_emu.h.

References EMU.

__STATIC_INLINE uint32_t EMU_IntGetEnabled ( void  )
Note
Interrupt flags are not cleared by the use of this function.
Returns
Pending and enabled EMU interrupt sources The return value is the bitwise AND of
  • the enabled interrupt sources in EMU_IEN and
  • the pending interrupt flags EMU_IF

Definition at line 576 of file em_emu.h.

References EMU.

__STATIC_INLINE void EMU_IntSet ( uint32_t  flags)
Parameters
[in]flagsEMU interrupt sources to set to pending. Use one or more valid interrupt flags for the EMU module (EMU_IFS_nnn).

Definition at line 593 of file em_emu.h.

References EMU.

__STATIC_INLINE void EMU_EM4Lock ( bool  enable)
Parameters
[in]enableIf true, locks down EM4 configuration

Definition at line 607 of file em_emu.h.

References _EMU_EM4CONF_LOCKCONF_SHIFT, BUS_RegBitWrite(), and EMU.

__STATIC_INLINE void EMU_BUPinEnable ( bool  enable)
Parameters
[in]enableIf true, enables BU_VIN input pin support, if false disables it

Definition at line 632 of file em_emu.h.

References _EMU_ROUTE_BUVINPEN_SHIFT, BUS_RegBitWrite(), and EMU.

Referenced by EMU_BUPDInit().

__STATIC_INLINE void EMU_Lock ( void  )
Note
If locking the EMU registers, they must be unlocked prior to using any EMU API functions modifying EMU registers, excluding interrupt control and regulator control if the architecture has a EMU_PWRCTRL register. An exception to this is the energy mode entering API (EMU_EnterEMn()), which can be used when the EMU registers are locked.

Definition at line 650 of file em_emu.h.

References EMU, and EMU_LOCK_LOCKKEY_LOCK.

Referenced by RMU_ResetCauseClear().