1 #include <PalmOS.h>
2 #include <stdint.h>
3 #include <stdio.h>
4 #include <string.h>
5
6 #include "testSuite.h"
7 #include "testSuiteConfig.h"
8 #include "dbvzRegisterNames.h"
9 #include "sed1376RegisterNames.h"
10 #include "debug.h"
11 #include "tools.h"
12 #include "cpu.h"
13 #include "ugui.h"
14 #include "viewer.h"
15 #include "armPrimitives.h"
16 #include "armSideCode/armSideCode.h"
17
18
testButtonInput(void)19 var testButtonInput(void){
20 static Boolean firstRun = true;
21 uint16_t y = 0;
22 uint8_t oldPkdata = readArbitraryMemory8(HW_REG_ADDR(PKDATA));
23
24 if(firstRun){
25 debugSafeScreenClear(C_WHITE);
26 firstRun = false;
27 }
28
29 if(getButton(buttonUp) && !getButton(buttonDown)){
30 firstRun = true;
31 exitSubprogram();
32 }
33
34 UG_PutString(0, y, "Press Up but not Down to exit this test.");
35 y += (FONT_HEIGHT + 1) * 2;
36
37 UG_PutString(0, y, "This requirement is to allow button testing.");
38 y += (FONT_HEIGHT + 1) * 2;
39
40 writeArbitraryMemory8(HW_REG_ADDR(PKDATA), 0xC0 | oldPkdata & 0x1F);
41 StrPrintF(sharedDataBuffer, "PKDATA Key Bits = 110");
42 UG_PutString(0, y, sharedDataBuffer);
43 y += FONT_HEIGHT + 1;
44 StrPrintF(sharedDataBuffer, "PDDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDDATA)));
45 UG_PutString(0, y, sharedDataBuffer);
46 y += FONT_HEIGHT + 1;
47
48 writeArbitraryMemory8(HW_REG_ADDR(PKDATA), 0xA0 | oldPkdata & 0x1F);
49 StrPrintF(sharedDataBuffer, "PKDATA Key Bits = 101");
50 UG_PutString(0, y, sharedDataBuffer);
51 y += FONT_HEIGHT + 1;
52 StrPrintF(sharedDataBuffer, "PDDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDDATA)));
53 UG_PutString(0, y, sharedDataBuffer);
54 y += FONT_HEIGHT + 1;
55
56 writeArbitraryMemory8(HW_REG_ADDR(PKDATA), 0x60 | oldPkdata & 0x1F);
57 StrPrintF(sharedDataBuffer, "PKDATA Key Bits = 011");
58 UG_PutString(0, y, sharedDataBuffer);
59 y += FONT_HEIGHT + 1;
60 StrPrintF(sharedDataBuffer, "PDDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDDATA)));
61 UG_PutString(0, y, sharedDataBuffer);
62 y += FONT_HEIGHT + 1;
63
64 writeArbitraryMemory8(HW_REG_ADDR(PKDATA), oldPkdata);
65
66 return makeVar(LENGTH_0, TYPE_NULL, 0);
67 }
68
listDataRegisters(void)69 var listDataRegisters(void){
70 static Boolean firstRun = true;
71 uint16_t y = 0;
72
73 if(firstRun){
74 firstRun = false;
75 debugSafeScreenClear(C_WHITE);
76 }
77
78 if(getButtonPressed(buttonBack)){
79 firstRun = true;
80 exitSubprogram();
81 }
82
83 StrPrintF(sharedDataBuffer, "PBDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PBDATA)));
84 UG_PutString(0, y, sharedDataBuffer);
85 y += FONT_HEIGHT + 1;
86 StrPrintF(sharedDataBuffer, "PCDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PCDATA)));
87 UG_PutString(0, y, sharedDataBuffer);
88 y += FONT_HEIGHT + 1;
89 StrPrintF(sharedDataBuffer, "PDDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDDATA)));
90 UG_PutString(0, y, sharedDataBuffer);
91 y += FONT_HEIGHT + 1;
92 StrPrintF(sharedDataBuffer, "PEDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PEDATA)));
93 UG_PutString(0, y, sharedDataBuffer);
94 y += FONT_HEIGHT + 1;
95 StrPrintF(sharedDataBuffer, "PFDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PFDATA)));
96 UG_PutString(0, y, sharedDataBuffer);
97 y += FONT_HEIGHT + 1;
98 StrPrintF(sharedDataBuffer, "PGDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PGDATA)));
99 UG_PutString(0, y, sharedDataBuffer);
100 y += FONT_HEIGHT + 1;
101 StrPrintF(sharedDataBuffer, "PJDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PJDATA)));
102 UG_PutString(0, y, sharedDataBuffer);
103 y += FONT_HEIGHT + 1;
104 StrPrintF(sharedDataBuffer, "PKDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PKDATA)));
105 UG_PutString(0, y, sharedDataBuffer);
106 y += FONT_HEIGHT + 1;
107 StrPrintF(sharedDataBuffer, "PMDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PMDATA)));
108 UG_PutString(0, y, sharedDataBuffer);
109 y += FONT_HEIGHT + 1;
110
111 return makeVar(LENGTH_0, TYPE_NULL, 0);
112 }
113
listRegisterFunctions(void)114 var listRegisterFunctions(void){
115 static Boolean firstRun = true;
116 uint16_t y = 0;
117
118 if(firstRun){
119 firstRun = false;
120 debugSafeScreenClear(C_WHITE);
121 }
122
123 if(getButtonPressed(buttonBack)){
124 firstRun = true;
125 exitSubprogram();
126 }
127
128 StrPrintF(sharedDataBuffer, "PBSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PBSEL)));
129 UG_PutString(0, y, sharedDataBuffer);
130 y += FONT_HEIGHT + 1;
131 StrPrintF(sharedDataBuffer, "PCSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PCSEL)));
132 UG_PutString(0, y, sharedDataBuffer);
133 y += FONT_HEIGHT + 1;
134 StrPrintF(sharedDataBuffer, "PDSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDSEL)));
135 UG_PutString(0, y, sharedDataBuffer);
136 y += FONT_HEIGHT + 1;
137 StrPrintF(sharedDataBuffer, "PESEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PESEL)));
138 UG_PutString(0, y, sharedDataBuffer);
139 y += FONT_HEIGHT + 1;
140 StrPrintF(sharedDataBuffer, "PFSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PFSEL)));
141 UG_PutString(0, y, sharedDataBuffer);
142 y += FONT_HEIGHT + 1;
143 StrPrintF(sharedDataBuffer, "PGSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PGSEL)));
144 UG_PutString(0, y, sharedDataBuffer);
145 y += FONT_HEIGHT + 1;
146 StrPrintF(sharedDataBuffer, "PJSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PJSEL)));
147 UG_PutString(0, y, sharedDataBuffer);
148 y += FONT_HEIGHT + 1;
149 StrPrintF(sharedDataBuffer, "PKSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PKSEL)));
150 UG_PutString(0, y, sharedDataBuffer);
151 y += FONT_HEIGHT + 1;
152 StrPrintF(sharedDataBuffer, "PMSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PMSEL)));
153 UG_PutString(0, y, sharedDataBuffer);
154 y += FONT_HEIGHT + 1;
155
156 return makeVar(LENGTH_0, TYPE_NULL, 0);
157 }
158
listRegisterDirections(void)159 var listRegisterDirections(void){
160 static Boolean firstRun = true;
161 uint16_t y = 0;
162
163 if(firstRun){
164 firstRun = false;
165 debugSafeScreenClear(C_WHITE);
166 }
167
168 if(getButtonPressed(buttonBack)){
169 firstRun = true;
170 exitSubprogram();
171 }
172
173 StrPrintF(sharedDataBuffer, "PBDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PBDIR)));
174 UG_PutString(0, y, sharedDataBuffer);
175 y += FONT_HEIGHT + 1;
176 StrPrintF(sharedDataBuffer, "PCDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PCDIR)));
177 UG_PutString(0, y, sharedDataBuffer);
178 y += FONT_HEIGHT + 1;
179 StrPrintF(sharedDataBuffer, "PDDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDDIR)));
180 UG_PutString(0, y, sharedDataBuffer);
181 y += FONT_HEIGHT + 1;
182 StrPrintF(sharedDataBuffer, "PEDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PEDIR)));
183 UG_PutString(0, y, sharedDataBuffer);
184 y += FONT_HEIGHT + 1;
185 StrPrintF(sharedDataBuffer, "PFDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PFDIR)));
186 UG_PutString(0, y, sharedDataBuffer);
187 y += FONT_HEIGHT + 1;
188 StrPrintF(sharedDataBuffer, "PGDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PGDIR)));
189 UG_PutString(0, y, sharedDataBuffer);
190 y += FONT_HEIGHT + 1;
191 StrPrintF(sharedDataBuffer, "PJDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PJDIR)));
192 UG_PutString(0, y, sharedDataBuffer);
193 y += FONT_HEIGHT + 1;
194 StrPrintF(sharedDataBuffer, "PKDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PKDIR)));
195 UG_PutString(0, y, sharedDataBuffer);
196 y += FONT_HEIGHT + 1;
197 StrPrintF(sharedDataBuffer, "PMDIR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PMDIR)));
198 UG_PutString(0, y, sharedDataBuffer);
199 y += FONT_HEIGHT + 1;
200
201 return makeVar(LENGTH_0, TYPE_NULL, 0);
202 }
203
checkSpi2EnableBitDelay(void)204 var checkSpi2EnableBitDelay(void){
205 static Boolean firstRun = true;
206
207 if(firstRun){
208 uint16_t y = 0;
209 uint16_t osSpi2Control = readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0xE030;/*use data rate, phase and polarity from OS*/
210
211 firstRun = false;
212 debugSafeScreenClear(C_WHITE);
213
214 /*disable SPI2*/
215 writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control);/*disable*/
216
217 /*try to enable and shift at the same time*/
218 writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), 0xD4 << 8);/*write control byte, 0xD4 means read channel 5 in 12 bit reference mode*/
219 writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control | 0x0200/*enable*/ | 0x0100/*exchange*/ | 0x000F);/*enable + exchange*/
220 while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100);/*wait on transfer*/
221 StrPrintF(sharedDataBuffer, "Enable + Shift:");
222 UG_PutString(0, y, sharedDataBuffer);
223 y += FONT_HEIGHT + 1;
224 StrPrintF(sharedDataBuffer, "SPIDATA2:0x%02X", readArbitraryMemory16(HW_REG_ADDR(SPIDATA2)));
225 UG_PutString(0, y, sharedDataBuffer);
226 y += FONT_HEIGHT + 1;
227 writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control);/*disable*/
228
229 /*try to disable and shift at the same time*/
230 writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control | 0x0200/*enable*/);/*enable*/
231 writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), 0xD4 << 8);/*write control byte, 0xD4 means read channel 5 in 12 bit reference mode*/
232 writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control | 0x0100/*exchange*/ | 0x000F);/*disable + exchange*/
233 while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100);/*wait on transfer*/
234 StrPrintF(sharedDataBuffer, "Disable + Shift:");
235 UG_PutString(0, y, sharedDataBuffer);
236 y += FONT_HEIGHT + 1;
237 StrPrintF(sharedDataBuffer, "SPIDATA2:0x%02X", readArbitraryMemory16(HW_REG_ADDR(SPIDATA2)));
238 UG_PutString(0, y, sharedDataBuffer);
239 y += FONT_HEIGHT + 1;
240
241 /*enable, shift then disable*/
242 writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control | 0x0200/*enable*/);/*enable*/
243 writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), 0xD4 << 8);/*write control byte, 0xD4 means read channel 5 in 12 bit reference mode*/
244 writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control | 0x0200/*enable*/ | 0x0100/*exchange*/ | 0x000F);/*exchange*/
245 while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100);/*wait on transfer*/
246 StrPrintF(sharedDataBuffer, "Enable, Shift, Disable:");
247 UG_PutString(0, y, sharedDataBuffer);
248 y += FONT_HEIGHT + 1;
249 StrPrintF(sharedDataBuffer, "SPIDATA2:0x%02X", readArbitraryMemory16(HW_REG_ADDR(SPIDATA2)));
250 UG_PutString(0, y, sharedDataBuffer);
251 y += FONT_HEIGHT + 1;
252 writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control);/*disable*/
253 }
254
255 if(getButtonPressed(buttonBack)){
256 firstRun = true;
257 exitSubprogram();
258 }
259
260 return makeVar(LENGTH_0, TYPE_NULL, 0);
261 }
262
tstat1GetSemaphoreLockOrder(void)263 var tstat1GetSemaphoreLockOrder(void){
264 static Boolean firstRun = true;
265 uint16_t testWriteValue = 0xF0F1;
266 uint16_t y = 0;
267
268 if(firstRun){
269 firstRun = false;
270 debugSafeScreenClear(C_WHITE);
271 }
272
273 if(getButtonPressed(buttonBack)){
274 firstRun = true;
275 exitSubprogram();
276 }
277
278 StrPrintF(sharedDataBuffer, "TSTAT1:0x%04X", readArbitraryMemory16(HW_REG_ADDR(TSTAT1)));
279 UG_PutString(0, y, sharedDataBuffer);
280 y += FONT_HEIGHT + 1;
281 writeArbitraryMemory16(HW_REG_ADDR(TSTAT1), testWriteValue);
282 StrPrintF(sharedDataBuffer, "Write TSTAT1:0x%04X", testWriteValue);
283 UG_PutString(0, y, sharedDataBuffer);
284 y += FONT_HEIGHT + 1;
285 StrPrintF(sharedDataBuffer, "New TSTAT1:0x%04X", readArbitraryMemory16(HW_REG_ADDR(TSTAT1)));
286 UG_PutString(0, y, sharedDataBuffer);
287 y += FONT_HEIGHT + 1;
288 writeArbitraryMemory16(HW_REG_ADDR(TSTAT1), 0xFFFF);
289 StrPrintF(sharedDataBuffer, "Clear Semaphore");
290 UG_PutString(0, y, sharedDataBuffer);
291 y += FONT_HEIGHT + 1;
292 StrPrintF(sharedDataBuffer, "New TSTAT1:0x%04X", readArbitraryMemory16(HW_REG_ADDR(TSTAT1)));
293 UG_PutString(0, y, sharedDataBuffer);
294 y += FONT_HEIGHT + 1;
295
296 return makeVar(LENGTH_0, TYPE_NULL, 0);
297 }
298
ads7846Read(void)299 var ads7846Read(void){
300 static Boolean firstRun = true;
301 static Boolean referenceMode;
302 static Boolean mode8Bit;
303 static uint16_t ads7846ChannelValues[8];
304 static uint16_t touchDrawX;
305 static uint16_t touchDrawY;
306 uint8_t ads7846Channel;
307 uint16_t y = 0;
308
309 if(firstRun){
310 firstRun = false;
311 referenceMode = false;
312 mode8Bit = false;
313 memset(ads7846ChannelValues, 0x00, 8 * sizeof(uint16_t));
314 touchDrawX = 0xFFFF;
315 touchDrawY = 0xFFFF;
316 debugSafeScreenClear(C_WHITE);
317 }
318
319 if(getButtonPressed(buttonSelect)){
320 if(!referenceMode && !mode8Bit){
321 referenceMode = true;
322 }
323 else if(referenceMode && !mode8Bit){
324 referenceMode = false;
325 mode8Bit = true;
326 }
327 else if(!referenceMode && mode8Bit){
328 referenceMode = true;
329 }
330 else{
331 referenceMode = false;
332 mode8Bit = false;
333 }
334 }
335
336 if(getButtonPressed(buttonBack)){
337 firstRun = true;
338 exitSubprogram();
339 }
340
341 if(getButton(buttonLeft)){
342 for(ads7846Channel = 0; ads7846Channel < 8; ads7846Channel++)
343 ads7846ChannelValues[ads7846Channel] = ads7846GetValue(ads7846Channel, referenceMode, mode8Bit);
344
345 touchDrawX = (1.0 - (float)(ads7846ChannelValues[5]) / 0xFFF) * 160;
346 touchDrawY = (1.0 - (float)(ads7846ChannelValues[1]) / 0xFFF) * 220;
347 }
348
349 StrPrintF(sharedDataBuffer, "Left To Refresh");
350 UG_PutString(0, y, sharedDataBuffer);
351 y += FONT_HEIGHT + 1;
352 StrPrintF(sharedDataBuffer, "Select To Change Mode");
353 UG_PutString(0, y, sharedDataBuffer);
354 y += FONT_HEIGHT + 1;
355 StrPrintF(sharedDataBuffer, "Ref Mode:%d, 8bit:%d", referenceMode, mode8Bit);
356 UG_PutString(0, y, sharedDataBuffer);
357 y += FONT_HEIGHT + 1;
358
359 for(ads7846Channel = 0; ads7846Channel < 8; ads7846Channel++){
360 StrPrintF(sharedDataBuffer, "Ch:%d Value:0x%04X", ads7846Channel, ads7846ChannelValues[ads7846Channel]);
361 UG_PutString(0, y, sharedDataBuffer);
362 y += FONT_HEIGHT + 1;
363 }
364
365 /*show estimated touch coord*/
366 if(touchDrawX < 160 && touchDrawY < 220)
367 UG_DrawPixel(touchDrawX, touchDrawY, C_BLACK);
368
369 return makeVar(LENGTH_0, TYPE_NULL, 0);
370 }
371
getClk32Frequency(void)372 var getClk32Frequency(void){
373 static Boolean firstRun = true;
374
375 if(firstRun){
376 firstRun = false;
377 debugSafeScreenClear(C_WHITE);
378 StrPrintF(sharedDataBuffer, "CLK32 Freq:%s", (readArbitraryMemory16(HW_REG_ADDR(RTCCTL)) & 0x0020) ? "38.4khz" : "32.7khz");
379 UG_PutString(0, 0, sharedDataBuffer);
380 }
381
382 if(getButtonPressed(buttonBack)){
383 firstRun = true;
384 exitSubprogram();
385 }
386
387 return makeVar(LENGTH_0, TYPE_NULL, 0);
388 }
389
getDeviceInfo(void)390 var getDeviceInfo(void){
391 static Boolean firstRun = true;
392
393 if(firstRun){
394 char deviceId[5];
395 uint16_t y = 0;
396
397 firstRun = false;
398 debugSafeScreenClear(C_WHITE);
399 FtrGet(sysFtrCreator, sysFtrNumOEMDeviceID, deviceId);
400 deviceId[4] = '\0';/*Palm OS sprintf doesnt support %.*s string length modifyers*/
401 StrPrintF(sharedDataBuffer, "Device ID:%s", &deviceId);
402 UG_PutString(0, y, sharedDataBuffer);
403 y += FONT_HEIGHT + 1;
404 StrPrintF(sharedDataBuffer, "OS String:%s", SysGetOSVersionString());
405 UG_PutString(0, y, sharedDataBuffer);
406 y += FONT_HEIGHT + 1;
407 }
408
409 if(getButtonPressed(buttonBack)){
410 firstRun = true;
411 exitSubprogram();
412 }
413
414 return makeVar(LENGTH_0, TYPE_NULL, 0);
415 }
416
getCpuInfo(void)417 var getCpuInfo(void){
418 static Boolean firstRun = true;
419
420 if(firstRun){
421 uint16_t y = 0;
422
423 firstRun = false;
424 debugSafeScreenClear(C_WHITE);
425 StrPrintF(sharedDataBuffer, "CPU Type:%s", getCpuString());
426 UG_PutString(0, y, sharedDataBuffer);
427 y += (FONT_HEIGHT + 1) * 5;
428 if(getPhysicalCpuType() & CPU_M68K){
429 StrPrintF(sharedDataBuffer, "SCR:0x%02X", readArbitraryMemory8(HW_REG_ADDR(SCR)));
430 UG_PutString(0, y, sharedDataBuffer);
431 y += FONT_HEIGHT + 1;
432 StrPrintF(sharedDataBuffer, "CPU ID(IDR):0x%08lX", readArbitraryMemory32(HW_REG_ADDR(IDR)));
433 UG_PutString(0, y, sharedDataBuffer);
434 y += FONT_HEIGHT + 1;
435 }
436 }
437
438 if(getButtonPressed(buttonBack)){
439 firstRun = true;
440 exitSubprogram();
441 }
442
443 return makeVar(LENGTH_0, TYPE_NULL, 0);
444 }
445
getInterruptInfo(void)446 var getInterruptInfo(void){
447 static Boolean firstRun = true;
448 uint16_t y = 0;
449
450 if(firstRun){
451 debugSafeScreenClear(C_WHITE);
452 firstRun = false;
453 }
454
455 if(getButtonPressed(buttonBack)){
456 firstRun = true;
457 exitSubprogram();
458 }
459
460 StrPrintF(sharedDataBuffer, "IMR:0x%08lX", readArbitraryMemory32(HW_REG_ADDR(IMR)));
461 UG_PutString(0, y, sharedDataBuffer);
462 y += FONT_HEIGHT + 1;
463 StrPrintF(sharedDataBuffer, "IPR:0x%08lX", readArbitraryMemory32(HW_REG_ADDR(IPR)));
464 UG_PutString(0, y, sharedDataBuffer);
465 y += FONT_HEIGHT + 1;
466 StrPrintF(sharedDataBuffer, "ISR:0x%08lX", readArbitraryMemory32(HW_REG_ADDR(ISR)));
467 UG_PutString(0, y, sharedDataBuffer);
468 y += FONT_HEIGHT + 1;
469 StrPrintF(sharedDataBuffer, "ILCR:0x%04X", readArbitraryMemory16(HW_REG_ADDR(ILCR)));
470 UG_PutString(0, y, sharedDataBuffer);
471 y += FONT_HEIGHT + 1;
472 StrPrintF(sharedDataBuffer, "ICR:0x%04X", readArbitraryMemory16(HW_REG_ADDR(ICR)));
473 UG_PutString(0, y, sharedDataBuffer);
474 y += FONT_HEIGHT + 1;
475 StrPrintF(sharedDataBuffer, "PDIRQEN:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDIRQEN)));
476 UG_PutString(0, y, sharedDataBuffer);
477 y += FONT_HEIGHT + 1;
478 StrPrintF(sharedDataBuffer, "PDIRQEG:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDIRQEG)));
479 UG_PutString(0, y, sharedDataBuffer);
480 y += FONT_HEIGHT + 1;
481 StrPrintF(sharedDataBuffer, "PDKBEN:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PDKBEN)));
482 UG_PutString(0, y, sharedDataBuffer);
483 y += FONT_HEIGHT + 1;
484
485 return makeVar(LENGTH_0, TYPE_NULL, 0);
486 }
487
getIcrInversion(void)488 var getIcrInversion(void){
489 static Boolean firstRun = true;
490 uint16_t oldIcr;
491 uint8_t portDValues[2];
492 uint16_t y = 0;
493
494 if(firstRun){
495 debugSafeScreenClear(C_WHITE);
496 firstRun = false;
497 }
498
499 if(getButtonPressed(buttonBack)){
500 firstRun = true;
501 exitSubprogram();
502 }
503
504 turnInterruptsOff();
505 oldIcr = readArbitraryMemory16(HW_REG_ADDR(ICR));
506
507 /*not inverted*/
508 portDValues[0] = readArbitraryMemory8(HW_REG_ADDR(PDDATA));
509
510 writeArbitraryMemory16(HW_REG_ADDR(ICR), oldIcr | 0xF000);
511
512 /*inverted*/
513 portDValues[1] = readArbitraryMemory8(HW_REG_ADDR(PDDATA));
514
515 writeArbitraryMemory16(HW_REG_ADDR(ICR), oldIcr);
516
517 turnInterruptsOn();
518
519 StrPrintF(sharedDataBuffer, "PDDATA Normal:0x%02X", portDValues[0]);
520 UG_PutString(0, y, sharedDataBuffer);
521 y += FONT_HEIGHT + 1;
522 StrPrintF(sharedDataBuffer, "PDDATA Inverted:0x%02X", portDValues[1]);
523 UG_PutString(0, y, sharedDataBuffer);
524 y += FONT_HEIGHT + 1;
525
526 return makeVar(LENGTH_0, TYPE_NULL, 0);
527 }
528
doesIsrClearChangePinValue(void)529 var doesIsrClearChangePinValue(void){
530 static Boolean firstRun = true;
531
532 if(firstRun){
533 uint8_t oldPdirqeg;
534 uint8_t oldPdirqen;
535 uint16_t y = 0;
536 Boolean testSd;
537
538 turnInterruptsOff();
539
540 debugSafeScreenClear(C_WHITE);
541
542 StrPrintF(sharedDataBuffer, "Select = Test SD");
543 UG_PutString(0, y, sharedDataBuffer);
544 y += FONT_HEIGHT + 1;
545 StrPrintF(sharedDataBuffer, "Back = Skip SD");
546 UG_PutString(0, y, sharedDataBuffer);
547 y += FONT_HEIGHT + 1;
548 forceFrameRedraw();
549 while(true){
550 testSd = readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x0C;
551 if(testSd)
552 break;
553 }
554
555 /*test if SD pin is cleared on write to ICR*/
556 if(testSd & 0x08){
557 uint16_t oldIcr = readArbitraryMemory16(HW_REG_ADDR(ICR));
558
559 debugSafeScreenClear(C_WHITE);
560 y = 0;
561
562 if(!(readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x20)){
563 StrPrintF(sharedDataBuffer, "Remove SD Card");
564 UG_PutString(0, y, sharedDataBuffer);
565 y += FONT_HEIGHT + 1;
566 forceFrameRedraw();
567 while(!(readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x20));/*SD is still inserted*/
568 }
569
570 /*set to edge triggered mode and reset IRQ2, trigger on insert event*/
571 writeArbitraryMemory16(HW_REG_ADDR(ICR), (oldIcr | 0x0400) & 0xBFFF);
572 writeArbitraryMemory32(HW_REG_ADDR(ISR), 0x00020000);
573 StrPrintF(sharedDataBuffer, "IRQ2 Pin:%s", (readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x20) ? "true " : "false");
574 UG_PutString(0, y, sharedDataBuffer);
575 y += FONT_HEIGHT + 1;
576 StrPrintF(sharedDataBuffer, "ISR IRQ2:%s", (readArbitraryMemory32(HW_REG_ADDR(ISR)) & 0x00020000) ? "true " : "false");
577 UG_PutString(0, y, sharedDataBuffer);
578 y += FONT_HEIGHT + 1;
579 forceFrameRedraw();
580
581 StrPrintF(sharedDataBuffer, "Insert SD Card");
582 UG_PutString(0, y, sharedDataBuffer);
583 y += FONT_HEIGHT + 1;
584 forceFrameRedraw();
585 while(readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x20);/*SD is not inserted*/
586 StrPrintF(sharedDataBuffer, "IRQ2 Pin:%s", (readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x20) ? "true " : "false");
587 UG_PutString(0, y, sharedDataBuffer);
588 y += FONT_HEIGHT + 1;
589 StrPrintF(sharedDataBuffer, "ISR IRQ2:%s", (readArbitraryMemory32(HW_REG_ADDR(ISR)) & 0x00020000) ? "true " : "false");
590 UG_PutString(0, y, sharedDataBuffer);
591 y += FONT_HEIGHT + 1;
592
593 writeArbitraryMemory32(HW_REG_ADDR(ISR), 0x00020000);
594 StrPrintF(sharedDataBuffer, "IRQ2 Cleared");
595 UG_PutString(0, y, sharedDataBuffer);
596 y += FONT_HEIGHT + 1;
597 StrPrintF(sharedDataBuffer, "IRQ2 Pin:%s", (readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x20) ? "true " : "false");
598 UG_PutString(0, y, sharedDataBuffer);
599 y += FONT_HEIGHT + 1;
600 StrPrintF(sharedDataBuffer, "ISR IRQ2:%s", (readArbitraryMemory32(HW_REG_ADDR(ISR)) & 0x00020000) ? "true " : "false");
601 UG_PutString(0, y, sharedDataBuffer);
602 y += FONT_HEIGHT + 1;
603
604 StrPrintF(sharedDataBuffer, "Select = Continue");
605 UG_PutString(0, y, sharedDataBuffer);
606 y += FONT_HEIGHT + 1;
607 forceFrameRedraw();
608 while(!(readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x08));
609
610 writeArbitraryMemory16(HW_REG_ADDR(ICR), oldIcr);
611 }
612
613 /*test if Notes button pin is cleared on write to ICR*/
614 debugSafeScreenClear(C_WHITE);
615 y = 0;
616
617 oldPdirqeg = readArbitraryMemory8(HW_REG_ADDR(PDIRQEG));
618 oldPdirqen = readArbitraryMemory8(HW_REG_ADDR(PDIRQEN));
619
620 if(readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x08){
621 StrPrintF(sharedDataBuffer, "Release Select");
622 UG_PutString(0, y, sharedDataBuffer);
623 y += FONT_HEIGHT + 1;
624 forceFrameRedraw();
625 while(readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x08);
626 }
627
628 /*set to edge triggered mode and reset INT3, trigger on button down*/
629 writeArbitraryMemory8(HW_REG_ADDR(PKDATA), readArbitraryMemory8(HW_REG_ADDR(PKDATA)) & 0x1F);/*enable all button rows*/
630 writeArbitraryMemory8(HW_REG_ADDR(PDIRQEN), 0x00);/*turn INT* off first to prevent glitches*/
631 writeArbitraryMemory8(HW_REG_ADDR(PDIRQEG), 0x0F);
632 writeArbitraryMemory8(HW_REG_ADDR(PDIRQEN), 0x0F);
633 writeArbitraryMemory32(HW_REG_ADDR(ISR), 0x00000800);/*clear any interrupt that may have triggered*/
634 StrPrintF(sharedDataBuffer, "INT3 Pin:%s", (readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x08) ? "true " : "false");
635 UG_PutString(0, y, sharedDataBuffer);
636 y += FONT_HEIGHT + 1;
637 StrPrintF(sharedDataBuffer, "ISR INT3:%s", (readArbitraryMemory32(HW_REG_ADDR(ISR)) & 0x00000800) ? "true " : "false");
638 UG_PutString(0, y, sharedDataBuffer);
639 y += FONT_HEIGHT + 1;
640
641 StrPrintF(sharedDataBuffer, "Press Select");
642 UG_PutString(0, y, sharedDataBuffer);
643 y += FONT_HEIGHT + 1;
644 forceFrameRedraw();
645 while(!(readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x08));
646 /*
647 StrPrintF(sharedDataBuffer, "Release Select");
648 UG_PutString(0, y, sharedDataBuffer);
649 y += FONT_HEIGHT + 1;
650 StrPrintF(sharedDataBuffer, "3sec Wait");
651 UG_PutString(0, y, sharedDataBuffer);
652 y += FONT_HEIGHT + 1;
653 forceFrameRedraw();
654 SysTaskDelay(SysTicksPerSecond() * 3);
655 */
656 StrPrintF(sharedDataBuffer, "INT3 Pin:%s", (readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x08) ? "true " : "false");
657 UG_PutString(0, y, sharedDataBuffer);
658 y += FONT_HEIGHT + 1;
659 StrPrintF(sharedDataBuffer, "ISR INT3:%s", (readArbitraryMemory32(HW_REG_ADDR(ISR)) & 0x00000800) ? "true " : "false");
660 UG_PutString(0, y, sharedDataBuffer);
661 y += FONT_HEIGHT + 1;
662
663 writeArbitraryMemory32(HW_REG_ADDR(ISR), 0x00000800);
664 StrPrintF(sharedDataBuffer, "INT3 Cleared");
665 UG_PutString(0, y, sharedDataBuffer);
666 y += FONT_HEIGHT + 1;
667 StrPrintF(sharedDataBuffer, "INT3 Pin:%s", (readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x08) ? "true " : "false");
668 UG_PutString(0, y, sharedDataBuffer);
669 y += FONT_HEIGHT + 1;
670 StrPrintF(sharedDataBuffer, "ISR INT3:%s", (readArbitraryMemory32(HW_REG_ADDR(ISR)) & 0x00000800) ? "true " : "false");
671 UG_PutString(0, y, sharedDataBuffer);
672 y += FONT_HEIGHT + 1;
673
674 forceFrameRedraw();
675
676 writeArbitraryMemory8(HW_REG_ADDR(PDIRQEG), oldPdirqeg);
677 writeArbitraryMemory8(HW_REG_ADDR(PDIRQEN), oldPdirqen);
678
679 turnInterruptsOn();
680
681 firstRun = false;
682 }
683
684 if(getButtonPressed(buttonBack)){
685 firstRun = true;
686 exitSubprogram();
687 }
688
689 return makeVar(LENGTH_0, TYPE_NULL, 0);
690 }
691
toggleBacklight(void)692 var toggleBacklight(void){
693 static Boolean firstRun = true;
694 uint16_t y = 0;
695
696 if(firstRun){
697 firstRun = false;
698 debugSafeScreenClear(C_WHITE);
699 StrPrintF(sharedDataBuffer, "Left = SED1376");
700 UG_PutString(0, y, sharedDataBuffer);
701 y += FONT_HEIGHT + 1;
702 StrPrintF(sharedDataBuffer, "Right = Port G");
703 UG_PutString(0, y, sharedDataBuffer);
704 y += FONT_HEIGHT + 1;
705 StrPrintF(sharedDataBuffer, "Select = Port K");
706 UG_PutString(0, y, sharedDataBuffer);
707 y += FONT_HEIGHT + 1;
708 }
709
710 if(getButtonPressed(buttonBack)){
711 firstRun = true;
712 exitSubprogram();
713 }
714
715 if(getButtonPressed(buttonLeft)){
716 writeArbitraryMemory8(0x1FF80000 + GPIO_CONT_0, readArbitraryMemory8(0x1FF80000 + GPIO_CONT_0) ^ 0x10);
717 }
718
719 if(getButtonPressed(buttonRight)){
720 writeArbitraryMemory8(HW_REG_ADDR(PGDATA), readArbitraryMemory8(HW_REG_ADDR(PGDATA)) ^ 0x02);
721 }
722
723 if(getButtonPressed(buttonSelect)){
724 writeArbitraryMemory8(HW_REG_ADDR(PKDATA), readArbitraryMemory8(HW_REG_ADDR(PKDATA)) ^ 0x02);
725 }
726
727 y = (FONT_HEIGHT + 1) * 3;
728 StrPrintF(sharedDataBuffer, "PGDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PGDATA)));
729 UG_PutString(0, y, sharedDataBuffer);
730 y += FONT_HEIGHT + 1;
731 StrPrintF(sharedDataBuffer, "PKDATA:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PKDATA)));
732 UG_PutString(0, y, sharedDataBuffer);
733 y += FONT_HEIGHT + 1;
734 StrPrintF(sharedDataBuffer, "PGSEL:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PGSEL)));
735 UG_PutString(0, y, sharedDataBuffer);
736 y += FONT_HEIGHT + 1;
737 StrPrintF(sharedDataBuffer, "PGPUEN:0x%02X", readArbitraryMemory8(HW_REG_ADDR(PGPUEN)));
738 UG_PutString(0, y, sharedDataBuffer);
739 y += FONT_HEIGHT + 1;
740
741 return makeVar(LENGTH_0, TYPE_NULL, 0);
742 }
743
toggleMotor(void)744 var toggleMotor(void){
745 static Boolean firstRun = true;
746
747 if(firstRun){
748 firstRun = false;
749 debugSafeScreenClear(C_WHITE);
750 StrPrintF(sharedDataBuffer, "Select = Toggle Motor");
751 UG_PutString(0, 0, sharedDataBuffer);
752 }
753
754 if(getButtonPressed(buttonBack)){
755 firstRun = true;
756 exitSubprogram();
757 }
758
759 if(getButtonPressed(buttonSelect)){
760 writeArbitraryMemory8(HW_REG_ADDR(PKDATA), readArbitraryMemory8(HW_REG_ADDR(PKDATA)) ^ 0x10);
761 }
762
763 return makeVar(LENGTH_0, TYPE_NULL, 0);
764 }
765
toggleAlarmLed(void)766 var toggleAlarmLed(void){
767 static Boolean firstRun = true;
768
769 if(firstRun){
770 firstRun = false;
771 debugSafeScreenClear(C_WHITE);
772 StrPrintF(sharedDataBuffer, "Select = Toggle Alarm LED");
773 UG_PutString(0, 0, sharedDataBuffer);
774 }
775
776 if(getButtonPressed(buttonBack)){
777 firstRun = true;
778 exitSubprogram();
779 }
780
781 if(getButtonPressed(buttonSelect)){
782 writeArbitraryMemory8(HW_REG_ADDR(PBDATA), readArbitraryMemory8(HW_REG_ADDR(PBDATA)) ^ 0x40);
783 }
784
785 return makeVar(LENGTH_0, TYPE_NULL, 0);
786 }
787
watchPenIrq(void)788 var watchPenIrq(void){
789 static Boolean firstRun = true;
790 uint16_t y = 0;
791
792 if(firstRun){
793 firstRun = false;
794 writeArbitraryMemory8(HW_REG_ADDR(PFDIR), readArbitraryMemory8(HW_REG_ADDR(PFDIR)) & 0xFD);
795 debugSafeScreenClear(C_WHITE);
796 }
797
798 if(getButtonPressed(buttonBack)){
799 firstRun = true;
800 exitSubprogram();
801 }
802
803 if(getButtonPressed(buttonSelect)){
804 writeArbitraryMemory16(HW_REG_ADDR(ICR), readArbitraryMemory16(HW_REG_ADDR(ICR)) ^ 0x0080);
805 }
806
807 StrPrintF(sharedDataBuffer, "Select = Toggle ICR POL5");
808 UG_PutString(0, y, sharedDataBuffer);
809 y += FONT_HEIGHT + 1;
810 StrPrintF(sharedDataBuffer, "IPR:0x%08lX", readArbitraryMemory32(HW_REG_ADDR(IPR)));
811 UG_PutString(0, y, sharedDataBuffer);
812 y += FONT_HEIGHT + 1;
813 StrPrintF(sharedDataBuffer, "ICR:0x%02X", readArbitraryMemory16(HW_REG_ADDR(ICR)));
814 UG_PutString(0, y, sharedDataBuffer);
815 y += FONT_HEIGHT + 1;
816 StrPrintF(sharedDataBuffer, "PENIRQ State:%s", (readArbitraryMemory8(HW_REG_ADDR(PFDATA)) & 0x02) ? "true " : "false");/*"true " needs the space to clear the e from "false"*/
817 UG_PutString(0, y, sharedDataBuffer);
818 y += FONT_HEIGHT + 1;
819
820 return makeVar(LENGTH_0, TYPE_NULL, 0);
821 }
822
getPenPosition(void)823 var getPenPosition(void){
824 static Boolean firstRun = true;
825 uint16_t y = 0;
826 PointType rawPen;
827 PointType screenPen;
828
829 if(firstRun){
830 firstRun = false;
831 writeArbitraryMemory8(HW_REG_ADDR(PFDIR), readArbitraryMemory8(HW_REG_ADDR(PFDIR)) & 0xFD);
832 debugSafeScreenClear(C_WHITE);
833 }
834
835 if(getButtonPressed(buttonBack)){
836 firstRun = true;
837 exitSubprogram();
838 }
839
840 PenGetRawPen(&rawPen);
841 screenPen = rawPen;
842 PenRawToScreen(&screenPen);
843
844 StrPrintF(sharedDataBuffer, "Raw X:%d ", rawPen.x);/*"true " needs the space to clear the e from "false"*/
845 UG_PutString(0, y, sharedDataBuffer);
846 y += FONT_HEIGHT + 1;
847 StrPrintF(sharedDataBuffer, "Raw Y:%d ", rawPen.y);/*"true " needs the space to clear the e from "false"*/
848 UG_PutString(0, y, sharedDataBuffer);
849 y += FONT_HEIGHT + 1;
850 StrPrintF(sharedDataBuffer, "Screen X:%d ", screenPen.x);/*"true " needs the space to clear the e from "false"*/
851 UG_PutString(0, y, sharedDataBuffer);
852 y += FONT_HEIGHT + 1;
853 StrPrintF(sharedDataBuffer, "Screen Y:%d ", screenPen.y);/*"true " needs the space to clear the e from "false"*/
854 UG_PutString(0, y, sharedDataBuffer);
855 y += FONT_HEIGHT + 1;
856
857 return makeVar(LENGTH_0, TYPE_NULL, 0);
858 }
859
playConstantTone(void)860 var playConstantTone(void){
861 /*static const uint16_t testFreq = 10000;*/
862 static const uint8_t samples[10] = {0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0x90, 0x80, 0x70, 0x60};/*this buffer needs to pe played testFreq times a second*/
863 static Boolean firstRun = true;
864 static uint8_t count;
865 #if 0
866 uint32_t basePwm1ClockSpeed = 33161216 / 1/*REPEAT*/ / 2/*CLKSEL*/;
867 uint32_t neededPwm1ClockSpeed = (uint32_t)testFreq * 0xFF/*period*/ * 10/*samples*/;
868 uint8_t prescaler = basePwm1ClockSpeed / neededPwm1ClockSpeed
869 #endif
870
871 if(firstRun){
872 firstRun = false;
873 debugSafeScreenClear(C_WHITE);
874 StrPrintF(sharedDataBuffer, "Squealing In Progress");
875 UG_PutString(0, 0, sharedDataBuffer);
876 forceFrameRedraw();
877 writeArbitraryMemory16(HW_REG_ADDR(PWMC1), 0x0F10);
878 writeArbitraryMemory8(HW_REG_ADDR(PWMP1), 0xFF);
879 count = 0;
880 }
881
882 while(true){
883 while(readArbitraryMemory16(HW_REG_ADDR(PWMC1)) & 0x0020){
884 /*add audio samples*/
885 writeArbitraryMemory8(HW_REG_ADDR(PWMS1 + 1), samples[count]);
886 count++;
887 if(count >= 10)
888 count = 0;
889 }
890
891 if(KeyCurrentState() & buttonBack)
892 break;
893 }
894
895 writeArbitraryMemory16(HW_REG_ADDR(PWMC1), 0x0000);
896 firstRun = true;
897 exitSubprogram();
898
899 return makeVar(LENGTH_0, TYPE_NULL, 0);
900 }
901
unaligned32bitAccess(void)902 var unaligned32bitAccess(void){
903 static Boolean firstRun = true;
904
905 if(firstRun){
906 uint8_t buffer[10];
907 uint8_t* align16Buffer = buffer;
908 uint32_t* test;
909
910 /*make sure its 16 bit aligned but not 32 bit aligned*/
911 while(((uint32_t)align16Buffer & 0x3) != 0x2)
912 align16Buffer++;
913
914 test = align16Buffer;
915
916 *test = 0xF1EAF1EA;
917 if(*test == 0xF1EAF1EA){
918 debugSafeScreenClear(C_WHITE);
919 StrPrintF(sharedDataBuffer, "It works!");
920 UG_PutString(0, 0, sharedDataBuffer);
921 }
922
923 firstRun = false;
924 }
925
926 if(getButtonPressed(buttonBack)){
927 firstRun = true;
928 exitSubprogram();
929 }
930
931 return makeVar(LENGTH_0, TYPE_NULL, 0);
932 }
933
isIrq2AttachedToSdCardChipSelect(void)934 var isIrq2AttachedToSdCardChipSelect(void){
935 static Boolean firstRun = true;
936 uint16_t y = 0;
937
938 if(firstRun){
939 firstRun = false;
940 debugSafeScreenClear(C_WHITE);
941
942 turnInterruptsOff();
943
944 StrPrintF(sharedDataBuffer, "IRQ2 value:%s", (readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x20) ? "true " : "false");/*"true " needs the space to clear the e from "false"*/
945 UG_PutString(0, y, sharedDataBuffer);
946 y += FONT_HEIGHT + 1;
947
948 writeArbitraryMemory8(HW_REG_ADDR(PJDATA), readArbitraryMemory8(HW_REG_ADDR(PJDATA)) ^ 0x08);
949 StrPrintF(sharedDataBuffer, "Chip Select Toggled");
950 UG_PutString(0, y, sharedDataBuffer);
951 y += FONT_HEIGHT + 1;
952
953 StrPrintF(sharedDataBuffer, "IRQ2 value:%s", (readArbitraryMemory8(HW_REG_ADDR(PDDATA)) & 0x20) ? "true " : "false");/*"true " needs the space to clear the e from "false"*/
954 UG_PutString(0, y, sharedDataBuffer);
955 y += FONT_HEIGHT + 1;
956
957 writeArbitraryMemory8(HW_REG_ADDR(PJDATA), readArbitraryMemory8(HW_REG_ADDR(PJDATA)) ^ 0x08);/*restore old chip select state*/
958 turnInterruptsOn();
959 }
960
961 if(getButtonPressed(buttonBack)){
962 firstRun = true;
963 exitSubprogram();
964 }
965
966 return makeVar(LENGTH_0, TYPE_NULL, 0);
967 }
968
callSysUnimplemented(void)969 var callSysUnimplemented(void){
970 /*used to test the SysUnimplemented handler in MuExpDriver*/
971 SysUnimplemented();
972 return makeVar(LENGTH_0, TYPE_NULL, 0);
973 }
974
testArmDataExchange(void)975 var testArmDataExchange(void){
976 ALIGN(4) uint32_t* args[3];
977 static Boolean firstRun = true;
978 uint16_t y = 0;
979
980 if(firstRun){
981 firstRun = false;
982 debugSafeScreenClear(C_WHITE);
983
984 }
985
986 if(getButtonPressed(buttonBack)){
987 firstRun = true;
988 exitSubprogram();
989 }
990
991 args[0] = ARM_TEST_DATA_EXCHANGE;
992 args[1] = 0x13245768;
993 callArmTests(args, 1);
994
995 StrPrintF(sharedDataBuffer, "0x12345678:0x%08lX", args[1]);
996 UG_PutString(0, y, sharedDataBuffer);
997 y += FONT_HEIGHT + 1;
998 StrPrintF(sharedDataBuffer, "0x13245768:0x%08lX", args[2]);
999 UG_PutString(0, y, sharedDataBuffer);
1000 y += FONT_HEIGHT + 1;
1001
1002 return makeVar(LENGTH_0, TYPE_NULL, 0);
1003 }
1004
tsc2101ReadAllAnalogValues(void)1005 var tsc2101ReadAllAnalogValues(void){
1006 ALIGN(4) uint32_t args[12];
1007 static Boolean firstRun = true;
1008 uint16_t y = 0;
1009
1010 if(firstRun){
1011 firstRun = false;
1012 debugSafeScreenClear(C_WHITE);
1013 }
1014
1015 if(getButtonPressed(buttonBack)){
1016 firstRun = true;
1017 exitSubprogram();
1018 }
1019
1020 args[0] = ARM_TEST_TSC2101_READ_ADC_VALUES;
1021 callArmTests(args, 0);
1022
1023 StrPrintF(sharedDataBuffer, "X:0x%04lX", args[1]);
1024 UG_PutString(0, y, sharedDataBuffer);
1025 y += FONT_HEIGHT + 1;
1026 StrPrintF(sharedDataBuffer, "Y:0x%04lX", args[2]);
1027 UG_PutString(0, y, sharedDataBuffer);
1028 y += FONT_HEIGHT + 1;
1029 StrPrintF(sharedDataBuffer, "Z1:0x%04lX", args[3]);
1030 UG_PutString(0, y, sharedDataBuffer);
1031 y += FONT_HEIGHT + 1;
1032 StrPrintF(sharedDataBuffer, "Z2:0x%04lX", args[4]);
1033 UG_PutString(0, y, sharedDataBuffer);
1034 y += FONT_HEIGHT + 1;
1035 StrPrintF(sharedDataBuffer, "BAT:0x%04lX", args[6]);
1036 UG_PutString(0, y, sharedDataBuffer);
1037 y += FONT_HEIGHT + 1;
1038 StrPrintF(sharedDataBuffer, "AUX1:0x%04lX", args[8]);
1039 UG_PutString(0, y, sharedDataBuffer);
1040 y += FONT_HEIGHT + 1;
1041 StrPrintF(sharedDataBuffer, "AUX2:0x%04lX", args[9]);
1042 UG_PutString(0, y, sharedDataBuffer);
1043 y += FONT_HEIGHT + 1;
1044 StrPrintF(sharedDataBuffer, "TEMP1:0x%04lX", args[10]);
1045 UG_PutString(0, y, sharedDataBuffer);
1046 y += FONT_HEIGHT + 1;
1047 StrPrintF(sharedDataBuffer, "TEMP2:0x%04lX", args[11]);
1048 UG_PutString(0, y, sharedDataBuffer);
1049 y += FONT_HEIGHT + 1;
1050
1051 return makeVar(LENGTH_0, TYPE_NULL, 0);
1052 }
1053