summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--decoders/cc1101/pd.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/decoders/cc1101/pd.py b/decoders/cc1101/pd.py
index 8b85136..f62f18e 100644
--- a/decoders/cc1101/pd.py
+++ b/decoders/cc1101/pd.py
@@ -19,10 +19,11 @@
import sigrokdecode as srd
from collections import namedtuple
+from common.srdhelper import SrdIntEnum
from .lists import *
-ANN_STROBE, ANN_SINGLE_READ, ANN_SINGLE_WRITE, ANN_BURST_READ, \
- ANN_BURST_WRITE, ANN_STATUS_READ, ANN_STATUS, ANN_WARN = range(8)
+Ann = SrdIntEnum.from_str('Ann', 'STROBE SINGLE_READ SINGLE_WRITE BURST_READ \
+ BURST_WRITE STATUS_READ STATUS WARN')
Pos = namedtuple('Pos', ['ss', 'es'])
Data = namedtuple('Data', ['mosi', 'miso'])
@@ -48,11 +49,10 @@ class Decoder(srd.Decoder):
('warning', 'Warning'),
)
annotation_rows = (
- ('cmds', 'Commands', (ANN_STROBE,)),
- ('data', 'Data', (ANN_SINGLE_READ, ANN_SINGLE_WRITE, ANN_BURST_READ,
- ANN_BURST_WRITE, ANN_STATUS_READ)),
- ('status', 'Status register', (ANN_STATUS,)),
- ('warnings', 'Warnings', (ANN_WARN,)),
+ ('cmds', 'Commands', (Ann.STROBE,)),
+ ('data', 'Data', (Ann.prefixes('SINGLE_ BURST_ STATUS_'))),
+ ('status', 'Status register', (Ann.STATUS,)),
+ ('warnings', 'Warnings', (Ann.WARN,)),
)
def __init__(self):
@@ -68,7 +68,7 @@ class Decoder(srd.Decoder):
def warn(self, pos, msg):
'''Put a warning message 'msg' at 'pos'.'''
- self.put(pos.ss, pos.es, self.out_ann, [ANN_WARN, [msg]])
+ self.put(pos.ss, pos.es, self.out_ann, [Ann.WARN, [msg]])
def putp(self, pos, ann, msg):
'''Put an annotation message 'msg' at 'pos'.'''
@@ -114,7 +114,7 @@ class Decoder(srd.Decoder):
self.cmd, self.dat, self.min, self.max = c
if self.cmd == 'Strobe':
- self.putp(pos, ANN_STROBE, self.format_command())
+ self.putp(pos, Ann.STROBE, self.format_command())
else:
# Don't output anything now, the command is merged with
# the data bytes following it.
@@ -179,7 +179,7 @@ class Decoder(srd.Decoder):
else:
name = regid
- if regid == 'STATUS' and ann == ANN_STATUS:
+ if regid == 'STATUS' and ann == Ann.STATUS:
label = 'Status'
self.decode_status_reg(pos, ann, data, label)
else:
@@ -227,17 +227,17 @@ class Decoder(srd.Decoder):
'''Decodes the remaining data bytes at position 'pos'.'''
if self.cmd == 'Write':
- self.decode_reg(pos, ANN_SINGLE_WRITE, self.dat, self.mosi_bytes())
+ self.decode_reg(pos, Ann.SINGLE_WRITE, self.dat, self.mosi_bytes())
elif self.cmd == 'Burst write':
- self.decode_reg(pos, ANN_BURST_WRITE, self.dat, self.mosi_bytes())
+ self.decode_reg(pos, Ann.BURST_WRITE, self.dat, self.mosi_bytes())
elif self.cmd == 'Read':
- self.decode_reg(pos, ANN_SINGLE_READ, self.dat, self.miso_bytes())
+ self.decode_reg(pos, Ann.SINGLE_READ, self.dat, self.miso_bytes())
elif self.cmd == 'Burst read':
- self.decode_reg(pos, ANN_BURST_READ, self.dat, self.miso_bytes())
+ self.decode_reg(pos, Ann.BURST_READ, self.dat, self.miso_bytes())
elif self.cmd == 'Strobe':
- self.decode_reg(pos, ANN_STROBE, self.dat, self.mosi_bytes())
+ self.decode_reg(pos, Ann.STROBE, self.dat, self.mosi_bytes())
elif self.cmd == 'Status read':
- self.decode_reg(pos, ANN_STATUS_READ, self.dat, self.miso_bytes())
+ self.decode_reg(pos, Ann.STATUS_READ, self.dat, self.miso_bytes())
else:
self.warn(pos, 'unhandled command')
@@ -282,7 +282,7 @@ class Decoder(srd.Decoder):
# First MOSI byte is always the command.
self.decode_command(pos, mosi)
# First MISO byte is always the status register.
- self.decode_reg(pos, ANN_STATUS, 'STATUS', [miso])
+ self.decode_reg(pos, Ann.STATUS, 'STATUS', [miso])
else:
if not self.cmd or len(self.mb) >= self.max:
self.warn(pos, 'excess byte')