FreeCalypso > hg > fc-magnetite
diff src/cs/layer1/cfile/l1_pwmgr.c @ 561:dc1e0a1c100f
sleep logic change: allow big sleep when UART or SIM is blocking deep sleep
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 06 Jan 2019 21:12:51 +0000 |
parents | daddb933047d |
children | b24d42baa30d |
line wrap: on
line diff
--- a/src/cs/layer1/cfile/l1_pwmgr.c Sat Dec 29 04:06:37 2018 +0000 +++ b/src/cs/layer1/cfile/l1_pwmgr.c Sun Jan 06 21:12:51 2019 +0000 @@ -782,7 +782,7 @@ #if (W_A_CALYPSO_PLUS_SPR_19599 == 1) BOOL extended_page_mode_state = 0; //Store state of extended page mode #endif - WORD32 time_from_last_wakeup=0; + WORD32 time_from_last_wakeup, min_time_from_last_wakeup; UWORD32 sleep_mode; #if (OP_BT == 1) @@ -793,8 +793,33 @@ why_big_sleep = BIG_SLEEP_DUE_TO_UNDEFINED; wakeup_type = WAKEUP_FOR_UNDEFINED; + /* + * FreeCalypso change: TI's original code implemented logic to + * suppress both big and deep sleep (i.e., retry on the next frame) + * if less than 7 frames have elapsed since the last wakeup and + * if the previous sleep cycle was CLOCK_STOP. We are changing + * this logic in two ways: the check has been moved up here + * (originally the check code was way down, wasting work on other + * logic if there will be no sleep anyway), and we additionally + * suppress both big and deep sleep (effecting retry on the next + * frame) if the previous sleep cycle was FRAME_STOP and less than + * 5 frames have elapsed since wakeup. The reason for the latter + * addition is that we now allow big sleep while UART and/or SIM + * activity timers are running (suppressing deep sleep), and + * holding off for 5 frames before going into another big sleep + * keeps us from fluttering in and out of big sleep as the external + * host or the SIM is trying to talk to us. + */ time_from_last_wakeup = (sleep_time - last_wakeup + 42432) % 42432; + if (previous_sleep == CLOCK_STOP) + min_time_from_last_wakeup = 7; + else + min_time_from_last_wakeup = 5; + + if (time_from_last_wakeup < min_time_from_last_wakeup) + return; + //================================================= // check System (SIM, UART, LDC ..... ) //================================================= @@ -844,10 +869,15 @@ // return and wait end of this activity (few TDMA frames) then check on next TDMA frames // if MS can go in deep sleep /* - * FreeCalypso change: the abstention from big sleep because of UART or SIM - * has been moved into Cust_check_system(), which now returns DO_NOT_SLEEP - * in these cases, while still returning FRAME_STOP if the cause is - * the backlight or charging. + * FreeCalypso change: we no longer abstain from big sleep because of UART + * and SIM activity timers, i.e., when deep sleep is suppressed because of + * either of those, we go into big sleep instead. We also do big sleep + * if deep sleep is disallowed because of the backlight or charging. + * However, if the UART issue is not the running activity timer, but some + * output being drained from the Tx FIFO, for that case our new code in + * Cust_check_system() will return DO_NOT_SLEEP (checked above), causing + * us to retry on the next frame and hopefully go into deep sleep after + * another frame or two. */ if ( !min_time || !HWtimer @@ -933,6 +963,8 @@ l1s.pw_mgr.sleep_performed = FRAME_STOP; + /* FreeCalypso change: check moved up and extended */ + #if 0 if ((previous_sleep == CLOCK_STOP) && (time_from_last_wakeup < 7)) { #if (CODE_VERSION != SIMULATION) @@ -944,6 +976,7 @@ #endif // NOT SIMULATION return; } + #endif // update previous sleep previous_sleep = l1s.pw_mgr.sleep_performed;