annotate chipsetsw/layer1/cfile/l1_pwmgr.c @ 126:c0a6b2f9723b

l1_pwmgr.c: removed a bunch of dead LoCosto code
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Fri, 13 May 2016 16:48:47 +0000
parents 813c4bb83603
children 633cc67bebbc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1 /************* Revision Controle System Header *************
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2 * GSM Layer 1 software
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
3 * L1_PWMGR.C
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
4 *
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
5 * Filename l1_pwmgr.c
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
6 * Copyright 2003 (C) Texas Instruments
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
7 *
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
8 ************* Revision Controle System Header *************/
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
9
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
10 #define L1_PWMGR_C
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
11 //#pragma DUPLICATE_FOR_INTERNAL_RAM_START
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
12
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
13 #include "timer/timer2.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
14 #include "armio/armio.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
15
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
16 //omaps00090550 #include "l1_macro.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
17 #include "l1_confg.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
18
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
19 #if (OP_L1_STANDALONE == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
20 #include "uart/serialswitch_core.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
21 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
22 #include "uart/serialswitch.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
23 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
24
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
25 #if (OP_L1_STANDALONE == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
26 #include "sim/sim.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
27 #include "rv_swe.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
28 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
29
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
30
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
31 #if (CODE_VERSION == SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
32 #include "l1_types.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
33 #include "l1_const.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
34
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
35 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
36 #include "inth/sys_inth.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
37 #include "sys_dma.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
38 #include "ulpd.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
39 #include "clkm.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
40
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
41 // typedef volatile unsigned short REG_UWORD16; //omaps00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
42 #define REG16(A) (*(REG_UWORD16*)(A))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
43
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
44 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
45 #include "inth/iq.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
46 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
47
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
48 #if TESTMODE
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
49 #include "l1tm_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
50 #endif // TESTMODE
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
51
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
52 #if (AUDIO_TASK == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
53 #include "l1audio_const.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
54 #include "l1audio_cust.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
55 #include "l1audio_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
56 #endif // AUDIO_TASK
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
57
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
58 #if (L1_GTT == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
59 #include "l1gtt_const.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
60 #include "l1gtt_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
61 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
62
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
63 #if (L1_MP3 == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
64 #include "l1mp3_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
65 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
66
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
67 #if (L1_MIDI == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
68 #include "l1midi_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
69 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
70 //ADDED FOR AAC
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
71 #if (L1_AAC == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
72 #include "l1aac_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
73 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
74 #include "l1_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
75 #include "l1_varex.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
76 #include "l1_tabs.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
77 #include "cust_os.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
78 #include "l1_msgty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
79 #include "l1_proto.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
80 #include "ulpd.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
81 #include "l1_trace.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
82
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
83 #if L1_GPRS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
84 #include "l1p_cons.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
85 #include "l1p_msgt.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
86 #include "l1p_deft.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
87 #include "l1p_vare.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
88 #endif // L1_GPRS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
89
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
90 #include <stdio.h>
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
91 #include "sim_cfg.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
92 #include "sim_cons.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
93 #include "sim_def.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
94 #include "sim_var.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
95 //omaps00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
96 #include "nucleus.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
97
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
98 extern NU_TASK L1S_task;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
99 STATUS status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
100
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
101
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
102
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
103 #else // NO SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
104
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
105
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
106
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
107 #include "l1_types.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
108 #include "l1_const.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
109
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
110 #include "abb/abb.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
111 #include "dma/sys_dma.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
112
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
113 #if (OP_BT == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
114 #include "hci_ll_simul.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
115 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
116
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
117 #if TESTMODE
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
118 #include "l1tm_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
119 #endif // TESTMODE
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
120
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
121 #if (AUDIO_TASK == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
122 #include "l1audio_const.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
123 #include "l1audio_cust.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
124 #include "l1audio_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
125 #endif // AUDIO_TASK
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
126
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
127 #if (L1_GTT == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
128 #include "l1gtt_const.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
129 #include "l1gtt_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
130 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
131
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
132 #if (L1_MP3 == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
133 #include "l1mp3_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
134 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
135
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
136 #if (L1_MIDI == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
137 #include "l1midi_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
138 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
139 //ADDED FOR AAC
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
140 #if (L1_AAC == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
141 #include "l1aac_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
142 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
143 #include "l1_defty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
144 #include "l1_varex.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
145 #include "l1_tabs.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
146 #include "sys_types.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
147 #include "tpudrv.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
148 #include "cust_os.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
149 #include "l1_msgty.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
150 #include "l1_proto.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
151 #include "l1_trace.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
152 #include "timer/timer.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
153
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
154 #include "l1_pwmgr.h"
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
155
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
156 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
157 #include "timer/timer_sec.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
158 #include "inth/sys_inth.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
159
126
c0a6b2f9723b l1_pwmgr.c: removed a bunch of dead LoCosto code
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 125
diff changeset
160 /* FreeCalypso: massive #if (CHIPSET == 15) chunk removed */
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
161
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
162 #else //(CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
163 #include "inth/iq.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
164 #include "inth/inth.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
165 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
166 // #include "timer1.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
167 #include "ulpd/ulpd.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
168 #include "clkm/clkm.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
169 #include "memif/mem.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
170 #if L2_L3_SIMUL
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
171 #include "hw_debug.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
172 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
173
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
174 #if (OP_WCP == 1) && (OP_L1_STANDALONE != 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
175 #include "csmi/sleep.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
176 #endif // OP_WCP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
177 #if (W_A_CALYPSO_PLUS_SPR_19599 == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
178 #include "sys_memif.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
179 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
180
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
181 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
182 #if (OP_L1_STANDALONE == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
183 #include "csmi_simul.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
184 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
185 #include "csmi/csmi.h"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
186 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
187 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
188
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
189 #if (CHIPSET == 15)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
190 #include "drp_api.h"
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
191 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
192
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
193 #endif // NO SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
194
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
195 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
196 // for PTOOL compatibility
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
197 extern void INT_DisableIRQ(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
198 extern void INT_EnableIRQ(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
199 extern void l1dmacro_RF_sleep(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
200 extern void l1dmacro_RF_wakeup(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
201 WORD32 l1s_get_HWTimers_ticks(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
202
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
203 // file timer1.h
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
204 SYS_UWORD16 Dtimer1_Get_cntlreg(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
205 void Dtimer1_AR(unsigned short Ar);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
206 void Dtimer1_PTV(unsigned short Ptv);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
207 void Dtimer1_Clken(unsigned short En);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
208 void Dtimer1_Start (unsigned short startStop);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
209 void Dtimer1_Init_cntl (SYS_UWORD16 St, SYS_UWORD16 Reload, SYS_UWORD16 clockScale, SYS_UWORD16 clkon);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
210 SYS_UWORD16 Dtimer1_WriteValue (SYS_UWORD16 value);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
211 SYS_UWORD16 Dtimer1_ReadValue (void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
212 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
213
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
214 void l1s_wakeup(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
215 BOOL l1s_compute_wakeup_ticks(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
216 void l1s_recover_Frame(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
217 UWORD8 Cust_recover_Os(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
218 void l1s_recover_HWTimers(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
219 UWORD8 Cust_check_system(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
220 void f_arm_sleep_cmd(UWORD8 d_sleep_mode);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
221
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
222 //#if (TRACE_TYPE == 2) || (TRACE_TYPE == 3)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
223 extern void L1_trace_string(char *s);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
224 extern void L1_trace_char (char s);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
225 //#endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
226 extern UWORD16 slp_debug_flag;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
227
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
228 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
229 extern void l1s_trace_mftab(void);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
230 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
231
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
232 #if (CODE_VERSION != SIMULATION) && (CHIPSET == 15)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
233 extern T_DRP_REGS_STR *drp_regs;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
234 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
235
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
236 #if L1_GPRS
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
237 WORD32 l1s_get_next_gauging_in_Packet_Idle(void);
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
238 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
239 //#pragma DUPLICATE_FOR_INTERNAL_RAM_END
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
240
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
241 #if !((MOVE_IN_INTERNAL_RAM == 1) && (GSM_IDLE_RAM !=0)) // MOVE TO INTERNAL MEM IN CASE GSM_IDLE_RAM enabled
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
242 //#pragma GSM_IDLE_DUPLICATE_FOR_INTERNAL_RAM_START // KEEP IN EXTERNAL MEM otherwise
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
243
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
244 /************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
245 /* Macros for power management */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
246 /************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
247 #define MIN(min, operand1) \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
248 if (operand1 <= min) min = operand1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
249
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
250 // ex: RATIO T32khz/T4.33Mhz = 132.2428385417
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
251 // => root = integer part of the ratio
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
252 // = 132
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
253 // => frac = fractionnal part of the ratio multiplied by 65536 rounded to make it integer
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
254 // = 0.2428385417 * 65536 (Cf. ULPD specification)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
255 // = 0.2428385417 * 2^16
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
256 // = 15914.66666689 = 15914
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
257
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
258 #define RATIO(HF,LF, root, frac) \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
259 root = (UWORD32)(HF/LF); \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
260 frac = (UWORD32)(((HF - (root*LF)) << 16) / LF);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
261
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
262 // previous ratio with frac + 0.5
124
190c68fa5689 l1_pwmgr.c: l1ctl_pgm_clk32() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 123
diff changeset
263 #if 0 /* original LoCosto code */
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
264 #define RATIO2(HF,LF, root, frac) \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
265 if(LF){ \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
266 root = (UWORD32)(HF/LF); \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
267 frac = (UWORD32)((((HF - (root*LF)) << 16) + 0.5*LF) / LF);}
124
190c68fa5689 l1_pwmgr.c: l1ctl_pgm_clk32() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 123
diff changeset
268 #else /* FreeCalypso TCS211 reconstruction */
190c68fa5689 l1_pwmgr.c: l1ctl_pgm_clk32() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 123
diff changeset
269 #define RATIO2(HF,LF, root, frac) \
190c68fa5689 l1_pwmgr.c: l1ctl_pgm_clk32() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 123
diff changeset
270 { \
190c68fa5689 l1_pwmgr.c: l1ctl_pgm_clk32() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 123
diff changeset
271 root = (UWORD32)(HF/LF); \
190c68fa5689 l1_pwmgr.c: l1ctl_pgm_clk32() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 123
diff changeset
272 frac = (UWORD32)((((HF - (root*LF)) << 16) + 0.5*LF) / LF);}
190c68fa5689 l1_pwmgr.c: l1ctl_pgm_clk32() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 123
diff changeset
273 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
274
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
275 #define HFTHEO(LF, root, frac, hftheo) \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
276 hftheo = root*LF + ((frac*LF) >>16);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
277
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
278 #define SUM(HF, LF, nb, ind) \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
279 LF=HF=0; \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
280 for(ind=0; ind<nb; ind++) \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
281 { \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
282 LF = LF +l1s.pw_mgr.histo[ind][0]; \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
283 HF = HF +l1s.pw_mgr.histo[ind][1]; \
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
284 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
285
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
286
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
287 #if (CODE_VERSION!=SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
288 T_PWMGR_DEBUG l1_pwmgr_debug;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
289 #endif // NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
290
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
291
126
c0a6b2f9723b l1_pwmgr.c: removed a bunch of dead LoCosto code
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 125
diff changeset
292 /* FreeCalypso: massive #if (CHIPSET == 15) chunk removed */
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
293
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
294
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
295 // l1ctl_pgm_clk32()
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
296 // convert ratio in 4.33Mhz and pgm INC_FRAC,INC_SIXTEEN.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
297
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
298 void l1ctl_pgm_clk32(UWORD32 nb_hf, UWORD32 nb_32khz)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
299 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
300 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
301 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
302 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
303 UWORD32 inc_sixteen= 0, inc_frac=0, lf;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
304
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
305 // REM: nb_hf is the real value of the high frequency (ex in nbr of 65Mhz clock)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
306 // To compute the ratio, nb_hf must be expressed in nbr of clock 4.33 Mhz
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
307 // that's why nb_hf is divided by 3*l1_config.dpll
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
308 // RATIO2(nb_hf/(3*l1_config.dpll),nb_32khz,inc_sixteen,inc_frac);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
309 // this line above is equal to the ligne below:
124
190c68fa5689 l1_pwmgr.c: l1ctl_pgm_clk32() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 123
diff changeset
310 lf=(UWORD32)(3*l1_config.dpll*nb_32khz);
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
311 RATIO2(nb_hf,lf,inc_sixteen,inc_frac);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
312
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
313 // integer part
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
314 ULDP_INCSIXTEEN_UPDATE(inc_sixteen);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
315
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
316 // fractional part
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
317 ULDP_INCFRAC_UPDATE(inc_frac);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
318 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
319 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
320 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
321
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
322
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
323 // l1ctl_gauging()
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
324 // Description: management of the gauging results
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
325 // At RESET state reset histogram and then go to INIT.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
326 // At INIT state, go back to RESET on each */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
327 // gauging > +- 100 ppm. If NB_INIT good gauging go to ACQUIS state.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
328 // At ACQUIS state, go back to RESET on each gauging > (+- 20ppm +- 1us). If NB_ACQU good gauging */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
329 // go to UPDATE state. Allow deep sleep feature.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
330 // At UPDATE state, count consecutive gauging >+- 1 us.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
331 // If MAX_BAD_GAUGING results go back to RESET.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
332 // Otherwise re-enable deep sleep feature and reset bad results counter.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
333
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
334 void l1ctl_gauging ( UWORD32 nb_32khz, UWORD32 nb_hf)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
335 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
336 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
337 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
338 enum states
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
339 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
340 RESET = 0,
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
341 INIT = 1,
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
342 ACQUIS = 2,
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
343 UPDATE = 3
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
344 };
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
345
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
346 static UWORD8 bad_count; // bad gauging values
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
347 static UWORD8 gauging_state= RESET; // RESET,INIT, ACQUIS, UPDATE
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
348 static UWORD8 nb_gaug; // number of gauging in ACQUIS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
349 static UWORD8 idx,i; // index
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
350 static UWORD32 root, frac; // ratio of HF and LF average
125
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
351 UWORD32 sumLF, sumHF; // sum of HF and LF counts
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
352 double nbHF_theo;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
353
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
354
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
355 // AFC or TEMPERATURE variation
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
356
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
357 //if ( (ABS( (WORD32)(l1s.pw_mgr.previous_afc-l1s.afc) ) > AFC_VARIATION) ||
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
358 // (ABS( (WORD32)(l1s.pw_mgr.previous_temp-l1s.afc) > TEMP_VARIATION) )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
359 // gauging_state = RESET;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
360
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
361 // reset state machine if not in IDLE mode
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
362 #if L1_GPRS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
363 if ((l1a_l1s_com.l1s_en_task[NP] != TASK_ENABLED) && (l1a_l1s_com.l1s_en_task[PNP] != TASK_ENABLED))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
364 gauging_state = RESET;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
365 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
366 if ((l1a_l1s_com.l1s_en_task[NP] != TASK_ENABLED) )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
367 gauging_state = RESET;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
368
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
369 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
370
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
371 switch (gauging_state)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
372 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
373
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
374 case RESET:
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
375 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
376 UWORD8 i;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
377
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
378 // Reset Histogram
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
379 for (i=0; i < SIZE_HIST; i++)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
380 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
381 l1s.pw_mgr.histo[i][0] = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
382 l1s.pw_mgr.histo[i][1] = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
383 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
384 idx = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
385 l1s.pw_mgr.enough_gaug= FALSE; // forbid Deep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
386 gauging_state = INIT;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
387 nb_gaug = NB_INIT; // counter for ACQUIS state
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
388 bad_count = 0; // reset count of BAD gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
389
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
390 #if (TRACE_TYPE != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
391 l1_trace_gauging_reset();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
392 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
393 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
394
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
395
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
396 case INIT:
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
397 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
398
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
399 // Acquire NB_INIT gauging wtw +- 100 ppm
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
400
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
401 if (l1a_l1s_com.mode != I_MODE) return;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
402
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
403 // compute clocks ratio from measurements.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
404 RATIO(nb_hf,nb_32khz,root,frac)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
405
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
406
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
407 // allow [-500ppm,+100ppm] derive on 32Khz at startup.
125
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
408 #if 0 /* really old code, apparently */
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
409 if (
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
410 (root > l1s.pw_mgr.c_clk_min ||
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
411 (root == l1s.pw_mgr.c_clk_min &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
412 frac >= l1s.pw_mgr.c_clk_init_min) ) &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
413 (root < l1s.pw_mgr.c_clk_max ||
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
414 (root == l1s.pw_mgr.c_clk_max &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
415 frac <= l1s.pw_mgr.c_clk_init_max ) )
125
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
416 #elif 1 /* TCS211 reconstruction */
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
417 if (
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
418 (root == l1s.pw_mgr.c_clk_min &&
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
419 frac >= l1s.pw_mgr.c_clk_init_min ) ||
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
420 (root == l1s.pw_mgr.c_clk_max &&
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
421 frac <= l1s.pw_mgr.c_clk_init_max )
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
422 #else /* LoCosto code */
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
423 if (
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
424 ( l1s.pw_mgr.c_clk_min == l1s.pw_mgr.c_clk_max &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
425 frac >= l1s.pw_mgr.c_clk_init_min &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
426 frac <= l1s.pw_mgr.c_clk_init_max )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
427 ||
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
428 ( l1s.pw_mgr.c_clk_min != l1s.pw_mgr.c_clk_max &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
429 ( (root == l1s.pw_mgr.c_clk_min &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
430 frac >= l1s.pw_mgr.c_clk_init_min ) ||
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
431 (root > l1s.pw_mgr.c_clk_min &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
432 root < l1s.pw_mgr.c_clk_max ) ||
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
433 (root == l1s.pw_mgr.c_clk_max &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
434 frac <= l1s.pw_mgr.c_clk_init_max ) ) )
125
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
435 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
436 )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
437 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
438 l1s.pw_mgr.histo[idx ][0] = nb_32khz; // init histo with the number of 32kHz
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
439 l1s.pw_mgr.histo[idx++][1] = nb_hf; // init histo with the number of hf (13Mhz)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
440
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
441 #if (CODE_VERSION == SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
442 #if (TRACE_TYPE==5)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
443 trace_ULPD("Gauging INIT Case ", l1s.actual_time.fn);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
444 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
445 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
446
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
447 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
448 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
449 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
450 // out of the allowed derive -> reset
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
451 idx=0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
452 #if (TRACE_TYPE != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
453 l1_trace_gauging_reset();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
454 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
455 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
456
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
457 if (idx == NB_INIT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
458 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
459 // enough measurement -> ACQUIS state
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
460 gauging_state = ACQUIS;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
461 // compute clk ratio on count average
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
462 SUM(sumHF,sumLF, NB_INIT,i) // returns sumHF and sumLF
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
463 RATIO(sumHF,sumLF,root, frac) // returns root and frac*2E16, computed on the average
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
464 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
465 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
466 break;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
467
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
468
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
469 case ACQUIS:
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
470 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
471 // Acquire NB_ACQU gauging at +-25ppm
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
472 // with jitter +- 1 us
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
473 UWORD8 n;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
474
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
475 // from nb_32khz "measured"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
476 // compute nbHF_theo
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
477 HFTHEO(nb_32khz,root,frac,nbHF_theo)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
478
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
479 if ( (nb_hf >= (nbHF_theo - l1s.pw_mgr.c_delta_hf_acquis)) &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
480 (nb_hf <= (nbHF_theo + l1s.pw_mgr.c_delta_hf_acquis)) )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
481 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
482 l1s.pw_mgr.histo[idx][0] = nb_32khz;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
483 l1s.pw_mgr.histo[idx++][1] = nb_hf;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
484 idx = idx % SIZE_HIST;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
485
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
486 // compute clk ratio on count average
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
487 if(++nb_gaug >= SIZE_HIST) n=SIZE_HIST;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
488 else n= nb_gaug;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
489 SUM(sumHF,sumLF, n,i)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
490 RATIO(sumHF,sumLF,root, frac)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
491
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
492 #if (CODE_VERSION == SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
493 #if (TRACE_TYPE==5)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
494 trace_ULPD("Gauging ACQUIS Case ", l1s.actual_time.fn);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
495 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
496 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
497
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
498 if ( nb_gaug == (NB_INIT+NB_ACQU)) // NB_ACQU good gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
499 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
500 gauging_state = UPDATE; // UPDATE state
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
501 l1s.pw_mgr.enough_gaug = TRUE; // allow Deep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
502 l1ctl_pgm_clk32(sumHF,sumLF); // clocks ratio in 4.33Mhz
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
503 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
504 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
505 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
506 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
507 gauging_state = RESET;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
508 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
509 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
510 break;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
511
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
512 case UPDATE:
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
513 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
514
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
515 // Update gauging histogram
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
516 // compute nbHF theoric for ratio_avg
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
517 HFTHEO(nb_32khz,root,frac,nbHF_theo)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
518
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
519 if ( (nb_hf >= (nbHF_theo-l1s.pw_mgr.c_delta_hf_update)) &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
520 (nb_hf <= (nbHF_theo+l1s.pw_mgr.c_delta_hf_update)) )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
521 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
522 l1s.pw_mgr.histo[idx][0] = nb_32khz;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
523 l1s.pw_mgr.histo[idx++][1] = nb_hf;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
524
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
525 // compute clk ratio on count average
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
526 SUM(sumHF,sumLF, SIZE_HIST,i)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
527 l1ctl_pgm_clk32(sumHF,sumLF); // clocks ratio in 4.33Mhz
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
528
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
529 l1s.pw_mgr.enough_gaug = TRUE; // allow Deep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
530 bad_count = 0; // reset count of BAD gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
531
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
532 #if (CODE_VERSION == SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
533 #if (TRACE_TYPE==5)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
534 trace_ULPD("Gauging UPDATE Case ", l1s.actual_time.fn);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
535 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
536 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
537
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
538 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
539 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
540 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
541 bad_count ++;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
542 if (bad_count >= MAX_BAD_GAUGING) gauging_state = RESET;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
543 l1s.pw_mgr.enough_gaug= FALSE; // forbid Deep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
544 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
545 idx = idx % SIZE_HIST;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
546 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
547 break;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
548 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
549 #if (TRACE_TYPE != 0) // Trace gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
550 // save parameters in the corresponding structure
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
551 l1s.pw_mgr.state = gauging_state;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
552 l1s.pw_mgr.lf = nb_32khz ;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
553 // WARNING WARNING, this case gauging_state == UPDATE modify the algo.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
554 // In case of trace the parameter root and frac are refresh.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
555 // it is not the case if no trace and it seems there is mistake
125
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
556 #if 0 /* FreeCalypso TCS211 reconstruction */
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
557 if (gauging_state == UPDATE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
558 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
559 RATIO2(sumHF,sumLF,root,frac);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
560 }
125
813c4bb83603 l1_pwmgr.c: l1ctl_gauging() reconstructed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 124
diff changeset
561 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
562 //End of Warning.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
563 l1s.pw_mgr.hf = nb_hf ;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
564 l1s.pw_mgr.root = root ;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
565 l1s.pw_mgr.frac = frac ;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
566 #endif // End Trace gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
567 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
568 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
569
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
570
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
571 /* GAUGING_Handler() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
572 /* Description: update increment counter for 32Khz */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
573 /* This interrupt function computes the ratio between */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
574 /* HF/32Khz gauging counters and program ULPD increment */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
575 /* values. */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
576
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
577 void GAUGING_Handler(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
578 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
579 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
580 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
581 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
582 UWORD32 nb_32khz, nb_hf;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
583
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
584 // Gauging task is ended
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
585 l1s.pw_mgr.gauging_task = INACTIVE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
586 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
587 F_INTH_DISABLE_ONE_IT(C_INTH_ULPD_GAUGING_IT); // Mask ULPD GAUGING int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
588 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
589 INTH_DISABLEONEIT(IQ_ULPD_GAUGING); // Mask ULPD GAUGING int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
590 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
591
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
592 // Number of 32 Khz clock at the end of the gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
593 nb_32khz = ((*( UWORD16 *)ULDP_COUNTER_32_MSB_REG) * 65536) +
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
594 (*( UWORD16 *)ULDP_COUNTER_32_LSB_REG);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
595
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
596 // Number of high frequency clock at the end of the gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
597 // Convert it in nbr of 13 Mhz clocks (5*13=65Mhz)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
598 nb_hf = ( ((*( UWORD16 *)ULDP_COUNTER_HI_FREQ_MSB_REG) * 65536) +
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
599 (*( UWORD16 *)ULDP_COUNTER_HI_FREQ_LSB_REG) ); // Divide by PLL ratio
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
600
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
601 l1ctl_gauging(nb_32khz, nb_hf);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
602 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
603 #else //Simulation part
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
604
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
605 // Gauging task is ended
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
606 l1s.pw_mgr.gauging_task = INACTIVE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
607
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
608 l1ctl_gauging(DEFAULT_32KHZ_VALUE,DEFAULT_HFMHZ_VALUE);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
609 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
610 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
611
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
612
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
613 // l1s_get_HWTimers_ticks()
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
614 // Description:
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
615 // evaluate the loading of the HW Timers for dep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
616 // BIG SLEEP: timers CLK may be stopped (user dependant)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
617 // DEEP SLEEP:timers CLK and WTCHDOG CLK are stopped
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
618 // CLKS are enabled after VTCX0+SLICER+13MHZ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
619 // setup time
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
620
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
621 WORD32 l1s_get_HWTimers_ticks(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
622 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
623 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
624 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
625 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
626 WORD32 timer1,timer2,watchdog,HWTimer;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
627 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
628 WORD32 watchdog_sec;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
629 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
630 UWORD16 cntlreg;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
631 UWORD16 modereg;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
632 WORD32 old = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
633
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
634 // read Hercules Timers & Watchdog
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
635 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
636 // Tint = Tclk * (LOAD_TIM+1) * 2^(PTV+1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
637 // Tclk = 1.2308us for Fclk=13Mhz
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
638 // PTV = X (pre-scaler field)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
639 //-------------------------------------------------
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
640 timer1 = timer2 = watchdog = HWTimer = -1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
641 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
642 watchdog_sec = -1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
643 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
644
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
645 cntlreg = Dtimer1_Get_cntlreg(); // AND 0x1F
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
646 if ( (cntlreg & D_TIMER_RUN) == D_TIMER_RUN)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
647 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
648 cntlreg = cntlreg&0x1F;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
649 cntlreg >>= 2; // take PTV
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
650 cntlreg = 1 << (cntlreg+1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
651 timer1 = (WORD32) ( ((Dtimer1_ReadValue()+1) * cntlreg * 0.0012308) / 4.615 );
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
652 if (timer1 <= MIN_SLEEP_TIME) return(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
653 old = Dtimer1_ReadValue();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
654 HWTimer = timer1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
655 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
656
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
657 cntlreg = Dtimer2_Get_cntlreg();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
658 if ( (cntlreg & D_TIMER_RUN) == D_TIMER_RUN)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
659 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
660 cntlreg = cntlreg&0x1F;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
661 cntlreg >>= 2; // take PTV
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
662 cntlreg = 1 << (cntlreg+1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
663 timer2 = (WORD32) ( ((Dtimer2_ReadValue()+1) * cntlreg * 0.0012308) / 4.615 );
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
664 if (timer2 <= MIN_SLEEP_TIME) return(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
665 if (HWTimer == -1) HWTimer = timer2;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
666 else MIN(HWTimer,timer2)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
667 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
668
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
669 cntlreg = TIMER_Read(0); // AND 0x0f80
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
670 modereg = TIMER_Read(2);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
671
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
672 if ( (cntlreg & TIMER_ST) || (modereg & TIMER_WDOG))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
673 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
674 // in watchdog mode PTV is forced to 7
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
675 if ( modereg & TIMER_WDOG )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
676 cntlreg |= TIMER_PTV;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
677
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
678 cntlreg = (cntlreg & TIMER_PTV) >> 9; // take PTV
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
679 cntlreg = 1 << (cntlreg+1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
680 watchdog = (WORD32) ( ((TIMER_ReadValue()+1) * cntlreg * 0.001078) / 4.615 );
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
681 if (watchdog <= MIN_SLEEP_TIME) return(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
682 if (HWTimer == -1) HWTimer = watchdog;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
683 else MIN(HWTimer,watchdog)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
684 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
685
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
686 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
687 /*
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
688 * Secure Watchdog Timer management
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
689 */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
690 cntlreg = TIMER_SEC_Read(0); // AND 0x0f80
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
691 modereg = TIMER_SEC_Read(2);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
692 if ( (cntlreg & TIMER_ST) || (modereg & TIMER_WDOG))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
693 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
694 // in watchdog mode PTV is forced to 7
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
695 if ( modereg & TIMER_WDOG )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
696 cntlreg |= TIMER_PTV;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
697
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
698 cntlreg = (cntlreg & TIMER_PTV) >> 9; // take PTV
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
699 cntlreg = 1 << (cntlreg+1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
700 watchdog_sec = (WORD32) ( ((TIMER_SEC_ReadValue()+1) * cntlreg * 0.001078) / 4.615 );
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
701 if (watchdog_sec <= MIN_SLEEP_TIME) return(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
702 if (HWTimer == -1) HWTimer = watchdog_sec;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
703 else MIN(HWTimer,watchdog_sec)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
704 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
705
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
706 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
707
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
708 return (HWTimer);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
709 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
710 #else // simulation part
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
711 return (-1); // no HW timer in simulation
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
712 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
713 return(-1); //omaps00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
714 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
715
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
716 #if (GSM_IDLE_RAM != 0) // Compile only if GSM_IDLE_RAM enabled
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
717
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
718 void l1s_adapt_traffic_controller(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
719 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
720 BOOL l1s_extram;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
721 UWORD8 nb_bitmap;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
722 T_L1S_GSM_IDLE_INTRAM * gsm_idle_ram_ctl;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
723
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
724 gsm_idle_ram_ctl = &(l1s.gsm_idle_ram_ctl);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
725
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
726 l1s_extram = FALSE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
727
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
728 for(nb_bitmap=0; ((nb_bitmap < SIZE_TAB_L1S_MONITOR) && (l1s_extram == FALSE)); nb_bitmap++)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
729 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
730 if (nb_bitmap == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
731 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
732 l1s_extram |= (((INT_RAM_GSM_IDLE_L1S_PROCESSES1 ^ gsm_idle_ram_ctl->task_bitmap_idle_ram[nb_bitmap]) & gsm_idle_ram_ctl->task_bitmap_idle_ram[nb_bitmap]) != 0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
733 }else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
734 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
735 l1s_extram |= (gsm_idle_ram_ctl->task_bitmap_idle_ram[nb_bitmap] != 0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
736 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
737 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
738
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
739 if ((l1s_extram != FALSE) && (!READ_TRAFFIC_CONT_STATE))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
740 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
741 CSMI_TrafficControllerOn();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
742 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
743 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
744 l1s_trace_mftab();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
745 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
746 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
747 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
748 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
749 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
750
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
751 UWORD32 last_wakeup;
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
752 UWORD8 wakeup_type; // Type of the interrupt
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
753 UWORD8 why_big_sleep; // Type of the big sleep
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
754
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
755 extern UWORD16 int_id;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
756
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
757 // l1s_sleep_manager()
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
758 // Description:
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
759 // evaluate the loading of the system
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
760 // - SIM, UART, LCD ....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
761 // - Nucleus tasks, Hisrs, timers
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
762 // - Timer1, Timer2, Watchdog
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
763 // program Big or Deep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
764
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
765 void l1s_sleep_manager()
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
766 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
767 //UWORD8 temp=0; OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
768
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
769 UWORD16 temp_clear_intr;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
770
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
771 // fn when l1s_sleep_manager function is called
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
772 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
773 UWORD32 sleep_time = l1s.actual_time.fn_mod42432;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
774 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
775 UWORD32 sleep_time = l1s.actual_time.fn;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
776 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
777
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
778 #if(CHIPSET == 15)
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
779 Uint8 sleep_status;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
780 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
781
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
782 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
783 T_L1S_GSM_IDLE_INTRAM * gsm_idle_ram_ctl;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
784 BOOL flag_traffic_controller_state = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
785 gsm_idle_ram_ctl = &(l1s.gsm_idle_ram_ctl);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
786
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
787 #if (AUDIO_TASK == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
788 gsm_idle_ram_ctl->l1s_full_exec = l1s.l1_audio_it_com;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
789 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
790
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
791 if (gsm_idle_ram_ctl->l1s_full_exec == TRUE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
792 return;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
793 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
794
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
795 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
796 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
797 // Power management is enabled
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
798 WORD32 min_time, OSload, HWtimer,wake_up_time,min_time_gauging;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
799 UWORD32 sleep_mode;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
800 #if (ANLG_FAM != 11)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
801 WORD32 afc_fix;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
802 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
803 UWORD32 uw32_store_next_time;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
804 #if (CHIPSET != 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
805 static UWORD32 previous_sleep = FRAME_STOP;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
806 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
807 #if (W_A_CALYPSO_PLUS_SPR_19599 == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
808 BOOL extended_page_mode_state = 0; //Store state of extended page mode
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
809 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
810 #if (CHIPSET != 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
811 WORD32 time_from_last_wakeup=0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
812 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
813
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
814 #if (OP_BT == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
815 WORD32 hci_ll_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
816 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
817
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
818 // init for trace and debug
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
819 why_big_sleep = BIG_SLEEP_DUE_TO_UNDEFINED;
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
820 wakeup_type = WAKEUP_FOR_UNDEFINED;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
821
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
822 #if (CHIPSET != 15)
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
823 time_from_last_wakeup = (sleep_time - last_wakeup + 42432) % 42432;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
824 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
825
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
826
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
827 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
828 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
829 // Protect System structures
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
830 // must be called BEFORE INT_DisableIRQ() while
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
831 // Nucleus does not restore IRQ/FIQ bits !!!!
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
832 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
833 OS_system_protect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
834 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
835 // Disable IRQ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
836 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
837 INT_DisableIRQ();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
838 #endif // NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
839 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
840 // check System (SIM, UART, LDC ..... )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
841 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
842 #if (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
843 #if (WCP_PROF == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
844 sleep_mode = Check_Peripheral_App(); /* For Locosto */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
845 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
846 sleep_mode = DO_NOT_SLEEP; //Check_Peripheral_App(); /* For Locosto */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
847 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
848 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
849 sleep_mode = Cust_check_system();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
850 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
851
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
852 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
853 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
854 // check System (SIM, UART, LDC ..... )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
855 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
856 gsm_idle_ram_ctl->sleep_mode = sleep_mode;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
857 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
858
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
859 if (sleep_mode == DO_NOT_SLEEP)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
860 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
861 OS_system_Unprotect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
862 // free System structure
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
863 // Enable all IRQ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
864 //l1_pwmgr_irq_dis_flag = 0;
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
865 #if (CODE_VERSION!=SIMULATION)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
866 INT_EnableIRQ();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
867 l1_trace_fail_sleep(FAIL_SLEEP_PERIPH_CHECK, l1_pwmgr_debug.fail_id, l1_pwmgr_debug.fail_ret_val);
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
868 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
869 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
870 gsm_idle_ram_ctl->os_load = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
871 gsm_idle_ram_ctl->hw_timer = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
872 #endif // GSM_IDLE_RAM
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
873 return;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
874 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
875
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
876
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
877 #if (OP_L1_STANDALONE == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
878 /*GC_Sleep(); OMAPS00134004*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
879 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
880 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
881 // check OS loading
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
882 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
883 OSload = OS_get_inactivity_ticks();
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
884 #if (CODE_VERSION!=SIMULATION)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
885 if ((OSload >= 0) && (OSload <= MIN_SLEEP_TIME)){
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
886 l1_pwmgr_debug.fail_id = FAIL_SLEEP_DUE_TO_OSLOAD;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
887 l1_pwmgr_debug.fail_ret_val = OSload;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
888 }
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
889 #endif //NOT SIMULATION
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
890
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
891 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
892 // check HW Timers loading
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
893 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
894 HWtimer= l1s_get_HWTimers_ticks();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
895 #if (CODE_VERSION!=SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
896 if (HWtimer == 0){
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
897 l1_pwmgr_debug.fail_id = FAIL_SLEEP_DUE_TO_HWTIMER;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
898 l1_pwmgr_debug.fail_ret_val = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
899 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
900 #endif //NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
901
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
902 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
903 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
904 // check OS loading
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
905 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
906 gsm_idle_ram_ctl->os_load = OSload;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
907
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
908 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
909 // check HW Timers loading
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
910 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
911 gsm_idle_ram_ctl->hw_timer = HWtimer;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
912 #endif // GSM_IDLE_RAM
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
913
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
914 if ((OSload > 0) && (OSload <= MIN_SLEEP_TIME))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
915 OSload =0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
916
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
917 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
918 // check next gauging task for Packet Idle
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
919 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
920 #if L1_GPRS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
921 min_time_gauging = l1s_get_next_gauging_in_Packet_Idle();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
922 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
923 min_time_gauging = -1; // not used
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
924 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
925 #if (CODE_VERSION!=SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
926 if (min_time_gauging == 0){
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
927 l1_pwmgr_debug.fail_id = FAIL_SLEEP_DUE_TO_MINTIMEGAUGING;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
928 l1_pwmgr_debug.fail_ret_val = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
929 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
930 #endif // NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
931
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
932
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
933 #if (OP_BT == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
934 hci_ll_status = hci_ll_ok_for_sleep();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
935 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
936 // check if immediate activity planned
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
937 // 0 means immediate activity
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
938 // in case big sleep is choosen (sleep mode == FRAME_STOP) because of UART or SIM,
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
939 // return and wait end of this activity (few TDMA frames) then check on next TDMA frames
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
940 // if MS can go in deep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
941 if ( !OSload
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
942 || !HWtimer
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
943 || !min_time_gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
944 #if (CHIPSET != 15)
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
945 || ((sleep_mode != CLOCK_STOP) && ((why_big_sleep == BIG_SLEEP_DUE_TO_UART) || (why_big_sleep == BIG_SLEEP_DUE_TO_SIM)))
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
946 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
947 #if (OP_BT == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
948 || !hci_ll_status
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
949 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
950 )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
951 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
952
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
953
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
954
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
955 #if (OP_L1_STANDALONE == 0)
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
956 /*GC_Wakeup(); OMAPS00134004*/
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
957 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
958
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
959 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
960 OS_system_Unprotect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
961 // free System structure
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
962 // Enable all IRQ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
963 INT_EnableIRQ();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
964 // Wake up UART
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
965 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
966 // Traffic controller has to be enabled before calling SER_WakeUpUarts
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
967 // as this function can access the external RAM.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
968 // Reset the flag that will indicates if an interrup will put the traffic
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
969 // controller ON during that time.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
970 l1s.gsm_idle_ram_ctl.trff_ctrl_enable_cause_int = FALSE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
971 if (!READ_TRAFFIC_CONT_STATE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
972 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
973 flag_traffic_controller_state = 1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
974 CSMI_TrafficControllerOn();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
975 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
976 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
977
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
978 #if (CHIPSET != 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
979 SER_WakeUpUarts(); // Wake up Uarts
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
980 #else
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
981 // To be checked if this needs a change
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
982 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
983
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
984 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
985 // The traffic controller state shall be restored as it was before
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
986 // calling SER_WakeUpUarts. Do not disable it if an interrup occured
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
987 // in between and activated the traffic controller.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
988 if ((flag_traffic_controller_state == 1) && (l1s.gsm_idle_ram_ctl.trff_ctrl_enable_cause_int == FALSE))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
989 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
990 CSMI_TrafficControllerOff();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
991 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
992 flag_traffic_controller_state = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
993 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
994 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
995 #if (CODE_VERSION!=SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
996 l1_trace_fail_sleep(FAIL_SLEEP_OSTIMERGAUGE, l1_pwmgr_debug.fail_id, l1_pwmgr_debug.fail_ret_val);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
997 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
998 return;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
999 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1000 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1001 // Select sleep duration ....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1002 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1003 // remember: -1 means no activity planned
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1004 min_time = OSload;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1005 //l1a_l1s_com.time_to_next_l1s_task is UW32, min_time is W32. Max value of l1a_l1s_com.time_to_next_l1s_task will be 2p31
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1006 //and ,min_time max value will be 2p30. If min_time > l1a_l1s_com.time_to_next_l1s_task,
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1007 //means MSB of l1a_l1s_com.time_to_next_l1s_task is zero. so, we can use- uw32_store_next_time & 0x7FFFFFFF
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1008 uw32_store_next_time = l1a_l1s_com.time_to_next_l1s_task;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1009
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1010 if (min_time == -1) min_time = (WORD32)uw32_store_next_time;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1011 //else MIN(min_time, (WORD32)l1a_l1s_com.time_to_next_l1s_task)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1012 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1013 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1014 if(min_time > l1a_l1s_com.time_to_next_l1s_task) min_time = uw32_store_next_time & 0x7FFFFFFF;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1015 //else min_time = min_time;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1016 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1017 if (HWtimer != -1) MIN(min_time, HWtimer)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1018 if (min_time_gauging != -1) MIN(min_time, min_time_gauging)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1019
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1020 #if (TRACE_TYPE !=0 ) && (TRACE_TYPE != 2) && (TRACE_TYPE != 3)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1021 // to trace the Wake up source
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1022 // depending of min_time choose the wakeup_type
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1023 wakeup_type = WAKEUP_FOR_L1_TASK;
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1024 if (min_time == l1a_l1s_com.time_to_next_l1s_task) wakeup_type = WAKEUP_FOR_L1_TASK;
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1025 if (min_time == HWtimer) wakeup_type = WAKEUP_FOR_HW_TIMER_TASK;
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1026 if (min_time == min_time_gauging) wakeup_type = WAKEUP_FOR_GAUGING_TASK;
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1027 if (min_time == OSload) wakeup_type = WAKEUP_FOR_OS_TASK;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1028 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1029
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1030 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1031 // Choose DEEP or BIG SLEEP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1032 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1033 if ( ((l1s.pw_mgr.mode_authorized == DEEP_SLEEP) && (sleep_mode == CLOCK_STOP)) ||
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1034 ((l1s.pw_mgr.mode_authorized == ALL_SLEEP) && (sleep_mode == CLOCK_STOP)) )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1035 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1036 // Check now gauging histogramme or if in inactive period of cell selection
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1037 #if (W_A_DSP_IDLE3 == 1) && (CODE_VERSION!=SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1038 if (((l1s.pw_mgr.enough_gaug == TRUE) || (l1a_l1s_com.mode == CS_MODE0)) &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1039 ( l1s_dsp_com.dsp_ndb_ptr->d_dsp_state == C_DSP_IDLE3))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1040 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1041 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1042 if (((l1s.pw_mgr.enough_gaug == TRUE) || (l1a_l1s_com.mode == CS_MODE0)) &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1043 !CLKM_READ_nIDLE3)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1044 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1045 if ((l1s.pw_mgr.enough_gaug == TRUE) || (l1a_l1s_com.mode == CS_MODE0))
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1046 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1047 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1048 l1s.pw_mgr.sleep_performed = CLOCK_STOP;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1049 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1050 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1051 // BIG SLEEP is chosen : check the reason
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1052 l1s.pw_mgr.sleep_performed = FRAME_STOP;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1053 if ((l1s.pw_mgr.enough_gaug != TRUE) && (l1a_l1s_com.mode != CS_MODE0))
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1054 why_big_sleep = BIG_SLEEP_DUE_TO_GAUGING;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1055 else
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1056 why_big_sleep = BIG_SLEEP_DUE_TO_DSP_TRACES;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1057 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1058 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1059 if (l1s.pw_mgr.mode_authorized == BIG_SLEEP)
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1060 why_big_sleep = BIG_SLEEP_DUE_TO_SLEEP_MODE;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1061
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1062 if ( ((l1s.pw_mgr.mode_authorized == BIG_SLEEP) && (sleep_mode >= FRAME_STOP)) ||
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1063 ((l1s.pw_mgr.mode_authorized >= DEEP_SLEEP) && (sleep_mode == FRAME_STOP)) )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1064 l1s.pw_mgr.sleep_performed = FRAME_STOP;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1065
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1066
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1067
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1068 #if (CHIPSET != 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1069 if ((previous_sleep == CLOCK_STOP) && (time_from_last_wakeup < 7))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1070 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1071 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1072 OS_system_Unprotect(); // free System structure
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1073 INT_EnableIRQ(); // Enable all IRQ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1074 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1075 // Traffic controller has to be enabled before calling SER_WakeUpUarts
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1076 // as this function can access the external RAM.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1077 // Reset the flag that will indicates if an interrup will put the traffic
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1078 // controller ON during that time.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1079 l1s.gsm_idle_ram_ctl.trff_ctrl_enable_cause_int = FALSE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1080 if (!READ_TRAFFIC_CONT_STATE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1081 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1082 flag_traffic_controller_state = 1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1083 CSMI_TrafficControllerOn();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1084 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1085 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1086
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1087
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1088 SER_WakeUpUarts(); // Wake up Uarts
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1089
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1090
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1091
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1092 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1093 // The traffic controller state shall be restored as it was before
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1094 // calling SER_WakeUpUarts. Do not disable it if an interrup occured
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1095 // in between and activated the traffic controller.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1096 if ((flag_traffic_controller_state == 1) && (l1s.gsm_idle_ram_ctl.trff_ctrl_enable_cause_int == FALSE))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1097 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1098 CSMI_TrafficControllerOff();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1099 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1100 flag_traffic_controller_state = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1101 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1102 #endif // NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1103 return;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1104 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1105 #else // CHIPSET == 15
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1106
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1107
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1108
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1109 if (l1s.pw_mgr.sleep_performed == CLOCK_STOP)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1110 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1111
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1112 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1113 UWORD8 local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1114
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1115
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1116 local_sleep_status = Peripheral_interface[UART_ID](SLEEP_CMD);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1117 sleep_status = local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1118 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1119 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1120 l1_pwmgr_debug.fail_id = UART_ID;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1121 l1_pwmgr_debug.fail_ret_val = sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1122 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1123
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1124 OS_system_Unprotect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1125 local_sleep_status = Peripheral_interface[MADC_AS_ID](SLEEP_CMD); /* Call MADC & Stereo Sleep before I2C */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1126 OS_system_protect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1127 sleep_status &= local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1128 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1129 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1130 l1_pwmgr_debug.fail_id = MADC_AS_ID;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1131 l1_pwmgr_debug.fail_ret_val = sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1132 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1133
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1134 local_sleep_status = Peripheral_interface[USB_ID](SLEEP_CMD);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1135 sleep_status &= local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1136 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1137 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1138 l1_pwmgr_debug.fail_id = USB_ID;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1139 l1_pwmgr_debug.fail_ret_val = sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1140 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1141
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1142 local_sleep_status = Peripheral_interface[USIM_ID](SLEEP_CMD);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1143 sleep_status &= local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1144 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1145 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1146 l1_pwmgr_debug.fail_id = USIM_ID;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1147 l1_pwmgr_debug.fail_ret_val = sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1148 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1149
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1150 local_sleep_status = Peripheral_interface[I2C_ID](SLEEP_CMD);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1151 sleep_status &= local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1152 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1153 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1154 l1_pwmgr_debug.fail_id = I2C_ID;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1155 l1_pwmgr_debug.fail_ret_val = sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1156 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1157
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1158 local_sleep_status = Peripheral_interface[LCD_ID](SLEEP_CMD);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1159 sleep_status &= local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1160 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1161 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1162 l1_pwmgr_debug.fail_id = LCD_ID;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1163 l1_pwmgr_debug.fail_ret_val = sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1164 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1165
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1166 local_sleep_status = Peripheral_interface[CAMERA_ID](SLEEP_CMD);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1167 sleep_status &= local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1168 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1169 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1170 l1_pwmgr_debug.fail_id = CAMERA_ID;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1171 l1_pwmgr_debug.fail_ret_val = sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1172 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1173 local_sleep_status = Peripheral_interface[BCI_ID](SLEEP_CMD);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1174 sleep_status &= local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1175 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1176 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1177 l1_pwmgr_debug.fail_id = BCI_ID;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1178 l1_pwmgr_debug.fail_ret_val = sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1179 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1180
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1181 #endif // NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1182 if(!sleep_status)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1183 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1184
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1185 #if (OP_L1_STANDALONE == 0)
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1186 /*GC_Wakeup(); OMAPS00134004*/
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1187 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1188
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1189 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1190 OS_system_Unprotect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1191 l1_trace_fail_sleep(FAIL_SLEEP_PERIPH_SLEEP, l1_pwmgr_debug.fail_id, l1_pwmgr_debug.fail_ret_val);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1192 #endif // NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1193 local_sleep_status = Peripheral_interface[UART_ID](WAKE_CMD); //OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1194 local_sleep_status = Peripheral_interface[USB_ID](WAKE_CMD); //OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1195 local_sleep_status = Peripheral_interface[USIM_ID](WAKE_CMD); //OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1196 local_sleep_status = Peripheral_interface[I2C_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1197 local_sleep_status = Peripheral_interface[LCD_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1198 local_sleep_status = Peripheral_interface[CAMERA_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1199 local_sleep_status = Peripheral_interface[MADC_AS_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1200 local_sleep_status = Peripheral_interface[BCI_ID](WAKE_CMD); //wake up for battery charger interface//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1201 INT_EnableIRQ();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1202 return;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1203 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1204 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1205
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1206 #endif // CHIPSET == 15
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1207
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1208 #if (CHIPSET != 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1209 // update previous sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1210 previous_sleep = l1s.pw_mgr.sleep_performed;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1211 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1212
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1213
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1214 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1215
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1216 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1217 F_INTH_DISABLE_ONE_IT(C_INTH_FRAME_IT); // mask Frame int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1218 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1219 INTH_DISABLEONEIT(IQ_FRAME); // mask Frame int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1220 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1221 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1222
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1223 //=====================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1224 // if CLOCK_STOP : stop RF, TPU, asleep Omega, DPLL, SPI
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1225 // if FRAME_STOP : asleep Omega, SPI
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1226 //=====================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1227 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1228 if ( l1s.pw_mgr.sleep_performed == CLOCK_STOP )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1229 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1230 // ==== STop RF and TPU..... ===================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1231
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1232 //L1_trace_string("Proceeding to Deep Sleep\n");
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1233
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1234
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1235 l1dmacro_RF_sleep();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1236
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1237 // (*(volatile UWORD16 *)l1s_tpu_com.reg_cmd) =TPU_CTRL_RESET |
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1238 // TSP_CTRL_RESET |TPU_CTRL_CLK_EN;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1239 // (*(volatile UWORD16 *)l1s_tpu_com.reg_cmd) =0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1240
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1241 //===== SET default value for gauging =========
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1242 // If we have come in here during the inactive period of cell
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1243 // selection, then load the ULPD timers with default values
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1244 // (used when the MS lost the network: in this case the deep sleep may be used)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1245 if (l1a_l1s_com.mode == CS_MODE0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1246 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1247 l1ctl_pgm_clk32(DEFAULT_HFMHZ_VALUE*8,DEFAULT_32KHZ_VALUE);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1248 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1249
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1250 #if (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1251
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1252
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1253 /* These APIs are to be provided by BSP */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1254 // Disable_APC_BG();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1255 gpio_sleep(); //LCD_Floating Pin Fix
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1256 DBB_Configure_DS();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1257
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1258 //gpio_sleep(); //LCD_Floating Pin Fix
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1259
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1260 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1261
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1262
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1263 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1264 #if (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1265 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1266 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1267 //DBB_Configure_BS(); // Not used
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1268 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1269 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1270
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1271
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1272 #if (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1273 // The following command writes '0' into CKM_OCPCLK register in DRP;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1274 // This is done before disabling DPLL
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1275 // CKM_OCPCLK (R/W) = Address 0xFFFF040C
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1276 // Bit 0: 0 ?OCP clock is the DCXO clock.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1277 // 1 ?OCP clock is the divided DSP clock
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1278 // Bit 31:1 Not Used
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1279 (drp_regs->CKM_OCPCLKL) &= (~(0x1));
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1280 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1281 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1282 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1283
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1284
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1285
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1286 //==============================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1287 // disable DPLL (do not provide clk to DSP & RIF (RIF))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1288 //==============================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1289 #if ((CHIPSET ==4) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12) || (CHIPSET == 15))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1290 // disable DPLL (do not provide clk to DSP & RIF (Bridge))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1291 ( * (volatile SYS_UWORD16 *) CLKM_CNTL_CLK) |= CLKM_DPLL_DIS ; /* CLKM_BRIDGE_DIS removed by Ranga*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1292 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1293
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1294 //==============================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1295 // if CLOCK_STOP or FRAME-STOP : Asleep OMEGA (ABB)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1296 //==============================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1297 #if (ANLG_FAM != 11)
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1298 afc_fix = ABB_sleep(l1s.pw_mgr.sleep_performed, l1s.afc);
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1299 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1300 // Nothing to be done as it should be handled by BSP_TWL3029_Configure_DS/BS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1301 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1302
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1303 #if (OP_BT == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1304 hci_ll_go_to_sleep();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1305 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1306 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1307 // STop SPI .....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1308 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1309
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1310 #if(CHIPSET != 15)
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1311 *((volatile UWORD16 *)MEM_SPI)&=0xFFFE; // SPI CLK DISABLED
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1312 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1313 #endif // NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1314
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1315
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1316 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1317 // CQ19599: For Calypso+ chipset, extended page mode
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1318 // shall be disabled before entering deep sleep and
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1319 // restored at wake up
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1320 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1321 #if (W_A_CALYPSO_PLUS_SPR_19599 == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1322 extended_page_mode_state = (BOOL) f_memif_extended_page_mode_read_bit();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1323 f_memif_extended_page_mode_disable();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1324 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1325
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1326 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1327 // Init the timer :
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1328 //
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1329 // a margin of 4 frames (>MIN_SLEEP_TIME) is taken
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1330 // when evaluating system loading, because 1 frame
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1331 // is lost for wakeup only, and because sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1332 // duration less than 1 frame is not worth ....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1333 //
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1334 // 1 2 3 4 5 6 7 8
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1335 // SLEEP_CTRL SLEEP WAKEUP TASK (RF,Timer, ...)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1336 //
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1337 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1338 //ULPD Timer can be loaded up to MAX_GSM_TIMER (possible in CS_MODE0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1339 if ( l1s.pw_mgr.sleep_performed == CLOCK_STOP )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1340 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1341 // DEEP SLEEP -> need time to setup afc and rf
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1342 wake_up_time = min_time - l1_config.params.setup_afc_and_rf;
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1343 #if (CODE_VERSION == NOT_SIMULATION)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1344 // Sleep one more TDMA - this is done as part of merging init and TPU control
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1345 wake_up_time += 1;
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1346 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1347
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1348 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1349 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1350 // BIG SLEEP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1351 wake_up_time = min_time - 1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1352
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1353
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1354
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1355 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1356 if ( wake_up_time >= MAX_GSM_TIMER)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1357 ULDP_TIMER_INIT(MAX_GSM_TIMER);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1358 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1359 ULDP_TIMER_INIT(wake_up_time);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1360
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1361 ULDP_TIMER_LD; // Load the timer
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1362
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1363 // BUG3060. Clear pending IQ_TGSM from ULPD. This could happen in case ULPD was frozen
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1364 // with zero into its GSM counter. In that case, the interrupt is still pending
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1365 // and if it is not cleared, it wakes the board up just after switching the clock.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1366 // Clear it into the ULPD...
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1367 // The ULDP_GSM_TIMER_IT_REG is a read only register and is cleared on
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1368 //reading the register.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1369 temp_clear_intr =(* (volatile UWORD16 *) ULDP_GSM_TIMER_IT_REG) & ULPD_IT_TIMER_GSM;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1370 // ... and next into the INTH. (must be done in this order
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1371
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1372 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1373 F_INTH_RESET_ONE_IT(C_INTH_TGSM_IT);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1374 F_INTH_ENABLE_ONE_IT(C_INTH_TGSM_IT);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1375 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1376 INTH_RESETONEIT(IQ_TGSM); // clear TDMA IRQ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1377 INTH_ENABLEONEIT(IQ_TGSM); // Unmask ULPD GSM int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1378 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1379
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1380 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1381 if (READ_TRAFFIC_CONT_STATE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1382 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1383 CSMI_TrafficControllerOff();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1384 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1385 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1386
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1387 ULDP_TIMER_START; // start count down
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1388
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1389
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1390 #if (GSM_IDLE_RAM_DEBUG == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1391 (*( volatile unsigned short* )(0xFFFE4802)) &= ~ (1 << 2); // GPIO-2=0
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1392 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1393
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1394 if ( l1s.pw_mgr.sleep_performed == CLOCK_STOP )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1395 // DEEP SLEEP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1396 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1397 #if (OP_WCP == 1) && (OP_L1_STANDALONE != 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1398 // specific sleep for WCP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1399 arm7_deep_sleep();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1400 #else // NO OP_WCP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1401 #if (W_A_CALYPSO_BUG_01435 == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1402 f_arm_sleep_cmd(DEEP_SLEEP);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1403 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1404 //EMIF_SetConfReg ( 0, 0, 2 ,1 ,0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1405 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1406 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1407 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1408 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1409 *((volatile UWORD16 *)CLKM_ARM_CLK) &= ~(CLKM_DEEP_SLEEP); // set deep sleep mode
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1410 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1411 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1412 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1413 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1414 // set deep sleep mode in case it is not set back by hardware
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1415 *((volatile UWORD16 *)CLKM_ARM_CLK) |= (CLKM_DEEP_SLEEP);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1416
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1417 //EMIF_SetConfReg ( 0, 0, 2 ,0 ,0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1418 // *((volatile UWORD16 *)CLKM_ARM_CLK) &= 0xFFFF; // set deep sleep mode
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1419 // *((volatile UWORD16 *)CLKM_ARM_CLK) &= ~(CLKM_MCLK_EN); // For Debug only
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1420
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1421
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1422 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1423 #endif // OP_WCP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1424 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1425 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1426 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1427 // BIG SLEEP / l1s.pw_mgr.sleep_performed == FRAME_STOP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1428
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1429 //==========================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1430 //Shut down PERIPHERALS clocks UWIRE and ARMIO if authorized
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1431 //==========================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1432
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1433 #if(CHIPSET != 15)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1434 UWORD16 clocks_stopped; //OMAPS90550- new
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1435 clocks_stopped = (l1s.pw_mgr.clocks & l1s.pw_mgr.modules_status);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1436 if((clocks_stopped & ARMIO_CLK_CUT) == ARMIO_CLK_CUT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1437 *((volatile UWORD16 *)ARMIO_CNTL_REG) &= ~(ARMIO_CLOCKEN);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1438 if((clocks_stopped & UWIRE_CLK_CUT) == UWIRE_CLK_CUT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1439 *((volatile UWORD16 *)(MEM_UWIRE + 0x8)) &= ~(0x0001);
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1440 #else
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1441 // Nothing to be done as it is taken care by Locosto_Configure_BS
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1442 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1443
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1444 #if (W_A_CALYPSO_BUG_01435 == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1445 f_arm_sleep_cmd(BIG_SLEEP);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1446 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1447
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1448 *((volatile UWORD16 *)CLKM_ARM_CLK) &= ~(CLKM_MCLK_EN); // set big sleep mode
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1449 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1450 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1451 #else // Simulation part
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1452 l1s.pw_mgr.sleep_duration = wake_up_time;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1453 hw.deep_sleep_en = 1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1454 status = NU_Suspend_Task(&L1S_task);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1455 // check status value...
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1456 if (status)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1457 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1458 #if (TRACE_TYPE==5)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1459 sprintf(errormsg,"Error somewhere in the L1S application to suspend : deep sleep\n");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1460 log_sim_error(ERR);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1461 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1462 EXIT;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1463 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1464 #endif // SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1465
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1466 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1467 // Wake-up procedure
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1468 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1469 // Restore L1 data base, Nucleus, HW Timers ....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1470 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1471
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1472 #if (GSM_IDLE_RAM_DEBUG == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1473 (*( volatile unsigned short* )(0xFFFE4802)) |= (1 << 2); // GPIO-2=1
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1474 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1475
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1476
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1477 l1s_wakeup();
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1478
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1479 #if (CHIPSET == 15)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1480 // The following command writes '1' into CKM_OCPCLK register in DRP;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1481 // This is done after the DPLL is up
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1482 // CKM_OCPCLK (R/W) = Address 0xFFFF040C
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1483 // Bit 0: 0 ?OCP clock is the DCXO clock.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1484 // 1 ?OCP clock is the divided DSP clock
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1485 // Bit 31:1 Not Used
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1486 (drp_regs->CKM_OCPCLKL) |= (0x1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1487 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1488 asm(" NOP");
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1489 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1490
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1491 last_wakeup = l1s.actual_time.fn_mod42432;
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1492
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1493 if (last_wakeup == sleep_time)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1494 // sleep duration == 0 -> wakeup in the same frame as sleep
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1495 wakeup_type = WAKEUP_ASYNCHRONOUS_SLEEP_DURATION_0;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1496
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1497 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1498 // Update counters with sleep duration -> will be used case expiration in next wake up phase before traffic controller is enabled by msg sending
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1499 gsm_idle_ram_ctl->os_load -= (l1s.pw_mgr.sleep_duration);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1500 gsm_idle_ram_ctl->hw_timer -= (l1s.pw_mgr.sleep_duration);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1501
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1502 if (l1s.pw_mgr.wakeup_type != WAKEUP_FOR_L1_TASK)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1503 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1504 if (!READ_TRAFFIC_CONT_STATE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1505 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1506 CSMI_TrafficControllerOn();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1507 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1508 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1509 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1510 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1511 //if CLOCK_STOP : restart TPU and RF....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1512 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1513 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1514 if ( l1s.pw_mgr.sleep_performed == CLOCK_STOP )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1515 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1516 // (*(volatile UWORD16 *)l1s_tpu_com.reg_cmd) = TPU_CTRL_CLK_EN;
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1517 UWORD8 local_sleep_status;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1518
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1519
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1520 #if (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1521
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1522 DBB_Wakeup_DS();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1523
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1524 gpio_wakeup(); //LCD_Floating Pin Fix
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1525
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1526 /* These APIs to be provided by BSP */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1527 //Enable_APC_BG();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1528 //BT_Wakeup();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1529 //IRDA_Wakeup();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1530 local_sleep_status = Peripheral_interface[UART_ID](WAKE_CMD); //OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1531 local_sleep_status = Peripheral_interface[USB_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1532 local_sleep_status = Peripheral_interface[USIM_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1533 local_sleep_status = Peripheral_interface[I2C_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1534 local_sleep_status = Peripheral_interface[LCD_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1535 local_sleep_status = Peripheral_interface[CAMERA_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1536
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1537 OS_system_Unprotect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1538 local_sleep_status = Peripheral_interface[MADC_AS_ID](WAKE_CMD);//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1539 local_sleep_status = Peripheral_interface[BCI_ID](WAKE_CMD); //wake up for battery charger//OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1540 OS_system_protect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1541 //added for OMAPS00090550 warning removal
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1542 if(local_sleep_status == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1543 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1544 l1_pwmgr_debug.fail_ret_val = local_sleep_status;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1545 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1546 //upto this OMAPS00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1547
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1548
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1549 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1550 l1dmacro_RF_wakeup();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1551
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1552 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1553
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1554 #if ((CHIPSET ==4) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1555 // enable DPLL (provide clk to DSP & RIF(Bridge) in small/big sleep)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1556 // On CALYPSO, BRIDGE clock can be cut according to the ARM sleep mode even during DMA transfer
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1557 ( * (volatile SYS_UWORD16 *) CLKM_CNTL_CLK) &= ~(CLKM_DPLL_DIS | CLKM_BRIDGE_DIS);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1558 #elif (CHIPSET == 12)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1559 // Nothing to be done because if DSP wants clock, it will exit from IDLE3 mode, which wakes up the DPLL
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1560 #elif (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1561 ( * (volatile SYS_UWORD16 *) CLKM_CNTL_CLK) &= ~(CLKM_DPLL_DIS);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1562 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1563
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1564 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1565 //if CLOCK_STOP or FRAME-STOP : ReStart SPI
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1566 //=================================================
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1567 #if(CHIPSET != 15)
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1568 *((volatile UWORD16 *)MEM_SPI)|=0x0001; // SPI CLK ENABLED
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1569 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1570
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1571 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1572 // Wake up ABB
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1573 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1574 #if (ANLG_FAM != 11)
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1575 ABB_wakeup(l1s.pw_mgr.sleep_performed, l1s.afc);
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1576 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1577 // Nothing to be done here as it will be handled by BSP_TWL3029_Wakeup_DS/BS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1578 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1579
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1580 #if (OP_BT == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1581 hci_ll_wake_up();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1582 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1583 #endif //CODE VERSION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1584
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1585 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1586 // CQ19599: For Calypso+ chipset, restore the extended
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1587 // page mode if it was enabled before entering in sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1588 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1589 #if (W_A_CALYPSO_PLUS_SPR_19599 == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1590 if ( extended_page_mode_state != 0 )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1591 f_memif_extended_page_mode_enable();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1592 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1593
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1594 #if (OP_L1_STANDALONE == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1595 /*GC_Wakeup(); OMAPS00134004*/
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1596 #endif
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1597
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1598 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1599 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1600 // enable IRQ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1601 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1602 OS_system_Unprotect();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1603 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1604
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1605 #if (TRACE_TYPE != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1606 if (l1a_l1s_com.mode != CS_MODE0) // in this mode the trace prevent from going to deep sleep due to UART activity
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1607 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1608 #if (GSM_IDLE_RAM == 0)
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1609 l1_trace_sleep(sleep_time, l1s.actual_time.fn_mod42432, l1s.pw_mgr.sleep_performed, wakeup_type, why_big_sleep);
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1610 #else
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1611 l1_trace_sleep_intram(sleep_time, l1s.actual_time.fn_mod42432, l1s.pw_mgr.sleep_performed, wakeup_type, why_big_sleep);
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1612 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1613 l1s_trace_mftab();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1614 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1615 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1616 }
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1617 int_id = 0;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1618 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1619
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1620 #if (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1621 trace_info.sleep_performed = TRUE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1622 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1623
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1624 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1625
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1626 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1627 // enable IRQ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1628 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1629 INT_EnableIRQ();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1630
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1631 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1632 // Be careful:in case of asynchronous wake-up after sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1633 // an IT_TDMA may be unmasked and executed just after OS_system_Unprotect().
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1634 // As we already are inside an hisr(), it implies the execution of an another hisr().
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1635 // In order to avoid issues with the execution of an hisr() inside the hisr()
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1636 // do not add code here after !!!
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1637 // if possible respect this rule !
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1638 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1639
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1640 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1641 // wake-up UARTs
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1642 //this function must be call after the UART interrupt,
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1643 //it means after the function INT_EnableIRQ()
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1644 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1645 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1646 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1647 // Traffic controller has to be enabled before calling SER_WakeUpUarts
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1648 // as this function can access the external RAM.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1649 // Reset the flag that will indicates if an interrup will put the traffic
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1650 // controller ON during that time.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1651 l1s.gsm_idle_ram_ctl.trff_ctrl_enable_cause_int = FALSE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1652 if (!READ_TRAFFIC_CONT_STATE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1653 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1654 flag_traffic_controller_state = 1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1655 CSMI_TrafficControllerOn();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1656 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1657 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1658
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1659
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1660
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1661 #if (CHIPSET != 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1662 SER_WakeUpUarts(); // Wake up Uarts
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1663 #else
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
1664 // To be checked if this needs a change
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1665 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1666
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1667
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1668 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1669 // The traffic controller state shall be restored as it was before
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1670 // calling SER_WakeUpUarts. Do not disable it if an interrup occured
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1671 // in between and activated the traffic controller.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1672 if ((flag_traffic_controller_state == 1) && (l1s.gsm_idle_ram_ctl.trff_ctrl_enable_cause_int == FALSE))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1673 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1674 CSMI_TrafficControllerOff();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1675 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1676 flag_traffic_controller_state = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1677 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1678 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1679 #endif // NOT SIMULATION
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1680 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1681 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1682
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1683 // l1s_wakeup() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1684 // Description: wake-up of the MCU from GSM Timer it OR unscheduled wake-up
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1685 // This function read the TPU timer and fix the :
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1686 // - system clock
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1687 // - Nucleus timers
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1688 // - L1 frame counter
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1689 // - L1 next task counter
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1690 // - Hardware timers
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1691
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1692 void l1s_wakeup(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1693 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1694 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1695 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1696 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1697 // Restore interrupts ....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1698
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1699 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1700 // mask TGSM int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1701 F_INTH_DISABLE_ONE_IT(C_INTH_TGSM_IT);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1702 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1703 INTH_DISABLEONEIT(IQ_TGSM); // mask TGSM int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1704 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1705
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1706 #if (CHIPSET == 12) || (CHIPSET == 15)
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1707 int_id = ((* (SYS_UWORD16 *) C_INTH_B_IRQ_REG) & C_INTH_SRC_NUM);// For debug: Save IRQ that causes the waking up
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1708 if ( int_id >= 256 )
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1709 int_id = ((* (SYS_UWORD16 *) C_INTH_B_FIQ_REG) & C_INTH_SRC_NUM)+100;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1710 #else
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1711 int_id = ((* (SYS_UWORD16 *) INTH_B_IRQ_REG) & INTH_SRC_NUM);// For debug: Save IRQ that causes the waking up
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1712 if ( int_id >= 256 )
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1713 int_id = ((* (SYS_UWORD16 *) INTH_B_FIQ_REG) & INTH_SRC_NUM)+100;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1714 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1715
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1716 // clear pending IQ_FRAME it and unmask it
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1717 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1718 F_INTH_RESET_ONE_IT(C_INTH_FRAME_IT);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1719 F_INTH_ENABLE_ONE_IT(C_INTH_FRAME_IT); // Unmask FRAME int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1720 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1721 INTH_RESETONEIT(IQ_FRAME); // clear TDMA IRQ
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1722 INTH_ENABLEONEIT(IQ_FRAME); // Unmask FRAME int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1723 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1724
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1725 #if (CHIPSET == 8)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1726 // if deep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1727 if ( l1s.pw_mgr.sleep_performed == CLOCK_STOP )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1728 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1729 UWORD8 i;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1730
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1731 // Loop with check whether DPLL is locked: 100 us max.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1732 for (i=0;i<16;i++)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1733 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1734 if (DPLL_READ_DPLL_LOCK)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1735 break;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1736 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1737 wait_ARM_cycles(convert_nanosec_to_cycles(50000)); // 50us
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1738
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1739 // Enable DPLL
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1740 //--------------------------------------------------
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1741 DPLL_SET_PLL_ENABLE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1742
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1743 // Loop with check whether DPLL is locked: 100 us max.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1744 for (i=0;i<16;i++)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1745 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1746 if (DPLL_READ_DPLL_LOCK)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1747 break;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1748 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1749 wait_ARM_cycles(convert_nanosec_to_cycles(50000)); // 50us
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1750 } // if deep sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1751
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1752 #endif // CHIPSET == 8
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1753
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1754 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1755 //Restart PERIPHERALS clocks if necessary after a big sleep period
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1756 // WARNING: restart other clocks modules!!!
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1757 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1758
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1759
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1760 #if(CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1761 if(l1s.pw_mgr.sleep_performed == FRAME_STOP )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1762 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1763
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1764 //ABB_Wakeup_BS(); //Not Used
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1765 //DBB_Wakeup_BS(); //Not Used
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1766 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1767 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1768 // if big sleep
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1769 if ( l1s.pw_mgr.sleep_performed == FRAME_STOP )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1770 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1771
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1772 UWORD16 clocks_stopped;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1773 clocks_stopped = (l1s.pw_mgr.clocks & l1s.pw_mgr.modules_status);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1774 if((clocks_stopped & ARMIO_CLK_CUT) == ARMIO_CLK_CUT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1775 *((volatile UWORD16 *)ARMIO_CNTL_REG) |= ARMIO_CLOCKEN;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1776 if((clocks_stopped & UWIRE_CLK_CUT) == UWIRE_CLK_CUT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1777 *((volatile UWORD16 *)(MEM_UWIRE + 0x8)) |= 0x0001;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1778
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1779 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1780 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1781
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1782
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1783 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1784 /* Compute effective sleeping time .... */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1785 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1786 /* sleep duration is */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1787 /* - TIMER_INIT */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1788 /* - or TIMER_INIT - TIMER_VALUE */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1789 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1790 /* "frame_adjust" = TRUE for unschedules wake-up */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1791 /* FALSE for scheduled wake-up */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1792 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1793 l1s.pw_mgr.frame_adjust = l1s_compute_wakeup_ticks();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1794
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1795 #if (TRACE_TYPE !=0 ) && (TRACE_TYPE != 2) && (TRACE_TYPE != 3)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1796 if ((l1s.pw_mgr.frame_adjust == TRUE))
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1797 wakeup_type = WAKEUP_BY_ASYNC_INTERRUPT;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1798 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1799
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1800
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1801 /* Fix Frame */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1802
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1803 l1s_recover_Frame();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1804
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1805
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1806 /* Fix Hardware Timers */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1807 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1808 /* GSM 1.0 : ntd - timer clock not cut */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1809 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1810 /* GSM 1.5 : deep sleep - need to fix timers */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1811
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1812 if (l1s.pw_mgr.sleep_performed == CLOCK_STOP)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1813 l1s_recover_HWTimers();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1814
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1815
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1816 /* Fix Os */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1817
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1818 if (Cust_recover_Os()) l1s.pw_mgr.Os_ticks_required = TRUE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1819 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1820 #else // SIMULATION part
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1821 // update L1 timers (FN,...)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1822 l1s_recover_Frame();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1823 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1824 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1825
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1826
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1827
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1828 /* l1s_wakeup_adjust() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1829 /* Description: 1 frame adjust a fter unscheduled wake-up */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1830 /* This function fix the : */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1831 /* - system clock */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1832 /* - Nucleus timers */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1833 /* - L1 frame counter */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1834 /* - L1 next task counter */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1835 /* - Hardware timers */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1836
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1837
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1838 void l1s_wakeup_adjust ()
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1839 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1840 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1841 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1842 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1843
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1844 UWORD32 previous_sleep_time;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1845
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1846 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1847 // Freeze GSM Timer .... */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1848 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1849 ULDP_TIMER_FREEZE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1850
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1851 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1852 // Compute effective sleeping time ....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1853 //
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1854 // compute sleep duration
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1855 // - TIMER_INIT
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1856 // - or TIMER_INIT - TIMER_VALUE
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1857 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1858 // save sleep duration that was computed at "unscheduled wakeup"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1859 previous_sleep_time = l1s.pw_mgr.sleep_duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1860
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1861 l1s_compute_wakeup_ticks();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1862
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1863 // reset flag for adjustment request ....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1864 l1s.pw_mgr.frame_adjust = FALSE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1865
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1866 // fix sleep duration
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1867 // => compute difference with duration computed at
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1868 // "unscheduled wakeup"
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1869 l1s.pw_mgr.sleep_duration -= previous_sleep_time;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1870
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1871 // adjust system with 1 frame IF NECESSARY ....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1872 if (l1s.pw_mgr.sleep_duration)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1873 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1874 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1875 /* Fix Frame */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1876 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1877 l1s_recover_Frame();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1878
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1879 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1880 /* Fix Os */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1881 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1882 if (Cust_recover_Os()) l1s.pw_mgr.Os_ticks_required = TRUE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1883 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1884 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1885 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1886 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1887
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1888
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1889 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1890 /* l1s_compute_wakeup_Ticks() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1891 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1892 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1893 /* Description: wake-up */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1894 /* ------------ */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1895 /* This function compute the sleep duration according to */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1896 /* current value of count down counter. */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1897 /* - if TIMER_VALUE = 0 it returns TIMER_INIT */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1898 /* - else it returns TIMER_INIT-TIMER_VALUE*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1899 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1900 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1901 BOOL l1s_compute_wakeup_ticks(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1902 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1903 UWORD16 temp_clear_intr;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1904 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1905 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1906 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1907 // read current value of count down counter
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1908 l1s.pw_mgr.sleep_duration = READ_ULDP_TIMER_VALUE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1909
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1910 // if count down=0 it's a scheduled wake-up....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1911 if (l1s.pw_mgr.sleep_duration == 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1912 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1913 // read sleeping planned value in TPU INIT register
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1914 l1s.pw_mgr.sleep_duration = READ_ULDP_TIMER_INIT;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1915 // INTH is different from the ULPD interrupt -> aynchronous wakeup
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1916 #if (CHIPSET == 12) || (CHIPSET == 15)
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1917 if (int_id != C_INTH_TGSM_IT)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1918 #else
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1919 if (int_id != IQ_TGSM)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1920 #endif
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1921 {
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1922 wakeup_type = WAKEUP_ASYNCHRONOUS_ULPD_0;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1923 // RESET IT_ULPD in ULPD module
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1924 // The ULDP_GSM_TIMER_IT_REG is a read only register and is cleared on reading the register
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1925 temp_clear_intr =(* (volatile UWORD16 *) ULDP_GSM_TIMER_IT_REG) & ULPD_IT_TIMER_GSM;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1926 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1927 // RESET IQ_TGSM (IT_ULPD) in IT register
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1928 F_INTH_RESET_ONE_IT(C_INTH_TGSM_IT);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1929 // RESET IQ_FRAME in IT register
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1930 F_INTH_RESET_ONE_IT(C_INTH_FRAME_IT);
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1931 int_id = C_INTH_TGSM_IT;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1932 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1933 // RESET IQ_TGSM (IT_ULPD) in IT register
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1934 INTH_RESETONEIT(IQ_TGSM);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1935 // RESET IQ_FRAME in IT register
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1936 INTH_RESETONEIT(IQ_FRAME);
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
1937 int_id = IQ_TGSM;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1938 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1939 return(FALSE);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1940 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1941 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1942 return(FALSE);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1943 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1944 else // Unscheduled wakeup
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1945 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1946 // read sleeping planned value in TPU INIT register & compute time elapsed
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1947 l1s.pw_mgr.sleep_duration = READ_ULDP_TIMER_INIT - l1s.pw_mgr.sleep_duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1948 return(TRUE);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1949 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1950 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1951 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1952 return(FALSE);//omaps00090550
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1953 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1954
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1955 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1956 /* l1s_recover_Frame() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1957 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1958 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1959 /* Description: adjust layer1 data from sleep duration */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1960 /* ------------ */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1961 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1962 void l1s_recover_Frame(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1963 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1964 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1965 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1966 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1967 /* Fix Frame counters . */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1968 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1969 l1s.debug_time += l1s.pw_mgr.sleep_duration; // used for debug and by L3 scenario.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1970
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1971 // Time...
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1972 // Update "actual time".
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1973 l1s_increment_time(&(l1s.actual_time), l1s.pw_mgr.sleep_duration);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1974
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1975 // Update "next time".
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1976 l1s.next_time = l1s.actual_time;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1977 l1s_increment_time(&(l1s.next_time), 1); // Next time is actual_time + 1
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1978
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1979 #if L1_GPRS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1980 // Update "next plus time".
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1981 l1s.next_plus_time = l1s.next_time;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1982 l1s_increment_time(&(l1s.next_plus_time), 1); // Next_plus time is next_time + 1
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1983 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1984
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1985 #if (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1986 trace_fct(CST_L1S_ADJUST_TIME, (UWORD32)(-1));
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1987 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1988
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1989 // Multiframe table...
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1990 // Increment active frame % mftab size.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1991 l1s.afrm = (l1s.afrm + l1s.pw_mgr.sleep_duration) % MFTAB_SIZE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1992
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1993 // Control function counters...
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1994 // Increment frame count from last AFC update.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1995 l1s.afc_frame_count+= l1s.pw_mgr.sleep_duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1996 // reset counter to mask SNR/TOA results for 2 fr.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1997 #if (TOA_ALGO == 2)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1998 l1s.toa_var.toa_snr_mask=0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
1999 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2000 l1s.toa_snr_mask=0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2001 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2002
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2003 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2004 /* Fix next L1S task counter */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2005 /***************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2006 // Decrement time to next L1S task.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2007 if((l1a_l1s_com.time_to_next_l1s_task > 0) &&
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2008 (l1a_l1s_com.time_to_next_l1s_task < MAX_FN))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2009 l1a_l1s_com.time_to_next_l1s_task -= l1s.pw_mgr.sleep_duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2010 } // l1_config.pwr_mngt == PWR_MNGT
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2011 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2012
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2013
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2014 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2015 /* l1s_recover_HWTimers() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2016 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2017 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2018 /* Description: adjust hardware timers from sleep */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2019 /* ------------ duration */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2020 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2021 /* Timers clocks are enabled after VTCX0+SLICER+13MHZ */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2022 /* setup times. So sleep duration is : */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2023 /* GSM TIMER - SETUP_FRAME + SETUP_SLICER + SETUP_VTCXO */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2024 /* + SETUP_CLK13 */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2025 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2026
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2027 void l1s_recover_HWTimers(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2028 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2029 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2030
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2031 #define SETUP_FRAME_IN_CLK32 (SETUP_FRAME*4.615*32.768)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2032 #if (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2033 #define DELTA_TIME (0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2034 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2035 #define DELTA_TIME (SETUP_FRAME_IN_CLK32 -SETUP_SLICER - SETUP_VTCXO)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2036 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2037
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2038
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2039 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2040 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2041 WORD32 timer1,timer2,timer;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2042 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2043 WORD32 timer_sec;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2044 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2045 UWORD16 cntlreg;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2046 UWORD16 modereg;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2047 double duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2048
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2049
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2050 //WORD32 old;- OMAPS 90550 new
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2051
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2052 // read Hercules Timers & Watchdog
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2053 //=================================================
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2054 // Tint = Tclk * (LOAD_TIM+1) * 2^(PTV+1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2055 // Tclk = 1.2308us for Fclk=13Mhz
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2056 // PTV = 7 (pre-scaler field)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2057 //-------------------------------------------------
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2058
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2059 cntlreg = Dtimer1_Get_cntlreg();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2060 if ( (cntlreg & D_TIMER_RUN) == D_TIMER_RUN)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2061 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2062 cntlreg = cntlreg&0x1F;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2063 cntlreg >>= 2; // take PTV
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2064 cntlreg = 1 << (cntlreg+1); // compute 2^(PTV+1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2065 // convert sleep duration in HWTimers ticks....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2066 duration = (l1s.pw_mgr.sleep_duration * 4.615 - (DELTA_TIME/32.768)) / (cntlreg * 0.0012308);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2067 if (duration < 0.0){
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2068 duration = 0.0; // This needs to be done for all the timers
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2069 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2070 timer1 = Dtimer1_ReadValue() - (UWORD16) duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2071
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2072 Dtimer1_Start(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2073 Dtimer1_WriteValue(timer1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2074 Dtimer1_Start(1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2075 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2076
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2077 cntlreg = Dtimer2_Get_cntlreg();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2078 if ( (cntlreg & D_TIMER_RUN) == D_TIMER_RUN)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2079 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2080 cntlreg = cntlreg&0x1F;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2081 cntlreg >>= 2; // take PTV
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2082 cntlreg = 1 << (cntlreg+1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2083 // convert sleep duration in HWTimers ticks....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2084 duration = (l1s.pw_mgr.sleep_duration * 4.615 - (DELTA_TIME/32.768)) / (cntlreg * 0.0012308);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2085 if (duration < 0.0){
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2086 duration = 0.0; // This needs to be done for all the timers
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2087 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2088 timer2 = Dtimer2_ReadValue() - (UWORD16) duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2089 Dtimer2_Start(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2090 Dtimer2_WriteValue(timer2);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2091 Dtimer2_Start(1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2092 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2093
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2094 cntlreg = TIMER_Read(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2095 modereg = TIMER_Read(2);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2096 if ( (cntlreg & TIMER_ST) || (modereg & TIMER_WDOG))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2097 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2098 // in watchdog mode PTV is forced to 7
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2099 if ( modereg & TIMER_WDOG )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2100 cntlreg |= TIMER_PTV;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2101
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2102 cntlreg = (cntlreg & TIMER_PTV) >> 9; // take PTV
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2103 cntlreg = 1 << (cntlreg+1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2104 // convert sleep duration in HWTimers ticks....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2105 duration = (l1s.pw_mgr.sleep_duration * 4.615 - (DELTA_TIME/32.768)) / (cntlreg * 0.001078);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2106
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2107 timer = TIMER_ReadValue() - (UWORD16) duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2108 TIMER_START_STOP(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2109 TIMER_WriteValue(timer);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2110 TIMER_START_STOP(1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2111 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2112
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2113 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2114 cntlreg = TIMER_SEC_Read(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2115 modereg = TIMER_SEC_Read(2);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2116 if ( (cntlreg & TIMER_ST) || (modereg & TIMER_WDOG))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2117 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2118 // in watchdog mode PTV is forced to 7
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2119 if ( modereg & TIMER_WDOG )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2120 cntlreg |= TIMER_PTV;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2122 cntlreg = (cntlreg & TIMER_PTV) >> 9; // take PTV
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2123 cntlreg = 1 << (cntlreg+1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2124 // convert sleep duration in HWTimers ticks....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2125 duration = (l1s.pw_mgr.sleep_duration * 4.615 - (DELTA_TIME/32.768)) / (cntlreg * 0.001078);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2126
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2127 timer_sec = TIMER_SEC_ReadValue() - (UWORD16) duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2128 TIMER_SEC_START_STOP(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2129 TIMER_SEC_WriteValue(timer_sec);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2130 TIMER_SEC_START_STOP(1);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2131 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2132 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2133
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2134 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2135 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2136 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2137 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2138 /* l1s_get_next_gauging_in_Packet_Idle() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2139 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2140 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2141 /* Description: */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2142 /* ------------ */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2143 /* return the nbr of frames before the next gauging */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2144 /* return -1 means no activity planned */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2145 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2146 #if L1_GPRS
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2147 UWORD32 next_gauging_scheduled_for_PNP; // gauging for Packet Idle
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2148
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2149 WORD32 l1s_get_next_gauging_in_Packet_Idle(void)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2150 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2151 WORD32 next_gauging;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2152
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2153 // gauging performed with Normal Paging (we are in Idle mode)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2154 if (l1a_l1s_com.l1s_en_task[NP] == TASK_ENABLED)
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2155 return (-1); // no activity planned
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2156
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2157 // we are not in Packet Idle Mode
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2158 if (l1a_l1s_com.l1s_en_task[PNP] != TASK_ENABLED)
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2159 return (-1); // no activity planned
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2160
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2161 next_gauging = next_gauging_scheduled_for_PNP - l1s.actual_time.fn ;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2162 if (next_gauging < 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2163 next_gauging+=MAX_FN;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2164
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2165 if (next_gauging <= MIN_SLEEP_TIME)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2166 return(0);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2167
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2168 return (next_gauging);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2169 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2170 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2171 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2172 /* l1s_gauging_decision_with_PNP() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2173 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2174 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2175 /* Description: */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2176 /* ------------ */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2177 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2178 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2179 #if L1_GPRS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2180 BOOL l1s_gauging_decision_with_PNP(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2181 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2182 #define TWO_SECONDS_IN_FRAME (UWORD16)(2000/4.615)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2183 WORD32 time_to_next_gauging=0; //changed to WORD32- sajal
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2184 // It's time to perform the next gauging
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2185 time_to_next_gauging = next_gauging_scheduled_for_PNP - l1s.actual_time.fn;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2186 if (time_to_next_gauging < 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2187 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2188 time_to_next_gauging += MAX_FN;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2189 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2190
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2191 if( (time_to_next_gauging == 0) || (time_to_next_gauging > TWO_SECONDS_IN_FRAME))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2192 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2193
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2194 next_gauging_scheduled_for_PNP = l1s.actual_time.fn + TWO_SECONDS_IN_FRAME;
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2195 if (next_gauging_scheduled_for_PNP >= MAX_FN) next_gauging_scheduled_for_PNP -= MAX_FN;
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2196 return (TRUE);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2197 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2198
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2199 return (FALSE); // do not perform gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2200 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2201 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2202 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2203 /* l1s_gauging_decision_with_NP() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2204 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2205 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2206 /* Description: */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2207 /* ------------ */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2208 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2209 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2210 BOOL l1s_gauging_decision_with_NP(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2211 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2212
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2213 static UWORD8 time_to_gaug;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2214
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2215 // a paging is scheduled or , was scheduled but discarded by a higher priority task
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2216 if (l1s.pw_mgr.paging_scheduled == TRUE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2217 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2218 l1s.pw_mgr.paging_scheduled = FALSE; // reset Flag.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2219
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2220 // A gauging session is needed : start gauging session with this paging bloc !
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2221
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2222 //Nina modify to save power, not forbid deep sleep, only force gauging in next paging
123
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2223 // FreeCalypso TCS211 reconstruction: Nina's change reverted
63137aa0ad1f l1_pwmgr.c: passes compilation (but link fails)
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 122
diff changeset
2224 #if 1
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2225 if (l1s.pw_mgr.enough_gaug != TRUE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2226 time_to_gaug = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2227 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2228 if ((l1s.pw_mgr.enough_gaug != TRUE)||(l1s.force_gauging_next_paging_due_to_CCHR == 1))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2229 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2230 time_to_gaug = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2231 l1s.force_gauging_next_paging_due_to_CCHR = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2232 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2233 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2234 if (time_to_gaug > 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2235 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2236 time_to_gaug--; // perform the gauging with an another paging.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2237 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2238 else // perform the gauging with this paging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2239 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2240 if (l1s.task_status[NP].current_status == ACTIVE )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2241 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2242 time_to_gaug = GAUG_VS_PAGING_RATE[l1a_l1s_com.bs_pa_mfrms-2]-1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2243
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2244 return (TRUE); // gauging allowed
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2245 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2246 else // a gauging is scheduled to be perform here but the paging is missing
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2247 { // (paging discarded by a higher priority task ?)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2248 l1s.pw_mgr.enough_gaug= FALSE; // forbid Deep sleep until next gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2249 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2250 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2251 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2252 return (FALSE); // gauging not allowed
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2253 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2254
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2255 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2256 /* Gauging task management : */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2257 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2258 /* CALYPSO */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2259 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2260 /* 9 8 7 6 5 4 3 2 1 0 */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2261 /* C0 C1 C2 C3 C4 W R - - - */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2262 /* | | */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2263 /* | | */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2264 /* |_ start gauging |_ stop gauging */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2265 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2266 /*OTHERS: */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2267 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2268 /* 11 10 9 8 7 6 5 4 3 2 1 0 */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2269 /* C0 C1 C2 C3 C4 W R - - - - - */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2270 /* | | | | | */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2271 /* | | |_ start gauging |_ stop gauging */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2272 /* | | | | */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2273 /* | |_ (ITCOM) | |(ITCOM) */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2274 /* | | */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2275 /* |_ pgm PLL |_restore PLL */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2276 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2277 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2278 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2279 void l1s_gauging_task(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2280 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2281 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2282 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2283 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2284 if (l1s.pw_mgr.gauging_task == ACTIVE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2285 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2286 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2287 // COUNT = 10 ==> PLL is at 65 Mhz, start the gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2288 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2289 #if (CHIPSET==7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2290 // the gauging was started with the begining of the paging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2291 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2292 if (l1s.pw_mgr.gaug_count == (l1s.pw_mgr.gaug_duration-1))
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2293 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2294 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2295 ULDP_GAUGING_START; // start gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2296 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2297
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2298 #if (TRACE_TYPE != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2299 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2300 l1_trace_gauging_intram();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2301 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2302 l1_trace_gauging();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2303 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2304 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2305 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2306 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2307
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2308 l1s.pw_mgr.gaug_count--; // decrement counter
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2309
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2310
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2311 // When a MISC task is enabled L1S must be ran every frame
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2312 // to be able to enable the frame interrupt for DSP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2313 l1a_l1s_com.time_to_next_l1s_task = 0;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2314 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2315
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2316 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2317 // REQUEST A GAUGING PROCESS ON EACH PAGING BLOCK
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2318 // IN IDLE MODE .....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2319 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2320
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2321 else if (l1s.pw_mgr.gauging_task == INACTIVE )
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2322 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2323 BOOL decision = FALSE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2324
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2325 if (l1a_l1s_com.l1s_en_task[NP] == TASK_ENABLED)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2326 decision = l1s_gauging_decision_with_NP();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2327 #if L1_GPRS
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2328 else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2329 if (l1a_l1s_com.l1s_en_task[PNP] == TASK_ENABLED)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2330 decision = l1s_gauging_decision_with_PNP();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2331 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2332
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2333 if (decision == TRUE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2334 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2335 // gauging duration
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2336 l1s.pw_mgr.gaug_count = l1s.pw_mgr.gaug_duration;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2337
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2338 #if (CHIPSET==7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2339 // start ULPD gauging immediately with Calypso because we needn't IT_COM.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2340 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2341 ULDP_GAUGING_START;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2342 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2343 // Force the DPLL to be active
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2344 ( * (volatile SYS_UWORD16 *) CLKM_CNTL_CLK) &= ~(CLKM_DPLL_DIS);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2345 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2346 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2347
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2348 #if (TRACE_TYPE != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2349 #if (GSM_IDLE_RAM != 0)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2350 l1_trace_gauging_intram();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2351 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2352 l1_trace_gauging();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2353 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2354 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2355 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2356
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2357 // DSP programmation .......
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
2358 #if (DSP >= 33)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2359 #if (CHIPSET==4)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2360 l1s_dsp_com.dsp_ndb_ptr->d_pll_config |= B_32KHZ_CALIB;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2361 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2362 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2363 l1s_dsp_com.dsp_ndb_ptr->d_pll_clkmod1 = CLKMOD2; // IDLE1 only for DSP
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2364 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2365
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2366 l1s.pw_mgr.gauging_task = ACTIVE;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2367 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2368 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2369 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2370 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2371 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2372 /* l1s_gauging_task_end() */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2373 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2374 /* */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2375 /* Description: */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2376 /* ------------ */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2377 /* stop the gauging activity */
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2378 /*-------------------------------------------------------*/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2379 void l1s_gauging_task_end(void)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2380 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2381 if (l1_config.pwr_mngt == PWR_MNGT)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2382 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2383 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2384 if (l1s.pw_mgr.gauging_task == ACTIVE)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2385 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2386 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2387 // COUNT = 1 ==> stop the gauging and free DSP idle modes....
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2388 /*************************************************************/
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2389 if (l1s.pw_mgr.gaug_count == 1)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2390 {
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2391 // wait for end of gauging interrupt ...
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2392 l1s.pw_mgr.gauging_task = WAIT_IQ;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2393
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2394 // Unmask ULPD GAUGING int.
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2395 #if (CODE_VERSION != SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2396 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2397 F_INTH_ENABLE_ONE_IT(C_INTH_ULPD_GAUGING_IT);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2398 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2399 INTH_ENABLEONEIT(IQ_ULPD_GAUGING);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2400 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2401 ULDP_GAUGING_STOP; // stop ULPD gauging
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2402 #if (CHIPSET == 12) || (CHIPSET == 15)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2403 // Allow the DPLL to be cut according to ARM sleep mode
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2404 //( * (volatile SYS_UWORD16 *) CLKM_CNTL_CLK) |= (CLKM_DPLL_DIS);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2405 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2406 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2407
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2408 // DSP programmation : free IDLE modes...
122
9360d1f31c00 l1_pwmgr.c: import of sensible changes from freecalypso-sw/gsm-fw version
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 121
diff changeset
2409 #if (DSP >= 33)
121
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2410 #if (CHIPSET==4)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2411 l1s_dsp_com.dsp_ndb_ptr->d_pll_config &= ~B_32KHZ_CALIB;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2412 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2413 #else
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2414 l1s_dsp_com.dsp_ndb_ptr->d_pll_clkmod1 = CLKMOD1;
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2415 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2416
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2417
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2418 #if (CODE_VERSION == SIMULATION)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2419 // in order to simulate the Gauging interrupt
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2420 GAUGING_Handler();
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2421
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2422 #if (TRACE_TYPE==5)
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2423 trace_ULPD("Stop Gauging", l1s.actual_time.fn);
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2424 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2425 #endif
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2426 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2427 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2428 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2429 }
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2430
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2431 //#pragma GSM_IDLE_DUPLICATE_FOR_INTERNAL_RAM_END
282e78e6e772 l1_pwmgr.c: initial import of LoCosto source
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 15
diff changeset
2432 #endif