EMU - Energy management unit#
Energy management unit control peripheral.
Example#
EMU Basic temperature measurement example:
{
// Wait for temperature sensor to be ready
while (!sl_hal_emu_is_temperature_ready()) {
// Wait for temperature readiness
}
// Read temperature in degrees Celsius
float temperature = sl_hal_emu_get_temperature();
// Power management example with DCDC
#if defined(SL_HAL_EMU_DCDC_BUCK_PRESENT)
// Initialize DCDC regulator
sl_hal_emu_dcdc_init_t init = SL_HAL_EMU_DCDC_INIT_DEFAULT;
sl_hal_emu_init_dcdc(&init);
// Set DCDC mode to regulation
sl_hal_emu_set_dcdc_mode(SL_HAL_EMU_DCDC_MODE_REGULATION);
#endif
// RAM power management
// Power down all RAM blocks except the first one
sl_hal_emu_ram_power_down(SRAM_BASE, SRAM_BASE + SRAM_SIZE);
// Power up all RAM blocks when needed again
sl_hal_emu_ram_power_up();
// Clear reset cause when done handling it
uint32_t reset_cause = sl_hal_emu_get_reset_cause();
sl_hal_emu_clear_reset_cause();
}
Enumerations#
Peripheral reset control.
Peripheral reset control and reset source control.
Functions#
Power down RAM memory blocks.
Power up all available RAM memory blocks.
Lock EMU registers in order to protect them against unintended modification.
Unlock the EMU so that writing to locked registers again is possible.
Enable one or more EMU interrupts.
Disable one or more EMU interrupts.
Clear one or more pending EMU interrupts.
Get pending EMU interrupt flags.
Get enabled and pending EMU interrupt flags.
Set one or more pending EMU interrupts.
Get EMU STATUS register.
Temperature measurement ready status.
Get temperature in degrees Celsius.
Clear the reset cause register.
Get the cause of the last reset.
Disable/enable reset for various peripherals and signal sources.
Enumeration Documentation#
sl_hal_emu_reset_mode_t#
sl_hal_emu_reset_mode_t
Peripheral reset control.
Enumerator | |
---|---|
SL_HAL_EMU_RESET_MODE_DISABLED | Reset mode disabled. |
SL_HAL_EMU_RESET_MODE_ENABLED | Reset mode enabled. |
sl_hal_emu_reset_source_t#
sl_hal_emu_reset_source_t
Peripheral reset control and reset source control.
Enumerator | |
---|---|
SL_HAL_EMU_RESET_WDOG0 | WDOG0 reset select. |
SL_HAL_EMU_RESET_WDOG1 | WDOG1 reset select. |
SL_HAL_EMU_RESET_SYS | SYSRESET select. |
SL_HAL_EMU_RESET_CORE_LOCKUP | Cortex lockup reset select. |
SL_HAL_EMU_RESET_AVDD | AVDD monitoring select. |
SL_HAL_EMU_RESET_IOVDD0 | IOVDD0 monitoring select. |
SL_HAL_EMU_RESET_DECOUPLE | Decouple monitoring select. |
Function Documentation#
sl_hal_emu_ram_power_down#
void sl_hal_emu_ram_power_down (uint32_t start, uint32_t end)
Power down RAM memory blocks.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | start | The start address of the RAM region to power down This address is inclusive. |
uint32_t | [in] | end | The end address of the RAM region to power down. Except for xg27 It can only have two values: 0 or more than RAM0_END. Any other valid RAM address will just do nothing without any error or indication that nothing happened. This address is exclusive. If this parameter is 0, all RAM blocks contained in the region from start to the end of RAM will be powered down. |
This function will power down all the RAM blocks that are within a given range. The RAM block layout is different between device families, so this function can be used in a generic way to power down a RAM memory region which is known to be unused.
This function will power down blocks from start to the end of RAM. For xg27, it will shut off blocks which are completely enclosed by the memory range given by [start, end].
This is an example to power down all RAM blocks except the first one. The first RAM block is special in that it cannot be powered down by the hardware. The size of the first RAM block is device-specific. See the reference manual to find the RAM block sizes.
sl_hal_emu_ram_power_down(SRAM_BASE, SRAM_BASE + SRAM_SIZE);
Note
The specified memory block(s) will stay off until a call to sl_hal_emu_ram_power_up() is done.
sl_hal_emu_ram_power_up#
void sl_hal_emu_ram_power_up (void )
Power up all available RAM memory blocks.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function will power up all the RAM blocks on a device this means that the RAM blocks are retained in EM2/EM3.
sl_hal_emu_lock#
void sl_hal_emu_lock (void )
Lock EMU registers in order to protect them against unintended modification.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Note
If locking 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.
sl_hal_emu_unlock#
void sl_hal_emu_unlock (void )
Unlock the EMU so that writing to locked registers again is possible.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_hal_emu_enable_interrupts#
void sl_hal_emu_enable_interrupts (uint32_t flags)
Enable one or more EMU interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EMU interrupt sources to enable. Use one or more valid interrupt flags for the EMU module (EMU_IEN_nnn). |
Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using sl_hal_emu_clear_interrupts() prior to enabling the interrupt.
sl_hal_emu_disable_interrupts#
void sl_hal_emu_disable_interrupts (uint32_t flags)
Disable one or more EMU interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EMU interrupt sources to disable. Use one or more valid interrupt flags for the EMU module (EMU_IEN_nnn). |
sl_hal_emu_clear_interrupts#
void sl_hal_emu_clear_interrupts (uint32_t flags)
Clear one or more pending EMU interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | Pending EMU interrupt sources to clear. Use one or more valid interrupt flags for the EMU module EMU_IF_nnn. |
sl_hal_emu_get_pending_interrupts#
uint32_t sl_hal_emu_get_pending_interrupts (void )
Get pending EMU interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
EMU interrupt sources pending. Returns one or more valid interrupt flags for the EMU module (EMU_IF_nnn).
Note
Event bits are not cleared by the use of this function.
sl_hal_emu_get_enabled_pending_interrupts#
uint32_t sl_hal_emu_get_enabled_pending_interrupts (void )
Get enabled and pending EMU interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Useful for handling more interrupt sources in the same interrupt handler.
Returns
Pending and enabled EMU interrupt sources Return value is the bitwise AND of
the enabled interrupt sources in EMU_IEN and
the pending interrupt flags EMU_IF.
Note
Interrupt flags are not cleared by the use of this function.
sl_hal_emu_set_interrupts#
void sl_hal_emu_set_interrupts (uint32_t flags)
Set one or more pending EMU interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EMU interrupt sources to set to pending. Use one or more valid interrupt flags for the EMU module (EMU_IFS_nnn). |
sl_hal_emu_get_status#
uint32_t sl_hal_emu_get_status (void )
Get EMU STATUS register.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
STATUS register value.
sl_hal_emu_is_temperature_ready#
bool sl_hal_emu_is_temperature_ready (void )
Temperature measurement ready status.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
True if temperature measurement is ready.
sl_hal_emu_get_temperature#
float sl_hal_emu_get_temperature (void )
Get temperature in degrees Celsius.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
Temperature in degrees Celsius.
sl_hal_emu_clear_reset_cause#
void sl_hal_emu_clear_reset_cause (void )
Clear the reset cause register.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function clears all the reset cause bits of the RSTCAUSE register. The reset cause bits must be cleared by software before a new reset occurs. Otherwise, reset causes may accumulate. See sl_hal_emu_get_reset_cause().
sl_hal_emu_get_reset_cause#
uint32_t sl_hal_emu_get_reset_cause (void )
Get the cause of the last reset.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
To be useful, the reset cause must be cleared by software before a new reset occurs. Otherwise, reset causes may accumulate, See sl_hal_emu_clear_reset_cause(). This function call will return the main cause for reset, which can be a bit mask (several causes) and clear away "noise".
Returns
A reset cause mask. See the reference manual for a description of the reset cause mask.
sl_hal_emu_set_reset_control#
void sl_hal_emu_set_reset_control (sl_hal_emu_reset_source_t reset, sl_hal_emu_reset_mode_t mode)
Disable/enable reset for various peripherals and signal sources.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_hal_emu_reset_source_t | [in] | reset | Reset types to enable/disable. |
sl_hal_emu_reset_mode_t | [in] | mode | Reset mode. |