diff src/cs/layer1/cust0/l1_cust.c @ 343:e0b27310e6ba

l1_cust.c: big sleep when charging with FCHG
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 Dec 2017 19:13:22 +0000
parents dd3c89e9ca2e
children 9e0608dc9170
line wrap: on
line diff
--- a/src/cs/layer1/cust0/l1_cust.c	Fri Dec 15 19:02:09 2017 +0000
+++ b/src/cs/layer1/cust0/l1_cust.c	Fri Dec 15 19:13:22 2017 +0000
@@ -83,6 +83,11 @@
   #include "l1_rf2.c"
 #endif
 
+#include "rv/rv_defined_swe.h"     // for RVM_FCHG_SWE
+#ifdef RVM_FCHG_SWE
+  #include "fchg/fchg_struct.h"
+#endif
+
 // Nucleus functions
 extern INT                TMD_Timer_State;
 extern UWORD32            TMD_Timer;               // for big sleep 
@@ -246,9 +251,26 @@
 UWORD8 Cust_check_system(void)
 {
   extern UWORD8 why_big_sleep;
+#ifdef RVM_FCHG_SWE
+  extern T_PWR_CTRL_BLOCK *pwr_ctrl;
+#endif
+
 #if (CODE_VERSION != SIMULATION)
 #if (L2_L3_SIMUL == 0)
-    // Forbid deep sleep if the light is on 
+
+#ifdef RVM_FCHG_SWE
+    // Forbig deep sleep when charging
+    if (pwr_ctrl && pwr_ctrl->state >= FCHG_STATE_I2V_CAL_1 &&
+        pwr_ctrl->state <= FCHG_STATE_CV_CHARGING)
+    {
+      //cut ARMIO and UWIRE clocks in big sleep
+      l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ;
+      why_big_sleep = BIG_SLEEP_DUE_TO_CHARGING;
+      return(FRAME_STOP);  // BIG sleep
+    }
+#endif
+
+    // Forbid deep sleep if the light is on
     if(LT_Status())
     {
       //cut ARMIO and UWIRE clocks in big sleep
@@ -257,7 +279,7 @@
       return(FRAME_STOP);  // BIG sleep
     }
 
-    // Forbid deep sleep if the SIM and UARTs not ready 
+    // Forbid deep sleep if the SIM and UARTs not ready
     if(SIM_SleepStatus())
     {
 #endif