GoodFET for Chipcon can erase chip and read/write info flash.
[goodfet] / client / GoodFETCC.py
index d171f86..7f6e334 100644 (file)
@@ -64,7 +64,10 @@ class GoodFETCC(GoodFET):
     def CCwr_config(self,config):
         """Write the config register of a Chipcon."""
         self.writecmd(0x30,0x81,1,[config&0xFF]);
-    
+    def CClockchip(self):
+        """Set the flash lock bit in info mem."""
+        self.writecmd(0x30, 0x9A, 0, None);
+        
     CCversions={0x0100:"CC1110",
                 0x8500:"CC2430",
                 0x8900:"CC2431",
@@ -114,9 +117,9 @@ class GoodFETCC(GoodFET):
         return ord(self.data[0])
     CCstatusbits={0x80 : "erased",
                   0x40 : "pcon_idle",
-                  0x20 : "halted",
+                  0x20 : "cpu_halted",
                   0x10 : "pm0",
-                  0x08 : "halted",
+                  0x08 : "halt_status",
                   0x04 : "locked",
                   0x02 : "oscstable",
                   0x01 : "overflow"};
@@ -146,4 +149,14 @@ class GoodFETCC(GoodFET):
     def CCstep_instr(self):
         """Step one instruction."""
         self.writecmd(0x30,0x89,0,self.data);
-
+    def CCeraseflashbuffer(self):
+        """Erase the 2kB flash buffer"""
+        self.writecmd(0x30,0x99);
+    def CCflashpage(self,adr):
+        """Flash 2kB a page of flash from 0xF000 in XDATA"""
+        data=[adr&0xFF,
+              (adr>>8)&0xFF,
+              (adr>>16)&0xFF,
+              (adr>>24)&0xFF];
+        print "Flashing buffer to 0x%06x" % adr;
+        self.writecmd(0x30,0x95,4,data);