0x1d: ('FEATURE', 1),
}
+xn297_regs = {
+ 0x19: ('DEMOD_CAL', 5),
+ 0x1e: ('RF_CAL', 7),
+ 0x1f: ('BB_CAL', 5),
+}
+
class Decoder(srd.Decoder):
api_version = 2
id = 'nrf24l01'
license = 'gplv2+'
inputs = ['spi']
outputs = ['nrf24l01']
+ options = (
+ {'id': 'chip', 'desc': 'Chip type',
+ 'default': 'nrf24l01', 'values': ('nrf24l01', 'xn297')},
+ )
annotations = (
# Sent from the host to the chip.
('cmd', 'Commands sent to the device'),
def __init__(self, **kwargs):
self.next()
+ self.requirements_met = True
+ self.cs_was_released = False
def start(self):
self.out_ann = self.register(srd.OUTPUT_ANN)
+ if self.options['chip'] == 'xn297':
+ regs.update(xn297_regs)
def warn(self, pos, msg):
'''Put a warning message 'msg' at 'pos'.'''
self.warn(pos, 'wrong data for "ACTIVATE" command')
def decode(self, ss, es, data):
+ if not self.requirements_met:
+ return
+
ptype, data1, data2 = data
if ptype == 'CS-CHANGE':
+ if data1 is None:
+ if data2 is None:
+ self.requirements_met = False
+ raise ChannelError('CS# pin required.')
+ elif data2 == 1:
+ self.cs_was_released = True
+
if data1 == 0 and data2 == 1:
# Rising edge, the complete command is transmitted, process
# the bytes that were send after the command byte.
self.finish_command((self.mb_s, self.mb_e))
self.next()
- elif ptype == 'DATA':
+ self.cs_was_released = True
+ elif ptype == 'DATA' and self.cs_was_released:
mosi, miso = data1, data2
pos = (ss, es)
if miso is None or mosi is None:
+ self.requirements_met = False
raise ChannelError('Both MISO and MOSI pins required.')
if self.first: