Skip to content

Commit d459f3e

Browse files
committed
Fix API bugs
1 parent 01806ed commit d459f3e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

api/scaffold/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,8 @@ def read(self, apndp, addr):
16501650
:param apndp: Address space of the register (0 for DP, 1 for AP).
16511651
:param addr: Address of the register.
16521652
"""
1653-
val = 0b0000_0100 | ((apndp & 0b1) << 3) | (addr & 0b11)
1653+
val = 0b0000_0100 | ((apndp & 0b1) << 3) | (((addr >> 2) & 1) << 1) \
1654+
| ((addr >> 3) & 1)
16541655
self.reg_cmd.write(val)
16551656
return (self.status(), self.rdata())
16561657

@@ -1680,8 +1681,9 @@ def debug_power_up(self, retry=10):
16801681
"""
16811682
Fully powers up the debug interface by writing to the CRTL/STAT register.
16821683
"""
1683-
self.clear_errors()
16841684
self.write(0, 0x4, (1 << 28) | (1 << 30))
1685+
self.clear_errors()
1686+
self.read(0, 0)
16851687
for _ in range(retry):
16861688
(status, ctrl_stat) = self.read(0, 0x4)
16871689
if ((ctrl_stat >> 29) & 0x1) == 1 and ((ctrl_stat >> 31) & 0x1) == 1:
@@ -1698,7 +1700,7 @@ def rdata(self):
16981700
"""
16991701
Retrieve the data read by the last emitted Read transaction.
17001702
"""
1701-
return int.from_bytes(self.reg_rdata.read(), 'little') | \
1703+
return int.from_bytes(self.reg_rdata.read(), 'little') << 0 | \
17021704
int.from_bytes(self.reg_rdata.read(), 'little') << 8 | \
17031705
int.from_bytes(self.reg_rdata.read(), 'little') << 16 | \
17041706
int.from_bytes(self.reg_rdata.read(), 'little') << 24

0 commit comments

Comments
 (0)