FreeCalypso > hg > fc-selenite
comparison src/cs/layer1/cfile/l1_pwmgr.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 |
---|---|
780 WORD32 afc_fix; | 780 WORD32 afc_fix; |
781 static UWORD32 previous_sleep = CLOCK_STOP; | 781 static UWORD32 previous_sleep = CLOCK_STOP; |
782 #if (W_A_CALYPSO_PLUS_SPR_19599 == 1) | 782 #if (W_A_CALYPSO_PLUS_SPR_19599 == 1) |
783 BOOL extended_page_mode_state = 0; //Store state of extended page mode | 783 BOOL extended_page_mode_state = 0; //Store state of extended page mode |
784 #endif | 784 #endif |
785 WORD32 time_from_last_wakeup=0; | 785 WORD32 time_from_last_wakeup, min_time_from_last_wakeup; |
786 UWORD32 sleep_mode; | 786 UWORD32 sleep_mode; |
787 | 787 |
788 #if (OP_BT == 1) | 788 #if (OP_BT == 1) |
789 WORD32 hci_ll_status; | 789 WORD32 hci_ll_status; |
790 #endif | 790 #endif |
791 | 791 |
792 // init for trace and debug | 792 // init for trace and debug |
793 why_big_sleep = BIG_SLEEP_DUE_TO_UNDEFINED; | 793 why_big_sleep = BIG_SLEEP_DUE_TO_UNDEFINED; |
794 wakeup_type = WAKEUP_FOR_UNDEFINED; | 794 wakeup_type = WAKEUP_FOR_UNDEFINED; |
795 | 795 |
796 /* | |
797 * FreeCalypso change: TI's original code implemented logic to | |
798 * suppress both big and deep sleep (i.e., retry on the next frame) | |
799 * if less than 7 frames have elapsed since the last wakeup and | |
800 * if the previous sleep cycle was CLOCK_STOP. We are changing | |
801 * this logic in two ways: the check has been moved up here | |
802 * (originally the check code was way down, wasting work on other | |
803 * logic if there will be no sleep anyway), and we additionally | |
804 * suppress both big and deep sleep (effecting retry on the next | |
805 * frame) if the previous sleep cycle was FRAME_STOP and less than | |
806 * 5 frames have elapsed since wakeup. The reason for the latter | |
807 * addition is that we now allow big sleep while UART and/or SIM | |
808 * activity timers are running (suppressing deep sleep), and | |
809 * holding off for 5 frames before going into another big sleep | |
810 * keeps us from fluttering in and out of big sleep as the external | |
811 * host or the SIM is trying to talk to us. | |
812 */ | |
796 time_from_last_wakeup = (sleep_time - last_wakeup + 42432) % 42432; | 813 time_from_last_wakeup = (sleep_time - last_wakeup + 42432) % 42432; |
814 | |
815 if (previous_sleep == CLOCK_STOP) | |
816 min_time_from_last_wakeup = 7; | |
817 else | |
818 min_time_from_last_wakeup = 5; | |
819 | |
820 if (time_from_last_wakeup < min_time_from_last_wakeup) | |
821 return; | |
797 | 822 |
798 //================================================= | 823 //================================================= |
799 // check System (SIM, UART, LDC ..... ) | 824 // check System (SIM, UART, LDC ..... ) |
800 //================================================= | 825 //================================================= |
801 sleep_mode = Cust_check_system(); | 826 sleep_mode = Cust_check_system(); |
842 // 0 means immediate activity | 867 // 0 means immediate activity |
843 // in case big sleep is choosen (sleep mode == FRAME_STOP) because of UART or SIM, | 868 // in case big sleep is choosen (sleep mode == FRAME_STOP) because of UART or SIM, |
844 // return and wait end of this activity (few TDMA frames) then check on next TDMA frames | 869 // return and wait end of this activity (few TDMA frames) then check on next TDMA frames |
845 // if MS can go in deep sleep | 870 // if MS can go in deep sleep |
846 /* | 871 /* |
847 * FreeCalypso change: the abstention from big sleep because of UART or SIM | 872 * FreeCalypso change: we no longer abstain from big sleep because of UART |
848 * has been moved into Cust_check_system(), which now returns DO_NOT_SLEEP | 873 * and SIM activity timers, i.e., when deep sleep is suppressed because of |
849 * in these cases, while still returning FRAME_STOP if the cause is | 874 * either of those, we go into big sleep instead. We also do big sleep |
850 * the backlight or charging. | 875 * if deep sleep is disallowed because of the backlight or charging. |
876 * However, if the UART issue is not the running activity timer, but some | |
877 * output being drained from the Tx FIFO, for that case our new code in | |
878 * Cust_check_system() will return DO_NOT_SLEEP (checked above), causing | |
879 * us to retry on the next frame and hopefully go into deep sleep after | |
880 * another frame or two. | |
851 */ | 881 */ |
852 if ( !min_time | 882 if ( !min_time |
853 || !HWtimer | 883 || !HWtimer |
854 || !min_time_gauging | 884 || !min_time_gauging |
855 #if 0 /* FreeCalypso change */ | 885 #if 0 /* FreeCalypso change */ |
923 why_big_sleep = BIG_SLEEP_DUE_TO_GAUGING; | 953 why_big_sleep = BIG_SLEEP_DUE_TO_GAUGING; |
924 else | 954 else |
925 why_big_sleep = BIG_SLEEP_DUE_TO_DSP_TRACES; | 955 why_big_sleep = BIG_SLEEP_DUE_TO_DSP_TRACES; |
926 } | 956 } |
927 } | 957 } |
928 if (l1s.pw_mgr.mode_authorized == BIG_SLEEP) | 958 if (l1s.pw_mgr.mode_authorized == BIG_SLEEP || |
959 l1s.pw_mgr.mode_authorized == BIG_SMALL_SLEEP) | |
929 why_big_sleep = BIG_SLEEP_DUE_TO_SLEEP_MODE; | 960 why_big_sleep = BIG_SLEEP_DUE_TO_SLEEP_MODE; |
930 | 961 |
931 if ( ((l1s.pw_mgr.mode_authorized == BIG_SLEEP) && (sleep_mode >= FRAME_STOP)) || | 962 if ( ((l1s.pw_mgr.mode_authorized == BIG_SLEEP) && (sleep_mode >= FRAME_STOP)) || |
963 ((l1s.pw_mgr.mode_authorized == BIG_SMALL_SLEEP) && (sleep_mode >= FRAME_STOP)) || | |
932 ((l1s.pw_mgr.mode_authorized >= DEEP_SLEEP) && (sleep_mode == FRAME_STOP)) ) | 964 ((l1s.pw_mgr.mode_authorized >= DEEP_SLEEP) && (sleep_mode == FRAME_STOP)) ) |
933 l1s.pw_mgr.sleep_performed = FRAME_STOP; | 965 l1s.pw_mgr.sleep_performed = FRAME_STOP; |
934 | 966 |
935 | 967 |
968 /* FreeCalypso change: check moved up and extended */ | |
969 #if 0 | |
936 if ((previous_sleep == CLOCK_STOP) && (time_from_last_wakeup < 7)) | 970 if ((previous_sleep == CLOCK_STOP) && (time_from_last_wakeup < 7)) |
937 { | 971 { |
938 #if (CODE_VERSION != SIMULATION) | 972 #if (CODE_VERSION != SIMULATION) |
939 OS_system_Unprotect(); // free System structure | 973 OS_system_Unprotect(); // free System structure |
940 INT_EnableIRQ(); // Enable all IRQ | 974 INT_EnableIRQ(); // Enable all IRQ |
942 SER_WakeUpUarts(); // Wake up Uarts | 976 SER_WakeUpUarts(); // Wake up Uarts |
943 | 977 |
944 #endif // NOT SIMULATION | 978 #endif // NOT SIMULATION |
945 return; | 979 return; |
946 } | 980 } |
981 #endif | |
947 | 982 |
948 // update previous sleep | 983 // update previous sleep |
949 previous_sleep = l1s.pw_mgr.sleep_performed; | 984 previous_sleep = l1s.pw_mgr.sleep_performed; |
950 | 985 |
951 | 986 |