Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to skip n SPI data bits #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions decoders/spi/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class Decoder(srd.Decoder):
'values': (0, 1)},
{'id': 'bitorder', 'desc': 'Bit order',
'default': 'msb-first', 'values': ('msb-first', 'lsb-first')},
{'id': 'skipbits', 'desc': 'Skip bits from start',
'default': 0},
{'id': 'wordsize', 'desc': 'Word size', 'default': 8},
)
annotations = (
Expand Down Expand Up @@ -131,6 +133,7 @@ def __init__(self):
def reset(self):
self.samplerate = None
self.bitcount = 0
self.bitsskipped = 0
self.misodata = self.mosidata = 0
self.misobits = []
self.mosibits = []
Expand Down Expand Up @@ -310,6 +313,10 @@ def find_clk_edge(self, miso, mosi, clk, cs, first):
elif mode == 3 and clk == 0: # Sample on rising clock edge
return

if self.bitsskipped < self.options["skipbits"]:
self.bitsskipped += 1
return

# Found the correct clock edge, now get the SPI bit(s).
self.handle_bit(miso, mosi, clk, cs)

Expand Down