Use ENERGEST_SWITCH to switch between different power modes to improve energest accuracy.
This commit is contained in:
parent
92c1a68b94
commit
2f79810b58
|
@ -128,8 +128,7 @@ periph_permit_pm1(void)
|
||||||
static void
|
static void
|
||||||
enter_pm0(void)
|
enter_pm0(void)
|
||||||
{
|
{
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
/* We are only interested in IRQ energest while idle or in LPM */
|
/* We are only interested in IRQ energest while idle or in LPM */
|
||||||
ENERGEST_IRQ_RESTORE(irq_energest);
|
ENERGEST_IRQ_RESTORE(irq_energest);
|
||||||
|
@ -147,8 +146,7 @@ enter_pm0(void)
|
||||||
/* Remember IRQ energest for next pass */
|
/* Remember IRQ energest for next pass */
|
||||||
ENERGEST_IRQ_SAVE(irq_energest);
|
ENERGEST_IRQ_SAVE(irq_energest);
|
||||||
|
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
|
@ -238,8 +236,7 @@ lpm_exit()
|
||||||
/* Remember IRQ energest for next pass */
|
/* Remember IRQ energest for next pass */
|
||||||
ENERGEST_IRQ_SAVE(irq_energest);
|
ENERGEST_IRQ_SAVE(irq_energest);
|
||||||
|
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
@ -312,8 +309,7 @@ lpm_enter()
|
||||||
|
|
||||||
/* We are only interested in IRQ energest while idle or in LPM */
|
/* We are only interested in IRQ energest while idle or in LPM */
|
||||||
ENERGEST_IRQ_RESTORE(irq_energest);
|
ENERGEST_IRQ_RESTORE(irq_energest);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
/* Remember the current time so we can keep stats when we wake up */
|
/* Remember the current time so we can keep stats when we wake up */
|
||||||
if(LPM_CONF_STATS) {
|
if(LPM_CONF_STATS) {
|
||||||
|
@ -339,8 +335,7 @@ lpm_enter()
|
||||||
|
|
||||||
/* Remember IRQ energest for next pass */
|
/* Remember IRQ energest for next pass */
|
||||||
ENERGEST_IRQ_SAVE(irq_energest);
|
ENERGEST_IRQ_SAVE(irq_energest);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
|
||||||
} else {
|
} else {
|
||||||
/* All clear. Assert WFI and drop to PM1/2. This is now un-interruptible */
|
/* All clear. Assert WFI and drop to PM1/2. This is now un-interruptible */
|
||||||
assert_wfi();
|
assert_wfi();
|
||||||
|
|
|
@ -202,8 +202,7 @@ wake_up(void)
|
||||||
|
|
||||||
/* Remember IRQ energest for next pass */
|
/* Remember IRQ energest for next pass */
|
||||||
ENERGEST_IRQ_SAVE(irq_energest);
|
ENERGEST_IRQ_SAVE(irq_energest);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
/* Sync so that we get the latest values before adjusting recharge settings */
|
/* Sync so that we get the latest values before adjusting recharge settings */
|
||||||
ti_lib_sys_ctrl_aon_sync();
|
ti_lib_sys_ctrl_aon_sync();
|
||||||
|
@ -396,8 +395,7 @@ lpm_drop()
|
||||||
|
|
||||||
/* We are only interested in IRQ energest while idle or in LPM */
|
/* We are only interested in IRQ energest while idle or in LPM */
|
||||||
ENERGEST_IRQ_RESTORE(irq_energest);
|
ENERGEST_IRQ_RESTORE(irq_energest);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
/* Sync the AON interface to ensure all writes have gone through. */
|
/* Sync the AON interface to ensure all writes have gone through. */
|
||||||
ti_lib_sys_ctrl_aon_sync();
|
ti_lib_sys_ctrl_aon_sync();
|
||||||
|
@ -429,8 +427,7 @@ lpm_drop()
|
||||||
void
|
void
|
||||||
lpm_sleep(void)
|
lpm_sleep(void)
|
||||||
{
|
{
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
/* We are only interested in IRQ energest while idle or in LPM */
|
/* We are only interested in IRQ energest while idle or in LPM */
|
||||||
ENERGEST_IRQ_RESTORE(irq_energest);
|
ENERGEST_IRQ_RESTORE(irq_energest);
|
||||||
|
@ -443,8 +440,7 @@ lpm_sleep(void)
|
||||||
/* Remember IRQ energest for next pass */
|
/* Remember IRQ energest for next pass */
|
||||||
ENERGEST_IRQ_SAVE(irq_energest);
|
ENERGEST_IRQ_SAVE(irq_energest);
|
||||||
|
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
|
|
@ -335,8 +335,7 @@ main(void) CC_NON_BANKED
|
||||||
if(SLEEPCMD & SLEEP_MODE0) {
|
if(SLEEPCMD & SLEEP_MODE0) {
|
||||||
#endif /* LPM_MODE==LPM_MODE_PM2 */
|
#endif /* LPM_MODE==LPM_MODE_PM2 */
|
||||||
|
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
/* We are only interested in IRQ energest while idle or in LPM */
|
/* We are only interested in IRQ energest while idle or in LPM */
|
||||||
ENERGEST_IRQ_RESTORE(irq_energest);
|
ENERGEST_IRQ_RESTORE(irq_energest);
|
||||||
|
@ -352,8 +351,7 @@ main(void) CC_NON_BANKED
|
||||||
/* Remember energest IRQ for next pass */
|
/* Remember energest IRQ for next pass */
|
||||||
ENERGEST_IRQ_SAVE(irq_energest);
|
ENERGEST_IRQ_SAVE(irq_energest);
|
||||||
|
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
#if (LPM_MODE==LPM_MODE_PM2)
|
#if (LPM_MODE==LPM_MODE_PM2)
|
||||||
SLEEPCMD &= ~SLEEP_OSC_PD; /* Make sure both HS OSCs are on */
|
SLEEPCMD &= ~SLEEP_OSC_PD; /* Make sure both HS OSCs are on */
|
||||||
|
|
|
@ -307,8 +307,7 @@ main(int argc, char **argv)
|
||||||
static unsigned long irq_energest = 0;
|
static unsigned long irq_energest = 0;
|
||||||
|
|
||||||
/* Re-enable interrupts and go to sleep atomically. */
|
/* Re-enable interrupts and go to sleep atomically. */
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
/* We only want to measure the processing done in IRQs when we
|
/* We only want to measure the processing done in IRQs when we
|
||||||
are asleep, so we discard the processing time done when we
|
are asleep, so we discard the processing time done when we
|
||||||
were awake. */
|
were awake. */
|
||||||
|
@ -327,8 +326,7 @@ main(int argc, char **argv)
|
||||||
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
||||||
eint();
|
eint();
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,15 +251,13 @@ main(void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
/* watchdog_stop(); */
|
||||||
/* watchdog_stop(); */
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
/* Go to idle mode. */
|
/* Go to idle mode. */
|
||||||
halSleepWithOptions(SLEEPMODE_IDLE,0);
|
halSleepWithOptions(SLEEPMODE_IDLE,0);
|
||||||
/* We are awake. */
|
/* We are awake. */
|
||||||
/* watchdog_start(); */
|
/* watchdog_start(); */
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,15 +165,13 @@ main(int argc, char **argv)
|
||||||
r = process_run();
|
r = process_run();
|
||||||
} while(r > 0);
|
} while(r > 0);
|
||||||
|
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
watchdog_stop();
|
watchdog_stop();
|
||||||
asm volatile("wait");
|
asm volatile("wait");
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
|
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -346,8 +346,7 @@ main(void)
|
||||||
if(SLEEP & SLEEP_MODE0) {
|
if(SLEEP & SLEEP_MODE0) {
|
||||||
#endif /* LPM_MODE==LPM_MODE_PM2 */
|
#endif /* LPM_MODE==LPM_MODE_PM2 */
|
||||||
|
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
/* We are only interested in IRQ energest while idle or in LPM */
|
/* We are only interested in IRQ energest while idle or in LPM */
|
||||||
ENERGEST_IRQ_RESTORE(irq_energest);
|
ENERGEST_IRQ_RESTORE(irq_energest);
|
||||||
|
@ -363,8 +362,7 @@ main(void)
|
||||||
/* Remember energest IRQ for next pass */
|
/* Remember energest IRQ for next pass */
|
||||||
ENERGEST_IRQ_SAVE(irq_energest);
|
ENERGEST_IRQ_SAVE(irq_energest);
|
||||||
|
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
|
||||||
|
|
||||||
#if (LPM_MODE==LPM_MODE_PM2)
|
#if (LPM_MODE==LPM_MODE_PM2)
|
||||||
SLEEP &= ~OSC_PD; /* Make sure both HS OSCs are on */
|
SLEEP &= ~OSC_PD; /* Make sure both HS OSCs are on */
|
||||||
|
|
|
@ -465,8 +465,7 @@ main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Re-enable interrupts and go to sleep atomically. */
|
/* Re-enable interrupts and go to sleep atomically. */
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
/* We only want to measure the processing done in IRQs when we
|
/* We only want to measure the processing done in IRQs when we
|
||||||
are asleep, so we discard the processing time done when we
|
are asleep, so we discard the processing time done when we
|
||||||
were awake. */
|
were awake. */
|
||||||
|
@ -489,8 +488,7 @@ main(int argc, char **argv)
|
||||||
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
||||||
eint();
|
eint();
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -425,8 +425,7 @@ main(int argc, char **argv)
|
||||||
static unsigned long irq_energest = 0;
|
static unsigned long irq_energest = 0;
|
||||||
|
|
||||||
/* Re-enable interrupts and go to sleep atomically. */
|
/* Re-enable interrupts and go to sleep atomically. */
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
/* We only want to measure the processing done in IRQs when we
|
/* We only want to measure the processing done in IRQs when we
|
||||||
are asleep, so we discard the processing time done when we
|
are asleep, so we discard the processing time done when we
|
||||||
were awake. */
|
were awake. */
|
||||||
|
@ -445,8 +444,7 @@ main(int argc, char **argv)
|
||||||
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
||||||
eint();
|
eint();
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,8 +452,7 @@ main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Re-enable interrupts and go to sleep atomically. */
|
/* Re-enable interrupts and go to sleep atomically. */
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
|
||||||
/* We only want to measure the processing done in IRQs when we
|
/* We only want to measure the processing done in IRQs when we
|
||||||
are asleep, so we discard the processing time done when we
|
are asleep, so we discard the processing time done when we
|
||||||
were awake. */
|
were awake. */
|
||||||
|
@ -472,8 +471,7 @@ main(int argc, char **argv)
|
||||||
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
||||||
eint();
|
eint();
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
|
||||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue