summaryrefslogtreecommitdiff
path: root/decoders/spiflash
diff options
context:
space:
mode:
authorVesa-Pekka Palmu <vpalmu@depili.fi>2018-10-17 18:49:29 +0300
committerUwe Hermann <uwe@hermann-uwe.de>2018-10-21 17:37:04 +0200
commit539e6dafe7889e76061b9015ac522699d46082c0 (patch)
tree93493563106a9fb627570b9ec64810e16076b242 /decoders/spiflash
parent51a91ed0e544e1e5c214040b714b5263846700c0 (diff)
downloadlibsigrokdecode-539e6dafe7889e76061b9015ac522699d46082c0.tar.gz
libsigrokdecode-539e6dafe7889e76061b9015ac522699d46082c0.zip
spiflash: Initial support for write enable state tracking
Diffstat (limited to 'decoders/spiflash')
-rw-r--r--decoders/spiflash/pd.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/decoders/spiflash/pd.py b/decoders/spiflash/pd.py
index 536b55c..304545f 100644
--- a/decoders/spiflash/pd.py
+++ b/decoders/spiflash/pd.py
@@ -104,6 +104,7 @@ class Decoder(srd.Decoder):
self.device_id = -1
self.on_end_transaction = None
self.end_current_transaction()
+ self.writestate = 0
# Build dict mapping command keys to handler functions. Each
# command in 'cmds' (defined in lists.py) has a matching
@@ -174,10 +175,11 @@ class Decoder(srd.Decoder):
def handle_wren(self, mosi, miso):
self.putx([Ann.WREN, self.cmd_ann_list()])
- self.state = None
+ self.writestate = 1
def handle_wrdi(self, mosi, miso):
- pass # TODO
+ self.putx([Ann.WRDI, self.cmd_ann_list()])
+ self.writestate = 0
def handle_rdid(self, mosi, miso):
if self.cmdstate == 1:
@@ -279,6 +281,8 @@ class Decoder(srd.Decoder):
if self.cmdstate == 1:
# Byte 1: Master sends command ID.
self.emit_cmd_byte()
+ if self.writestate == 0:
+ self.putc([Ann.WARN, ['Warning: WREN might be missing']])
elif self.cmdstate in (2, 3, 4):
# Bytes 2/3/4: Master sends write address (24bits, MSB-first).
self.emit_addr_bytes(mosi)
@@ -363,11 +367,12 @@ class Decoder(srd.Decoder):
self.cmdstate += 1
# TODO: Warn/abort if we don't see the necessary amount of bytes.
- # TODO: Warn if WREN was not seen before.
def handle_se(self, mosi, miso):
if self.cmdstate == 1:
# Byte 1: Master sends command ID.
self.emit_cmd_byte()
+ if self.writestate == 0:
+ self.putx([Ann.WARN, ['Warning: WREN might be missing']])
elif self.cmdstate in (2, 3, 4):
# Bytes 2/3/4: Master sends sector address (24bits, MSB-first).
self.emit_addr_bytes(mosi)
@@ -387,13 +392,15 @@ class Decoder(srd.Decoder):
def handle_be(self, mosi, miso):
pass # TODO
- # TODO: Warn if WREN was not seen before.
def handle_ce(self, mosi, miso):
self.putx([Ann.CE, self.cmd_ann_list()])
+ if self.writestate == 0:
+ self.putx([Ann.WARN, ['Warning: WREN might be missing']])
- # TODO: Warn if WREN was not seen before.
def handle_ce2(self, mosi, miso):
self.putx([Ann.CE2, self.cmd_ann_list()])
+ if self.writestate == 0:
+ self.putx([Ann.WARN, ['Warning: WREN might be missing']])
def handle_pp(self, mosi, miso):
# Page program: Master asserts CS#, sends PP command, sends 3-byte