From 50da5bfbf011dc4d675dc012e4b46401a43b76ad Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Sat, 15 Sep 2012 20:13:18 +0200 Subject: [PATCH] remove buggy workaround on read --- spi2Csr/tools/uart2Spi.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/spi2Csr/tools/uart2Spi.py b/spi2Csr/tools/uart2Spi.py index cac9b3cf..9f5568df 100644 --- a/spi2Csr/tools/uart2Spi.py +++ b/spi2Csr/tools/uart2Spi.py @@ -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) -- 2.30.2