FreeCalypso > hg > fc-selenite
comparison src/cs/layer1/cust0/l1_cust.c @ 148:c47e2dc10134
l1_pwmgr.c & l1_cust.c: sleep logic changes from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 06 Feb 2019 23:15:04 +0000 |
parents | b6a5e36de839 |
children |
comparison
equal
deleted
inserted
replaced
147:0d96c28dedb1 | 148:c47e2dc10134 |
---|---|
252 { | 252 { |
253 extern UWORD8 why_big_sleep; | 253 extern UWORD8 why_big_sleep; |
254 #ifdef RVM_FCHG_SWE | 254 #ifdef RVM_FCHG_SWE |
255 extern T_PWR_CTRL_BLOCK *pwr_ctrl; | 255 extern T_PWR_CTRL_BLOCK *pwr_ctrl; |
256 #endif | 256 #endif |
257 extern SYS_BOOL uart_sleep_timer_enabled; | |
257 | 258 |
258 #if (CODE_VERSION != SIMULATION) | 259 #if (CODE_VERSION != SIMULATION) |
259 #if (L2_L3_SIMUL == 0) | 260 |
261 //cut ARMIO and UWIRE clocks in big sleep | |
262 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT; | |
260 | 263 |
261 #ifdef RVM_FCHG_SWE | 264 #ifdef RVM_FCHG_SWE |
262 // Forbig deep sleep when charging | 265 // Forbig deep sleep when charging |
263 if (pwr_ctrl && pwr_ctrl->state >= FCHG_STATE_I2V_CAL_1 && | 266 if (pwr_ctrl && pwr_ctrl->state >= FCHG_STATE_I2V_CAL_1 && |
264 pwr_ctrl->state <= FCHG_STATE_CV_CHARGING) | 267 pwr_ctrl->state <= FCHG_STATE_CV_CHARGING) |
265 { | 268 { |
266 //cut ARMIO and UWIRE clocks in big sleep | |
267 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ; | |
268 why_big_sleep = BIG_SLEEP_DUE_TO_CHARGING; | 269 why_big_sleep = BIG_SLEEP_DUE_TO_CHARGING; |
269 return(FRAME_STOP); // BIG sleep | 270 return(FRAME_STOP); // BIG sleep |
270 } | 271 } |
271 #endif | 272 #endif |
272 | 273 |
273 // Forbid deep sleep if the light is on | 274 // Forbid deep sleep if the light is on |
274 if(LT_Status()) | 275 if (LT_Status()) |
275 { | 276 { |
276 //cut ARMIO and UWIRE clocks in big sleep | |
277 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ; | |
278 why_big_sleep = BIG_SLEEP_DUE_TO_LIGHT_ON; | 277 why_big_sleep = BIG_SLEEP_DUE_TO_LIGHT_ON; |
279 return(FRAME_STOP); // BIG sleep | 278 return(FRAME_STOP); // BIG sleep |
280 } | 279 } |
281 | 280 |
282 // Forbid deep sleep if the SIM and UARTs not ready | 281 // Forbid deep sleep if the SIM and UARTs not ready |
283 if(SIM_SleepStatus()) | 282 if (!SIM_SleepStatus()) |
284 { | 283 { |
285 #endif | 284 why_big_sleep = BIG_SLEEP_DUE_TO_SIM; |
285 return(FRAME_STOP); // BIG sleep | |
286 } | |
287 | |
288 /* FreeCalypso: check UART activity timer */ | |
289 if (uart_sleep_timer_enabled) | |
290 { | |
291 why_big_sleep = BIG_SLEEP_DUE_TO_UART; | |
292 return(FRAME_STOP); // BIG sleep | |
293 } | |
294 | |
295 if ((l1s.pw_mgr.mode_authorized == DEEP_SLEEP) || | |
296 (l1s.pw_mgr.mode_authorized == ALL_SLEEP)) | |
297 { | |
286 if(SER_UartSleepStatus()) | 298 if(SER_UartSleepStatus()) |
287 { | |
288 return(CLOCK_STOP); // DEEP sleep | 299 return(CLOCK_STOP); // DEEP sleep |
289 } | 300 else |
290 else why_big_sleep = BIG_SLEEP_DUE_TO_UART; | 301 return(DO_NOT_SLEEP); /* wait another frame or two */ |
291 #if (L2_L3_SIMUL == 0) | 302 } |
292 } | 303 else |
293 else why_big_sleep = BIG_SLEEP_DUE_TO_SIM; | 304 { |
294 #endif | 305 why_big_sleep = BIG_SLEEP_DUE_TO_SLEEP_MODE; |
295 // cut ARMIO and UWIRE clocks in big sleep | 306 return(FRAME_STOP); // BIG sleep |
296 l1s.pw_mgr.modules_status = ARMIO_CLK_CUT | UWIRE_CLK_CUT ; | 307 } |
297 /* | 308 |
298 * FreeCalypso change: in TI's original code, whenever | |
299 * this Cust_check_system() function returns FRAME_STOP | |
300 * instead of CLOCK_STOP, l1s_sleep_manager() would | |
301 * abstain from all sleep and not just from deep sleep. | |
302 * The comments there say that the intent is to avoid | |
303 * big sleep when there is UART or SIM activity, | |
304 * but the result is that when we tell L1 to do big sleep | |
305 * instead of deep sleep because of the backlight or | |
306 * charging, it doesn't sleep at all, except small sleep | |
307 * via Nucleus idle loop. | |
308 * | |
309 * Our change preserves TI's abstention from big sleep | |
310 * due to UART or SIM activity, but allows big sleep when | |
311 * the cause is light or charging. We've changed this | |
312 * Cust_check_system() function to return DO_NOT_SLEEP | |
313 * instead of FRAME_STOP for UART and SIM, while still | |
314 * returning FRAME_STOP for light and charging, and | |
315 * changed the code in l1s_sleep_manager() to do big sleep | |
316 * when this Cust_check_system() function returns FRAME_STOP. | |
317 */ | |
318 return(DO_NOT_SLEEP); // NO sleep | |
319 #else // Simulation part | 309 #else // Simulation part |
320 return(CLOCK_STOP); // DEEP sleep | 310 return(CLOCK_STOP); // DEEP sleep |
321 #endif | 311 #endif |
322 } | 312 } |
323 | 313 |