From 23bc324781eff13493d806ae073967c93d667341 Mon Sep 17 00:00:00 2001 From: Artem Garmash Date: Mon, 10 Mar 2025 23:24:12 +0100 Subject: [PATCH 1/3] Rearrange code comments --- decoders/spi/pd.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index fd9a78fd7..a789a5f9f 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -314,15 +314,16 @@ def find_clk_edge(self, miso, mosi, clk, cs, first): self.handle_bit(miso, mosi, clk, cs) def decode(self): - # The CLK input is mandatory. Other signals are (individually) - # optional. Yet either MISO or MOSI (or both) must be provided. - # Tell stacked decoders when we don't have a CS# signal. + # The CLK input is mandatory. if not self.has_channel(0): raise ChannelError('Either MISO or MOSI (or both) pins required.') + # Other signals are (individually) optional. + # Yet either MISO or MOSI (or both) must be provided. self.have_miso = self.has_channel(1) self.have_mosi = self.has_channel(2) if not self.have_miso and not self.have_mosi: raise ChannelError('Either MISO or MOSI (or both) pins required.') + # Tell stacked decoders when we don't have a CS# signal. self.have_cs = self.has_channel(3) if not self.have_cs: self.put(0, 0, self.out_python, ['CS-CHANGE', None, None]) From 83c9560cca87d84a04a76f085c63aef81a26bfd4 Mon Sep 17 00:00:00 2001 From: Artem Garmash Date: Mon, 10 Mar 2025 23:28:58 +0100 Subject: [PATCH 2/3] Improve channel error wordings --- decoders/spi/pd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index a789a5f9f..ad8898945 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -316,13 +316,13 @@ def find_clk_edge(self, miso, mosi, clk, cs, first): def decode(self): # The CLK input is mandatory. if not self.has_channel(0): - raise ChannelError('Either MISO or MOSI (or both) pins required.') + raise ChannelError('CLK pin is required.') # Other signals are (individually) optional. # Yet either MISO or MOSI (or both) must be provided. self.have_miso = self.has_channel(1) self.have_mosi = self.has_channel(2) if not self.have_miso and not self.have_mosi: - raise ChannelError('Either MISO or MOSI (or both) pins required.') + raise ChannelError('Either MISO or MOSI (or both) pins are required.') # Tell stacked decoders when we don't have a CS# signal. self.have_cs = self.has_channel(3) if not self.have_cs: From 5499595bf283d7ac73360183a451e1d8cef2fc88 Mon Sep 17 00:00:00 2001 From: Artem Garmash Date: Mon, 10 Mar 2025 23:29:49 +0100 Subject: [PATCH 3/3] Remove empty object from the wait() method call --- decoders/spi/pd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index ad8898945..d48e13957 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -340,7 +340,7 @@ def decode(self): # process the very first sample before checking for edges. The # previous implementation did this by seeding old values with # None, which led to an immediate "change" in comparison. - (clk, miso, mosi, cs) = self.wait({}) + (clk, miso, mosi, cs) = self.wait() self.find_clk_edge(miso, mosi, clk, cs, True) while True: