added new mcpCAN communication file to allow for easier testing and data storage.
[goodfet] / client / GoodFETSLC2.py
1 #!/usr/bin/env python\r
2 # GoodFET Client Library\r
3 \r
4 import sys;\r
5 import binascii;\r
6 \r
7 from GoodFET import GoodFET;\r
8 \r
9 class GoodFETSLC2(GoodFET):\r
10         """GoodFET variant for the Silicon lab C2 protocol"""\r
11         APP=0x06;\r
12         \r
13         def setup(self):\r
14                 """Setup the SLC2 protocol"""\r
15                 self.writecmd(0x06, 0x10, 0);\r
16 \r
17         def reset(self):\r
18                 self.writecmd(0x06, 0x84, 0);\r
19                 \r
20         def peekblock(self, addr, len):\r
21                 """Grab block from FLASH at address addr"""\r
22                 dat= [addr&0xFF, (addr&0xFF00)>>8];\r
23                 self.writecmd(0x06, 0x02, 2, dat);\r
24                 return self.data;\r
25                 \r
26         def pokeblock(self, addr, len, data):\r
27                 d = [len, data];\r
28                 self.writecmd(0x06, 0x03, len, d);\r
29                 \r
30         def getdevid(self):\r
31                 return self.writecmd(0x06, 0x80, 0, []);\r
32         \r
33         def getrevid(self):\r
34                 return self.writecmd(0x06, 0x81, 0, []);\r
35                 \r
36         def page_erase(self, addr):\r
37                 self.writecmd(0x06, 0x82, 1, addr);\r
38         \r
39         def device_erase(self):\r
40                 self.writecmd(0x06, 0x83, 0, []);\r