diff --git a/api/scaffold/__init__.py b/api/scaffold/__init__.py index 304481f..ccf26ba 100644 --- a/api/scaffold/__init__.py +++ b/api/scaffold/__init__.py @@ -1650,7 +1650,8 @@ def read(self, apndp, addr): :param apndp: Address space of the register (0 for DP, 1 for AP). :param addr: Address of the register. """ - val = 0b0000_0100 | ((apndp & 0b1) << 3) | (addr & 0b11) + val = 0b0000_0100 | ((apndp & 0b1) << 3) | (((addr >> 2) & 1) << 1) \ + | ((addr >> 3) & 1) self.reg_cmd.write(val) return (self.status(), self.rdata()) @@ -1682,6 +1683,7 @@ def debug_power_up(self, retry=10): """ self.clear_errors() self.write(0, 0x4, (1 << 28) | (1 << 30)) + self.read(0, 0) for _ in range(retry): (status, ctrl_stat) = self.read(0, 0x4) if ((ctrl_stat >> 29) & 0x1) == 1 and ((ctrl_stat >> 31) & 0x1) == 1: @@ -1698,10 +1700,10 @@ def rdata(self): """ Retrieve the data read by the last emitted Read transaction. """ - return int.from_bytes(self.reg_rdata.read(), 'little') | \ - int.from_bytes(self.reg_rdata.read(), 'little') << 8 | \ - int.from_bytes(self.reg_rdata.read(), 'little') << 16 | \ - int.from_bytes(self.reg_rdata.read(), 'little') << 24 + return int.from_bytes(self.reg_rdata.read(), 'little') << 16 | \ + int.from_bytes(self.reg_rdata.read(), 'little') << 24 | \ + int.from_bytes(self.reg_rdata.read(), 'little') << 0 | \ + int.from_bytes(self.reg_rdata.read(), 'little') << 8 class IOMode(Enum):