FreeCalypso > hg > fc-magnetite
comparison src/cs/layer1/cfile/l1_api_hisr.c @ 69:50a15a54801e
src/cs/layer1: import from tcs211-l1-reconst project
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 01 Oct 2016 23:45:38 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
68:838717193e09 | 69:50a15a54801e |
---|---|
1 /************* Revision Controle System Header ************* | |
2 * GSM Layer 1 software | |
3 * L1_API_HISR.C | |
4 * | |
5 * Filename l1_api_hisr.c | |
6 * Copyright 2003 (C) Texas Instruments | |
7 * | |
8 ************* Revision Controle System Header *************/ | |
9 | |
10 #include "l1_confg.h" | |
11 #include "nucleus.h" | |
12 #include "sys_types.h" | |
13 #include "l1_types.h" | |
14 #include "l1audio_cust.h" | |
15 #include "l1audio_defty.h" | |
16 #include "l1audio_const.h" | |
17 #include "l1_const.h" | |
18 #include "cust_os.h" | |
19 #include "l1tm_defty.h" | |
20 #if (L1_GTT == 1) | |
21 #include "l1gtt_const.h" | |
22 #include "l1gtt_defty.h" | |
23 #endif | |
24 #if (L1_MP3 == 1) | |
25 #include "l1mp3_const.h" | |
26 #include "l1mp3_signa.h" | |
27 #include "l1mp3_defty.h" | |
28 #include "l1mp3_proto.h" | |
29 #endif | |
30 #if (L1_MIDI == 1) | |
31 #include "l1midi_const.h" | |
32 #include "l1midi_signa.h" | |
33 #include "l1midi_defty.h" | |
34 #include "l1midi_proto.h" | |
35 #endif | |
36 #if (L1_AAC == 1) | |
37 #include "l1aac_const.h" | |
38 #include "l1aac_signa.h" | |
39 #include "l1aac_defty.h" | |
40 #include "l1aac_proto.h" | |
41 #endif | |
42 #if (L1_DYN_DSP_DWNLD==1) | |
43 #include "l1_dyn_dwl_defty.h" | |
44 #include "l1_dyn_dwl_msgty.h" | |
45 #include "l1_dyn_dwl_const.h" | |
46 #include "l1_dyn_dwl_signa.h" | |
47 #include "l1_dyn_dwl_error.h" | |
48 #include "l1_dyn_dwl_proto.h" | |
49 #include "l1_api_hisr.h" | |
50 #endif | |
51 #include "l1_defty.h" | |
52 #include "l1_api_hisr.h" | |
53 #include "l1audio_signa.h" | |
54 #include "l1_varex.h" | |
55 #include "l1_macro.h" | |
56 #include "mem.h" | |
57 | |
58 | |
59 /*-------------------------------------------------------------*/ | |
60 /* l1_api_handler() */ | |
61 /*-------------------------------------------------------------*/ | |
62 /* */ | |
63 /* Parameters : none */ | |
64 /* */ | |
65 /* Return : n/a */ | |
66 /* */ | |
67 /* Description : API interrupt handler, multiplexed for: */ | |
68 /* 1) audio sources: MP3 or AAC */ | |
69 /* 2) modem sources: USF */ | |
70 /* */ | |
71 // The API Interrupt is multiplexed between (DYN DWNLD, MP3 ,AAC) and FAST USF. | |
72 // DYN DWNLD, MP3 and AAC are mutually exclusive and hence only one would be | |
73 // active at one time. But FAST USF would co-exist with any of the them and hence | |
74 // there needs to be a way to distinguish the two sources of the API Interrupt. A flag | |
75 // d_dsp_hint_flag is used by the DSP to signify the source of the interrupt. The bit | |
76 // configuration of d_dsp_hint_flag is | |
77 // 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0 | |
78 // | |____> Fast USF | |
79 // |______> (DYN DWNLD, MP3, AAC) | |
80 | |
81 | |
82 void l1_api_handler() | |
83 { | |
84 #if (FF_L1_IT_DSP_USF == 1) || (FF_L1_IT_DSP_DTX == 1) || (FF_L1_FAST_DECODING == 1) | |
85 extern NU_HISR api_modemHISR; | |
86 #endif | |
87 | |
88 #if ( (L1_MP3 == 1) || (L1_AAC == 1) || (L1_MIDI == 1) || (L1_DYN_DSP_DWNLD == 1) ) | |
89 extern NU_HISR apiHISR; | |
90 #endif | |
91 | |
92 #if (FF_L1_IT_DSP_USF == 1) || (FF_L1_IT_DSP_DTX == 1) || (FF_L1_FAST_DECODING == 1) | |
93 #if (FF_L1_FAST_DECODING == 1) | |
94 if (l1s_dsp_com.dsp_ndb_ptr->d_dsp_hint_flag & (1 << B_FAST_DECODING_FLAG)) | |
95 { | |
96 // Flag HISR to be scheduled | |
97 l1a_apihisr_com.fast_decoding.pending = TRUE; | |
98 // Clear API ISR condition | |
99 l1s_dsp_com.dsp_ndb_ptr->d_dsp_hint_flag &= ~(1 << B_FAST_DECODING_FLAG); | |
100 l1a_apihisr_com.fast_decoding.crc_error = | |
101 l1s_dsp_com.dsp_ndb_ptr->d_fast_paging_data & (C_FAST_DECODING_CRC_FIRE1); | |
102 NU_Activate_HISR(&api_modemHISR); // activate API modem HISR | |
103 } | |
104 #endif /* FF_L1_FAST_DECODING */ | |
105 #if (FF_L1_IT_DSP_USF == 1) | |
106 if (l1s_dsp_com.dsp_ndb_ptr->d_dsp_hint_flag & (1 << B_USF_HINT_ISSUED)) | |
107 { | |
108 // Flag HISR to be scheduled | |
109 l1a_apihisr_com.usf.pending = TRUE; | |
110 // Clear API ISR condition | |
111 l1s_dsp_com.dsp_ndb_ptr->d_dsp_hint_flag &= ~(1 << B_USF_HINT_ISSUED); | |
112 NU_Activate_HISR(&api_modemHISR); // activate API modem HISR | |
113 } | |
114 #endif //(FF_L1_IT_DSP_USF == 1) | |
115 #if (FF_L1_IT_DSP_DTX == 1) | |
116 | |
117 if ((l1s_dsp_com.dsp_ndb_ptr->d_dsp_hint_flag & 0x4 ) != 0) // DTX interrupt set by 3rd bit position from left | |
118 { | |
119 // Flag HISR to be scheduled | |
120 l1a_apihisr_com.dtx.pending = TRUE; | |
121 // Clear API ISR condition | |
122 | |
123 l1s_dsp_com.dsp_ndb_ptr->d_dsp_hint_flag &= 0xFB; //reset the 3rd bit position | |
124 NU_Activate_HISR(&api_modemHISR); // activate API modem HISR | |
125 } | |
126 #endif //(FF_L1_IT_DSP_DTX == 1) | |
127 // Call the API HISR when MP3, AAC, DYN DWNLD comes | |
128 #if ( (L1_MP3 == 1) || (L1_MIDI == 1) || (L1_AAC == 1) || (L1_DYN_DSP_DWNLD == 1) ) | |
129 | |
130 | |
131 | |
132 | |
133 if (l1s_dsp_com.dsp_ndb_ptr->d_dsp_aud_hint_flag & (1 << B_NON_USF_HINT_ISSUED)) | |
134 { | |
135 // Clear API ISR condition | |
136 l1s_dsp_com.dsp_ndb_ptr->d_dsp_aud_hint_flag = 0; | |
137 //Activate the API HISR | |
138 NU_Activate_HISR(&apiHISR); | |
139 } | |
140 #endif // (L1_MP3 == 1) || (L1_MIDI == 1) || (L1_DYN_DSP_DWNLD == 1) | |
141 #endif //(FF_L1_IT_DSP_USF == 1) || //(FF_L1_IT_DSP_DTX == 1) | |
142 | |
143 #if 0 /* FreeCalypso Frankenstein */ | |
144 /* This is the original LoCosto code */ | |
145 | |
146 //When Fast USF is not enabled, then the API HISR needs to be called every time the DSP | |
147 //sends a HINT interrupt. | |
148 #if (!FF_L1_IT_DSP_USF) && (!FF_L1_IT_DSP_DTX) | |
149 #if ( (L1_MP3 == 1) || (L1_MIDI == 1) || (L1_AAC == 1) || (L1_DYN_DSP_DWNLD == 1) ) | |
150 NU_Activate_HISR(&apiHISR); | |
151 #endif | |
152 #endif | |
153 //NU_Activate_HISR(&apiHISR); //hack remove | |
154 return; | |
155 | |
156 #else | |
157 | |
158 /* reconstruction of what the TCS211 code was probably like */ | |
159 #if (L1_DYN_DSP_DWNLD == 1) | |
160 if( l1_apihisr.dyn_dwnld.running == TRUE ) | |
161 { | |
162 NU_Activate_HISR(&apiHISR); | |
163 } | |
164 #endif | |
165 | |
166 #endif | |
167 } | |
168 | |
169 /*-------------------------------------------------------------*/ | |
170 /* api_hisr() */ | |
171 /*-------------------------------------------------------------*/ | |
172 /* */ | |
173 /* Parameters : none */ | |
174 /* */ | |
175 /* Return : n/a */ | |
176 /* */ | |
177 /* Description : main function dealing with DSP->MCU interrupt */ | |
178 /* */ | |
179 /*-------------------------------------------------------------*/ | |
180 void api_hisr(void) | |
181 { | |
182 #if (L1_MP3 == 1) | |
183 if(l1a_apihisr_com.mp3.running==TRUE) | |
184 { | |
185 l1mp3_apihisr(); | |
186 } | |
187 #endif | |
188 #if (L1_MIDI == 1) | |
189 if(l1_apihisr.midi.running==TRUE) | |
190 { | |
191 l1midi_apihisr(); | |
192 } | |
193 #endif | |
194 #if (L1_AAC == 1) | |
195 if(l1a_apihisr_com.aac.running==TRUE) | |
196 { | |
197 l1aac_apihisr(); | |
198 } | |
199 #endif | |
200 #if (L1_DYN_DSP_DWNLD == 1) | |
201 if( l1_apihisr.dyn_dwnld.running == TRUE ) | |
202 { | |
203 l1_dyn_dwnld_apihisr(); | |
204 } | |
205 #endif | |
206 | |
207 } | |
208 | |
209 #if 0 /* FreeCalypso */ | |
210 /*-------------------------------------------------------------*/ | |
211 /* api_modem_hisr() */ | |
212 /*-------------------------------------------------------------*/ | |
213 /* */ | |
214 /* Parameters : none */ | |
215 /* */ | |
216 /* Return : n/a */ | |
217 /* */ | |
218 /* Description : main function dealing with DSP->MCU interrupt */ | |
219 /* */ | |
220 /*-------------------------------------------------------------*/ | |
221 void api_modem_hisr(void) | |
222 { | |
223 #if (FF_L1_FAST_DECODING == 1) | |
224 if(l1a_apihisr_com.fast_decoding.pending == TRUE) | |
225 { | |
226 extern void l1_fast_decoding_apihisr(void); | |
227 l1_fast_decoding_apihisr(); | |
228 } | |
229 | |
230 #endif /* FF_L1_FAST_DECODING */ | |
231 #if (FF_L1_IT_DSP_USF == 1) | |
232 if(l1a_apihisr_com.usf.pending == TRUE) | |
233 { | |
234 extern void l1usf_apihisr(void); | |
235 l1usf_apihisr(); | |
236 } | |
237 #endif | |
238 #if (FF_L1_IT_DSP_DTX == 1) | |
239 if(l1a_apihisr_com.dtx.pending == TRUE) | |
240 { | |
241 extern void l1dtx_apihisr(void); | |
242 l1dtx_apihisr(); | |
243 } | |
244 #endif | |
245 } | |
246 #endif /* FreeCalypso */ | |
247 | |
248 /*-------------------------------------------------------------*/ | |
249 /* l1_trigger_api_interrupt() */ | |
250 /*-------------------------------------------------------------*/ | |
251 /* */ | |
252 /* Parameters : none */ | |
253 /* */ | |
254 /* Return : n/a */ | |
255 /* */ | |
256 /* Description : Trigger an MCU->DSP interrupt */ | |
257 /* */ | |
258 /*-------------------------------------------------------------*/ | |
259 void l1_trigger_api_interrupt() | |
260 { | |
261 #if (CODE_VERSION == SIMULATION) | |
262 extern void sim_it_mcu_to_dsp(); | |
263 sim_it_mcu_to_dsp(); | |
264 #else | |
265 #if (L1_DYN_DSP_DWNLD == 1) | |
266 *((volatile UWORD32 *)MEM_APIC_REG)|=ID_API_INT; | |
267 #else | |
268 *((volatile UWORD32 *)MEM_APIC_REG)|=0x4; | |
269 #endif | |
270 #endif | |
271 | |
272 } |