FreeCalypso > hg > fc-tourmaline
diff src/cs/drivers/drv_app/power/board/power.c @ 213:0947a816580c
first stage of FreeCalypso handset switch-on logic rework
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 22 Apr 2021 21:23:16 +0000 |
parents | 96c7a4eed1df |
children | 740a8e8fc9d7 |
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/power/board/power.c Thu Apr 22 20:41:41 2021 +0000 +++ b/src/cs/drivers/drv_app/power/board/power.c Thu Apr 22 21:23:16 2021 +0000 @@ -10,8 +10,8 @@ * * Author: Candice Bazanegue (c-brille@ti.com) * -* -* (C) Texas Instruments 2001 +* The present FreeCalypso version is heavily modified from TI's original, +* for the new FreeCalypso way of managing handset on/off state. * ******************************************************************************/ @@ -30,19 +30,6 @@ #include "ffs/ffs.h" #endif // _WINDOWS -#ifdef RVM_PWR_SWE - #include "spi/spi_task.h" - #ifndef _WINDOWS - #include "l1sw.cfg" - #include "chipset.cfg" - #endif // _WINDOWS - #include "pwr/pwr_messages.h" - #include "pwr/pwr_liion_cha.h" - #include "pwr/pwr_disch.h" -#endif /* #ifdef RVM_PWR_SWE */ - - - #ifndef _WINDOWS /* Declare the variable containing pressed and released callback. */ extern T_KPD_KEYPAD Kp; @@ -50,7 +37,6 @@ extern effs_t ffs_exit(void); #endif // _WINDOWS - /// The ABB status used to know the cause of the Switch ON event. static SYS_UWORD16 Power_abb_status = 0; @@ -60,70 +46,42 @@ ** Function Power_ON_Button ** ** Description: Informs the Protocol Stack that the Power ON key has been -** pressed, and thus allows it to start. +** pressed, and thus allows it to start. ** *******************************************************************************/ void Power_ON_Button(void) { -#ifndef _WINDOWS - SPI_GBL_INFO_PTR->is_gsm_on = TRUE; - - /* - When we build for ACI, we have no MMI, so there's no point waiting - for a keypress. See CR 17958. - */ - -#if (OP_WCP == 0) && (MMI != 0) - - /* Wait until the pointers initialization by the SMI */ - while(!(Kp.pressed && Kp.released)) - rvf_delay(1); +#if (MMI != 0) + extern void fchs_pwon_button_boot(void); -#if (TEST==0) - (Kp.pressed)(KPD_PWR); /* tell key is pressed */ - rvf_delay(5); - (Kp.released)(); /* allow protocol stack to start */ + fchs_pwon_button_boot(); #endif - -#endif // OP_WCP == 0 - -#else - rvf_send_trace("Start from button", 17, NULL_PARAM, RV_TRACE_LEVEL_WARNING, LCC_USE_ID); - SPI_GBL_INFO_PTR->is_gsm_on = TRUE; -#endif // _WINDOWS } - /******************************************************************************* ** ** Function Power_OFF_Button ** ** Description: Informs the Protocol Stack that the Power OFF key has been -** pressed, and thus allows it to stop. +** pressed, and thus allows it to stop. ** *******************************************************************************/ void Power_OFF_Button(void) { -#ifndef _WINDOWS - ffs_exit (); -#endif // _WINDOWS - rvf_send_trace("Power off button", 16, NULL_PARAM, RV_TRACE_LEVEL_WARNING, LCC_USE_ID); - SPI_GBL_INFO_PTR->is_gsm_on = FALSE; -#ifndef _WINDOWS - #if (OP_WCP == 0) && (MMI != 0) - (Kp.pressed)(KPD_PWR); /* tell key is pressed */ - rvf_delay(5); - (Kp.released)(); /* tell key is released */ - #else - ABB_Power_Off(); - #endif -#endif // _WINDOWS + rvf_send_trace("Power off button", 16, NULL_PARAM, RV_TRACE_LEVEL_WARNING, + LCC_USE_ID); + if (Kp.pressed && Kp.released) { + (Kp.pressed)(KPD_PWR); /* tell key is pressed */ + rvf_delay(5); + (Kp.released)(); /* tell key is released */ + } else + ABB_Power_Off(); } /** - * @brief Sets the cause of the swith ON event. + * @brief Sets the cause of the switch ON event. * * This function get the ABB status register and stores it into the * global variable Power_abb_status. @@ -151,60 +109,38 @@ *******************************************************************************/ void Switch_ON(void) { -#if ((ANLG_FAM == 1) || (ANLG_FAM == 2)) if (Power_abb_status & ONBSTS) -#elif (ANLG_FAM == 3) - if (Power_abb_status & PWONBSTS) -#endif { /* Switch on Condition on ON BUTTON Push */ - rvf_send_trace("Push Button from OFF to ON",26, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); + rvf_send_trace("Push Button from OFF to ON",26, NULL_PARAM, + RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); Power_ON_Button(); - #ifdef RVM_PWR_SWE - pwr_handle_discharge(); - #endif } -#if ((ANLG_FAM == 1) || (ANLG_FAM == 2)) else if (Power_abb_status & ONRSTS) -#elif (ANLG_FAM == 3) - else if (Power_abb_status & RPSTS) -#endif { /* Switch on Condition on ON REM transition 0->1 */ - rvf_send_trace("ON Remote",9, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); + rvf_send_trace("ON Remote",9, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, + LCC_USE_ID); Power_ON_Remote(); - #ifdef RVM_PWR_SWE - pwr_handle_discharge(); - #endif } -#ifdef RVM_PWR_SWE else if (Power_abb_status & CHGSTS) { /* Switch on Condition on CHARGER IC PLUG */ - rvf_send_trace("PWR: Charger Plug",17, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); - if (Power_abb_status & CHGPRES) - { - /* charger still present */ - PWR_Charger_Plug(); - } + rvf_send_trace("Boot: Charger Plug",18, NULL_PARAM, + RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); } -#endif /* #ifdef RVM_PWR_SWE */ else { - // The reset should run the SW in the same way than a Power ON - rvf_send_trace("Start from reset",16, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); - Power_ON_Button(); - #ifdef RVM_PWR_SWE - pwr_handle_discharge(); - #endif + /* In FreeCalypso start from reset is NOT the same as PWON! */ + rvf_send_trace("Start from reset",16, NULL_PARAM, + RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); } } - /******************************************************************************* ** ** Function Power_ON_Remote @@ -218,7 +154,6 @@ } - /******************************************************************************* ** ** Function Power_OFF_Remote @@ -232,7 +167,6 @@ } - /******************************************************************************* ** ** Function Power_IT_WakeUp @@ -244,78 +178,3 @@ void Power_IT_WakeUp(void) { } - - - -#ifdef RVM_PWR_SWE -/******************************************************************************* -** -** Function PWR_Charger_Plug -** -** Description -** -** -*******************************************************************************/ -void PWR_Charger_Plug(void) -{ - - /* Start the fast charging cycle */ - - /* Since this function is called from the SPI task - it can't be interrupt by another task - so we can directly access the SPI through the low-level driver */ - - if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */ - { - rvf_delay(RVF_MS_TO_TICKS(2000)); - } - - rvf_stop_timer(SPI_TIMER3); - - /* informs the upper layer that the charger has been plugged */ - pwr_send_charger_plug_event(); - - /* get the type of the battery */ - pwr_get_battery_type(); -} - - - -/******************************************************************************* -** -** Function PWR_Charger_Unplug -** -** Description -** -** -*******************************************************************************/ -void PWR_Charger_Unplug(void) -{ - /* informs the upper layer that the charger has been unplugged */ - pwr_send_charger_unplug_event(); - - rvf_send_trace("Charger unplug", 14, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID ); - pwr_stop_charging(); - if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */ - { - #ifndef _WINDOWS - #if (ANLG_FAM == 1) - ABB_Write_Register_on_page(PAGE0, VRPCCTL2, 0x00EE); - #elif ((ANLG_FAM == 2) || (ANLG_FAM == 3)) - ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001); - #endif - #else - ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x00EE); - #endif // _WINDOWS - } - else - { - pwr_handle_discharge(); - } -} -#endif /* #ifdef RVM_PWR_SWE */ - - - - -