changeset 328:daddb933047d

L1 sleep logic change: allow big sleep when light is on or we are charging
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 14 Dec 2017 02:45:22 +0000
parents d7b25dca1266
children 047fb78947d5
files src/cs/layer1/cfile/l1_pwmgr.c src/cs/layer1/cust0/l1_cust.c
diffstat 2 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/layer1/cfile/l1_pwmgr.c	Fri Dec 08 03:05:19 2017 +0000
+++ b/src/cs/layer1/cfile/l1_pwmgr.c	Thu Dec 14 02:45:22 2017 +0000
@@ -843,10 +843,18 @@
     // in case big sleep is choosen (sleep mode == FRAME_STOP) because of UART or SIM,
     // 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.
+     */
     if (    !min_time
          || !HWtimer
          || !min_time_gauging
+       #if 0	/* FreeCalypso change */
          || (sleep_mode != CLOCK_STOP)
+       #endif
        #if (OP_BT == 1)
          || !hci_ll_status
        #endif
--- a/src/cs/layer1/cust0/l1_cust.c	Fri Dec 08 03:05:19 2017 +0000
+++ b/src/cs/layer1/cust0/l1_cust.c	Thu Dec 14 02:45:22 2017 +0000
@@ -272,7 +272,28 @@
 #endif
         // cut ARMIO and UWIRE clocks in big sleep
         l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ;
-        return(FRAME_STOP);  // BIG sleep
+	/*
+	 * FreeCalypso change: in TI's original code, whenever
+	 * this Cust_check_system() function returns FRAME_STOP
+	 * instead of CLOCK_STOP, l1s_sleep_manager() would
+	 * abstain from all sleep and not just from deep sleep.
+	 * The comments there say that the intent is to avoid
+	 * big sleep when there is UART or SIM activity,
+	 * but the result is that when we tell L1 to do big sleep
+	 * instead of deep sleep because of the backlight or
+	 * charging, it doesn't sleep at all, except small sleep
+	 * via Nucleus idle loop.
+	 *
+	 * Our change preserves TI's abstention from big sleep
+	 * due to UART or SIM activity, but allows big sleep when
+	 * the cause is light or charging.  We've changed this
+	 * Cust_check_system() function to return DO_NOT_SLEEP
+	 * instead of FRAME_STOP for UART and SIM, while still
+	 * returning FRAME_STOP for light and charging, and
+	 * changed the code in l1s_sleep_manager() to do big sleep
+	 * when this Cust_check_system() function returns FRAME_STOP.
+	 */
+        return(DO_NOT_SLEEP);  // NO sleep
 #else // Simulation part
   return(CLOCK_STOP);   // DEEP sleep
 #endif