1 |
kusanagi |
1.1 |
/**************************************************************************** |
2 |
|
|
/* F i l e D a t a |
3 |
|
|
/* |
4 |
|
|
/* Module : BasicSW |
5 |
|
|
/* C.I. No. : |
6 |
|
|
/* $Revision: 1.3 $ |
7 |
|
|
/* $Date: 2004/03/10 16:21:40 $ |
8 |
|
|
/* Belonging to : |
9 |
|
|
/* : |
10 |
|
|
/* $RCSfile: CD_CrimeaDriver_op.c,v $ |
11 |
|
|
/* Program Type : |
12 |
|
|
/* Sub-modules : |
13 |
|
|
/* |
14 |
|
|
/**************************************************************************** |
15 |
|
|
/* S W D e v e l o p m e n t E n v i r o n m e n t |
16 |
|
|
/* |
17 |
|
|
/* Host system : |
18 |
|
|
/* SW Compiler : |
19 |
|
|
/* $Author: faber $ |
20 |
|
|
/* : |
21 |
|
|
/**************************************************************************** |
22 |
|
|
/* U p d a t i n g |
23 |
|
|
/* |
24 |
|
|
/* $Log: CD_CrimeaDriver_op.c,v $ |
25 |
|
|
/* Revision 1.3 2004/03/10 16:21:40 faber |
26 |
|
|
/* more powered bugfixing about new implementation of TMTC task. In the simulator looks now to be stable. |
27 |
|
|
/* |
28 |
|
|
/* Revision 1.2 2003/11/18 09:01:14 alfarano |
29 |
|
|
/* laben patch fixes some problems |
30 |
|
|
/* |
31 |
|
|
/* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani |
32 |
|
|
/* Imported sources laben rel. 19.06.2003 integrated with pam2 |
33 |
|
|
/* |
34 |
|
|
/* Revision 1.6 2002/11/14 09:41:58 zulia |
35 |
|
|
/* Removed unused "status" variable |
36 |
|
|
/* |
37 |
|
|
/* Revision 1.5 2002/05/09 08:16:34 zulia |
38 |
|
|
/* * acceptance release |
39 |
|
|
/* |
40 |
|
|
/* |
41 |
|
|
/*****************************************************************************/ |
42 |
|
|
|
43 |
|
|
|
44 |
|
|
/*============================= Include File ================================*/ |
45 |
|
|
|
46 |
|
|
#include <src/BasicSW/CrimeaDriver/CD_CrimeaDriver_op.h> |
47 |
|
|
|
48 |
|
|
/*****************************************************************************/ |
49 |
|
|
/*============================= Object variables ============================*/ |
50 |
|
|
|
51 |
|
|
/*****************************************************************************/ |
52 |
|
|
/* @Constant: CD_CrimeaReg */ |
53 |
|
|
/* @Purpose : */ |
54 |
|
|
/* Array of unsigned short pointer. */ |
55 |
|
|
/* Physical addresses of the component CRIMEA. */ |
56 |
|
|
/* @@ */ |
57 |
|
|
/*****************************************************************************/ |
58 |
|
|
const unsigned short* CD_CrimeaReg[] ={(unsigned short* )(BASE_CRIMEA + 0x0004), |
59 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0008), |
60 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x000c), |
61 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0010), |
62 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0014), |
63 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0018), |
64 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x001c), |
65 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0020), |
66 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0024), |
67 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0028), |
68 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x002c), |
69 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0030), |
70 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0034), |
71 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0038), |
72 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0040), |
73 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0044), |
74 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x004c), |
75 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0050), |
76 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0054), |
77 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0058), |
78 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x005c), |
79 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0060), |
80 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0064), |
81 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0068), |
82 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0100), |
83 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0104), |
84 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0108), |
85 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x010c), |
86 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0110), |
87 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0114), |
88 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0118), |
89 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x011c), |
90 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0120), |
91 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0124), |
92 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0128), |
93 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x012c), |
94 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0130), |
95 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0134), |
96 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0138), |
97 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x013c), |
98 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0140), |
99 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0144), |
100 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0300), |
101 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0304), |
102 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0310), |
103 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0320), |
104 |
|
|
(unsigned short* )(BASE_CRIMEA + 0x0340) |
105 |
|
|
}; |
106 |
|
|
|
107 |
|
|
/*****************************************************************************/ |
108 |
|
|
|
109 |
|
|
/*= C D _ C r i m e a D r i v e r O P E R A T I O N A L F U N C T I O N S =*/ |
110 |
|
|
|
111 |
|
|
/*****************************************************************************/ |
112 |
|
|
/* @Function: CD_opInitCrimeaDriver */ |
113 |
|
|
/* @Purpose : */ |
114 |
|
|
/* Initialialization function of the CRIMEA component. */ |
115 |
|
|
/* The following register are initialized: */ |
116 |
|
|
/* Exchange Memory Area Select register used to configure the memory access */ |
117 |
|
|
/* by CPU and by SuMMIT. */ |
118 |
|
|
/* PCMCIA Mode register, PCMCIA B Command register, PCMCIA B Configuration */ |
119 |
|
|
/* register used to configure the PCMCIA port B for MMSU operation. */ |
120 |
|
|
/* */ |
121 |
|
|
/* @@ */ |
122 |
|
|
/* @Parameter Name @Mode @Description */ |
123 |
|
|
/* status_code OUT Return code */ |
124 |
|
|
/* @@ */ |
125 |
|
|
/*****************************************************************************/ |
126 |
|
|
|
127 |
|
|
status_code CD_opInitCrimeaDriver(void) |
128 |
|
|
{ |
129 |
|
|
#ifndef SIMULATOR |
130 |
|
|
void* p; |
131 |
|
|
unsigned short* pC; |
132 |
|
|
|
133 |
|
|
|
134 |
|
|
/* Program Exchange Memory Area Selection register */ |
135 |
|
|
p =(void* )CD_CrimeaReg[EXC_MEM_AREA_SEL_REG]; |
136 |
|
|
pC =(unsigned short* )p; |
137 |
|
|
*pC =(unsigned short)CD_EXCHANG_MEMORY_AREA_CONF; |
138 |
|
|
|
139 |
|
|
/*===== Program PCMCIA port for MMSU operation ========*/ |
140 |
|
|
/* Setting CRIMEA wait state to zero */ |
141 |
|
|
p = (void* )CD_CrimeaReg[WAIT_STATE_1553_MEM]; |
142 |
|
|
pC = (unsigned short*)p; |
143 |
|
|
*pC = (unsigned short)0; |
144 |
|
|
/* PCMCIA Mode register */ |
145 |
|
|
p =(void* )CD_CrimeaReg[PCMCIA_MODE_REG]; |
146 |
|
|
pC =(unsigned short* )p; |
147 |
|
|
*pC =(unsigned short)CD_CARD_CONFIG; |
148 |
|
|
/* PCMCIA B Command register */ |
149 |
|
|
p =(void* )CD_CrimeaReg[PCMCIA_B_COMMAND_REG_0]; |
150 |
|
|
pC =(unsigned short* )p; |
151 |
|
|
*pC =(unsigned short)CD_TIMING_REGISTER_VALUE; |
152 |
|
|
/* PCMCIA B Configuration register */ |
153 |
|
|
p =(void* )CD_CrimeaReg[PCMCIA_B_CONFIG_REG]; |
154 |
|
|
pC =(unsigned short* )p; |
155 |
|
|
*pC =(unsigned short)CD_ADDRESS_SPACE_ENABLE; |
156 |
|
|
|
157 |
|
|
/* Program Interrupt Sensitivity Register CRIMEA */ |
158 |
|
|
p =(void* )CD_CrimeaReg[INTER_SENSITIVITY_REG]; |
159 |
|
|
pC =(unsigned short* )p; |
160 |
|
|
*pC =(unsigned short)CD_SENSITIVITY_VALUE; |
161 |
|
|
|
162 |
|
|
/* Program Interrupt Mask Register CRIMEA */ |
163 |
|
|
p =(void* )CD_CrimeaReg[INTER_MASK_REG_HIGH]; |
164 |
|
|
pC =(unsigned short* )p; |
165 |
|
|
*pC =(unsigned short)CD_INTERRUPT_MASK; |
166 |
|
|
|
167 |
|
|
/* Program SBUS90 first 64 kbytes page */ |
168 |
|
|
p =(void* )CD_CrimeaReg[SBUS90_ADDR_PAGE_REG]; |
169 |
|
|
pC =(unsigned short* )p; |
170 |
|
|
*pC =(unsigned short)CD_SBUS90_ADDR_PAGE; |
171 |
|
|
|
172 |
|
|
/* Program EEPROM wait state */ |
173 |
|
|
p =(void* )CD_CrimeaReg[EEPROM_WS_REG]; |
174 |
|
|
pC =(unsigned short* )p; |
175 |
|
|
*pC =(unsigned short)CD_EEPROM_WAIT_STATE; |
176 |
|
|
|
177 |
|
|
/* Program increase time between two PCMCIA access */ |
178 |
|
|
p =(void* )CD_CrimeaReg[PCMCIA_B_RECOVERY_REG_0]; |
179 |
|
|
pC =(unsigned short* )p; |
180 |
|
|
*pC =(unsigned short)CD_INCREASE_TIME; |
181 |
|
|
#endif // SIMULATOR |
182 |
|
|
return (SUCCESSFUL); |
183 |
|
|
|
184 |
|
|
} |
185 |
|
|
|
186 |
|
|
|
187 |
|
|
/*****************************************************************************/ |
188 |
|
|
/* @Function: CD_opWrCrimeaReg */ |
189 |
|
|
/* @Purpose : */ |
190 |
|
|
/* The function writes a generic CRIMEA register. A parameter value is */ |
191 |
|
|
/* written into specified CRIMEA register. */ |
192 |
|
|
/* */ |
193 |
|
|
/* @@ */ |
194 |
|
|
/* @Parameter Name @Mode @Description */ |
195 |
|
|
/* Reg IN Crimea register (CD_CRIMEA_REG type) */ |
196 |
|
|
/* Value IN Value to write into the register */ |
197 |
|
|
/* status_code OUT Return code */ |
198 |
|
|
/* @@ */ |
199 |
|
|
/*****************************************************************************/ |
200 |
|
|
|
201 |
|
|
status_code CD_opWrCrimeaReg (unsigned int Reg, unsigned int Value) |
202 |
|
|
{ |
203 |
|
|
status_code status; |
204 |
|
|
void* p; |
205 |
|
|
unsigned short* pC; |
206 |
|
|
|
207 |
|
|
/* Check CRIMEA register validity */ |
208 |
|
|
if (Reg < MAX_CRIMEA_REG) |
209 |
|
|
{ |
210 |
|
|
/* Write CRIMEA register */ |
211 |
|
|
p =(void* )CD_CrimeaReg[Reg]; |
212 |
|
|
pC =(unsigned short* )p; |
213 |
|
|
*pC =(unsigned short)Value; |
214 |
|
|
status =SUCCESSFUL; |
215 |
|
|
} |
216 |
|
|
else |
217 |
|
|
{ |
218 |
|
|
status =INVALID_ADDRESS; |
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
return (status); |
222 |
|
|
|
223 |
|
|
} |
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
/*****************************************************************************/ |
228 |
|
|
/* @Function: CD_opRdCrimeaReg */ |
229 |
|
|
/* @Purpose : */ |
230 |
|
|
/* The function reads a generic CRIMEA register. A parameter value is read */ |
231 |
|
|
/* form the specified CRIMEA register. */ |
232 |
|
|
/* */ |
233 |
|
|
/* @@ */ |
234 |
|
|
/* @Parameter Name @Mode @Description */ |
235 |
|
|
/* Reg IN Crimea register (CD_CRIMEA_REG type) */ |
236 |
|
|
/* Value OUT Value read */ |
237 |
|
|
/* status_code OUT Return code */ |
238 |
|
|
/* @@ */ |
239 |
|
|
/*****************************************************************************/ |
240 |
|
|
|
241 |
|
|
status_code CD_opRdCrimeaReg (unsigned int Reg, unsigned int* Value) |
242 |
|
|
{ |
243 |
|
|
status_code status; |
244 |
|
|
|
245 |
|
|
/* Check CRIMEA register validity */ |
246 |
|
|
if (Reg < MAX_CRIMEA_REG) |
247 |
|
|
{ |
248 |
|
|
/* Read CRIMEA register */ |
249 |
|
|
*Value =(unsigned int)*CD_CrimeaReg[Reg]; |
250 |
|
|
status =SUCCESSFUL; |
251 |
|
|
} |
252 |
|
|
else |
253 |
|
|
{ |
254 |
|
|
status =INVALID_ADDRESS; |
255 |
|
|
} |
256 |
|
|
return (status); |
257 |
|
|
|
258 |
|
|
} |
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
/*****************************************************************************/ |
263 |
|
|
/* @Function: CD_opGetCrimeaInterPending */ |
264 |
|
|
/* @Purpose : */ |
265 |
|
|
/* The function reads the CRIMEA Interrupt Pending value. Two register are */ |
266 |
|
|
/* read Interrupt Pending High and Interrupt Pending Low for returning a */ |
267 |
|
|
/* 32 bit value. */ |
268 |
|
|
/* */ |
269 |
|
|
/* @@ */ |
270 |
|
|
/* @Parameter Name @Mode @Description */ |
271 |
|
|
/* InterPending OUT Interrupt Pending value read */ |
272 |
|
|
/* status_code OUT Return code (always SUCCESSFUL) */ |
273 |
|
|
/* @@ */ |
274 |
|
|
/*****************************************************************************/ |
275 |
|
|
|
276 |
|
|
status_code CD_opGetCrimeaInterPending (unsigned int* InterPending) |
277 |
|
|
{ |
278 |
|
|
unsigned int tmpInterPending; |
279 |
|
|
|
280 |
|
|
/* Read Interrupt Pending High register */ |
281 |
|
|
tmpInterPending =(unsigned int)*CD_CrimeaReg[INTER_PENDING_REG_HIGH]; |
282 |
|
|
tmpInterPending <<=16; |
283 |
|
|
/* Read Interrupt Pending Low register */ |
284 |
|
|
tmpInterPending |=(unsigned int)*CD_CrimeaReg[INTER_PENDING_REG_LOW]; |
285 |
|
|
*InterPending =tmpInterPending; |
286 |
|
|
return (SUCCESSFUL); |
287 |
|
|
|
288 |
|
|
} |
289 |
|
|
|
290 |
|
|
|
291 |
|
|
/*****************************************************************************/ |
292 |
|
|
/* @Function: CD_opSetCrimeaInterClear */ |
293 |
|
|
/* @Purpose : */ |
294 |
|
|
/* The function writes a 32 bit value in two register. The MSW is written */ |
295 |
|
|
/* into the CRIMEA Interrupt Clear High and the LSW into the CRIMEA */ |
296 |
|
|
/* Interrupt Clear Low register. */ |
297 |
|
|
/* */ |
298 |
|
|
/* @@ */ |
299 |
|
|
/* @Parameter Name @Mode @Description */ |
300 |
|
|
/* InterClear IN Interrupt Clear value */ |
301 |
|
|
/* status_code OUT Return code */ |
302 |
|
|
/* @@ */ |
303 |
|
|
/*****************************************************************************/ |
304 |
|
|
|
305 |
|
|
status_code CD_opSetCrimeaInterClear (unsigned int InterClear) |
306 |
|
|
{ |
307 |
|
|
void* p; |
308 |
|
|
unsigned short* pC; |
309 |
|
|
|
310 |
|
|
/* Write CRIMEA Interrupt Clear Low register */ |
311 |
|
|
p =(void* )CD_CrimeaReg[INTER_CLEAR_REG_LOW]; |
312 |
|
|
pC =(unsigned short* )p; |
313 |
|
|
*pC =(unsigned short)InterClear; |
314 |
|
|
|
315 |
|
|
/* Write CRIMEA Interrupt Clear High register */ |
316 |
|
|
p =(void* )CD_CrimeaReg[INTER_CLEAR_REG_HIGH]; |
317 |
|
|
pC =(unsigned short* )p; |
318 |
|
|
*pC =(unsigned short)(InterClear >> 16); |
319 |
|
|
|
320 |
|
|
return (SUCCESSFUL); |
321 |
|
|
|
322 |
|
|
} |
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
/*****************************************************************************/ |
327 |
|
|
/* @Function: CD_opSetCrimeaInterMask */ |
328 |
|
|
/* @Purpose : */ |
329 |
|
|
/* The function writes a 32 bit value in two register. The MSW is written */ |
330 |
|
|
/* into the CRIMEA Interrupt Mask High and the LSW into the CRIMEA */ |
331 |
|
|
/* Interrupt Mask Low register. */ |
332 |
|
|
/* */ |
333 |
|
|
/* @@ */ |
334 |
|
|
/* @Parameter Name @Mode @Description */ |
335 |
|
|
/* InterMask IN Interrupt mask value */ |
336 |
|
|
/* status_code OUT Return code */ |
337 |
|
|
/* @@ */ |
338 |
|
|
/*****************************************************************************/ |
339 |
|
|
|
340 |
|
|
status_code CD_opSetCrimeaInterMask (unsigned int InterMask) |
341 |
|
|
{ |
342 |
|
|
void* p; |
343 |
|
|
unsigned short* pC; |
344 |
|
|
|
345 |
|
|
/* Write CRIMEA Interrupt Mask Low register */ |
346 |
|
|
p =(void* )CD_CrimeaReg[INTER_MASK_REG_LOW]; |
347 |
|
|
pC =(unsigned short*)p; |
348 |
|
|
*pC =(unsigned short)InterMask; |
349 |
|
|
|
350 |
|
|
/* Write CRIMEA Interrupt Mask High register */ |
351 |
|
|
p =(void* )CD_CrimeaReg[INTER_MASK_REG_HIGH]; |
352 |
|
|
pC =(unsigned short* )p; |
353 |
|
|
*pC =(unsigned short)(InterMask >> 16); |
354 |
|
|
|
355 |
|
|
return (SUCCESSFUL); |
356 |
|
|
|
357 |
|
|
} |
358 |
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
|
|
/*****************************************************************************/ |
362 |
|
|
/* @Function: CD_opGetCrimeaInterMask */ |
363 |
|
|
/* @Purpose : */ |
364 |
|
|
/* The function reads a 32 bit value in two register. The MSW is read */ |
365 |
|
|
/* from the CRIMEA Interrupt Mask High and the LSW from the CRIMEA */ |
366 |
|
|
/* Interrupt Mask Low register. */ |
367 |
|
|
/* */ |
368 |
|
|
/* @@ */ |
369 |
|
|
/* @Parameter Name @Mode @Description */ |
370 |
|
|
/* InterMask OUT Interrupt mask value */ |
371 |
|
|
/* status_code OUT Return code */ |
372 |
|
|
/* @@ */ |
373 |
|
|
/*****************************************************************************/ |
374 |
|
|
|
375 |
|
|
status_code CD_opGetCrimeaInterMask (unsigned int* InterMask) |
376 |
|
|
{ |
377 |
|
|
void* p; |
378 |
|
|
unsigned short* pC; |
379 |
|
|
|
380 |
|
|
/* Write CRIMEA Interrupt Mask High register */ |
381 |
|
|
p =(void* )CD_CrimeaReg[INTER_MASK_REG_HIGH]; |
382 |
|
|
pC =(unsigned short* )p; |
383 |
|
|
*InterMask =*pC; |
384 |
|
|
*InterMask <<=16; |
385 |
|
|
|
386 |
|
|
/* Write CRIMEA Interrupt Mask Low register */ |
387 |
|
|
p =(void* )CD_CrimeaReg[INTER_MASK_REG_LOW]; |
388 |
|
|
pC =(unsigned short* )p; |
389 |
|
|
*InterMask |=(*pC & 0x0000ffff); |
390 |
|
|
|
391 |
|
|
return (SUCCESSFUL); |
392 |
|
|
|
393 |
|
|
} |
394 |
|
|
|