MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
POWER: Power Driver

Overview

This driver covers the PMU functions and SMU functions in PCRM module. PMU functions include VBAT and USB VBUS. SMU functions include the lower power modes, such as standby mode, ULP standby mode, ULPCD mode, and so on.

Macros

#define FSL_PMU_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
 PMU driver version. More...
 
#define PMU_USB_VBUS_DEBOUNCE_TIMEOUT   (0x0474)
 
#define PMU_USB_VBUSOK_WAIT_TIME   (5)
 
#define PMU_USB_VBUS_FASTDISCHARGE_ENABLE   (0)
 
#define SMU_PREVENTED_USER_ABORT   (0x04000000UL)
 
#define PCRM_SETREG(RegAddr, RegVal)   (void)PN76_Sys_WriteRegister((RegAddr), (RegVal))
 
#define PCRM_SETBITN(RegAddr, BitPos)   (void)PN76_Sys_WriteRegisterOrMask((RegAddr), (1UL << (uint32_t)(BitPos)))
 
#define PCRM_CLEARBITN(RegAddr, BitPos)   (void)PN76_Sys_WriteRegisterAndMask((RegAddr), ~(1UL << (uint32_t)(BitPos)))
 
#define PCRM_SETFIELD(RegAddr, BitMask, MaskVal)   (void)PN76_Sys_WriteRegisterField((RegAddr), (uint32_t)(BitMask), (uint32_t)(MaskVal))
 
#define PCRM_SETFIELDSHIFT(RegAddr, BitMask, BitPos, Value)   (void)PN76_Sys_WriteRegisterField((RegAddr), (uint32_t)(BitMask), ((uint32_t)(Value) << (uint32_t)(BitPos)))
 
#define PCRM_TESTBITN(RegAddr, BitPos)   PCRM_TestBitN((RegAddr), (BitPos))
 

Enumerations

enum  smu_hif_sel_t {
  kSMU_HifNone = 0,
  kSMU_HifI2c = 1,
  kSMU_HifSpi = 2,
  kSMU_HifUart = 3,
  kSMU_HifI3c = 4
}
 Host interface selection. More...
 
enum  smu_standby_prev_reason_t {
  kSMU_Success = 0U,
  kSMU_UserAbort = SMU_PREVENTED_USER_ABORT,
  kSMU_HostCommOngoing = PCRM_SYS_BOOT2_STS_PREV_HOSTCOMM_MASK,
  kSMU_SpiSelected = PCRM_SYS_BOOT2_STS_PREV_SPI_MASK,
  kSMU_I2cAddressSelected = PCRM_SYS_BOOT2_STS_PREV_I2C_MASK,
  kSMU_I3cAddressSelected = PCRM_SYS_BOOT2_STS_PREV_I3C_MASK,
  kSMU_HsuSelected = PCRM_SYS_BOOT2_STS_PREV_HSU_MASK,
  kSMU_Gpio3Selected = PCRM_SYS_BOOT2_STS_PREV_GPIO3_MASK,
  kSMU_Gpio2Selected = PCRM_SYS_BOOT2_STS_PREV_GPIO2_MASK,
  kSMU_Gpio1Selected = PCRM_SYS_BOOT2_STS_PREV_GPIO1_MASK,
  kSMU_Gpio0Selected = PCRM_SYS_BOOT2_STS_PREV_GPIO0_MASK,
  kSMU_WucEqualZero = PCRM_SYS_BOOT2_STS_PREV_WUC_MASK,
  kSMU_LpdetEvent = PCRM_SYS_BOOT2_STS_PREV_LPDET_MASK,
  kSMU_UlpdetEvent = PCRM_SYS_BOOT2_STS_PREV_RX_ULPDET_MASK,
  kSMU_NoVddioOn = PCRM_SYS_BOOT2_STS_PREV_INT_NO_VDDIO_MASK,
  kSMU_TempErrorLow = PCRM_SYS_BOOT2_STS_PREV_TEMP_MASK,
  kSMU_InterfaceError = PCRM_SYS_BOOT2_STS_PREV_INTERFACE_MASK,
  kSMU_VddioLoss = PCRM_SYS_BOOT2_STS_PREV_VDDIO_LOSS_MASK,
  kSMU_NoWakeupEnabled = PCRM_SYS_BOOT2_STS_PREV_NOENABLE_MASK,
  kSMU_VupDetected = PCRM_SYS_BOOT2_STS_PREV_VUPDET_MASK,
  kSMU_RxProt = PCRM_SYS_BOOT2_STS_PREV_RXPROT_MASK
}
 Standby Prevention Reasons. More...
 

Standby wake-up sources

#define SMU_WAKEUP_SOURCE_TIMER   (0x00000001UL)
 
#define SMU_WAKEUP_SOURCE_HOST   (0x00000002UL)
 
#define SMU_WAKEUP_SOURCE_RFFIELD   (0x00000004UL)
 
#define SMU_WAKEUP_SOURCE_TEMPSENSOR   (0x00000008UL)
 
#define SMU_WAKEUP_SOURCE_VUP   (0x00000010UL)
 
#define SMU_WAKEUP_SOURCE_VDDIO_LOSS   (0x00000020UL)
 
#define SMU_WAKEUP_SOURCE_RX_PROT   (0x00000040UL)
 
#define SMU_WAKEUP_SOURCE_VDDIO_START   (0x00000080UL)
 
#define SMU_WAKEUP_SOURCE_GPIO_MASK   (0x00000F00UL)
 
#define SMU_WAKEUP_SOURCE_GPIO0   (0x00000100UL)
 
#define SMU_WAKEUP_SOURCE_GPIO1   (0x00000200UL)
 
#define SMU_WAKEUP_SOURCE_GPIO2   (0x00000400UL)
 
#define SMU_WAKEUP_SOURCE_GPIO3   (0x00000800UL)
 
#define SMU_WAKEUP_SOURCE_ULPDET   (0x00001000UL)
 

PMU APIs

void PMU_Init (void)
 This Initializes the Power Management Unit.
 
void PMU_HandleIRQ (void)
 This function is called when Pmu interrupt is triggered.
 
void PMU_VbatMonitorConfig (bool enableMonitor, bool setStandbyCfg)
 This function configures the VBAT monitoring FSM. More...
 
status_t PMU_UsbVbusCheck (void)
 This function enables USB VBUS Monitor and checks USB VBUS. More...
 
void PCRM_IRQHandler (void)
 

SMU APIs

void SMU_Init (void)
 This function is used to Initialize the Smu. More...
 
void SMU_ReEnterStandby (void)
 This function is used to Re-enter into standby mode. More...
 
void SMU_EnterStandby (uint32_t dwWakeUpSource, uint32_t dwWakeUpCntValue, smu_standby_prev_reason_t *ptStandbyPrevReason)
 This function is used to Switch into standby mode. More...
 
void SMU_Enter_UlpStandby (uint16_t wWakeupSource, uint16_t dwWakeUpCntValue)
 This function is used to Switch into ULP Standby with wakeup counter time. More...
 
void SMU_EnterULPCD (uint16_t dwWakeUpCntValue, uint8_t bCalibrationEn, uint16_t wwakeupsrc)
 This function is used to Switch into ULPCD mode. More...
 
void SMU_RestoreStandby (uint32_t dwWakeUpSource)
 Function used to restore context if for some reason we fail going in standby. More...
 

Macro Definition Documentation

#define FSL_PMU_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
#define PMU_USB_VBUS_DEBOUNCE_TIMEOUT   (0x0474)

USB VBUS debounce time, used for USB VBUS detection

#define PMU_USB_VBUSOK_WAIT_TIME   (5)

Timeout for waiting for USB VBUS HI (Unit - us)

#define PMU_USB_VBUS_FASTDISCHARGE_ENABLE   (0)

Enable/Disable Fast discharge for USB VBUS

#define SMU_WAKEUP_SOURCE_TIMER   (0x00000001UL)

Wake Up source is Timer

#define SMU_WAKEUP_SOURCE_HOST   (0x00000002UL)

Wake Up source is communication on Host Interface

#define SMU_WAKEUP_SOURCE_RFFIELD   (0x00000004UL)

Wake Up source is Presence of External RF Field

#define SMU_WAKEUP_SOURCE_TEMPSENSOR   (0x00000008UL)

Wake Up source is Temperature of the IC

#define SMU_WAKEUP_SOURCE_VUP   (0x00000010UL)

Wake Up source is Voltage Monitor

#define SMU_WAKEUP_SOURCE_VDDIO_LOSS   (0x00000020UL)

Wake Up due to VDDIO loss

#define SMU_WAKEUP_SOURCE_RX_PROT   (0x00000040UL)

Wake Up in case of RX_PROT

#define SMU_WAKEUP_SOURCE_VDDIO_START   (0x00000080UL)

Wake Up in case of VDDIO Start

#define SMU_WAKEUP_SOURCE_GPIO_MASK   (0x00000F00UL)

Bit mask for GPIO wake up sources

#define SMU_WAKEUP_SOURCE_GPIO0   (0x00000100UL)

Wake Up source is GPIO0

#define SMU_WAKEUP_SOURCE_GPIO1   (0x00000200UL)

Wake Up source is GPIO1

#define SMU_WAKEUP_SOURCE_GPIO2   (0x00000400UL)

Wake Up source is GPIO2

#define SMU_WAKEUP_SOURCE_GPIO3   (0x00000800UL)

Wake Up source is GPIO3

#define SMU_WAKEUP_SOURCE_ULPDET   (0x00001000UL)

Wake Up source is ULPDET

#define SMU_PREVENTED_USER_ABORT   (0x04000000UL)

Prevention reason in case of User aborting standby

#define PCRM_SETREG (   RegAddr,
  RegVal 
)    (void)PN76_Sys_WriteRegister((RegAddr), (RegVal))

Macro to write a register

#define PCRM_SETBITN (   RegAddr,
  BitPos 
)    (void)PN76_Sys_WriteRegisterOrMask((RegAddr), (1UL << (uint32_t)(BitPos)))

Macro to set a bit

#define PCRM_CLEARBITN (   RegAddr,
  BitPos 
)    (void)PN76_Sys_WriteRegisterAndMask((RegAddr), ~(1UL << (uint32_t)(BitPos)))

Macro to clear a bit

#define PCRM_SETFIELD (   RegAddr,
  BitMask,
  MaskVal 
)    (void)PN76_Sys_WriteRegisterField((RegAddr), (uint32_t)(BitMask), (uint32_t)(MaskVal))

Macro to write a specific field in a register

#define PCRM_SETFIELDSHIFT (   RegAddr,
  BitMask,
  BitPos,
  Value 
)    (void)PN76_Sys_WriteRegisterField((RegAddr), (uint32_t)(BitMask), ((uint32_t)(Value) << (uint32_t)(BitPos)))

Macro to write a specific field at specific position in a register

#define PCRM_TESTBITN (   RegAddr,
  BitPos 
)    PCRM_TestBitN((RegAddr), (BitPos))

Macro to to test a bit

Enumeration Type Documentation

Enumerator
kSMU_HifNone 

no Interface selected (Reset state)

kSMU_HifI2c 

I2C selected

kSMU_HifSpi 

SPI selected

kSMU_HifUart 

UART selected

kSMU_HifI3c 

I3C selected

Enumerator
kSMU_Success 

Standby applied

kSMU_UserAbort 

User Abort

kSMU_HostCommOngoing 

Host communication ongoing

kSMU_SpiSelected 

SPI interface selected and spi_nss pin is low

kSMU_I2cAddressSelected 

I2C interface selected and Venus I2C address detected

kSMU_I3cAddressSelected 

I3C interface selected and Venus I2C address detected

kSMU_HsuSelected 

HSU interface selected and hsu_rx pin is low

kSMU_Gpio3Selected 

GPIO3 selected and GPIO3 pins has polarity as wakeup polarity

kSMU_Gpio2Selected 

GPIO2 selected and GPIO2 pins has polarity as wakeup polarity

kSMU_Gpio1Selected 

GPIO1 selected and GPIO1 pins has polarity as wakeup polarity

kSMU_Gpio0Selected 

GPIO0 selected and GPIO0 pins has polarity as wakeup polarity

kSMU_WucEqualZero 

Wake up counter is enabled but wake up counter value is equal to zero

kSMU_LpdetEvent 

Either RF Level detector is activated as wake up source and RF level Detector is not enabled or RF Field is already present

kSMU_UlpdetEvent 

ULPDET wakeup active

kSMU_NoVddioOn 

Host Interface is selected as wake up source and no VDDIO is available

kSMU_TempErrorLow 

Temperature Error is selected as wake up source AND the temp_error_irq signal is low

kSMU_InterfaceError 

Wrong HIF Selection or NSS is low

kSMU_VddioLoss 

power loss on VDDIO

kSMU_NoWakeupEnabled 

No Wake up source in the PCRM_SYS_STBY_CFG is enabled.

kSMU_VupDetected 

VUP has been switched on

kSMU_RxProt 

RX Prot

Function Documentation

void PMU_VbatMonitorConfig ( bool  enableMonitor,
bool  setStandbyCfg 
)
Parameters
enableMonitorEnable/disable VBAT monitor
setStandbyCfgPut the standby configuration if true
status_t PMU_UsbVbusCheck ( void  )
Return values
kStatus_SuccessOperation successful
kStatus_TimeoutOperation Timed out
void SMU_Init ( void  )
Returns
Nothing to Return
void SMU_ReEnterStandby ( void  )
Returns
Nothing to Return
Note
The function will never return if switch into standby was successful.
void SMU_EnterStandby ( uint32_t  dwWakeUpSource,
uint32_t  dwWakeUpCntValue,
smu_standby_prev_reason_t ptStandbyPrevReason 
)
Parameters
[in]dwWakeUpSource: Selection of wake-up source.
[in]dwWakeUpCntValue: 10 bit wake-up counter value: resolution=2, 63ms -> max time slot=2,57s
[out]ptStandbyPrevReason: Pointer to enum standby prevention reason
Note
The function will never return if switch into standby was successful.
In case the function returns, the standby prevention can be found in smu_standby_prev_reason_t.
void SMU_Enter_UlpStandby ( uint16_t  wWakeupSource,
uint16_t  dwWakeUpCntValue 
)
Parameters
wWakeupSource: Selection of wake-up source
dwWakeUpCntValue: 12 bit wake-up counter value. Max value = 4094msecs(Tulpcd_wkup_time = dwWakeUpCntValue * Tulfo)
Returns
Nothing to Return
Note
The function will never return if switch into standby was successful.
void SMU_EnterULPCD ( uint16_t  dwWakeUpCntValue,
uint8_t  bCalibrationEn,
uint16_t  wwakeupsrc 
)
Parameters
dwWakeUpCntValue: 12 bit wake-up counter value. Max value = 4094msecs.
bCalibrationEn: To enable or disable calibration. 1: Calibration enable. 0: Calibration disabled
wwakeupsrc: Selection of wake-up source. SMU_WAKEUP_SOURCE_ULPDET(0x00001000UL) to enabled ULPDET, any other value ULPDET is disabled
Returns
Nothing to Return
Note
The function will never return if switch into ULPCD was successful.
void SMU_RestoreStandby ( uint32_t  dwWakeUpSource)
Parameters
dwWakeUpSource: Selection of wake-up source.
Returns
Nothing to Return