Skip to content

Commit ade96e5

Browse files
committed
add option to skip n SPI data bits
1 parent 73cb546 commit ade96e5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

decoders/spi/pd.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class Decoder(srd.Decoder):
100100
'values': (0, 1)},
101101
{'id': 'bitorder', 'desc': 'Bit order',
102102
'default': 'msb-first', 'values': ('msb-first', 'lsb-first')},
103+
{'id': 'skipbits', 'desc': 'Skip bits from start',
104+
'default': 0},
103105
{'id': 'wordsize', 'desc': 'Word size', 'default': 8},
104106
)
105107
annotations = (
@@ -131,6 +133,7 @@ def __init__(self):
131133
def reset(self):
132134
self.samplerate = None
133135
self.bitcount = 0
136+
self.bitsskipped = 0
134137
self.misodata = self.mosidata = 0
135138
self.misobits = []
136139
self.mosibits = []
@@ -310,6 +313,10 @@ def find_clk_edge(self, miso, mosi, clk, cs, first):
310313
elif mode == 3 and clk == 0: # Sample on rising clock edge
311314
return
312315

316+
if self.bitsskipped < self.options["skipbits"]:
317+
self.bitsskipped += 1
318+
return
319+
313320
# Found the correct clock edge, now get the SPI bit(s).
314321
self.handle_bit(miso, mosi, clk, cs)
315322

0 commit comments

Comments
 (0)