MCUXpresso SDK API Reference Manual  Rev 2.12.1
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
VBAT: Smart Power Switch

Overview

The MCUXpresso SDK provides a peripheral driver for the Smart Power Switch (VBAT) block of MCUXpresso SDK devices.

Based on VBAT's features the VBAT driver are divided into 4 function groups.

FRO16K Control Interfaces

Functions in this group can be used to configure internal 16kHz free running oscillator.

RAM_LDO Control Interfaces

Functions in this group can be used to control internal bandgap and RAM_LDO.

Bandgap Timer Control Interfaces

Functions in this group can be used to control internal software bandgap timers. Please note that bandgap timers are available when the bandgap is enabled and are clocked by the FRO16k.

Status, Interrupt, Wakeup Control Interfaces

VBAT_GetStatusFlags() and VBAT_ClearStatusFlags() function in this group can be used to get and clear status flags. VBAT_EnableInterrupts() and VBAT_DisableInterrupts() function in this group can be used to enable/disable interrupt. VBAT_EnableWakeup() and VBAT_DisableWakeup() function in this group can be used to enable/disable wakeup features.

Data Structures

struct  vbat_fro16k_config_t
 The structure of internal 16kHz free running oscillator attributes. More...
 

Enumerations

enum  {
  kStatus_VBAT_Fro16kNotEnabled,
  kStatus_VBAT_BandgapNotEnabled = MAKE_STATUS(kStatusGroup_VBAT, 1)
}
 The enumeration of VBAT module status. More...
 
enum  _vbat_status_flag {
  kVBAT_StatusFlagPORDetect = VBAT_STATUSA_POR_DET_MASK,
  kVBAT_StatusFlagWakeupPin = VBAT_STATUSA_WAKEUP_FLAG_MASK,
  kVBAT_StatusFlagBandgapTimer0 = VBAT_STATUSA_TIMER0_FLAG_MASK,
  kVBAT_StatusFlagBandgapTimer1 = VBAT_STATUSA_TIMER1_FLAG_MASK,
  kVBAT_StatusFlagLdoReady = VBAT_STATUSA_LDO_RDY_MASK
}
 The enumeration of VBAT status flags. More...
 
enum  _vbat_interrupt_enable {
  kVBAT_InterruptEnablePORDetect = VBAT_IRQENA_POR_DET_MASK,
  kVBAT_InterruptEnableWakeupPin = VBAT_IRQENA_WAKEUP_FLAG_MASK,
  kVBAT_InterruptEnableBandgapTimer0 = VBAT_IRQENA_TIMER0_FLAG_MASK,
  kVBAT_InterruptEnableBandgapTimer1 = VBAT_IRQENA_TIMER1_FLAG_MASK,
  kVBAT_InterruptEnableLdoReady = VBAT_IRQENA_LDO_RDY_MASK,
  kVBAT_AllInterruptsEnable
}
 The enumeration of VBAT interrupt enable. More...
 
enum  _vbat_wakeup_enable {
  kVBAT_WakeupEnablePORDetect = VBAT_WAKENA_POR_DET_MASK,
  kVBAT_WakeupEnableWakeupPin = VBAT_WAKENA_WAKEUP_FLAG_MASK,
  kVBAT_WakeupEnableBandgapTimer0 = VBAT_WAKENA_TIMER0_FLAG_MASK,
  kVBAT_WakeupEnableBandgapTimer1 = VBAT_WAKENA_TIMER1_FLAG_MASK,
  kVBAT_WakeupEnableLdoReady = VBAT_WAKENA_LDO_RDY_MASK,
  kVBAT_AllWakeupsEnable
}
 The enumeration of VBAT wakeup enable. More...
 
enum  _vbat_bandgap_timer_id {
  kVBAT_BandgapTimer0 = 1U << 0U,
  kVBAT_BandgapTimer1 = 1U << 1U
}
 The enumeration of bandgap timer id, VBAT support two bandgap timers. More...
 
enum  vbat_bandgap_refresh_period_t {
  kVBAT_BandgapRefresh7P8125ms = 0U,
  kVBAT_BandgapRefresh15P625ms = 1U,
  kVBAT_BandgapRefresh31P25ms = 2U,
  kVBAT_BandgapRefresh62P5ms = 3U
}
 The enumeration of bandgap refresh period. More...
 
enum  vbat_bandgap_timer_timeout_period_t {
  kVBAT_BangapTimerTimeout1s = 0U,
  kVBAT_BangapTimerTimeout500ms = 1U,
  kVBAT_BangapTimerTimeout250ms = 2U,
  kVBAT_BangapTimerTimeout125ms = 3U,
  kVBAT_BangapTimerTimeout62P5ms = 4U,
  kVBAT_BangapTimerTimeout31P25ms = 5U
}
 The enumeration of bandgap timer timeout period. More...
 

Driver version

#define FSL_VBAT_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))
 VBAT driver version 2.1.0. More...
 

FRO16K Control Interfaces

void VBAT_ConfigFRO16k (VBAT_Type *base, const vbat_fro16k_config_t *config)
 Configure internal 16kHz free running oscillator, including enabel FRO16k, gate FRO16k output. More...
 
static void VBAT_EnableFRO16k (VBAT_Type *base, bool enable)
 Enable/disable internal 16kHz free running oscillator. More...
 
static bool VBAT_CheckFRO16kEnabled (VBAT_Type *base)
 Check if internal 16kHz free running oscillator is enabled. More...
 
static void VBAT_UngateFRO16k (VBAT_Type *base, bool unGateFRO16k)
 Ungate/gate FRO 16kHz output clock to other modules. More...
 
static void VBAT_LockFRO16kSettings (VBAT_Type *base)
 Lock settings of internal 16kHz free running oscillator, please note that if locked 16kHz FRO's settings can not be updated until the next POR. More...
 

RAM_LDO Control Interfaces

status_t VBAT_EnableBandgap (VBAT_Type *base, bool enable)
 Enable/disable Bandgap. More...
 
static bool VBAT_CheckBandgapEnabled (VBAT_Type *base)
 Check if bandgap is enabled. More...
 
static void VBAT_EnableBandgapRefreshMode (VBAT_Type *base, bool enableRefreshMode)
 Enable/disable bandgap low power refresh mode. More...
 
status_t VBAT_EnableBackupSRAMRegulator (VBAT_Type *base, bool enable)
 Enable/disable Backup RAM Regulator(RAM_LDO). More...
 
static void VBAT_LockLdoRamSettings (VBAT_Type *base)
 Lock settings of RAM_LDO, please note that if locked then RAM_LDO's settings can not be updated until the next POR. More...
 
status_t VBAT_SwitchSRAMPowerByVBAT (VBAT_Type *base)
 Switch the SRAM to be powered by VBAT in software mode. More...
 
static void VBAT_SwitchSRAMPowerBySocSupply (VBAT_Type *base)
 Switch the RAM to be powered by Soc Supply in software mode. More...
 
static void VBAT_EnableSRAMArrayRetained (VBAT_Type *base, bool enable)
 Enable/disable SRAM array remains powered from Soc power, when LDO_RAM is disabled. More...
 
static void VBAT_EnableSRAMIsolation (VBAT_Type *base, bool enable)
 Enable/disable SRAM isolation. More...
 

Bandgap Timer Control Interfaces

status_t VBAT_EnableBandgapTimer (VBAT_Type *base, bool enable, uint8_t timerIdMask)
 Enable/disable Bandgap timer. More...
 
void VBAT_SetBandgapTimerTimeoutValue (VBAT_Type *base, vbat_bandgap_timer_timeout_period_t timeoutPeriod, uint8_t timerIdMask)
 Set bandgap timer timeout value. More...
 

Status, Interrupt, Wakeup Control Interfaces

static uint32_t VBAT_GetStatusFlags (VBAT_Type *base)
 Get VBAT status flags. More...
 
static void VBAT_ClearStatusFlags (VBAT_Type *base, uint32_t mask)
 Clear VBAT status flags. More...
 
static void VBAT_EnableInterrupts (VBAT_Type *base, uint32_t mask)
 Enable interrupts for the VBAT module, such as POR detect interrupt, Wakeup Pin interrupt and so on. More...
 
static void VBAT_DisableInterrupts (VBAT_Type *base, uint32_t mask)
 Disable interrupts for the VBAT module, such as POR detect interrupt, wakeup pin interrupt and so on. More...
 
static void VBAT_EnableWakeup (VBAT_Type *base, uint32_t mask)
 Enable wakeup for the VBAT module, such as POR detect wakeup, wakeup pin wakeup and so on. More...
 
static void VBAT_DisableWakeup (VBAT_Type *base, uint32_t mask)
 Disable wakeup for VBAT module, such as POR detect wakeup, wakeup pin wakeup and so on. More...
 
static void VBAT_LockInterruptWakeupSettings (VBAT_Type *base)
 Lock VBAT interrupt and wakeup settings, please note that if locked the interrupt and wakeup settings can not be updated until the next POR. More...
 

Data Structure Documentation

struct vbat_fro16k_config_t

Data Fields

bool enableFRO16k
 Enable/disable internal 16kHz free running oscillator. More...
 
bool enableFRO16kOutput
 Enable/disable FRO 16k output clock to other modules. More...
 

Field Documentation

bool vbat_fro16k_config_t::enableFRO16k
bool vbat_fro16k_config_t::enableFRO16kOutput

Macro Definition Documentation

#define FSL_VBAT_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_VBAT_Fro16kNotEnabled 

Internal 16kHz free running oscillator not enabled.

kStatus_VBAT_BandgapNotEnabled 

Bandgap not enabled.

Enumerator
kVBAT_StatusFlagPORDetect 

VBAT domain has been reset.

kVBAT_StatusFlagWakeupPin 

A falling edge is detected on the wakeup pin.

kVBAT_StatusFlagBandgapTimer0 

Bandgap Timer0 period reached.

kVBAT_StatusFlagBandgapTimer1 

Bandgap Timer1 period reached.

kVBAT_StatusFlagLdoReady 

LDO is enabled and ready.

Enumerator
kVBAT_InterruptEnablePORDetect 

Enable POR detect interrupt.

kVBAT_InterruptEnableWakeupPin 

Enable the interrupt when a falling edge is detected on the wakeup pin.

kVBAT_InterruptEnableBandgapTimer0 

Enable the interrupt if Bandgap Timer0 period reached.

kVBAT_InterruptEnableBandgapTimer1 

Enable the interrupt if Bandgap Timer1 period reached.

kVBAT_InterruptEnableLdoReady 

Enable LDO ready interrupt.

kVBAT_AllInterruptsEnable 

Enable all interrupts.

Enumerator
kVBAT_WakeupEnablePORDetect 

Enable POR detect wakeup.

kVBAT_WakeupEnableWakeupPin 

Enable wakeup feature when a falling edge is detected on the wakeup pin.

kVBAT_WakeupEnableBandgapTimer0 

Enable wakeup feature when bandgap timer0 period reached.

kVBAT_WakeupEnableBandgapTimer1 

Enable wakeup feature when bandgap timer1 period reached.

kVBAT_WakeupEnableLdoReady 

Enable wakeup when LDO ready.

kVBAT_AllWakeupsEnable 

Enable all wakeup.

Enumerator
kVBAT_BandgapTimer0 

Bandgap Timer0.

kVBAT_BandgapTimer1 

Bandgap Timer1.

Enumerator
kVBAT_BandgapRefresh7P8125ms 

Bandgap refresh every 7.8125ms.

kVBAT_BandgapRefresh15P625ms 

Bandgap refresh every 15.625ms.

kVBAT_BandgapRefresh31P25ms 

Bandgap refresh every 31.25ms.

kVBAT_BandgapRefresh62P5ms 

Bandgap refresh every 62.5ms.

Enumerator
kVBAT_BangapTimerTimeout1s 

Bandgap timer timerout every 1s.

kVBAT_BangapTimerTimeout500ms 

Bandgap timer timerout every 500ms.

kVBAT_BangapTimerTimeout250ms 

Bandgap timer timerout every 250ms.

kVBAT_BangapTimerTimeout125ms 

Bandgap timer timerout every 125ms.

kVBAT_BangapTimerTimeout62P5ms 

Bandgap timer timerout every 62.5ms.

kVBAT_BangapTimerTimeout31P25ms 

Bandgap timer timerout every 31.25ms.

Function Documentation

void VBAT_ConfigFRO16k ( VBAT_Type *  base,
const vbat_fro16k_config_t config 
)
Parameters
baseVBAT peripheral base address.
configPointer to vbat_fro16k_config_t structure.
static void VBAT_EnableFRO16k ( VBAT_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
enableUsed to enable/disable 16kHz FRO.
  • true Enable internal 16kHz free running oscillator.
  • false Disable internal 16kHz free running oscillator.
static bool VBAT_CheckFRO16kEnabled ( VBAT_Type *  base)
inlinestatic
Parameters
baseVBAT peripheral base address.
Return values
trueThe internal 16kHz Free running oscillator is enabled.
falseThe internal 16kHz Free running oscillator is enabled.
static void VBAT_UngateFRO16k ( VBAT_Type *  base,
bool  unGateFRO16k 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
unGateFRO16kUsed to gate/ungate FRO 16kHz output.
  • true FRO 16kHz output clock to other modules is enabled.
  • false FRO 16kHz output clock to other modules is disabled.
static void VBAT_LockFRO16kSettings ( VBAT_Type *  base)
inlinestatic
Note
Please note that the operation to ungate/gate FRO 16kHz output clock can not be locked by this function.
Parameters
baseVBAT peripheral base address.
status_t VBAT_EnableBandgap ( VBAT_Type *  base,
bool  enable 
)
Note
The FRO16K must be enabled before enabling the bandgap.
This setting can be locked by VBAT_LockLdoRamSettings() function.
Parameters
baseVBAT peripheral base address.
enableUsed to enable/disable bandgap.
  • true Enable the bandgap.
  • false Disable the bandgap.
Return values
kStatus_SuccessSuccess to enable/disable the bandgap.
kStatus_VBAT_Fro16kNotEnabledFail to enable the bandgap due to FRO16k is not enabled previously.
static bool VBAT_CheckBandgapEnabled ( VBAT_Type *  base)
inlinestatic
Parameters
baseVBAT peripheral base address.
Return values
trueThe bandgap is enabled.
falseThe bandgap is disabled.
static void VBAT_EnableBandgapRefreshMode ( VBAT_Type *  base,
bool  enableRefreshMode 
)
inlinestatic
Note
This setting can be locked by VBAT_LockLdoRamSettings() function.
Parameters
baseVBAT peripheral base address.
enableRefreshModeUsed to enable/disable bandgap low power refresh mode.
  • true Enable bandgap low power refresh mode.
  • false Disable bandgap low power refresh mode.
status_t VBAT_EnableBackupSRAMRegulator ( VBAT_Type *  base,
bool  enable 
)
Note
This setting can be locked by VBAT_LockLdoRamSettings() function.
Parameters
baseVBAT peripheral base address.
enableUsed to enable/disable RAM_LDO.
  • true Enable backup SRAM regulator.
  • false Disable backup SRAM regulator.
Return values
kStatusSuccessSuccess to enable/disable backup SRAM regulator.
kStatus_VBAT_Fro16kNotEnabledFail to enable backup SRAM regulator due to FRO16k is not enabled previously.
kStatus_VBAT_BandgapNotEnabledFail to enable backup SRAM regulator due to the bandgap is not enabled previously.
static void VBAT_LockLdoRamSettings ( VBAT_Type *  base)
inlinestatic
Parameters
baseVBAT peripheral base address.
status_t VBAT_SwitchSRAMPowerByVBAT ( VBAT_Type *  base)
Note
This function can be used to switch the SRAM to the VBAT retention supply at any time, but please note that the SRAM must not be accessed during this time and software must manually invoke VBAT_SwitchSRAMPowerBySocSupply() before accessing the SRAM again.
Parameters
baseVBAT peripheral base address.
Return values
kStatusSuccessSuccess to Switch SRAM powered by VBAT.
kStatus_VBAT_Fro16kNotEnabledFail to switch SRAM powered by VBAT due to FRO16K not enabled previously.
static void VBAT_SwitchSRAMPowerBySocSupply ( VBAT_Type *  base)
inlinestatic
Parameters
baseVBAT peripheral base address.
static void VBAT_EnableSRAMArrayRetained ( VBAT_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
enableUsed to enable/disable SRAM array power retained.
  • true SRAM array is retained when powered from VDD_CORE.
  • false SRAM array is not retained when powered from VDD_CORE.
static void VBAT_EnableSRAMIsolation ( VBAT_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
enableUsed to enable/disable SRAM violation.
  • true SRAM will be isolated.
  • false SRAM state follows the SoC power modes.
status_t VBAT_EnableBandgapTimer ( VBAT_Type *  base,
bool  enable,
uint8_t  timerIdMask 
)
Note
The bandgap timer is available when the bandgap is enabled and are clocked by the FRO16k.
Parameters
baseVBAT peripheral base address.
enableUsed to enable/disable bandgap timer.
timerIdMaskThe mask of bandgap timer Id, should be the OR'ed value of vbat_bandgap_timer_id_t.
Return values
kStatus_SuccessSuccess to enable/disable selected bandgap timer.
kStatus_VBAT_Fro16kNotEnabledFail to enable/disable selected bandgap timer due to FRO16k not enabled previously.
kStatus_VBAT_BandgapNotEnabledFail to enable/disable selected bandgap timer due to bandgap not enabled previously.
void VBAT_SetBandgapTimerTimeoutValue ( VBAT_Type *  base,
vbat_bandgap_timer_timeout_period_t  timeoutPeriod,
uint8_t  timerIdMask 
)
Parameters
baseVBAT peripheral base address.
timeoutPeriodBandgap timer timeout value, please refer to vbat_bandgap_timer_timeout_period_t.
timerIdMaskThe mask of bandgap timer Id, should be the OR'ed value of vbat_bandgap_timer_id_t.
static uint32_t VBAT_GetStatusFlags ( VBAT_Type *  base)
inlinestatic
Parameters
baseVBAT peripheral base address.
Returns
The asserted status flags, should be the OR'ed value of vbat_status_flag_t.
static void VBAT_ClearStatusFlags ( VBAT_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
maskThe mask of status flags to be cleared, should be the OR'ed value of vbat_status_flag_t except kVBAT_StatusFlagLdoReady.
static void VBAT_EnableInterrupts ( VBAT_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
maskThe mask of interrupts to be enabled, should be the OR'ed value of vbat_interrupt_enable_t.
static void VBAT_DisableInterrupts ( VBAT_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
maskThe mask of interrupts to be disabled, should be the OR'ed value of vbat_interrupt_enable_t.
static void VBAT_EnableWakeup ( VBAT_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
maskThe mask of enumerators in vbat_wakeup_enable_t.
static void VBAT_DisableWakeup ( VBAT_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseVBAT peripheral base address.
maskThe mask of enumerators in vbat_wakeup_enable_t.
static void VBAT_LockInterruptWakeupSettings ( VBAT_Type *  base)
inlinestatic
Parameters
baseVBAT peripheral base address.