Skip to content

Commit

Permalink
Fix API bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cchr-ledger committed Aug 1, 2024
1 parent 01806ed commit f5f8a5a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/scaffold/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit f5f8a5a

Please sign in to comment.