Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions libsigrokdecode4DSL/decoders/nrf24l01/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class ChannelError(Exception):
}

xn297_regs = {
0x19: ('DEMOD_CAL', 5),
0x1e: ('RF_CAL', 7),
0x19: ('DEMOD_CAL', 1),
0x1a: ('RF_CAL2', 6),
0x1b: ('DEM_CAL2', 3),
0x1e: ('RF_CAL', 3),
0x1f: ('BB_CAL', 5),
}

Expand Down Expand Up @@ -153,7 +155,7 @@ def decode_command(self, pos, b):

self.cmd, self.dat, self.min, self.max = c

if self.cmd in ('W_REGISTER', 'ACTIVATE'):
if self.cmd in ('W_REGISTER', 'ACTIVATE', 'RST_FSPI'):
# Don't output anything now, the command is merged with
# the data bytes following it.
self.mb_s = pos[0]
Expand All @@ -177,7 +179,9 @@ def parse_command(self, b):
- minimum number of following bytes
- maximum number of following bytes
'''

buflen = 32
if self.options['chip'] == 'xn297':
buglen = 64
if (b & 0xe0) in (0b00000000, 0b00100000):
c = 'R_REGISTER' if not (b & 0xe0) else 'W_REGISTER'
d = b & 0x1f
Expand All @@ -187,15 +191,15 @@ def parse_command(self, b):
# nRF24L01 only
return ('ACTIVATE', None, 1, 1)
if b == 0b01100001:
return ('R_RX_PAYLOAD', None, 1, 32)
return ('R_RX_PAYLOAD', None, 1, buflen)
if b == 0b01100000:
return ('R_RX_PL_WID', None, 1, 1)
if b == 0b10100000:
return ('W_TX_PAYLOAD', None, 1, 32)
return ('W_TX_PAYLOAD', None, 1, buflen)
if b == 0b10110000:
return ('W_TX_PAYLOAD_NOACK', None, 1, 32)
return ('W_TX_PAYLOAD_NOACK', None, 1, buflen)
if (b & 0xf8) == 0b10101000:
return ('W_ACK_PAYLOAD', b & 0x07, 1, 32)
return ('W_ACK_PAYLOAD', b & 0x07, 1, buflen)
if b == 0b11100001:
return ('FLUSH_TX', None, 0, 0)
if b == 0b11100010:
Expand All @@ -205,6 +209,14 @@ def parse_command(self, b):
if b == 0b11111111:
return ('NOP', None, 0, 0)

if self.options['chip'] == 'xn297':
if b == 0b11111101:
return ('CE_FSPI_ON', None, 1, 1)
if b == 0b11111100:
return ('CE_FSPI_OFF', None, 1, 1)
if b == 0b01010011:
return ('RST_FSPI', None, 1, 1)

def decode_register(self, pos, ann, regid, data):
'''Decodes a register.

Expand Down Expand Up @@ -280,9 +292,20 @@ def finish_command(self, pos):
msg = 'Payload width = {}'.format(self.mb[0][1])
self.putp(pos, self.ann_reg, msg)
elif self.cmd == 'ACTIVATE':
self.putp(pos, self.ann_cmd, self.format_command())
if self.mosi_bytes()[0] != 0x73:
if self.mosi_bytes()[0] == 0x8c:
self.cmd = 'DEACTIVATE'
elif self.mosi_bytes()[0] != 0x73:
self.warn(pos, 'wrong data for "ACTIVATE" command')
self.putp(pos, self.ann_cmd, self.format_command())
elif self.cmd == 'RST_FSPI':
if self.mosi_bytes()[0] == 0x5a:
self.cmd = 'RST_FSPI_HOLD'
elif self.mosi_bytes()[0] == 0xa5:
self.cmd = 'RST_FSPI_RELS'
else:
self.warn(pos, 'wrong data for "RST_FSPI" command')
self.putp(pos, self.ann_cmd, self.format_command())


def decode(self, ss, es, data):
if not self.requirements_met:
Expand Down