DS800C400 fun, improved ROM interface and tinibios
[fw/sdcc] / device / examples / ds400 / monitor400 / mon400.c
index 478c592792d9f8134cf8f364870e2ac0f62e065a..c0060ded8355cf1f9051825e476969638354789d 100644 (file)
@@ -11,30 +11,50 @@ void usage(void)
     puts("Available commands:\n");
     puts("ledon: turns LED on.");
     puts("ledoff: turns LED off.");
-    puts("startclock: starts millisecond timer.");
     puts("clock: reports millisecond timer.");
     puts("sleep: sleeps for 10 seconds (or forever if you didn't startclock first).");
 }
 
-void main(void)
+void blinker(void)
 {
-    char buffer[80];
+    int i, j;
     
-    // At this stage, the rom isn't initalized. We do have polled serial I/O, though.
-    printf("TINIm400 monitor rev 0.0\n");
-
-    // Intialize the ROM.
-    if (romInit(1))
+    while (1)
     {
-       // We're hosed. romInit will have printed an error, nothing more to do.
-       return;
+       P5 |= 4;
+       for (j = 0; j < 10; j++)
+       {
+           for (i = 0; i < 32767; i++)
+           {
+               ;
+           }
+       }
+       
+       P5 &= ~4;
+       
+       for (j = 0; j < 10; j++)
+       {
+           for (i = 0; i < 32767; i++)
+           {
+               ;
+           }
+       }       
     }
+}
+
+
+void main(void)
+{
+    char buffer[80];
     
-    P5 &= ~4; // LED on.
+    // At this stage, the rom isn't initalized. We do have polled serial I/O, but that's
+    // about the only functional library service.
+    printf("TINIm400 monitor rev 0.0\n");
 
-    // Switch to interrupt driven serial I/O now that the rom is initialized.
-    Serial0SwitchToBuffered();
+    romInit(1, SPEED_2X);
 
+    // Now we're cooking with gas.
+    
     while (1)
     {
        // monitor prompt.
@@ -52,15 +72,14 @@ void main(void)
            P5 |= 4;
            printf("LED off.\n");
        }
-       else if (!strcmp(buffer, "startclock"))
-       {
-           printf("Starting clock...\n");
-           ClockInit();
-       }
        else if (!strcmp(buffer, "clock"))
        {
            printf("Clock: %ld\n", ClockTicks());
        }
+       else if (!strcmp(buffer, "thread"))
+       {
+           printf("Thread ID: %d\n", (int)task_getthreadID());
+       }
        else if (!strcmp(buffer, "sleep"))
        {
            printf("Sleeping for 10 seconds...\n");
@@ -69,7 +88,46 @@ void main(void)
            
            printf("Back.\n");
        }
-       
+       else if (!strcmp(buffer, "pmr"))
+       {
+           printf("PMR: %x\n", PMR);
+       }
+       else if (!strcmp(buffer, "exif"))
+       {
+           printf("EXIF: %x\n", EXIF);
+       }
+       else if (!strcmp(buffer, "blink"))
+       {
+           blinker();
+       }
+       else if (!strcmp(buffer, "t0"))
+       {
+           printf("TH0:TL0 %x:%x\n", TH0, TL0);
+       }
+       else if (!strcmp(buffer, "t2"))
+       {
+           printf("TH2:TL2 %x:%x\n", TH2, TH2);
+       }       
+       else if (!strcmp(buffer, "faster"))
+       {
+           printf("going really fast...\n");
+           P5 |= 4; // LED off.
+
+           PMR = 0x82; 
+           PMR = 0x8a; // 8a for REAL fast
+           PMR = 0x9a; // 9a for REAL fast.
+           
+           while (!(EXIF & 8))
+               ;
+
+           PMR = 0x1a; // 1a for REAL fast.
+           
+_asm
+               nop
+_endasm;               
+           
+           P5 &= ~5; // LED on.
+       }
        else if (buffer[0])
        {
            printf("Unknown command \"%s\".\n", buffer);