X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Flib%2Fcommand.c;h=dadffbd0e4fa0dd5a8fe28f3e4216a389e1e8d6a;hp=c9c1b1cbbbc7a523906598fe0e72b089a062dc74;hb=6c9b0c0ee024ae117e2b99698fab53556a25eda1;hpb=6a87a627534bd71abda0c446269dd03c5cad4a42 diff --git a/firmware/lib/command.c b/firmware/lib/command.c index c9c1b1c..dadffbd 100644 --- a/firmware/lib/command.c +++ b/firmware/lib/command.c @@ -1,12 +1,45 @@ -//! Different command handling functions. +/*! \file command.c + \author Travis Goodspeed + \brief These functions manage command interpretation. +*/ + +#include "command.h" +#include "platform.h" +#include unsigned char cmddata[256]; +unsigned char silent=0; + +//! 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++)); +} + +/*! \brief Transmit a debug string. + + Transmits a debugging string that is to be printed + out of line by the client. This is just for record-keeping; + it is not considered a proper reply to a query. + */ +void debugstr(const char *str){ + txstring(0xFF,0xFF,str); +} + -//!Transmit data. +//! Transmit data. void txdata(unsigned char app, unsigned char verb, unsigned char len){ unsigned int i=0; + if(silent) + return; serial_tx(app); serial_tx(verb); serial_tx(len); @@ -14,3 +47,22 @@ void txdata(unsigned char app, 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. +}