1 |
kusanagi |
1.1 |
/**************************************************************************** |
2 |
|
|
* F i l e D a t a |
3 |
|
|
* $Id: TRK_Driver_INFN.c,v 1.4 2003/10/30 14:55:52 faber Exp $ |
4 |
|
|
* $Revision: 1.4 $ |
5 |
|
|
* $Date: 2003/10/30 14:55:52 $ |
6 |
|
|
* $RCSfile: TRK_Driver_INFN.c,v $ |
7 |
|
|
* |
8 |
|
|
**************************************************************************** |
9 |
|
|
* S W D e v e l o p m e n t E n v i r o n m e n t |
10 |
|
|
* |
11 |
|
|
* $Author: faber $ |
12 |
|
|
* : |
13 |
|
|
**************************************************************************** |
14 |
|
|
* U p d a t i n g |
15 |
|
|
|
16 |
|
|
* $Log: TRK_Driver_INFN.c,v $ |
17 |
|
|
* Revision 1.4 2003/10/30 14:55:52 faber |
18 |
|
|
* CRC function debuggin (some fixes) |
19 |
|
|
* |
20 |
|
|
* Revision 1.3 2003/10/27 18:59:38 sebastiani |
21 |
|
|
* CRC moved into Commong module |
22 |
|
|
* |
23 |
|
|
* Revision 1.2 2003/10/22 12:47:06 faber |
24 |
|
|
* *** empty log message *** |
25 |
|
|
* |
26 |
|
|
* |
27 |
|
|
*****************************************************************************/ |
28 |
|
|
|
29 |
|
|
|
30 |
|
|
/*============================= Include File ================================*/ |
31 |
|
|
|
32 |
|
|
#ifndef I386 |
33 |
|
|
#include <src/INFN/LU_SourceFileID_INFN.h> |
34 |
|
|
#define __FILEID__ _TRK_Driver_INFN__c |
35 |
|
|
#include <src/INFN/PRH_ParamHandler_INFN.h> |
36 |
|
|
#include <src/INFN/LU_LogUtility_INFN.h> |
37 |
|
|
#include <src/INFN/PRH_ParamHandler_INFN_auto.h> |
38 |
|
|
LU_DECL_MASK(); |
39 |
|
|
#endif // no I386 |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
#include <src/INFN/DAQ_IDAQ_INFN.h> |
43 |
|
|
#include <src/INFN/CM_Common_INFN.h> |
44 |
|
|
#include <src/INFN/Drivers/TRK_Driver_INFN.h> |
45 |
|
|
|
46 |
|
|
#ifndef I386 |
47 |
|
|
#include <src/INFN/CH_CommandHandler_INFN.h> |
48 |
|
|
#include <src/INFN/TRG_Trigger_INFN.h> |
49 |
|
|
#include <src/INFN/RM_RunManager_INFN.h> |
50 |
|
|
#endif |
51 |
|
|
|
52 |
|
|
/*============================ External define ================================*/ |
53 |
|
|
|
54 |
|
|
/*============================ Global define ================================*/ |
55 |
|
|
|
56 |
|
|
|
57 |
|
|
DAQ_DECLBUF(TRK_TempBuf,TRK_MAXTEMPBUFFER); |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
/*============================== global types ==============================*/ |
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
/*=========================== Structure define ==============================*/ |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
/*============================ Enumerate define =============================*/ |
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
status_code TRK_Driver_Init() |
74 |
|
|
{ |
75 |
|
|
DAQ_BUFFER_INIT(TRK_TempBuf); |
76 |
|
|
return CM_RC_SUCCESSFUL; |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
/*****************************************************************************/ |
82 |
|
|
/* |
83 |
|
|
* TRK_Format_Cmd |
84 |
|
|
* |
85 |
|
|
* format the command for the FE when there is no data block to write |
86 |
|
|
* |
87 |
|
|
* Input parameters: |
88 |
|
|
* periph_no = peripheral number |
89 |
|
|
* command_no = command number |
90 |
|
|
* febuf = pointer to the buffer to fill |
91 |
|
|
* |
92 |
|
|
* Output parameters: status_code |
93 |
|
|
* |
94 |
|
|
*/ |
95 |
|
|
/*****************************************************************************/ |
96 |
|
|
|
97 |
|
|
status_code TRK_Format_Cmd(DAQ_CMD_BUF *febuf,BYTE periph_no, BYTE command_no) |
98 |
|
|
{ |
99 |
|
|
febuf->buf[0] = 0; // comm. length MSB |
100 |
|
|
febuf->buf[1] = 2; // comm. length LSB |
101 |
|
|
febuf->buf[2] = command_no | (periph_no << 4); // command id |
102 |
|
|
|
103 |
|
|
febuf->buf[3]=CM_Compute_CRC8_8(0,febuf->buf,3); // intermediate crc |
104 |
|
|
|
105 |
|
|
febuf->buf[4] = febuf->buf[3]; // final crc |
106 |
|
|
febuf->len = 5; |
107 |
|
|
|
108 |
|
|
return CM_RC_SUCCESSFUL; |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
/*****************************************************************************/ |
112 |
|
|
/* |
113 |
|
|
* TRK_Format_CmdWriteBlock |
114 |
|
|
* |
115 |
|
|
* format the command for the FE when there is a data block to write |
116 |
|
|
* |
117 |
|
|
* Input parameters: |
118 |
|
|
* periph_no = peripheral number |
119 |
|
|
* command_no = command number |
120 |
|
|
* data_block = pointer to the buffer to write |
121 |
|
|
* data_length = size of the data block |
122 |
|
|
* febuf = pointer to the buffer to fill |
123 |
|
|
* |
124 |
|
|
* Output parameters: status_code |
125 |
|
|
* |
126 |
|
|
*/ |
127 |
|
|
/*****************************************************************************/ |
128 |
|
|
|
129 |
|
|
status_code TRK_Format_CmdWriteBlock(DAQ_CMD_BUF *febuf,BYTE periph_no,BYTE command_no,DAQ_CMD_BUF *data_block) |
130 |
|
|
{ |
131 |
|
|
UINT16 len; |
132 |
|
|
|
133 |
|
|
len = data_block->len; |
134 |
|
|
|
135 |
|
|
febuf->buf[0] = CM_HI_UINT16(2+len); // comm. length MSB |
136 |
|
|
febuf->buf[1] = CM_LO_UINT16(2+len); // comm. length LSB |
137 |
|
|
febuf->buf[2] = command_no | (periph_no << 4); // command id |
138 |
|
|
|
139 |
|
|
febuf->buf[3]=CM_Compute_CRC8_8(0,febuf->buf,3); // intermediate crc |
140 |
|
|
memcpy(&febuf->buf[4],data_block->buf,len); // fill data block |
141 |
|
|
febuf->buf[4+len]=CM_Compute_CRC8_8(febuf->buf[3],data_block->buf,len); // final crc |
142 |
|
|
febuf->len = 5+len; |
143 |
|
|
|
144 |
|
|
return CM_RC_SUCCESSFUL; |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
/*****************************************************************************/ |
148 |
|
|
/* |
149 |
|
|
* TRK_Format_DataBlock |
150 |
|
|
* |
151 |
|
|
* format a data block to send to a dsp |
152 |
|
|
* |
153 |
|
|
* Input parameters: |
154 |
|
|
* block = pointer to the formatted block |
155 |
|
|
* type = DATA_MEMORY or PROGRAM_MEMORY |
156 |
|
|
* ovlay = DM or PM overlay |
157 |
|
|
* address = starting address on dsp |
158 |
|
|
* data = pointer to actual data or program to store |
159 |
|
|
* data_len = length of data |
160 |
|
|
* |
161 |
|
|
* Output parameters: status_code |
162 |
|
|
* |
163 |
|
|
*/ |
164 |
|
|
/*****************************************************************************/ |
165 |
|
|
|
166 |
|
|
|
167 |
|
|
status_code TRK_Format_DataBlock(DAQ_CMD_BUF *block,BYTE type,BYTE ovlay,UINT16 address,BYTE *data,UINT32 data_len) |
168 |
|
|
{ |
169 |
|
|
BYTE dm; |
170 |
|
|
|
171 |
|
|
dm = (type << 6); |
172 |
|
|
|
173 |
|
|
block->buf[0] = dm ? (ovlay << 4) : ovlay; |
174 |
|
|
block->buf[1] = dm | (BYTE) ((address & 0x3f00) >> 8); |
175 |
|
|
block->buf[2] = (BYTE) address & 0x00ff; |
176 |
|
|
memcpy(&block->buf[3],data,data_len); |
177 |
|
|
block->len = 3 + data_len; |
178 |
|
|
|
179 |
|
|
return CM_RC_SUCCESSFUL; |
180 |
|
|
} |
181 |
|
|
|
182 |
|
|
|
183 |
|
|
/*****************************************************************************/ |
184 |
|
|
/* |
185 |
|
|
* TRK_Format_ResetDSP |
186 |
|
|
* |
187 |
|
|
* format buffer to send a reset to periph_no DSP (non read cmd) |
188 |
|
|
* |
189 |
|
|
* Input parameters: |
190 |
|
|
* periph_no = number of dsp |
191 |
|
|
* link = tracker link |
192 |
|
|
* buffer = pointer to the buffer to fill |
193 |
|
|
* |
194 |
|
|
* Output parameters: status_code |
195 |
|
|
* |
196 |
|
|
*/ |
197 |
|
|
/*****************************************************************************/ |
198 |
|
|
|
199 |
|
|
status_code TRK_Format_ResetDSP(DAQ_CMD_BUF *buffer,BYTE periph_no,DAQ_FE link) |
200 |
|
|
{ |
201 |
|
|
status_code status; |
202 |
|
|
|
203 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
204 |
|
|
{ |
205 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
206 |
|
|
|
207 |
|
|
TRK_Format_Cmd(&TRK_TempBuf,periph_no,RESET_DSP); |
208 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
209 |
|
|
} |
210 |
|
|
else |
211 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
212 |
|
|
|
213 |
|
|
return(status); |
214 |
|
|
} |
215 |
|
|
|
216 |
|
|
/*****************************************************************************/ |
217 |
|
|
/* |
218 |
|
|
* TRK_Format_WriteDSP |
219 |
|
|
* |
220 |
|
|
* format buffer to send a write request to periph_no DSP (non read cmd) |
221 |
|
|
* |
222 |
|
|
* Input parameters: |
223 |
|
|
* periph_no = number of dsp |
224 |
|
|
* link = tracker link |
225 |
|
|
* data_block = pointer to the buffer to fill (see TRK_Format_DataBlock) |
226 |
|
|
* buffer = pointer to formatted output buffer |
227 |
|
|
* |
228 |
|
|
* Output parameters: status_code |
229 |
|
|
* |
230 |
|
|
*/ |
231 |
|
|
/*****************************************************************************/ |
232 |
|
|
|
233 |
|
|
status_code TRK_Format_WriteDSP(DAQ_CMD_BUF *buffer,BYTE periph_no,DAQ_FE link, DAQ_CMD_BUF *data_block) |
234 |
|
|
{ |
235 |
|
|
status_code status; |
236 |
|
|
|
237 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
238 |
|
|
{ |
239 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
240 |
|
|
|
241 |
|
|
TRK_Format_CmdWriteBlock(&TRK_TempBuf,periph_no,WRITE_DSP,data_block); |
242 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
243 |
|
|
} |
244 |
|
|
else |
245 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
246 |
|
|
|
247 |
|
|
return(status); |
248 |
|
|
} |
249 |
|
|
|
250 |
|
|
/*****************************************************************************/ |
251 |
|
|
/* |
252 |
|
|
* TRK_Format_LoadPMDSP |
253 |
|
|
* |
254 |
|
|
* format buffer to send a load PM request to periph_no DSP (non read cmd) |
255 |
|
|
* |
256 |
|
|
* Input parameters: |
257 |
|
|
* periph_no = number of dsp |
258 |
|
|
* link = tracker link |
259 |
|
|
* buffer = pointer to formatted output buffer |
260 |
|
|
* |
261 |
|
|
* Output parameters: status_code |
262 |
|
|
* |
263 |
|
|
*/ |
264 |
|
|
/*****************************************************************************/ |
265 |
|
|
|
266 |
|
|
status_code TRK_Format_LoadPMDSP(DAQ_CMD_BUF *buffer,BYTE periph_no,DAQ_FE link) |
267 |
|
|
{ |
268 |
|
|
status_code status; |
269 |
|
|
|
270 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
271 |
|
|
{ |
272 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
273 |
|
|
|
274 |
|
|
TRK_Format_Cmd(&TRK_TempBuf,periph_no,LOAD_DSP_PRG_BLOCK); |
275 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
276 |
|
|
} |
277 |
|
|
else |
278 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
279 |
|
|
|
280 |
|
|
return(status); |
281 |
|
|
} |
282 |
|
|
|
283 |
|
|
/*****************************************************************************/ |
284 |
|
|
/* |
285 |
|
|
* TRK_Format_LoadWriteOnCR |
286 |
|
|
* |
287 |
|
|
* format buffer to send a write on CR command (non read cmd) |
288 |
|
|
* |
289 |
|
|
* Input parameters: |
290 |
|
|
* link = tracker link |
291 |
|
|
* mask = CR mask to set |
292 |
|
|
* buffer = pointer to formatted output buffer |
293 |
|
|
* |
294 |
|
|
* Output parameters: status_code |
295 |
|
|
* |
296 |
|
|
*/ |
297 |
|
|
/*****************************************************************************/ |
298 |
|
|
|
299 |
|
|
status_code TRK_Format_WriteOnCR(DAQ_CMD_BUF *buffer,DAQ_FE link,BYTE mask) |
300 |
|
|
{ |
301 |
|
|
status_code status; |
302 |
|
|
DAQ_DECL_LOCAL_BUF(Temp,1); |
303 |
|
|
|
304 |
|
|
DAQ_Format_CMD_Empty(&Temp); |
305 |
|
|
|
306 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
307 |
|
|
{ |
308 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
309 |
|
|
|
310 |
|
|
*Temp.buf = mask; |
311 |
|
|
Temp.len = 1; |
312 |
|
|
|
313 |
|
|
TRK_Format_CmdWriteBlock(&TRK_TempBuf,OTHER_COMMAND,WRITE_CR,&Temp); |
314 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
315 |
|
|
} |
316 |
|
|
else |
317 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
318 |
|
|
|
319 |
|
|
return(status); |
320 |
|
|
} |
321 |
|
|
|
322 |
|
|
/*****************************************************************************/ |
323 |
|
|
/* |
324 |
|
|
* TRK_Format_TurnOnFlash |
325 |
|
|
* |
326 |
|
|
* format buffer to send a turn-on flash command (non read cmd) |
327 |
|
|
* |
328 |
|
|
* Input parameters: |
329 |
|
|
* link = tracker link |
330 |
|
|
* buffer = pointer to formatted output buffer |
331 |
|
|
* |
332 |
|
|
* Output parameters: status_code |
333 |
|
|
* |
334 |
|
|
*/ |
335 |
|
|
/*****************************************************************************/ |
336 |
|
|
|
337 |
|
|
status_code TRK_Format_TurnOnFlash(DAQ_CMD_BUF *buffer,DAQ_FE link) |
338 |
|
|
{ |
339 |
|
|
status_code status; |
340 |
|
|
|
341 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
342 |
|
|
{ |
343 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
344 |
|
|
|
345 |
|
|
TRK_Format_Cmd(&TRK_TempBuf,OTHER_COMMAND,TURN_ON_FLASH); |
346 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
347 |
|
|
} |
348 |
|
|
else |
349 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
350 |
|
|
|
351 |
|
|
return(status); |
352 |
|
|
} |
353 |
|
|
|
354 |
|
|
/*****************************************************************************/ |
355 |
|
|
/* |
356 |
|
|
* TRK_Format_ShutDownFlash |
357 |
|
|
* |
358 |
|
|
* format buffer to send a shutdown flash command (non read cmd) |
359 |
|
|
* |
360 |
|
|
* Input parameters: |
361 |
|
|
* link = tracker link |
362 |
|
|
* buffer = pointer to formatted output buffer |
363 |
|
|
* |
364 |
|
|
* Output parameters: status_code |
365 |
|
|
* |
366 |
|
|
*/ |
367 |
|
|
/*****************************************************************************/ |
368 |
|
|
|
369 |
|
|
status_code TRK_Format_ShutDownFlash(DAQ_CMD_BUF *buffer,DAQ_FE link) |
370 |
|
|
{ |
371 |
|
|
status_code status; |
372 |
|
|
|
373 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
374 |
|
|
{ |
375 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
376 |
|
|
|
377 |
|
|
TRK_Format_Cmd(&TRK_TempBuf,OTHER_COMMAND,SHUTDOWN_FLASH); |
378 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
379 |
|
|
} |
380 |
|
|
else |
381 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
382 |
|
|
|
383 |
|
|
return(status); |
384 |
|
|
} |
385 |
|
|
|
386 |
|
|
/*****************************************************************************/ |
387 |
|
|
/* |
388 |
|
|
* TRK_Format_GeneralReset |
389 |
|
|
* |
390 |
|
|
* format buffer to send a general reset command (non read cmd) |
391 |
|
|
* |
392 |
|
|
* Input parameters: |
393 |
|
|
* link = tracker link |
394 |
|
|
* buffer = pointer to formatted output buffer |
395 |
|
|
* |
396 |
|
|
* Output parameters: status_code |
397 |
|
|
* |
398 |
|
|
*/ |
399 |
|
|
/*****************************************************************************/ |
400 |
|
|
|
401 |
|
|
status_code TRK_Format_GeneralReset(DAQ_CMD_BUF *buffer,DAQ_FE link) |
402 |
|
|
{ |
403 |
|
|
status_code status; |
404 |
|
|
|
405 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
406 |
|
|
{ |
407 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
408 |
|
|
|
409 |
|
|
TRK_Format_Cmd(&TRK_TempBuf,OTHER_COMMAND,GENERAL_RESET); |
410 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
411 |
|
|
} |
412 |
|
|
else |
413 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
414 |
|
|
|
415 |
|
|
return(status); |
416 |
|
|
} |
417 |
|
|
|
418 |
|
|
/*****************************************************************************/ |
419 |
|
|
/* |
420 |
|
|
* TRK_Format_SetFlashMemAddress |
421 |
|
|
* |
422 |
|
|
* format buffer to send a set flash memory address command (non read cmd) |
423 |
|
|
* |
424 |
|
|
* Input parameters: |
425 |
|
|
* link = tracker link |
426 |
|
|
* address = address to store |
427 |
|
|
* buffer = pointer to formatted output buffer |
428 |
|
|
* |
429 |
|
|
* Output parameters: status_code |
430 |
|
|
* |
431 |
|
|
*/ |
432 |
|
|
/*****************************************************************************/ |
433 |
|
|
|
434 |
|
|
status_code TRK_Format_SetFlashMemAddress(DAQ_CMD_BUF *buffer,DAQ_FE link,UINT32 address) |
435 |
|
|
{ |
436 |
|
|
status_code status; |
437 |
|
|
DAQ_DECL_LOCAL_BUF(Temp,4); |
438 |
|
|
|
439 |
|
|
DAQ_Format_CMD_Empty(&Temp); |
440 |
|
|
|
441 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
442 |
|
|
{ |
443 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
444 |
|
|
|
445 |
|
|
Temp.buf[0] = FLASH_CONTROL_SET_ADDR; |
446 |
|
|
Temp.buf[1] = (BYTE)(address & 0xff); |
447 |
|
|
Temp.buf[2] = (BYTE)((address & 0xff00) >> 8); |
448 |
|
|
Temp.buf[3] = (BYTE)((address & 0xf0000) >> 16); |
449 |
|
|
Temp.len = 4; |
450 |
|
|
|
451 |
|
|
TRK_Format_CmdWriteBlock(&TRK_TempBuf,OTHER_COMMAND,FLASH_CONTROL,&Temp); |
452 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
453 |
|
|
} |
454 |
|
|
else |
455 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
456 |
|
|
|
457 |
|
|
return(status); |
458 |
|
|
} |
459 |
|
|
|
460 |
|
|
/*****************************************************************************/ |
461 |
|
|
/* |
462 |
|
|
* TRK_Format_WriteSingleByte |
463 |
|
|
* |
464 |
|
|
* format buffer to send a set flash memory address command (non read cmd) |
465 |
|
|
* |
466 |
|
|
* Input parameters: |
467 |
|
|
* link = tracker link |
468 |
|
|
* towrite = byte to write |
469 |
|
|
* buffer = pointer to formatted output buffer |
470 |
|
|
* |
471 |
|
|
* Output parameters: status_code |
472 |
|
|
* |
473 |
|
|
*/ |
474 |
|
|
/*****************************************************************************/ |
475 |
|
|
|
476 |
|
|
status_code TRK_Format_WriteSingleByte(DAQ_CMD_BUF *buffer,DAQ_FE link,BYTE towrite) |
477 |
|
|
{ |
478 |
|
|
status_code status; |
479 |
|
|
DAQ_DECL_LOCAL_BUF(Temp,2); |
480 |
|
|
|
481 |
|
|
DAQ_Format_CMD_Empty(&Temp); |
482 |
|
|
|
483 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
484 |
|
|
{ |
485 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
486 |
|
|
|
487 |
|
|
Temp.buf[0] = FLASH_CONTROL_WRITE_BYTE; |
488 |
|
|
Temp.buf[1] = towrite; |
489 |
|
|
Temp.len = 2; |
490 |
|
|
|
491 |
|
|
TRK_Format_CmdWriteBlock(&TRK_TempBuf,OTHER_COMMAND,FLASH_CONTROL,&Temp); |
492 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
493 |
|
|
} |
494 |
|
|
else |
495 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
496 |
|
|
|
497 |
|
|
return(status); |
498 |
|
|
} |
499 |
|
|
|
500 |
|
|
|
501 |
|
|
/*****************************************************************************/ |
502 |
|
|
/* |
503 |
|
|
* TRK_Format_WriteEndBlock |
504 |
|
|
* |
505 |
|
|
* format buffer to send a set flash memory address command (non read cmd) |
506 |
|
|
* |
507 |
|
|
* Input parameters: |
508 |
|
|
* link = tracker link |
509 |
|
|
* buffer = pointer to formatted output buffer |
510 |
|
|
* |
511 |
|
|
* Output parameters: status_code |
512 |
|
|
* |
513 |
|
|
*/ |
514 |
|
|
/*****************************************************************************/ |
515 |
|
|
|
516 |
|
|
status_code TRK_Format_WriteEndBlock(DAQ_CMD_BUF *buffer,DAQ_FE link) |
517 |
|
|
{ |
518 |
|
|
status_code status; |
519 |
|
|
DAQ_DECL_LOCAL_BUF(Temp,1); |
520 |
|
|
|
521 |
|
|
DAQ_Format_CMD_Empty(&Temp); |
522 |
|
|
|
523 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
524 |
|
|
{ |
525 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
526 |
|
|
|
527 |
|
|
Temp.buf[0] = FLASH_CONTROL_WRITE_END_BLOCK; |
528 |
|
|
Temp.len = 1; |
529 |
|
|
|
530 |
|
|
TRK_Format_CmdWriteBlock(&TRK_TempBuf,OTHER_COMMAND,FLASH_CONTROL,&Temp); |
531 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
532 |
|
|
} |
533 |
|
|
else |
534 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
535 |
|
|
|
536 |
|
|
return(status); |
537 |
|
|
} |
538 |
|
|
|
539 |
|
|
/*****************************************************************************/ |
540 |
|
|
/* |
541 |
|
|
* TRK_Format_EraseFlashSector |
542 |
|
|
* |
543 |
|
|
* format buffer to send a set flash memory address command (non read cmd) |
544 |
|
|
* |
545 |
|
|
* Input parameters: |
546 |
|
|
* link = tracker link |
547 |
|
|
* buffer = pointer to formatted output buffer |
548 |
|
|
* |
549 |
|
|
* Output parameters: status_code |
550 |
|
|
* |
551 |
|
|
*/ |
552 |
|
|
/*****************************************************************************/ |
553 |
|
|
|
554 |
|
|
status_code TRK_Format_EraseFlashSector(DAQ_CMD_BUF *buffer,DAQ_FE link,BYTE sector) |
555 |
|
|
{ |
556 |
|
|
status_code status; |
557 |
|
|
DAQ_DECL_LOCAL_BUF(Temp,2); |
558 |
|
|
|
559 |
|
|
DAQ_Format_CMD_Empty(&Temp); |
560 |
|
|
|
561 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
562 |
|
|
{ |
563 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
564 |
|
|
|
565 |
|
|
Temp.buf[0] = FLASH_CONTROL_ERASE_SECTOR; |
566 |
|
|
Temp.buf[1] = sector; |
567 |
|
|
Temp.len = 2; |
568 |
|
|
|
569 |
|
|
TRK_Format_CmdWriteBlock(&TRK_TempBuf,OTHER_COMMAND,FLASH_CONTROL,&Temp); |
570 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
571 |
|
|
} |
572 |
|
|
else |
573 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
574 |
|
|
|
575 |
|
|
return(status); |
576 |
|
|
} |
577 |
|
|
|
578 |
|
|
/*****************************************************************************/ |
579 |
|
|
/* |
580 |
|
|
* TRK_Format_ResetFlashController |
581 |
|
|
* |
582 |
|
|
* format buffer to send a general reset command (non read cmd) |
583 |
|
|
* |
584 |
|
|
* Input parameters: |
585 |
|
|
* link = tracker link |
586 |
|
|
* buffer = pointer to formatted output buffer |
587 |
|
|
* |
588 |
|
|
* Output parameters: status_code |
589 |
|
|
* |
590 |
|
|
*/ |
591 |
|
|
/*****************************************************************************/ |
592 |
|
|
|
593 |
|
|
status_code TRK_Format_ResetFlashController(DAQ_CMD_BUF *buffer,DAQ_FE link) |
594 |
|
|
{ |
595 |
|
|
status_code status; |
596 |
|
|
|
597 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
598 |
|
|
{ |
599 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
600 |
|
|
|
601 |
|
|
TRK_Format_Cmd(&TRK_TempBuf,OTHER_COMMAND,FLASH_RESET); |
602 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
603 |
|
|
} |
604 |
|
|
else |
605 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
606 |
|
|
|
607 |
|
|
return(status); |
608 |
|
|
} |
609 |
|
|
|
610 |
|
|
/*****************************************************************************/ |
611 |
|
|
/* |
612 |
|
|
* TRK_Format_ReadDSPDataBuffer |
613 |
|
|
* |
614 |
|
|
* format buffer to send a set flash memory address command (non read cmd) |
615 |
|
|
* |
616 |
|
|
* Input parameters: |
617 |
|
|
* periph_no = peripheral number |
618 |
|
|
* link = tracker link |
619 |
|
|
* buffer = pointer to formatted output buffer |
620 |
|
|
* ovlay = overlay |
621 |
|
|
* adress = starting address |
622 |
|
|
* maxnumber = max word number |
623 |
|
|
* |
624 |
|
|
* Output parameters: status_code |
625 |
|
|
* |
626 |
|
|
*/ |
627 |
|
|
/*****************************************************************************/ |
628 |
|
|
|
629 |
|
|
status_code TRK_Format_ReadDSPDataBuffer(DAQ_CMD_BUF *buffer,DAQ_FE link,BYTE periph_no,BYTE ovlay,UINT16 address, UINT16 maxnumber) |
630 |
|
|
{ |
631 |
|
|
status_code status; |
632 |
|
|
DAQ_DECL_LOCAL_BUF(Temp,5); |
633 |
|
|
|
634 |
|
|
DAQ_Format_CMD_Empty(&Temp); |
635 |
|
|
|
636 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
637 |
|
|
{ |
638 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
639 |
|
|
|
640 |
|
|
Temp.buf[0] = ovlay << 4; |
641 |
|
|
Temp.buf[1] = 64 | (CM_HI_UINT16(address) & 0x3f); |
642 |
|
|
Temp.buf[2] = CM_LO_UINT16(address); |
643 |
|
|
Temp.buf[3] = CM_HI_UINT16(maxnumber) & 0x7f; |
644 |
|
|
Temp.buf[4] = CM_LO_UINT16(maxnumber); |
645 |
|
|
Temp.len = 5; |
646 |
|
|
|
647 |
|
|
TRK_Format_CmdWriteBlock(&TRK_TempBuf,periph_no,READ_DSP_DATA,&Temp); |
648 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
649 |
|
|
} |
650 |
|
|
else |
651 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
652 |
|
|
|
653 |
|
|
return(status); |
654 |
|
|
} |
655 |
|
|
|
656 |
|
|
/*****************************************************************************/ |
657 |
|
|
/* |
658 |
|
|
* TRK_Format_ReadDSPMemoryBlock |
659 |
|
|
* |
660 |
|
|
* format buffer to send a set flash memory address command (non read cmd) |
661 |
|
|
* |
662 |
|
|
* Input parameters: |
663 |
|
|
* periph_no = peripheral number |
664 |
|
|
* link = tracker link |
665 |
|
|
* type = DATA_MEMORY or PROGRAM_MEMORY |
666 |
|
|
* ovlay = overlay |
667 |
|
|
* adress = starting address |
668 |
|
|
* wordnumber = number of words to read |
669 |
|
|
* buffer = pointer to formatted output buffer |
670 |
|
|
* |
671 |
|
|
* Output parameters: status_code |
672 |
|
|
* |
673 |
|
|
*/ |
674 |
|
|
/*****************************************************************************/ |
675 |
|
|
|
676 |
|
|
status_code TRK_Format_ReadDSPMemoryBlock(DAQ_CMD_BUF *buffer,DAQ_FE link,BYTE datatype,BYTE periph_no,BYTE ovlay,UINT16 address, UINT16 wordnumber) |
677 |
|
|
{ |
678 |
|
|
BYTE dm; |
679 |
|
|
status_code status; |
680 |
|
|
DAQ_DECL_LOCAL_BUF(Temp,5); |
681 |
|
|
|
682 |
|
|
dm = (datatype << 6); |
683 |
|
|
DAQ_Format_CMD_Empty(&Temp); |
684 |
|
|
|
685 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
686 |
|
|
{ |
687 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
688 |
|
|
|
689 |
|
|
Temp.buf[0] = dm ? (ovlay << 4) : ovlay; |
690 |
|
|
Temp.buf[1] = dm | (BYTE) ((address & 0x3f00) >> 8); |
691 |
|
|
Temp.buf[2] = CM_LO_UINT16(address); |
692 |
|
|
Temp.buf[3] = CM_HI_UINT16(wordnumber) & 0x7f; |
693 |
|
|
Temp.buf[4] = CM_LO_UINT16(wordnumber); |
694 |
|
|
Temp.len = 5; |
695 |
|
|
|
696 |
|
|
TRK_Format_CmdWriteBlock(&TRK_TempBuf,periph_no,READ_DSP_MEM_BLOCK,&Temp); |
697 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
698 |
|
|
} |
699 |
|
|
else |
700 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
701 |
|
|
|
702 |
|
|
return(status); |
703 |
|
|
} |
704 |
|
|
|
705 |
|
|
/*****************************************************************************/ |
706 |
|
|
/* |
707 |
|
|
* TRK_Format_ReadControlRegister |
708 |
|
|
* |
709 |
|
|
* format buffer to send a general reset command (non read cmd) |
710 |
|
|
* |
711 |
|
|
* Input parameters: |
712 |
|
|
* link = tracker link |
713 |
|
|
* buffer = pointer to formatted output buffer |
714 |
|
|
* |
715 |
|
|
* Output parameters: status_code |
716 |
|
|
* |
717 |
|
|
*/ |
718 |
|
|
/*****************************************************************************/ |
719 |
|
|
|
720 |
|
|
status_code TRK_Format_ReadControlRegister(DAQ_CMD_BUF *buffer,DAQ_FE link) |
721 |
|
|
{ |
722 |
|
|
status_code status; |
723 |
|
|
|
724 |
|
|
if ((link == DAQ_FE_TRK_1) || (link == DAQ_FE_TRK_2)) |
725 |
|
|
{ |
726 |
|
|
DAQ_Format_CMD_Empty(&TRK_TempBuf); |
727 |
|
|
|
728 |
|
|
TRK_Format_Cmd(&TRK_TempBuf,OTHER_COMMAND,READ_CR); |
729 |
|
|
status = DAQ_Format_Cmd2Fe(buffer,&TRK_TempBuf,link); |
730 |
|
|
} |
731 |
|
|
else |
732 |
|
|
status = CM_RC_BAD_IDAQ_LINK; |
733 |
|
|
|
734 |
|
|
return(status); |
735 |
|
|
} |