1746 |
kakl |
1 |
#include "main.h" |
|
|
2 |
|
|
|
3 |
#case |
|
|
4 |
|
|
|
5 |
#define S105A PIN_A0 |
|
|
6 |
#define R105AU PIN_A1 |
|
|
7 |
#define R105AD PIN_A2 |
|
|
8 |
#define S104A PIN_A3 |
|
|
9 |
#define R104AU PIN_A4 |
|
|
10 |
#define R104AD PIN_A5 |
|
|
11 |
#define R104BU PIN_A6 |
|
|
12 |
#define R104BD PIN_A7 |
|
|
13 |
|
|
|
14 |
#define S103A PIN_B0 |
|
|
15 |
#define R103AU PIN_B1 |
|
|
16 |
#define R103AD PIN_B2 |
|
|
17 |
#define S106A PIN_B3 |
|
|
18 |
#define S107A PIN_B4 |
|
|
19 |
#define S109A PIN_B5 |
|
|
20 |
|
|
|
21 |
//#define OS101 PIN_C0 |
|
|
22 |
//#define OS105B PIN_C1 |
|
|
23 |
//#define OS105C PIN_C2 |
|
|
24 |
//#define PIN_C3 31763 |
|
|
25 |
//#define PIN_C4 31764 |
|
|
26 |
//#define PIN_C5 31765 |
|
|
27 |
|
|
|
28 |
//#define PIN_C6 31766 //TX |
|
|
29 |
//#define PIN_C7 31767 //RX |
|
|
30 |
|
|
|
31 |
#define S101A PIN_D0 |
|
|
32 |
#define S105D PIN_D1 |
|
|
33 |
#define S102A PIN_D2 |
|
|
34 |
#define S110C PIN_D3 |
|
|
35 |
#define S108A PIN_D4 |
|
|
36 |
#define S201A PIN_D5 |
|
|
37 |
#define S110B PIN_D6 |
|
|
38 |
|
|
|
39 |
/* |
|
|
40 |
#define PIN_E0 31776 |
|
|
41 |
#define PIN_E1 31777 |
|
|
42 |
#define PIN_E2 31778 |
|
|
43 |
#define PIN_E3 31779 |
|
|
44 |
#define PIN_E4 31780 |
|
|
45 |
#define PIN_E5 31781 |
|
|
46 |
#define PIN_E6 31782 |
|
|
47 |
#define PIN_E7 31783 |
|
|
48 |
|
|
|
49 |
#define PIN_F0 31784 |
|
|
50 |
#define PIN_F1 31785 |
|
|
51 |
#define PIN_F2 31786 |
|
|
52 |
#define PIN_F3 31787 |
|
|
53 |
#define PIN_F4 31788 |
|
|
54 |
#define PIN_F5 31789 |
|
|
55 |
#define PIN_F6 31790 |
|
|
56 |
#define PIN_F7 31791 |
|
|
57 |
|
|
|
58 |
#define PIN_G0 31792 |
|
|
59 |
#define PIN_G1 31793 |
|
|
60 |
#define PIN_G2 31794 |
|
|
61 |
#define PIN_G3 31795 |
|
|
62 |
#define PIN_G4 31796 |
|
|
63 |
#define PIN_G5 31797 |
|
|
64 |
|
|
|
65 |
#define PIN_H0 31800 |
|
|
66 |
#define PIN_H1 31801 |
|
|
67 |
#define PIN_H2 31802 |
|
|
68 |
#define PIN_H3 31803 |
|
|
69 |
#define PIN_H4 31804 |
|
|
70 |
#define PIN_H5 31805 |
|
|
71 |
#define PIN_H6 31806 |
|
|
72 |
#define PIN_H7 31807 |
|
|
73 |
|
|
|
74 |
#define PIN_J0 31808 |
|
|
75 |
#define PIN_J1 31809 |
|
|
76 |
#define PIN_J2 31810 |
|
|
77 |
#define PIN_J3 31811 |
|
|
78 |
#define PIN_J4 31812 |
|
|
79 |
#define PIN_J5 31813 |
|
|
80 |
#define PIN_J6 31814 |
|
|
81 |
#define PIN_J7 31815 |
|
|
82 |
*/ |
|
|
83 |
|
|
|
84 |
#define LED1 PIN_J7 |
|
|
85 |
#define LED2 PIN_J6 |
|
|
86 |
|
|
|
87 |
#define ON(port) output_low(port); |
|
|
88 |
#define OFF(port) output_high(port); |
|
|
89 |
|
|
|
90 |
typedef enum {UP, DOWN, NOTHING} request; |
|
|
91 |
|
|
|
92 |
void main() |
|
|
93 |
{ |
|
|
94 |
char c; |
|
|
95 |
|
|
|
96 |
if(restart_cause()!= WDT_TIMEOUT) |
|
|
97 |
{ |
|
|
98 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
99 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
100 |
setup_psp(PSP_DISABLED); |
|
|
101 |
setup_spi(SPI_SS_DISABLED); |
|
|
102 |
setup_wdt(WDT_ON); |
|
|
103 |
setup_timer_0(RTCC_INTERNAL); |
|
|
104 |
setup_timer_1(T1_DISABLED); |
|
|
105 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
106 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
|
|
107 |
setup_ccp1(CCP_OFF); |
|
|
108 |
setup_comparator(NC_NC_NC_NC); |
|
|
109 |
setup_vref(FALSE); |
|
|
110 |
|
|
|
111 |
OFF(S105A); |
|
|
112 |
OFF(R105AU); |
|
|
113 |
OFF(R105AD); |
|
|
114 |
OFF(S104A); |
|
|
115 |
OFF(R104AU); |
|
|
116 |
OFF(R104AD); |
|
|
117 |
OFF(R104BU); |
|
|
118 |
OFF(R104BD); |
|
|
119 |
OFF(S103A); |
|
|
120 |
OFF(R103AU); |
|
|
121 |
OFF(R103AD); |
|
|
122 |
OFF(S106A); |
|
|
123 |
OFF(S107A); |
|
|
124 |
OFF(S109A); |
|
|
125 |
OFF(S101A); |
|
|
126 |
OFF(S105D); |
|
|
127 |
OFF(S102A); |
|
|
128 |
OFF(S110C); |
|
|
129 |
OFF(S108A); |
|
|
130 |
OFF(S201A); |
|
|
131 |
OFF(S110B); |
|
|
132 |
} |
|
|
133 |
|
|
|
134 |
while(TRUE) |
|
|
135 |
{ |
|
|
136 |
if(kbhit()) |
|
|
137 |
{ |
|
|
138 |
c=getc(); |
|
|
139 |
if(c=='S') |
|
|
140 |
{ |
|
|
141 |
getc(); |
|
|
142 |
switch(getc()) |
|
|
143 |
{ |
|
|
144 |
case '1': |
|
|
145 |
output_toggle(S101A); |
|
|
146 |
break; |
|
|
147 |
case '2': |
|
|
148 |
output_toggle(S102A); |
|
|
149 |
break; |
|
|
150 |
case '3': |
|
|
151 |
output_toggle(S103A); |
|
|
152 |
break; |
|
|
153 |
case '4': |
|
|
154 |
output_toggle(S104A); |
|
|
155 |
break; |
|
|
156 |
case '5': |
|
|
157 |
c=getc(); |
|
|
158 |
if(c=='A') {output_toggle(S105A);} |
|
|
159 |
if(c=='D') {output_toggle(S105D);} |
|
|
160 |
break; |
|
|
161 |
case '6': |
|
|
162 |
output_toggle(S106A); |
|
|
163 |
break; |
|
|
164 |
case '7': |
|
|
165 |
output_toggle(S107A); |
|
|
166 |
break; |
|
|
167 |
case '8': |
|
|
168 |
output_toggle(S108A); |
|
|
169 |
break; |
|
|
170 |
case '9': |
|
|
171 |
output_toggle(S109A); |
|
|
172 |
break; |
|
|
173 |
case 'a': |
|
|
174 |
output_toggle(S110B); |
|
|
175 |
output_toggle(S110C); |
|
|
176 |
break; |
|
|
177 |
} |
|
|
178 |
} |
|
|
179 |
|
|
|
180 |
if(c=='R') |
|
|
181 |
{ |
|
|
182 |
getc(); |
|
|
183 |
switch(getc()) |
|
|
184 |
{ |
|
|
185 |
case '3': |
|
|
186 |
getc(); |
|
|
187 |
c=getc(); |
|
|
188 |
if((c=='U')) {}; |
|
|
189 |
break; |
|
|
190 |
case '4': |
|
|
191 |
c=getc(); |
|
|
192 |
if(c=='A') {}; |
|
|
193 |
if(c=='B') {}; |
|
|
194 |
break; |
|
|
195 |
case '5': |
|
|
196 |
getc(); |
|
|
197 |
getc(); |
|
|
198 |
break; |
|
|
199 |
} |
|
|
200 |
} |
|
|
201 |
output_toggle(LED1); |
|
|
202 |
} |
|
|
203 |
else |
|
|
204 |
{ |
|
|
205 |
restart_wdt(); |
|
|
206 |
} |
|
|
207 |
} |
|
|
208 |
} |