40 #include <inc/hw_types.h>
41 #include <inc/hw_ccfg.h>
55 #undef SysCtrlPowerEverything
56 #define SysCtrlPowerEverything NOROM_SysCtrlPowerEverything
57 #undef SysCtrlSetRechargeBeforePowerDown
58 #define SysCtrlSetRechargeBeforePowerDown NOROM_SysCtrlSetRechargeBeforePowerDown
59 #undef SysCtrlAdjustRechargeAfterPowerDown
60 #define SysCtrlAdjustRechargeAfterPowerDown NOROM_SysCtrlAdjustRechargeAfterPowerDown
61 #undef SysCtrl_DCDC_VoltageConditionalControl
62 #define SysCtrl_DCDC_VoltageConditionalControl NOROM_SysCtrl_DCDC_VoltageConditionalControl
63 #undef SysCtrlResetSourceGet
64 #define SysCtrlResetSourceGet NOROM_SysCtrlResetSourceGet
73 #define PD_STATE_CACHE_RET 1
74 #define PD_STATE_RFMEM_RET 2
75 #define PD_STATE_XOSC_LPM 4
76 #define PD_STATE_EXT_REG_MODE 8
124 uint32_t ui32AuxClocks;
221 int32_t shiftedTemp ;
222 int32_t deltaVddrSleepTrim ;
223 int32_t vddrTrimSleep ;
224 int32_t vddrTrimActve ;
225 int32_t diffVddrActiveSleep ;
226 uint32_t ccfg_ModeConfReg ;
228 uint32_t prcmRamRetention ;
237 uint32_t newRechargePeriod ;
240 const uint32_t * pLookupTable ;
261 deltaVddrSleepTrim = ((((int32_t) ccfg_ModeConfReg )
263 >> ( 32 - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_W )) + 1;
266 int32_t tcDelta = ( 62 - curTemp ) >> 3;
267 if ( tcDelta > 8 ) tcDelta = 8;
268 if ( tcDelta > deltaVddrSleepTrim ) deltaVddrSleepTrim = tcDelta;
280 vddrTrimSleep += deltaVddrSleepTrim;
281 if ( vddrTrimSleep > 21 ) vddrTrimSleep = 21;
282 if ( vddrTrimSleep < -10 ) vddrTrimSleep = -10;
299 if ((( curTemp - powerQualGlobals.
pdTemp ) >= 5 ) || ( curState != powerQualGlobals.
pdState )) {
301 shiftedTemp = curTemp - 15;
314 if ( shiftedTemp >= 0 ) {
316 shiftedTemp += ( shiftedTemp << 4 );
319 ti = ( shiftedTemp >> 8 );
329 cd = pLookupTable[ dii + 1 ] - pLookupTable[ dii ];
336 di += (( cd >> 8 ) & 0xFF );
339 di += (( cd >> 16 ) & 0xFF );
342 di += (( cd >> 24 ) & 0xFF );
350 cl = pLookupTable[ ti ];
357 load += (( cl >> 8 ) & 0xFF );
360 load += (( cl >> 16 ) & 0xFF );
363 load += (( cl >> 24 ) & 0xFF );
367 load += ((( di * ( shiftedTemp - ( ti << 8 ))) + 128 ) >> 8 );
374 diffVddrActiveSleep = ( vddrTrimActve - vddrTrimSleep );
375 if ( diffVddrActiveSleep < 1 ) diffVddrActiveSleep = 1;
376 k = ( diffVddrActiveSleep * 52 );
382 newRechargePeriod = ( vddrCap * k ) / load;
383 if ( newRechargePeriod > 0xFFFF ) {
384 newRechargePeriod = 0xFFFF;
389 if ( curTemp > 127 ) curTemp = 127;
390 if ( curTemp < -128 ) curTemp = -128;
391 powerQualGlobals.
pdTemp = curTemp;
392 powerQualGlobals.
pdState = curState;
406 while ( perM > 511 ) {
410 perM = ( perM - 15 ) >> 4;
429 uint32_t longestRechargePeriod ;
431 uint32_t newRechargePeriod ;
438 if ( longestRechargePeriod != 0 ) {
441 if ( curTemp < powerQualGlobals.
pdTemp ) {
442 if ( curTemp < -128 ) {
445 powerQualGlobals.
pdTemp = curTemp;
454 if ( deltaTime > 31 ) {
458 if ( newRechargePeriod > 0xFFFF ) {
459 newRechargePeriod = 0xFFFF;
475 uint32_t batThreshold ;
476 uint32_t aonBatmonBat ;
477 uint32_t ccfg_ModeConfReg ;
478 uint32_t aonSysctlPwrctl ;
487 if ( aonBatmonBat != 0 ) {
511 if ( aonBatmonBat < batThreshold ) {
520 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[]
#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 AUX_WUC_AIODIO0_CLOCK
#define PD_STATE_XOSC_LPM
#define AUX_WUC_ADI_CLOCK
#define PD_STATE_CACHE_RET
#define PRCM_PERIPH_TIMER2
#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
#define AUX_WUC_REF_CLOCK
#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 OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
#define RSTSRC_WAKEUP_FROM_SHUTDOWN
uint16_t pdRechargePeriod
#define AUX_WUC_TIMER_CLOCK
void SysCtrlPowerEverything(void)
Power up everything.
static int32_t SetupSignExtendVddrTrimValue(uint32_t ui32VddrTrimVal)
Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21)