40 #include <inc/hw_types.h>
41 #include <inc/hw_ccfg.h>
56 #undef SysCtrlPowerEverything
57 #define SysCtrlPowerEverything NOROM_SysCtrlPowerEverything
59 #define SysCtrlStandby NOROM_SysCtrlStandby
60 #undef SysCtrlPowerdown
61 #define SysCtrlPowerdown NOROM_SysCtrlPowerdown
62 #undef SysCtrlShutdown
63 #define SysCtrlShutdown NOROM_SysCtrlShutdown
64 #undef SysCtrlResetSourceGet
65 #define SysCtrlResetSourceGet NOROM_SysCtrlResetSourceGet
74 #define PD_STATE_CACHE_RET 1
75 #define PD_STATE_RFMEM_RET 2
76 #define PD_STATE_XOSC_LPM 4
77 #define PD_STATE_EXT_REG_MODE 8
124 uint32_t ui32AuxClocks;
329 #define CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_WIDTH 4
340 int32_t shiftedTemp ;
341 int32_t deltaVddrSleepTrim ;
342 int32_t vddrTrimSleep ;
343 int32_t vddrTrimActve ;
344 int32_t diffVddrActiveSleep ;
345 uint32_t ccfg_ModeConfReg ;
347 uint32_t prcmRamRetention ;
356 uint32_t newRechargePeriod ;
359 const uint32_t * pLookupTable ;
380 deltaVddrSleepTrim = ((((int32_t) ccfg_ModeConfReg )
385 int32_t tcDelta = ( 62 - curTemp ) >> 3;
386 if ( tcDelta > 8 ) tcDelta = 8;
387 if ( tcDelta > deltaVddrSleepTrim ) deltaVddrSleepTrim = tcDelta;
399 vddrTrimSleep += deltaVddrSleepTrim;
400 if ( vddrTrimSleep > 21 ) vddrTrimSleep = 21;
401 if ( vddrTrimSleep < -10 ) vddrTrimSleep = -10;
418 if ((( curTemp - powerQualGlobals.
pdTemp ) >= 5 ) || ( curState != powerQualGlobals.
pdState )) {
420 shiftedTemp = curTemp - 15;
433 if ( shiftedTemp >= 0 ) {
435 shiftedTemp += ( shiftedTemp << 4 );
438 ti = ( shiftedTemp >> 8 );
448 cd = pLookupTable[ dii + 1 ] - pLookupTable[ dii ];
455 di += (( cd >> 8 ) & 0xFF );
458 di += (( cd >> 16 ) & 0xFF );
461 di += (( cd >> 24 ) & 0xFF );
469 cl = pLookupTable[ ti ];
476 load += (( cl >> 8 ) & 0xFF );
479 load += (( cl >> 16 ) & 0xFF );
482 load += (( cl >> 24 ) & 0xFF );
486 load += ((( di * ( shiftedTemp - ( ti << 8 ))) + 128 ) >> 8 );
493 diffVddrActiveSleep = ( vddrTrimActve - vddrTrimSleep );
494 if ( diffVddrActiveSleep < 1 ) diffVddrActiveSleep = 1;
495 k = ( diffVddrActiveSleep * 52 );
501 newRechargePeriod = ( vddrCap * k ) / load;
502 if ( newRechargePeriod > 0xFFFF ) {
503 newRechargePeriod = 0xFFFF;
508 if ( curTemp > 127 ) curTemp = 127;
509 if ( curTemp < -128 ) curTemp = -128;
510 powerQualGlobals.
pdTemp = curTemp;
511 powerQualGlobals.
pdState = curState;
525 while ( perM > 511 ) {
529 perM = ( perM - 15 ) >> 4;
548 uint32_t longestRechargePeriod ;
550 uint32_t newRechargePeriod ;
557 if ( longestRechargePeriod != 0 ) {
560 if ( curTemp < powerQualGlobals.
pdTemp ) {
561 if ( curTemp < -128 ) {
564 powerQualGlobals.
pdTemp = curTemp;
573 if ( deltaTime > 31 ) {
577 if ( newRechargePeriod > 0xFFFF ) {
578 newRechargePeriod = 0xFFFF;
594 uint32_t batThreshold ;
595 uint32_t aonBatmonBat ;
596 uint32_t ccfg_ModeConfReg ;
597 uint32_t aonSysctlPwrctl ;
606 if ( aonBatmonBat != 0 ) {
628 if ( aonBatmonBat < batThreshold ) {
637 if ( aonBatmonBat > batThreshold ) {
#define AUX_WUC_TDC_CLOCK
#define PRCM_PERIPH_TIMER1
static void AONWUCAuxWakeupEvent(uint32_t ui32Mode)
Control the wake up procedure of the AUX domain.
#define XOSC_IN_HIGH_POWER_MODE
static uint32_t AONWUCPowerStatusGet(void)
Get the power status of the device.
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
void AUXWUCClockEnable(uint32_t ui32Clocks)
Enable clocks for peripherals in the AUX domain.
static const uint32_t g_pui32ModuleCG[]
int32_t SignExtendVddrTrimValue(uint32_t ui32VddrTrimVal)
Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21)
#define AUX_WUC_OSCCTRL_CLOCK
void SysCtrl_DCDC_VoltageConditionalControl(void)
Turns DCDC on or off depending of what is considered to be optimal usage.
uint32_t AUXWUCClockStatus(uint32_t ui32Clocks)
Get the status of a clock.
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
#define PRCM_PERIPH_TIMER0
uint32_t PRCMPowerDomainStatus(uint32_t ui32Domains)
Get the status for a specific power domain.
#define AUX_WUC_CLOCK_READY
uint32_t SysCtrlResetSourceGet(void)
Returns last reset source (including "wakeup from shutdown").
#define CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_WIDTH
#define AUX_WUC_AIODIO0_CLOCK
#define PD_STATE_XOSC_LPM
#define AUX_WUC_ADI_CLOCK
#define PD_STATE_CACHE_RET
#define PRCM_PERIPH_TIMER2
void OSCInterfaceEnable(void)
Enable System CPU access to the OSC_DIG module.
#define AONWUC_AUX_POWER_ON
void PRCMPeripheralSleepEnable(uint32_t ui32Peripheral)
Enables a peripheral in sleep mode.
#define AUX_WUC_AIODIO1_CLOCK
#define PRCM_DOMAIN_PERIPH
#define PD_STATE_EXT_REG_MODE
static bool PRCMLoadGet(void)
Check if any of the load sensitive register has been updated.
#define AONWUC_AUX_WAKEUP
#define PRCM_PERIPH_TIMER3
void SysCtrlAdjustRechargeAfterPowerDown(void)
Adjust Recharge calculations to be used next.
static PowerQualGlobals_t powerQualGlobals
#define AUX_WUC_SMPH_CLOCK
#define PD_STATE_RFMEM_RET
#define PRCM_PERIPH_CRYPTO
void SysCtrlShutdown(void)
Force the system in to shutdown.
void SysCtrlStandby(void)
Force the system in to standby mode.
#define AUX_WUC_REF_CLOCK
void PowerCtrlStateSet(uint32_t ui32Powerstate)
Force the system into low power modes.
#define PRCM_PERIPH_UART0
void SysCtrlSetRechargeBeforePowerDown(uint32_t xoscPowerMode)
Set Recharge values before entering Power Down.
#define AUX_WUC_TDCIF_CLOCK
static void PRCMDomainEnable(uint32_t ui32Domains)
Enable clock domains in the MCU voltage domain.
#define PRCM_DOMAIN_POWER_ON
void PRCMPowerDomainOn(uint32_t ui32Domains)
Turn power on in power domains in the MCU domain.
#define AUX_WUC_ANAIF_CLOCK
#define PRCM_DOMAIN_SERIAL
#define PRCM_DOMAIN_RFCORE
static void PRCMLoadSet(void)
Use this function to synchronize the load settings.
void PRCMPeripheralRunEnable(uint32_t ui32Peripheral)
Enables a peripheral in Run mode.
void PRCMPeripheralDeepSleepEnable(uint32_t ui32Peripheral)
Enables a peripheral in deep-sleep mode.
#define AUX_WUC_ADC_CLOCK
void SysCtrlPowerdown(void)
Force the system in to power down.
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
#define RSTSRC_WAKEUP_FROM_SHUTDOWN
static void OSCInterfaceDisable(void)
Disable System CPU access to the OSC_DIG module.
uint16_t pdRechargePeriod
#define PWRCTRL_POWER_DOWN
#define AUX_WUC_TIMER_CLOCK
void SysCtrlPowerEverything(void)
Power up everything.