Support for debugging strings, closer to a clean MSP430X2 implementation.
[goodfet] / firmware / lib / command.c
index c9c1b1c..c5e35b5 100644 (file)
@@ -1,8 +1,31 @@
+#include "command.h"
+#include "platform.h"
+#include <string.h>
+
 //! Different command handling functions.
 
 unsigned char cmddata[256];
 
 //! Different command handling functions.
 
 unsigned char cmddata[256];
 
-//!Transmit data.
+
+//! Transmit a string.
+void txstring(unsigned char app,
+             unsigned char verb,
+             const char *str){
+  unsigned char len=strlen(str);
+  serial_tx(app);
+  serial_tx(verb);
+  serial_tx(len);
+  while(len--)
+    serial_tx(*(str++));
+}
+
+//! Transmits a debugging string out of line.
+void debugstr(const char *str){
+  txstring(0xFF,0xFF,str);
+}
+
+
+//! Transmit data.
 void txdata(unsigned char app,
            unsigned char verb,
            unsigned char len){
 void txdata(unsigned char app,
            unsigned char verb,
            unsigned char len){
@@ -14,3 +37,22 @@ void txdata(unsigned char app,
     serial_tx(cmddata[i]);
   }
 }
     serial_tx(cmddata[i]);
   }
 }
+
+//Be very careful changing delay().
+//It was chosen poorly by trial and error.
+
+//! Delay for a count.
+void delay(unsigned int count){
+  volatile unsigned int i=count;
+  while(i--) asm("nop");
+}
+//! MSDelay
+void msdelay(unsigned int ms){
+  volatile unsigned int i,j;
+  i=100;
+  while(i--){
+    j=ms;
+    while(j--) asm("nop");
+  }
+  //Using TimerA might be cleaner.
+}