A major refactor of the GoodFET firmware build system and apps to give better
[goodfet] / firmware / apps / plugins / ps2.c
index aa43efc..b751416 100644 (file)
 #include "ps2.h"
 #include "jtag.h"
 
+//! Handles a monitor command.
+void ps2_handle_fn( uint8_t const app,
+                                       uint8_t const verb,
+                                       uint32_t const len);
+
+
+// define the ps2 app's app_t
+app_t const ps2_app = {
+
+       /* app number */
+       PS2,
+
+       /* handle fn */
+       ps2_handle_fn,
+
+       /* name */
+       "PS2",
 
-u16 mclock=0;
+       /* desc */
+       "\tThe PS2 app spies on PS/2.  For now, it just reports the\n"
+       "\tinter-character timing information.\n"
+};
+
+
+u32 mclock=0;
 u32 clock=0;
 
 // Timer A0 interrupt service routine
@@ -30,14 +53,12 @@ interrupt(TIMERA0_VECTOR) Timer_A (void)
     TDO P5.2
 */
 
-// This is just a plugin for now.
-#define ps2handle pluginhandle
-
 u32 oldclock=0;
 //! Handles a monitor command.
-int ps2handle(unsigned char app,
-             unsigned char verb,
-             unsigned int len){
+void ps2_handle_fn( uint8_t const app,
+                                       uint8_t const verb,
+                                       uint32_t const len)
+{
   switch(verb){
   case START:
     WDTCTL = WDTPW + WDTHOLD;             // Stop WDT
@@ -60,10 +81,13 @@ int ps2handle(unsigned char app,
        while((P5IN&TDI));// && P5IN&TDO));
       
       //Transmit the data only if it is new.
-      
-      if((cmddatalong[0]=clock-oldclock)>0x80)
+      if((clock-oldclock)>0x100){
+       cmddatalong[0]=clock;//-oldclock;
+       cmddatalong[0]-=oldclock;
+       oldclock=clock;
+       
        txdata(app,verb,4);
-      oldclock=clock;
+      }
     }
     break;
   case STOP: