1 /*
2    Copyright (C) 1999 T. Scott Dattalo
3 
4 This file is part of gpsim.
5 
6 gpsim is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10 
11 gpsim is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with gpsim; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20 
21 
22 #include <iostream>
23 #include <iomanip>
24 #include <string>
25 
26 #include "command.h"
27 #include "cmd_icd.h"
28 #include "../src/icd.h"
29 
30 cmd_icd c_icd;
31 
32 #define ICD_OPEN_CMD 1
33 
34 static cmd_options cmd_icd_options[] =
35 {
36   {"open",	ICD_OPEN_CMD,	OPT_TT_STRING},
37   {0,0,0}
38 };
39 
cmd_icd()40 cmd_icd::cmd_icd()
41   : command("icd",0)
42 {
43   brief_doc = string("ICD command.");
44 
45   long_doc = string ("\nicd [open <port>]\n\
46 \tThe open command is used to enable ICD mode and specify the serial\n\
47 \tport where the ICD is. (e.g. \"icd open /dev/ttyS0\").\n\
48 \tWithout options (and after the icd is enabled), it will print some\n\
49 \tinformation about the ICD.\n\
50 ");
51 
52   op = cmd_icd_options;
53 }
54 
55 #include <stdio.h>
56 
icd()57 void cmd_icd::icd()
58 {
59     if(icd_detected())
60     {
61         printf("ICD version \"%s\" was found.\n",icd_version());
62         printf("Target controller is %s.\n", icd_target());
63         printf("Vdd: %.1f\t",icd_vdd());
64         printf("Vpp: %.1f\n",icd_vpp());
65 	if(icd_has_debug_module())
66 		puts("Debug module is present");
67 	else
68 		puts("Debug moudle is NOT present.");
69     }
70     else
71     {
72         printf("ICD has not been opened (use the \"icd open\" command)\n");
73     }
74 }
75 
icd(cmd_options_str * cos)76 void cmd_icd::icd(cmd_options_str *cos)
77 {
78   switch(cos->co->value) {
79   case ICD_OPEN_CMD:
80 	cout << "ICD open " << cos->str << endl;
81 	icd_connect(cos->str);
82 	break;
83   default:
84     cout << " Invalid set option\n";
85   }
86 
87 }
88