Merge pull request #1371 from g-oikonomou/bugfix/cc26xx/lpm-operation
Improve the stability of CC13xx/CC26xx low-power operation
This commit is contained in:
commit
ab59a387b3
|
@ -142,14 +142,12 @@ soc_rtc_last_isr_time(void)
|
||||||
void
|
void
|
||||||
soc_rtc_isr(void)
|
soc_rtc_isr(void)
|
||||||
{
|
{
|
||||||
uint32_t now, next;
|
uint32_t next;
|
||||||
|
|
||||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||||
|
|
||||||
last_isr_time = RTIMER_NOW();
|
last_isr_time = RTIMER_NOW();
|
||||||
|
|
||||||
now = ti_lib_aon_rtc_current_compare_value_get();
|
|
||||||
|
|
||||||
/* Adjust the s/w tick counter irrespective of which event trigger this */
|
/* Adjust the s/w tick counter irrespective of which event trigger this */
|
||||||
clock_update();
|
clock_update();
|
||||||
|
|
||||||
|
@ -161,7 +159,8 @@ soc_rtc_isr(void)
|
||||||
* event on the next 512 tick boundary. If we drop to deep sleep before it
|
* event on the next 512 tick boundary. If we drop to deep sleep before it
|
||||||
* happens, lpm_drop() will reschedule us in the 'distant' future
|
* happens, lpm_drop() will reschedule us in the 'distant' future
|
||||||
*/
|
*/
|
||||||
next = (now + COMPARE_INCREMENT) & MULTIPLE_512_MASK;
|
next = ((ti_lib_aon_rtc_current_compare_value_get() + 5) +
|
||||||
|
COMPARE_INCREMENT) & MULTIPLE_512_MASK;
|
||||||
ti_lib_aon_rtc_compare_value_set(AON_RTC_CH1, next);
|
ti_lib_aon_rtc_compare_value_set(AON_RTC_CH1, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,8 +244,18 @@ lpm_drop()
|
||||||
|
|
||||||
uint32_t domains = LOCKABLE_DOMAINS;
|
uint32_t domains = LOCKABLE_DOMAINS;
|
||||||
|
|
||||||
|
/* Critical. Don't get interrupted! */
|
||||||
|
ti_lib_int_master_disable();
|
||||||
|
|
||||||
|
/* Check if any events fired before we turned interrupts off. If so, abort */
|
||||||
|
if(process_nevents()) {
|
||||||
|
ti_lib_int_master_enable();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(RTIMER_CLOCK_LT(soc_rtc_get_next_trigger(),
|
if(RTIMER_CLOCK_LT(soc_rtc_get_next_trigger(),
|
||||||
RTIMER_NOW() + STANDBY_MIN_DURATION)) {
|
RTIMER_NOW() + STANDBY_MIN_DURATION)) {
|
||||||
|
ti_lib_int_master_enable();
|
||||||
lpm_sleep();
|
lpm_sleep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -261,30 +271,20 @@ lpm_drop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if any events fired during this process. Last chance to abort */
|
/* Reschedule AON RTC CH1 to fire just in time for the next etimer event */
|
||||||
if(process_nevents()) {
|
next_event = etimer_next_expiration_time();
|
||||||
return;
|
|
||||||
|
if(etimer_pending()) {
|
||||||
|
next_event = next_event - clock_time();
|
||||||
|
soc_rtc_schedule_one_shot(AON_RTC_CH1, soc_rtc_last_isr_time() +
|
||||||
|
(next_event * (RTIMER_SECOND / CLOCK_SECOND)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Drop */
|
/* Drop */
|
||||||
if(max_pm == LPM_MODE_SLEEP) {
|
if(max_pm == LPM_MODE_SLEEP) {
|
||||||
|
ti_lib_int_master_enable();
|
||||||
lpm_sleep();
|
lpm_sleep();
|
||||||
} else {
|
} else {
|
||||||
/* Critical. Don't get interrupted! */
|
|
||||||
ti_lib_int_master_disable();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reschedule AON RTC CH1 to fire an event N ticks before the next etimer
|
|
||||||
* event
|
|
||||||
*/
|
|
||||||
next_event = etimer_next_expiration_time();
|
|
||||||
|
|
||||||
if(next_event) {
|
|
||||||
next_event = next_event - clock_time();
|
|
||||||
soc_rtc_schedule_one_shot(AON_RTC_CH1, soc_rtc_last_isr_time() +
|
|
||||||
(next_event * (RTIMER_SECOND / CLOCK_SECOND)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Notify all registered modules that we are dropping to mode X. We do not
|
* Notify all registered modules that we are dropping to mode X. We do not
|
||||||
* need to do this for simple sleep.
|
* need to do this for simple sleep.
|
||||||
|
|
Loading…
Reference in a new issue