From d459f3e07eb3582a56a4e383c90070678868941d Mon Sep 17 00:00:00 2001 From: cchr Date: Thu, 1 Aug 2024 20:11:27 +0200 Subject: [PATCH] Fix API bugs --- api/scaffold/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/scaffold/__init__.py b/api/scaffold/__init__.py index 304481f..5625789 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()) @@ -1680,8 +1681,9 @@ def debug_power_up(self, retry=10): """ Fully powers up the debug interface by writing to the CRTL/STAT register. """ - self.clear_errors() self.write(0, 0x4, (1 << 28) | (1 << 30)) + self.clear_errors() + 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,7 +1700,7 @@ def rdata(self): """ Retrieve the data read by the last emitted Read transaction. """ - return int.from_bytes(self.reg_rdata.read(), 'little') | \ + return int.from_bytes(self.reg_rdata.read(), 'little') << 0 | \ 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