set/get SYNC on CC2420.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 24 Feb 2011 02:07:09 +0000 (02:07 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 24 Feb 2011 02:07:09 +0000 (02:07 +0000)
Fixed warning in SetFreq.

git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@950 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETCCSPI.py
client/goodfet.ccspi

index e205811..394c7f6 100644 (file)
@@ -24,6 +24,7 @@ class GoodFETCCSPI(GoodFET):
         self.poke(0x12, 0x0500); #MDMCTRL1
         self.poke(0x1C, 0x007F); #IOCFG0
         self.poke(0x19, 0x01C4); #SECCTRL0, disabling crypto
         self.poke(0x12, 0x0500); #MDMCTRL1
         self.poke(0x1C, 0x007F); #IOCFG0
         self.poke(0x19, 0x01C4); #SECCTRL0, disabling crypto
+        self.RF_setsync();
         
     def ident(self):
         return self.peek(0x1E); #MANFIDL
         
     def ident(self):
         return self.peek(0x1E); #MANFIDL
@@ -120,10 +121,18 @@ class GoodFETCCSPI(GoodFET):
         return 0;
     def RF_setrate(self,rate=0):
         return 0;
         return 0;
     def RF_setrate(self,rate=0):
         return 0;
+    def RF_getsync(self):
+        return self.peek(0x14);
+    def RF_setsync(self,sync=0xa70F):
+        """Set the SYNC preamble.
+        Use 0xA70F for 0xA7."""
+        self.poke(0x14,sync);
+        return;
+    
     def RF_setfreq(self,frequency):
         """Set the frequency in Hz."""
         mhz=frequency/1000000;
     def RF_setfreq(self,frequency):
         """Set the frequency in Hz."""
         mhz=frequency/1000000;
-        fsctrl=self.peek(0x18)&~0x3FF;
+        fsctrl=0x8000; #self.peek(0x18)&(~0x3FF);
         fsctrl=fsctrl+int(mhz-2048)
         self.poke(0x18,fsctrl);
         self.strobe(0x02);
         fsctrl=fsctrl+int(mhz-2048)
         self.poke(0x18,fsctrl);
         self.strobe(0x02);
index 359f2c4..d361285 100755 (executable)
@@ -162,32 +162,40 @@ if(sys.argv[1]=="txpiptest"):
         client.RF_getsmac(),
         client.RF_getfreq()/10**6);
     
         client.RF_getsmac(),
         client.RF_getfreq()/10**6);
     
+    client.RF_setsync(0xFFFF);
+    
     while 1:
     while 1:
-        client.RF_txpacket([0x3f, 0x01, 0x08, 0x82,
-                            0xDE, 0xff, 0xff, 0xff,
-                            0xde, 0xad, 0xbe, 0xef,
-                            0xba, 0xbe, 0xc0,
-                            
-                            0x00, 0x00, 0x00,
-                            0x00, 0x00, 0x00,
-                            0x00, 0x00, 0x00,
-                            0x00, 0x00, 0x00,
-                            
-                            #0x00, 0xA7,  #CC2420 SFD
-                            
-                            0x0f, 0x01, 0x08, 0x82,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xde, 0xad, 0xbe, 0xef,
-                            0xba, 0xbe, 0xc0,
-                            
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            ]);
+        client.RF_txpacket([
+                0x7f, 
+                #Real header, must begin with SFD.
+                0x00, 0x00, 0x00,
+                0x00, 0xA7,
+                
+                #Length
+                0x1f, 0x01, 0x08, 0x82,
+                0xDF, 0xff, 0xff, 0xff,
+                0xde, 0xad, 0xbe, 0xef,
+                0xba, 0xbe, 0xc0,
+                
+                
+                #Preamble
+                0x00, 0x00, 0x00,
+                #SFD
+                0x00, 0xA7,  #CC2420 SFD
+                #Packet In Packet
+                0x0f, 0x01, 0x08, 0x82,
+                0xff, 0xff, 0xff, 0xff,
+                0xde, 0xad, 0xbe, 0xef,
+                0xba, 0xbe, 0xc0,
+                
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                ]);
 
 if(sys.argv[1]=="peek"):
     start=0x0000;
 
 if(sys.argv[1]=="peek"):
     start=0x0000;