summaryrefslogtreecommitdiff
path: root/decoders/enc28j60/pd.py
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2019-05-15 01:16:52 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2019-05-15 01:22:14 +0200
commit72db471edc03396ac2d0e3ffd490984617978346 (patch)
treee60d1482484eecd56696e7c406c4c5dc8315628e /decoders/enc28j60/pd.py
parentfbf652db22b8b5a0f86525b1f15edbfb8d3fa4a5 (diff)
downloadlibsigrokdecode-72db471edc03396ac2d0e3ffd490984617978346.tar.gz
libsigrokdecode-72db471edc03396ac2d0e3ffd490984617978346.zip
enc28j60: Factor out self.putc().
Diffstat (limited to 'decoders/enc28j60/pd.py')
-rw-r--r--decoders/enc28j60/pd.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/decoders/enc28j60/pd.py b/decoders/enc28j60/pd.py
index 0bf4c61..d1a601f 100644
--- a/decoders/enc28j60/pd.py
+++ b/decoders/enc28j60/pd.py
@@ -89,6 +89,9 @@ class Decoder(srd.Decoder):
def start(self):
self.ann = self.register(srd.OUTPUT_ANN)
+ def putc(self, data):
+ self.put(self.cmd_ss, self.cmd_es, self.ann, data)
+
def _process_command(self):
if len(self.mosi) == 0:
self.active = False
@@ -173,7 +176,7 @@ class Decoder(srd.Decoder):
]])
def _put_command_warning(self, reason):
- self.put(self.cmd_ss, self.cmd_es, self.ann, [
+ self.putc([
ANN_WARNING,
[
'Warning: {0}'.format(reason),
@@ -181,8 +184,7 @@ class Decoder(srd.Decoder):
]])
def _process_rcr(self):
- self.put(self.cmd_ss, self.cmd_es,
- self.ann, [ANN_RCR, ['Read Control Register', 'RCR']])
+ self.putc([ANN_RCR, ['Read Control Register', 'RCR']])
if (len(self.mosi) != 2) and (len(self.mosi) != 3):
self._put_command_warning('Invalid command length.')
@@ -223,7 +225,7 @@ class Decoder(srd.Decoder):
self._put_command_warning('Invalid header byte.')
return
- self.put(self.cmd_ss, self.cmd_es, self.ann, [
+ self.putc([
ANN_RBM,
[
'Read Buffer Memory: Length {0}'.format(
@@ -235,8 +237,7 @@ class Decoder(srd.Decoder):
self._put_data_byte(self.miso[i], i)
def _process_wcr(self):
- self.put(self.cmd_ss, self.cmd_es,
- self.ann, [ANN_WCR, ['Write Control Register', 'WCR']])
+ self.putc([ANN_WCR, ['Write Control Register', 'WCR']])
if len(self.mosi) != 2:
self._put_command_warning('Invalid command length.')
@@ -254,7 +255,7 @@ class Decoder(srd.Decoder):
self._put_command_warning('Invalid header byte.')
return
- self.put(self.cmd_ss, self.cmd_es, self.ann, [
+ self.putc([
ANN_WBM,
[
'Write Buffer Memory: Length {0}'.format(
@@ -266,8 +267,7 @@ class Decoder(srd.Decoder):
self._put_data_byte(self.mosi[i], i)
def _process_bfc(self):
- self.put(self.cmd_ss, self.cmd_es,
- self.ann, [ANN_BFC, ['Bit Field Clear', 'BFC']])
+ self.putc([ANN_BFC, ['Bit Field Clear', 'BFC']])
if len(self.mosi) != 2:
self._put_command_warning('Invalid command length.')
@@ -283,8 +283,7 @@ class Decoder(srd.Decoder):
self.bsel1 = 0
def _process_bfs(self):
- self.put(self.cmd_ss, self.cmd_es,
- self.ann, [ANN_BFS, ['Bit Field Set', 'BFS']])
+ self.putc([ANN_BFS, ['Bit Field Set', 'BFS']])
if len(self.mosi) != 2:
self._put_command_warning('Invalid command length.')
@@ -300,8 +299,7 @@ class Decoder(srd.Decoder):
self.bsel1 = 1
def _process_src(self):
- self.put(self.cmd_ss, self.cmd_es,
- self.ann, [ANN_SRC, ['System Reset Command', 'SRC']])
+ self.putc([ANN_SRC, ['System Reset Command', 'SRC']])
if len(self.mosi) != 1:
self._put_command_warning('Invalid command length.')