c29ca1a72d29624579645265361b60ae30b5b553
[goodfet] / client / goodfet.nrf
1 #!/usr/bin/env python
2
3 #GoodFET SPI Flash Client
4 #by Travis Goodspeed
5
6 import sys;
7 import binascii;
8 import array;
9
10 from GoodFETNRF import GoodFETNRF;
11 from intelhex import IntelHex;
12
13 if(len(sys.argv)==1):
14     print "Usage: %s verb [objects]\n" % sys.argv[0];
15     print "%s info" % sys.argv[0];
16     print "%s test" % sys.argv[0];
17     sys.exit();
18
19 #Initialize FET and set baud rate
20 client=GoodFETNRF();
21 print "Connecting."
22 client.serInit()
23
24 print "Connected."
25 client.NRFsetup();
26 print "Setup."
27 client.status();
28
29
30 if(sys.argv[1]=="test"):
31     # Set PWR_UP=1 and PRIM_RX=0 in CONFIG.
32     client.poke(0x00,2);
33     #Delay of 1.5ms by round-trip.
34     # Set CONT_WAVE, PLL_LOCK, and 0dBm in RF_SETUP
35     client.poke(0x06,8+10+4+2); 
36     client.RF_freq(2480 * 10**6);
37     
38     #Print register, no idea why.
39     for r in range(0,30):
40         print "r[0x%02x]=0x%02x" % (r,client.peek(r));
41     print "SMAC=%010x" % client.RF_getsmac();
42
43 if(sys.argv[1]=="regs"):
44     for r in range(0,30):
45         print "r[0x%02x]=0x%02x" % (r,client.peek(r));