Skip to content

Commit

Permalink
Correct extracted address values for AP r/w.
Browse files Browse the repository at this point in the history
  • Loading branch information
flit committed Apr 10, 2021
1 parent 1e7d2a1 commit af4d9d5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pyocd_pemicro/pemicro_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ class PEMicroProbe(DebugProbe):
DP_SELECT = 0x8

# Bitmasks for AP register address fields.
APBANKSEL = 0x000000f0
APREG_MASK = 0x000000fc # APBANKSEL | A[3:2]
APSEL = 0xff000000
APSEL_SHIFT = 24
APSEL_APBANKSEL = APSEL | APBANKSEL

## Part of the error message for exceptions raised when there isn't a PEMicro library
# matching the system's architecture, or other similar reasons.
Expand Down Expand Up @@ -300,7 +299,9 @@ def write_dp(self, addr, data, now = True):
def read_ap(self, addr, now=True):
assert isinstance(addr, int)
try:
value = self._pemicro.read_ap_register(addr=(addr & self.APADDR), now=now, apselect= ((addr & self.APSEL_APBANKSEL) >> self.APSEL_SHIFT))
reg_addr = addr & self.APREG_MASK
ap_select = (addr & self.APSEL) >> self.APSEL_SHIFT
value = self._pemicro.read_ap_register(addr=reg_addr, now=now, apselect=ap_select)
except PEMicroTransferException as exc:
raise self._convert_exception(exc) from exc
else:
Expand All @@ -312,7 +313,9 @@ def read_reg_cb():
def write_ap(self, addr, data, now = True):
assert isinstance(addr, int)
try:
self._pemicro.write_ap_register(addr=(addr & self.APADDR), value=data, apselect=((addr & self.APSEL_APBANKSEL) >> self.APSEL_SHIFT))
reg_addr = addr & self.APREG_MASK
ap_select = (addr & self.APSEL) >> self.APSEL_SHIFT
self._pemicro.write_ap_register(addr=reg_addr, value=data, apselect=ap_select)
except PEMicroTransferException as exc:
raise self._convert_exception(exc) from exc

Expand Down

0 comments on commit af4d9d5

Please sign in to comment.