remove buggy workaround on read
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Sat, 15 Sep 2012 18:13:18 +0000 (20:13 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Sat, 15 Sep 2012 18:13:18 +0000 (20:13 +0200)
spi2Csr/tools/uart2Spi.py

index cac9b3cf02593efc1e57b5e6775d13db2df8a0dd..9f5568df127afe966650d3db311193e25334276d 100644 (file)
@@ -12,17 +12,16 @@ class Uart2Spi:
                self.port = port
                self.baudrate = baudrate
                self.debug = debug
-               self.uart = serial.Serial(port, baudrate, timeout=0.01)
+               self.uart = serial.Serial(port, baudrate, timeout=0.25)
        
        def read(self, addr):
-               while True:
-                       write_b(self.uart, 0x02)
-                       write_b(self.uart, (addr>>8)&0xFF)
-                       write_b(self.uart, (addr&0xFF))
-                       write_b(self.uart, 0x00)
-                       read = self.uart.read()
-                       if len(read) == 1:
-                               break
+               write_b(self.uart, 0x02)
+               write_b(self.uart, (addr>>8)&0xFF)
+               write_b(self.uart, (addr&0xFF))
+               write_b(self.uart, 0x00)
+               read = self.uart.read()
+               if self.debug:
+                       print("RD @ %04X" %addr)
                return int(read[0])
        
        def read_n(self, addr, n, endianess = "LE"):
@@ -33,7 +32,10 @@ class Uart2Spi:
                                r += self.read(addr+i)<<(8*i)
                        elif endianess == "LE":
                                r += self.read(addr+words-1-i)<<(8*i)
+               if self.debug:
+                       print("RD @ %04X" %addr)
                return r
+               
        
        def write(self, addr, data):
                write_b(self.uart, 0x01)