Imported Upstream version 2.9.0
[debian/cc1111] / device / examples / ds390 / clock390 / clock390.c
1 #include <stdio.h>
2
3 /* If you don't have an lcd display, don't worry, it will just
4    toggle some bits in the void, but ok
5 */
6 #define USE_LCD
7
8 void main (void) {
9   unsigned long ms, seconds, oldSeconds=-1;
10   
11   printf ("\nStarting systemclock test.\n");
12
13 #ifdef USE_LCD
14   LcdInit();
15   LcdLPutString(0, "Testing clock");
16   LcdLPutString(2, "ms: ");
17 #endif
18
19   while (1) {
20     ms=ClockTicks();
21     seconds=ms/1000;
22
23 #ifdef USE_LCD
24     LcdLPrintf (2 + (4<<8), "%10ld", ms);
25 #endif
26
27     if (seconds!=oldSeconds) {
28       printf ("%02d:%02d.%02d\n", (int)seconds/3600, 
29               (int)(seconds/60)%60, 
30               (int)seconds%60);
31       oldSeconds=seconds;
32       _asm
33         cpl P3.5 ; toggle led
34       _endasm;
35     }
36     if (Serial0CharArrived()) {
37       switch (getchar()) {
38       case '2': printf ("Switching to 2 clocks/cycle\n"); CpuSpeed(2); break;
39       case '4': printf ("Switching to 4 clocks/cycle\n"); CpuSpeed(4); break;
40       }
41     }
42   }
43 }
44
45