Added a GLITCHTIME verb (0x82) for timing the execution of a verb.
[goodfet] / firmware / apps / chipcon / chipcon.c
index ccacb95..92542fc 100644 (file)
@@ -142,14 +142,17 @@ void cchandle(unsigned char app,
     break;
   case READ:  //Write a command and return 1-byte reply.
     cccmd(len);
-    ccread(1);
+    if(cmddata[0]&0x4)
+      ccread(1);
     txdata(app,verb,1);
+    
     break;
   case WRITE: //Write a command with no reply.
     cccmd(len);
     txdata(app,verb,0);
     break;
   case START://enter debugger
+    ccsetup();
     ccdebuginit();
     txdata(app,verb,0);
     break;
@@ -278,7 +281,7 @@ void cc_wr_config(unsigned char config){
 
 //! Locks the chip.
 void cc_lockchip(){
-  register i;
+  register int i;
   
   debugstr("Locking chip.");
   cc_wr_config(1);//Select Info Flash 
@@ -409,12 +412,12 @@ void cc_write_flash_page(u32 adr){
   cmddata[1]=0xc7;
   cmddata[2]=0x51;
   cc_debug_instr(3);
-  //debugstr("Loaded bank info.");
+  debugstr("Loaded bank info.");
   
   cc_set_pc(0xf000+FLASHPAGE_SIZE);//execute code fragment
   cc_resume();
   
-  //debugstr("Executing.");
+  debugstr("Executing.");
   
   
   while(!(cc_read_status()&CC_STATUS_CPUHALTED)){
@@ -422,7 +425,7 @@ void cc_write_flash_page(u32 adr){
   }
   
   
-  //debugstr("Done flashing.");
+  debugstr("Done flashing.");
   
   P1OUT&=~1;//clear LED
 }
@@ -555,8 +558,7 @@ for (n = 0; n < count; n++) {
 unsigned char cc_peekdatabyte(unsigned int adr){
   unsigned char
     hb=(adr&0xFF00)>>8,
-    lb=adr&0xFF,
-    toret;
+    lb=adr&0xFF;
   
   //MOV DPTR, adr
   cc_debug(3, 0x90, hb, lb);