Rev 83 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 83 | Rev 93 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | return 0; |
44 | return 0; |
45 | } |
45 | } |
46 | 46 | ||
47 | int Pts_read(uint32_t addr, uint32_t *data ){ |
47 | int Pts_read(uint32_t addr, uint32_t *data ){ |
48 | VME_A32D32_R(ptaddr+addr,data); |
48 | VME_A32D32_R(ptaddr+addr,data); |
- | 49 | return 0; |
|
- | 50 | } |
|
- | 51 | ||
- | 52 | int Pts_Mread(uint32_t addr, uint32_t *data ){ |
|
- | 53 | VME_MRRST(); |
|
- | 54 | VME_MR(VME_A32, VME_D32,ptaddr+addr, data); |
|
- | 55 | VME_MREXEC(data); |
|
49 | return 0; |
56 | return 0; |
50 | } |
57 | } |
51 | 58 | ||
52 | 59 | ||
53 | int Pts_erase( int verbose ) { |
60 | int Pts_erase( int verbose ) { |
Line 212... | Line 219... | ||
212 | sprintf(str,"Example: %s --address 0x1000000 --verbose 1 --input pts_scaler.bit --load-bit 2\n", argv); |
219 | sprintf(str,"Example: %s --address 0x1000000 --verbose 1 --input pts_scaler.bit --load-bit 2\n", argv); |
213 | SetCtrlVal(p1,P1_RESPONSE,str); |
220 | SetCtrlVal(p1,P1_RESPONSE,str); |
214 | sprintf(str,"Example: %s --address 0x1000004 --write-csr 0x7600\n", argv);SetCtrlVal(p1,P1_RESPONSE,str); |
221 | sprintf(str,"Example: %s --address 0x1000004 --write-csr 0x7600\n", argv);SetCtrlVal(p1,P1_RESPONSE,str); |
215 | } |
222 | } |
216 | 223 | ||
217 | - | ||
218 | 224 | ||
219 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
- | |
220 | LPSTR lpszCmdLine, int nCmdShow) |
- | |
221 | { |
- | |
222 | char saddr[255]; |
- | |
223 | if (InitCVIRTE (hInstance, 0, 0) == 0) |
- | |
224 | return -1; /* out of memory */ |
- | |
225 | if ((p1 = LoadPanel (0, "PtsModule_CVI.uir", P1)) < 0) |
- | |
226 | return -1; |
- | |
227 | DisplayPanel (p1); |
- | |
228 | - | ||
229 | GetCtrlVal(p1,P1_VERBOSE,&verbose); |
- | |
230 | GetCtrlVal(p1,P1_ADDRESS,saddr); |
- | |
231 | ptaddr = strtoul (saddr,NULL,0); |
- | |
232 | RunUserInterface (); |
- | |
233 | DiscardPanel (p1); |
- | |
234 | VME_STOP(); |
- | |
235 | return 0; |
- | |
236 | } |
- | |
237 | - | ||
238 | int CVICALLBACK Reset (int panel, int control, int event, |
225 | int CVICALLBACK Reset (int panel, int control, int event, |
239 | void *callbackData, int eventData1, int eventData2) |
226 | void *callbackData, int eventData1, int eventData2) |
240 | { |
227 | { |
241 | switch (event) |
228 | switch (event) |
242 | { |
229 | { |
243 | case EVENT_COMMIT: |
230 | case EVENT_COMMIT: |
244 | Pts_reset(verbose); |
231 | Pts_reset(verbose); |
245 | break; |
232 | break; |
246 | } |
233 | } |
247 | return 0; |
234 | return 0; |
248 | } |
235 | } |
249 | 236 | ||
250 | int CVICALLBACK Erase (int panel, int control, int event, |
237 | int CVICALLBACK Erase (int panel, int control, int event, |
251 | void *callbackData, int eventData1, int eventData2) |
238 | void *callbackData, int eventData1, int eventData2) |
252 | { |
239 | { |
253 | switch (event) |
240 | switch (event) |
254 | { |
241 | { |
255 | case EVENT_COMMIT: |
242 | case EVENT_COMMIT: |
256 | Pts_erase(verbose); |
243 | Pts_erase(verbose); |
257 | break; |
244 | break; |
258 | } |
245 | } |
259 | return 0; |
246 | return 0; |
Line 270... | Line 257... | ||
270 | GetCtrlVal(p1,P1_FIRMWARE,filename); |
257 | GetCtrlVal(p1,P1_FIRMWARE,filename); |
271 | GetCtrlVal(p1,P1_MODE,&mode); |
258 | GetCtrlVal(p1,P1_MODE,&mode); |
272 | if(VME_CONNECTED() >=0 ) { |
259 | if(VME_CONNECTED() >=0 ) { |
273 | Pts_configure_bit( filename, mode, verbose ); |
260 | Pts_configure_bit( filename, mode, verbose ); |
274 | } else { |
261 | } else { |
275 | MessagePopup ("Warning", "Connect VME!!"); |
262 | MessagePopup ("Warning", "Connect VME!!"); |
276 | } |
263 | } |
277 | break; |
264 | break; |
278 | } |
265 | } |
279 | return 0; |
266 | return 0; |
280 | } |
267 | } |
Line 381... | Line 368... | ||
381 | 368 | ||
382 | int CVICALLBACK Address (int panel, int control, int event, |
369 | int CVICALLBACK Address (int panel, int control, int event, |
383 | void *callbackData, int eventData1, int eventData2) |
370 | void *callbackData, int eventData1, int eventData2) |
384 | { |
371 | { |
385 | char saddr[100]; |
372 | char saddr[100]; |
386 | switch (event) |
373 | switch (event) |
387 | { |
374 | { |
388 | case EVENT_COMMIT: |
375 | case EVENT_COMMIT: |
389 | GetCtrlVal(p1,P1_ADDRESS,saddr); |
376 | GetCtrlVal(p1,P1_ADDRESS,saddr); |
390 | ptaddr = strtoul (saddr,NULL,0); |
377 | ptaddr = strtoul (saddr,NULL,0); |
391 | break; |
378 | break; |
392 | } |
379 | } |
393 | return 0; |
380 | return 0; |
394 | } |
381 | } |
395 | 382 | ||
396 | int CVICALLBACK Exit (int panel, int control, int event, |
383 | int CVICALLBACK Exit (int panel, int control, int event, |
397 | void *callbackData, int eventData1, int eventData2) |
384 | void *callbackData, int eventData1, int eventData2) |
398 | { |
385 | { |
399 | switch (event) |
386 | switch (event) |
400 | { |
387 | { |
401 | case EVENT_COMMIT: |
388 | case EVENT_COMMIT: |
402 | QuitUserInterface(0); |
389 | QuitUserInterface(0); |
403 | break; |
390 | break; |
404 | } |
391 | } |
405 | return 0; |
392 | return 0; |
406 | } |
393 | } |
Line 408... | Line 395... | ||
408 | int CVICALLBACK FSelect (int panel, int control, int event, |
395 | int CVICALLBACK FSelect (int panel, int control, int event, |
409 | void *callbackData, int eventData1, int eventData2) |
396 | void *callbackData, int eventData1, int eventData2) |
410 | { |
397 | { |
411 | int status; |
398 | int status; |
412 | char pathName[MAX_PATHNAME_LEN]; |
399 | char pathName[MAX_PATHNAME_LEN]; |
413 | switch (event) |
400 | switch (event) |
414 | { |
401 | { |
415 | case EVENT_COMMIT: |
402 | case EVENT_COMMIT: |
416 | status = FileSelectPopup ("", "*.bit", "*.bit", "Select Firmware file", |
403 | status = FileSelectPopup ("", "*.bit", "*.bit", "Select Firmware file", |
417 | VAL_SELECT_BUTTON, 0, 0, 1, 0, pathName); |
404 | VAL_SELECT_BUTTON, 0, 0, 1, 0, pathName); |
418 | if (status>0) SetCtrlVal(p1,P1_FIRMWARE,pathName); |
405 | if (status>0) SetCtrlVal(p1,P1_FIRMWARE,pathName); |
419 | break; |
406 | break; |
420 | } |
407 | } |
421 | return 0; |
408 | return 0; |
422 | } |
409 | } |
423 | 410 | ||
424 | int CVICALLBACK LedCB (int panel, int control, int event, |
411 | int CVICALLBACK LedCB (int panel, int control, int event, |
425 | void *callbackData, int eventData1, int eventData2) |
412 | void *callbackData, int eventData1, int eventData2) |
426 | { |
413 | { |
427 | switch (event) |
414 | switch (event) |
428 | { |
415 | { |
429 | int value=0; |
416 | int value=0; |
430 | case EVENT_COMMIT: |
417 | case EVENT_COMMIT: |
- | 418 | if(VME_CONNECTED() <0 ) { |
|
- | 419 | MessagePopup ("Warning", "Connect VME!!"); |
|
- | 420 | return 0; |
|
- | 421 | } |
|
431 | GetCtrlVal(p1,P1_LED,&value); |
422 | GetCtrlVal(p1,P1_LED,&value); |
432 | 423 | ||
433 | Pts_write( 0 , value+1 ); |
424 | Pts_write( 0 , value+1 ); |
434 | 425 | ||
435 | break; |
426 | break; |
Line 437... | Line 428... | ||
437 | return 0; |
428 | return 0; |
438 | } |
429 | } |
439 | 430 | ||
440 | int CVICALLBACK Execute (int panel, int control, int event, |
431 | int CVICALLBACK Execute (int panel, int control, int event, |
441 | void *callbackData, int eventData1, int eventData2) |
432 | void *callbackData, int eventData1, int eventData2) |
442 | { |
433 | { |
443 | switch (event) |
434 | switch (event) |
444 | { |
435 | { |
445 | case EVENT_COMMIT:{ |
436 | case EVENT_COMMIT:{ |
446 | int n,i,nb; |
437 | int n,i,nb; |
447 | char buf[400]; |
438 | char buf[400]; |
448 | unsigned int data, addr; |
439 | unsigned int data, addr; |
449 | char sdata[255], saddr[255], rw[255]; |
440 | char sdata[255], saddr[255], rw[255]; |
- | 441 | if(VME_CONNECTED() <0 ) { |
|
- | 442 | MessagePopup ("Warning", "Connect VME!!"); |
|
- | 443 | return 0; |
|
- | 444 | } |
|
450 | GetNumTextBoxLines(panel, P1_COMMANDS,&n); |
445 | GetNumTextBoxLines(panel, P1_COMMANDS,&n); |
451 | for (i=0;i<n;i++){ |
446 | for (i=0;i<n;i++){ |
452 | GetTextBoxLine(panel, P1_COMMANDS, i, buf); |
447 | GetTextBoxLine(panel, P1_COMMANDS, i, buf); |
453 | nb = sscanf(buf,"%s%s%s",rw, saddr,sdata); |
448 | nb = sscanf(buf,"%s%s%s",rw, saddr,sdata); |
454 | addr = strtoul (saddr,NULL,0); |
449 | addr = strtoul (saddr,NULL,0); |
Line 458... | Line 453... | ||
458 | if( verbose ) { |
453 | if( verbose ) { |
459 | sprintf(str, "VME Write addr 0x%0x+0x%0x data 0x%0x\n", ptaddr, addr, data ); |
454 | sprintf(str, "VME Write addr 0x%0x+0x%0x data 0x%0x\n", ptaddr, addr, data ); |
460 | SetCtrlVal (p1, P1_RESPONSE, str); |
455 | SetCtrlVal (p1, P1_RESPONSE, str); |
461 | } |
456 | } |
462 | } else { |
457 | } else { |
463 |
|
458 | Pts_Mread( addr , &data ); |
464 | if( verbose ) { |
459 | if( verbose ) { |
465 | sprintf(str, "VME Read addr 0x%0x+0x%0x response 0x%0x\n", ptaddr, addr, data); |
460 | sprintf(str, "VME Read addr 0x%0x+0x%0x response 0x%0x\n", ptaddr, addr, data); |
466 | SetCtrlVal (p1, P1_RESPONSE, str); |
461 | SetCtrlVal (p1, P1_RESPONSE, str); |
467 | } |
462 | } |
468 | } |
463 | } |
469 | } |
464 | } |
470 | break; |
465 | break; |
471 | } |
466 | } |
472 | } |
467 | } |
473 | return 0; |
468 | return 0; |
474 | } |
469 | } |
475 | 470 | ||
476 | int CVICALLBACK Connect (int panel, int control, int event, |
471 | int CVICALLBACK Connect (int panel, int control, int event, |
477 | void *callbackData, int eventData1, int eventData2) |
472 | void *callbackData, int eventData1, int eventData2) |
Line 481... | Line 476... | ||
481 | { |
476 | { |
482 | 477 | ||
483 | case EVENT_COMMIT: |
478 | case EVENT_COMMIT: |
484 | GetCtrlVal (p1, P1_VMEINTERFACE, &interface); |
479 | GetCtrlVal (p1, P1_VMEINTERFACE, &interface); |
485 | VME_START(interface); |
480 | VME_START(interface); |
486 | break; |
481 | break; |
487 | } |
482 | } |
488 | return 0; |
483 | return 0; |
489 | } |
484 | } |
490 | 485 | ||
491 | int CVICALLBACK Disconnect (int panel, int control, int event, |
486 | int CVICALLBACK Disconnect (int panel, int control, int event, |
492 | void *callbackData, int eventData1, int eventData2) |
487 | void *callbackData, int eventData1, int eventData2) |
493 | { |
488 | { |
494 | switch (event) |
489 | switch (event) |
495 | { |
490 | { |
496 | case EVENT_COMMIT: |
491 | case EVENT_COMMIT: |
497 | VME_STOP(); |
492 | VME_STOP(); |
498 | break; |
493 | break; |
499 | } |
494 | } |
- | 495 | return 0; |
|
- | 496 | } |
|
- | 497 | ||
- | 498 | ||
- | 499 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
|
- | 500 | LPSTR lpszCmdLine, int nCmdShow) |
|
- | 501 | { |
|
- | 502 | char saddr[255]; |
|
- | 503 | if (InitCVIRTE (hInstance, 0, 0) == 0) |
|
- | 504 | return -1; /* out of memory */ |
|
- | 505 | if ((p1 = LoadPanel (0, "PtsModule_CVI.uir", P1)) < 0) |
|
- | 506 | return -1; |
|
- | 507 | DisplayPanel (p1); |
|
- | 508 | ||
- | 509 | GetCtrlVal(p1,P1_VERBOSE,&verbose); |
|
- | 510 | GetCtrlVal(p1,P1_ADDRESS,saddr); |
|
- | 511 | ptaddr = strtoul (saddr,NULL,0); |
|
- | 512 | RunUserInterface (); |
|
- | 513 | DiscardPanel (p1); |
|
- | 514 | VME_STOP(); |
|
500 | return 0; |
515 | return 0; |
501 | } |
516 | } |