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:
George Oikonomou 2016-01-09 18:07:47 +00:00
commit ab59a387b3
2 changed files with 21 additions and 22 deletions

View file

@ -142,14 +142,12 @@ soc_rtc_last_isr_time(void)
void
soc_rtc_isr(void)
{
uint32_t now, next;
uint32_t next;
ENERGEST_ON(ENERGEST_TYPE_IRQ);
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 */
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
* 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);
}

View file

@ -244,8 +244,18 @@ lpm_drop()
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(),
RTIMER_NOW() + STANDBY_MIN_DURATION)) {
ti_lib_int_master_enable();
lpm_sleep();
return;
}
@ -261,30 +271,20 @@ lpm_drop()
}
}
/* Check if any events fired during this process. Last chance to abort */
if(process_nevents()) {
return;
/* Reschedule AON RTC CH1 to fire just in time for the next etimer event */
next_event = etimer_next_expiration_time();
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 */
if(max_pm == LPM_MODE_SLEEP) {
ti_lib_int_master_enable();
lpm_sleep();
} 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
* need to do this for simple sleep.