import sigrokdecode as srd
from .lists import *
+TX, RX = range(2)
+
class Decoder(srd.Decoder):
api_version = 3
id = 'mrf24j40'
('lread', 'Long register read commands'),
('lwrite', 'Long register write commands'),
('warning', 'Warnings'),
+ ('tx-frame', 'TX frame'),
+ ('rx-frame', 'RX frame'),
)
annotation_rows = (
('read', 'Read', (0, 2)),
('write', 'Write', (1, 3)),
('warnings', 'Warnings', (4,)),
+ ('tx-frames', 'TX frames', (5,)),
+ ('rx-frames', 'RX frames', (6,)),
)
def __init__(self):
def reset(self):
self.ss_cmd, self.es_cmd = 0, 0
- self.mosi_bytes = []
- self.miso_bytes = []
+ self.ss_frame, self.es_frame = [0, 0], [0, 0]
+ self.mosi_bytes, self.miso_bytes = [], []
+ self.framecache = [[], []]
def start(self):
self.out_ann = self.register(srd.OUTPUT_ANN)
write = self.mosi_bytes[0] & 0x1
reg = (self.mosi_bytes[0] >> 1) & 0x3f
reg_desc = sregs.get(reg, 'illegal')
+ for rxtx in (RX, TX):
+ if self.framecache[rxtx] == []:
+ continue
+ bit0 = self.mosi_bytes[1] & (1 << 0)
+ if rxtx == TX and not (reg_desc == 'TXNCON' and bit0 == 1):
+ continue
+ if rxtx == RX and not (reg_desc == 'RXFLUSH' and bit0 == 1):
+ continue
+ idx = 5 if rxtx == TX else 6
+ xmitdir = 'TX' if rxtx == TX else 'RX'
+ frame = ' '.join(['%02X' % b for b in self.framecache[rxtx]])
+ self.put(self.ss_frame[rxtx], self.es_frame[rxtx], self.out_ann,
+ [idx, ['%s frame: %s' % (xmitdir, frame)]])
+ self.framecache[rxtx] = []
if write:
self.putx([1, ['%s: %#x' % (reg_desc, self.mosi_bytes[1])]])
else:
else:
self.putx([2, ['%s: %#x' % (reg_desc, self.miso_bytes[2])]])
+ for rxtx in (RX, TX):
+ if rxtx == RX and reg_desc[:3] != 'RX:':
+ continue
+ if rxtx == TX and reg_desc[:3] != 'TX:':
+ continue
+ if len(self.framecache[rxtx]) == 0:
+ self.ss_frame[rxtx] = self.ss_cmd
+ self.es_frame[rxtx] = self.es_cmd
+ self.framecache[rxtx] += [self.mosi_bytes[2]] if rxtx == TX else [self.miso_bytes[2]]
+
def decode(self, ss, es, data):
ptype = data[0]
if ptype == 'CS-CHANGE':