Register names for NRF.
[goodfet] / client / GoodFETSPI.py
index e0a6126..0020ec2 100644 (file)
@@ -29,7 +29,9 @@ class GoodFETSPIFlash(GoodFETSPI):
     JEDECmanufacturers={0xFF: "MISSING",
                         0xEF: "Winbond",
                         0xC2: "MXIC",
-                        0x20: "Numonyx/ST"
+                        0x20: "Numonyx/ST",
+                        0x1F: "Atmel",
+                        0x01: "AMD/Spansion"
                         };
 
     JEDECdevices={0xFFFFFF: "MISSING",
@@ -61,6 +63,7 @@ class GoodFETSPIFlash(GoodFETSPI):
         """Grab an SPI Flash ROM's JEDEC bytes."""
         data=[0x9f, 0, 0, 0];
         data=self.SPItrans(data);
+        
         self.JEDECmanufacturer=ord(data[1]);
         self.JEDECtype=ord(data[2]);
         self.JEDECcapacity=ord(data[3]);
@@ -78,30 +81,31 @@ class GoodFETSPIFlash(GoodFETSPI):
               0];
         self.SPItrans(data);
         return ord(self.data[4]);
-    def SPIpeekblock(self,adr,blocks=1):
+    def SPIpeekblock(self,adr):
         """Grab a few block from an SPI Flash ROM.  Block size is unknown"""
         data=[(adr&0xFF0000)>>16,
               (adr&0xFF00)>>8,
-              adr&0xFF,
-              blocks];
+              adr&0xFF];
         
-        self.writecmd(0x01,0x02,4,data,blocks);
+        self.writecmd(0x01,0x02,3,data);
         return self.data;
     
     def SPIpokebyte(self,adr,val):
         self.SPIpokebytes(adr,[val]);
     def SPIpokebytes(self,adr,data):
-        #self.SPIwriteenable();
-        adranddata=[(adr&0xFF0000)>>16,
-              (adr&0xFF00)>>8,
-              adr&0xFF
-              ]+data;
+        #Used to be 24 bits, BE, not 32 bits, LE.
+        adranddata=[adr&0xFF,
+                    (adr&0xFF00)>>8,
+                    (adr&0xFF0000)>>16,
+                    0, #MSB
+                    ]+data;
+        #print "%06x: poking %i bytes" % (adr,len(data));
         self.writecmd(0x01,0x03,
                       len(adranddata),adranddata);
         
     def SPIchiperase(self):
         """Mass erase an SPI Flash ROM."""
-        self.writecmd(0x01,0x81,0,[]);
+        self.writecmd(0x01,0x81);
     def SPIwriteenable(self):
         """SPI Flash Write Enable"""
         data=[0x06];