From 1071b42a0f69b1539ac3d0da160fc8f74da97b90 Mon Sep 17 00:00:00 2001 From: travisutk Date: Tue, 30 Oct 2012 19:40:49 +0000 Subject: [PATCH] New rates, array of supported rates. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1301 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/GoodFETMCPCAN.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/client/GoodFETMCPCAN.py b/client/GoodFETMCPCAN.py index b75c034..165d972 100644 --- a/client/GoodFETMCPCAN.py +++ b/client/GoodFETMCPCAN.py @@ -32,8 +32,11 @@ class GoodFETMCPCAN(GoodFETSPI): # packets. It can be manually disabled later. self.poke8(0x60,0xFF); #TODO Does this have any unpleasant side effects? - #Set the default rate of 125kHz. - self.MCPsetrate(125); + #Set the default rate. + self.MCPsetrate(); + + #Array of supported rates. + MCPrates=[100,125,250,500,1000]; def MCPsetrate(self,rate=125): """Sets the data rate in kHz.""" @@ -79,18 +82,21 @@ class GoodFETMCPCAN(GoodFETSPI): CNF1=0x04; CNF2=0xB8; CNF3=0x05; - elif rate==500: - #500 kHz, 20 TQ - CNF1=0x00; - CNF2=0xBA; - CNF3=0x07; - pass; elif rate==100: #100 kHz, 20 TQ CNF1=0x04; CNF2=0xBA; CNF3=0x07; - pass; + elif rate==250: + #256 kHz, 20 TQ + CNF1=0x01; + CNF2=0xBA; + CNF3=0x07; + elif rate==500: + #500 kHz, 20 TQ + CNF1=0x00; + CNF2=0xBA; + CNF3=0x07; elif rate==1000: #1,000 kHz, 10 TQ CNF1=0x00; @@ -98,7 +104,7 @@ class GoodFETMCPCAN(GoodFETSPI): CNF3=0x02; print "WARNING: Because of chip errata, this probably won't work." else: - print "Given unsupported rate of %i kHz."; + print "Given unsupported rate of %i kHz." % rate; print "Defaulting to 125kHz."; CNF1=0x04; CNF2=0xB8; -- 2.20.1