C_test

C code posted by John
created at 03 Jun 03:55

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
int main(int Parm_Count, char *Parms[])
{
   int Quit = 0, i;
   dsp_struct dsp;
   char input_buffer[MAX_LINE_LENGTH];

   // Setup structure (to be saved to a file)
   memset(&dsp, 0, sizeof(dsp_struct));
   dsp.last_menu = 2;
   dsp.last_device = 0;       // control FPGA regs
   dsp.last_board = 0;        // master hub
   dsp.last_fpga = 0;
   strcpy(dsp.hostName, "192.168.3.3");
   strcpy(dsp.last_filename[0], "dsp_control.bit");
   
   for(i=1;i<5;i++) {
      strcpy(dsp.last_filename[i], "beamformer.bit"); }
   
   // Reset event gen stats
   memset(&eg, 0, sizeof(event_struct));

   // Ask about connection type
   printf("Connect using USB/Ethernet [E] :>");
   fgets_lc(input_buffer, MAX_LINE_LENGTH, stdin); 
   
   if (input_buffer[0] == 'u') {
      dsp.comms.type = TYPE_USB;
   } else {      
      dsp.comms.type = TYPE_ETHERNET; 

      // Ask about Eth connection name
   printf("Connect to which shelf? [%s] :>", dsp.hostName);
      fgets_lc(input_buffer, MAX_LINE_LENGTH, stdin);       
   if (input_buffer[0] != '\n') {
      input_buffer[strlen(input_buffer)-1] = 0;          // Strip out trailing newline
         strcpy(dsp.hostName, input_buffer); } }

   // Open the Card
   if (control_open(&dsp.comms, dsp.hostName) < 0) {
      printf("Ethernet connect failed\n");
      goto Exit; }

   if (control_read_register(&dsp.comms, MASTER_HUB_CARD, CONTROL_REGS, DSP_CTRL_SYS_GOODBEEF) != 0x900dbeef) {
      printf("Master hub card magic ERROR\n");
      goto Exit; }

   // Ask about startup (setup temp and voltage monitoring on the dsp and rtm)
   printf("Execute DSP hub card startup? [y] :>");
   fgets_lc(input_buffer, MAX_LINE_LENGTH, stdin);
   if (input_buffer[0] == 'y' || input_buffer[0] == '\n') {
      dsp_init(&dsp, MASTER_HUB_CARD); 
      printf("Startup sequence complete\n");
      while(!kbhit()); }
      
   //Main processing loop
   Quit = 0;
   do {
      //Display the initial menu    
      dsp.last_menu = displayMainMenu(&dsp);

      //Handle menu options
      switch(dsp.last_menu) {
         case 1:
            do_program_fpga(&dsp);
            break;
         case 2:
            do_view_dsp_card(&dsp);
            break;
         case 3:
            do_dsp_program(&dsp);
            break;
         case 8:
            do_set_DSPIP(&dsp);
            break;
         case 9:
            do_RTM_clkcond_setup(&dsp);
            break;
         case 10:
            do_program_spi(&dsp);
            break;
         case 11:
            do_capture_bat(&dsp);
            break;
         case 16:
            do_PatrnGenRAMInit(&dsp);
            break;
         case 17:
            do_crosspoint_ber_setup(&dsp);
            break;
         case 18:
            do_sandwich_test(&dsp);
            break;
         case 20:
            do_PatrnChkRAMInit(&dsp);
            break;
         case 21:
            do_interactive_debug(&dsp);
            break;
         case 22:                                     // Exit the test program
            Quit = 1;
            break;
         default:                                     // On invalid input generate an error
            printf("Selection Unhandled:%d\n", dsp.last_menu);}

   } while(Quit != 1);                                // Loop until a quit message is signaled by the user  

Exit:
   control_close(&dsp.comms);
   return 0;
}
3.39 KB in 4 ms with coderay