summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2016-10-24 02:02:12 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2016-11-06 17:22:27 +0100
commitdb1882287c6e29d7c22f55f21c0735a67e580d3d (patch)
tree4a3156a17dd849c8bf5c4a207ea544a80c5a8931 /decoders
parente33410d3f96db7bb6a2ed0e2540e0df17bf561b5 (diff)
downloadlibsigrokdecode-db1882287c6e29d7c22f55f21c0735a67e580d3d.tar.gz
libsigrokdecode-db1882287c6e29d7c22f55f21c0735a67e580d3d.zip
spiflash: Remove hardcoded Macronix references.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/spiflash/lists.py8
-rw-r--r--decoders/spiflash/pd.py16
2 files changed, 16 insertions, 8 deletions
diff --git a/decoders/spiflash/lists.py b/decoders/spiflash/lists.py
index 4ed6aaf..a2a0a65 100644
--- a/decoders/spiflash/lists.py
+++ b/decoders/spiflash/lists.py
@@ -47,9 +47,11 @@ cmds = {
}
device_name = {
- 0x14: 'MX25L1605D',
- 0x15: 'MX25L3205D',
- 0x16: 'MX25L6405D',
+ 'macronix': {
+ 0x14: 'MX25L1605D',
+ 0x15: 'MX25L3205D',
+ 0x16: 'MX25L6405D',
+ },
}
chips = {
diff --git a/decoders/spiflash/pd.py b/decoders/spiflash/pd.py
index 3d40ceb..d33ac0c 100644
--- a/decoders/spiflash/pd.py
+++ b/decoders/spiflash/pd.py
@@ -89,6 +89,7 @@ class Decoder(srd.Decoder):
)
def __init__(self):
+ self.device_id = -1
self.on_end_transaction = None
self.end_current_transaction()
@@ -112,6 +113,7 @@ class Decoder(srd.Decoder):
def start(self):
self.out_ann = self.register(srd.OUTPUT_ANN)
self.chip = chips[self.options['chip']]
+ self.vendor = self.options['chip'].split('_')[0]
def putx(self, data):
# Simplification, most annotations span exactly one SPI byte/packet.
@@ -120,6 +122,10 @@ class Decoder(srd.Decoder):
def putb(self, data):
self.put(self.ss_block, self.es_block, self.out_ann, data)
+ def vendor_device(self):
+ dev = device_name[self.vendor].get(self.device_id, 'Unknown')
+ return '%s %s' % (self.chip['vendor'], dev)
+
def handle_wren(self, mosi, miso):
self.putx([0, ['Command: %s' % cmds[self.state][1]]])
self.state = None
@@ -145,9 +151,8 @@ class Decoder(srd.Decoder):
self.putx([2, ['Device ID: 0x%02x' % miso]])
if self.cmdstate == 4:
- # TODO: Check self.device_id is valid & exists in device_names.
# TODO: Same device ID? Check!
- d = 'Device: Macronix %s' % device_name[self.device_id]
+ d = 'Device: %s' % self.vendor_device()
self.put(self.ss_block, self.es, self.out_ann, [0, [d]])
self.state = None
else:
@@ -311,8 +316,8 @@ class Decoder(srd.Decoder):
self.putx([24, ['Dummy byte: %02x' % mosi]])
elif self.cmdstate == 5:
# Byte 5: Slave sends device ID.
- self.ids = [miso]
- self.putx([24, ['Device: Macronix %s' % device_name[self.ids[0]]]])
+ self.device_id = miso
+ self.putx([24, ['Device: %s' % self.vendor_device()]])
self.state = None
self.cmdstate += 1
@@ -346,7 +351,8 @@ class Decoder(srd.Decoder):
if self.cmdstate == 6:
id = self.ids[1] if self.manufacturer_id_first else self.ids[0]
- self.putx([24, ['Device: Macronix %s' % device_name[id]]])
+ self.device_id = id
+ self.putx([24, ['Device: %s' % self.vendor_device()]])
self.state = None
else:
self.cmdstate += 1