Beginnings of info flash support. It isn't very good.
[goodfet] / firmware / apps / monitor / monitor.c
index 33b31c7..218afca 100644 (file)
@@ -9,9 +9,9 @@
 
 //! Call a function by address.
 int fncall(unsigned int adr){
-  //TODO replace this with portable C.
-  //Preprocessor definition might help.
-  __asm__("call r15"); //r12 on IAR
+  int (*machfn)() = 0;
+  machfn= (int (*)()) adr;
+  return machfn();
 }
 
 //! Handles a monitor command.
@@ -19,6 +19,13 @@ void monitorhandle(unsigned char app,
                   unsigned char verb,
                   unsigned long len){
   switch(verb){
+  default:
+    debugstr("ERROR: Command unsupported by debug monitor.");
+    break;
+  case MONITOR_ECHO:
+    //Echo back the same buffer.
+    txdata(app,verb,len);
+    break;
   case PEEK:
     cmddata[0]=memorybyte[cmddataword[0]];
     txdata(app,verb,1);
@@ -72,6 +79,10 @@ void monitorhandle(unsigned char app,
     silent=cmddata[0];
     txdata(app,verb,1);
     break;
+  case MONITOR_CONNECTED:
+    msp430_init_dco_done();
+    txdata(app,verb,0);
+    break;
   }
 }
 
@@ -86,7 +97,9 @@ void monitor_ram_pattern(){
   txdata(0x00,0x90,0);
   
   //Reboot
+  #ifdef MSP430
   asm("br &0xfffe");
+  #endif
 }
 
 //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.