X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fmx25lxx05d%2Fmx25lxx05d.py;h=801ab809c09aa3146a4f98dc764252bf732c9461;hp=cd97deeb5b986601d627087062078fa6f7ee3bcd;hb=156509ca42f0df2380c9f205f9aad337e1a07802;hpb=64c29e28e0efa184319f7831b3eca18c7f73f7d0 diff --git a/decoders/mx25lxx05d/mx25lxx05d.py b/decoders/mx25lxx05d/mx25lxx05d.py index cd97dee..801ab80 100644 --- a/decoders/mx25lxx05d/mx25lxx05d.py +++ b/decoders/mx25lxx05d/mx25lxx05d.py @@ -18,17 +18,9 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -# -# Macronix MX25Lxx05D SPI (NOR) flash chip decoder. -# Works for MX25L1605D/MX25L3205D/MX25L6405D. -# +# Macronix MX25Lxx05D SPI (NOR) flash chip protocol decoder -# -# TODO: Description -# -# Details: -# http://www.macronix.com/QuickPlace/hq/PageLibrary4825740B00298A3B.nsf/h_Index/3F21BAC2E121E17848257639003A3146/$File/MX25L1605D-3205D-6405D-1.5.pdf -# +# Note: Works for MX25L1605D/MX25L3205D/MX25L6405D. import sigrokdecode as srd @@ -102,15 +94,20 @@ device_name = { } class Decoder(srd.Decoder): + api_version = 1 id = 'mx25lxx05d' name = 'MX25Lxx05D' longname = 'Macronix MX25Lxx05D' desc = 'Macronix MX25Lxx05D SPI flash chip decoder' longdesc = 'TODO' license = 'gplv2+' - inputs = ['spi', 'spi', 'logic'] + inputs = ['spi', 'logic'] outputs = ['mx25lxx05d'] - probes = [] # TODO: HOLD#, WP#/ACC + probes = [] + optional_probes = [ + {'id': 'hold', 'name': 'HOLD#', 'desc': 'TODO.'}, + {'id': 'wp_acc', 'name': 'WP#/ACC', 'desc': 'TODO.'}, + ] options = {} # TODO annotations = [ ['TODO', 'TODO'], @@ -127,12 +124,12 @@ class Decoder(srd.Decoder): def report(self): pass - def putann(self, data): + def putx(self, data): # Simplification, most annotations span extactly one SPI byte/packet. self.put(self.ss, self.es, self.out_ann, data) def handle_wren(self, mosi, miso): - self.putann([0, ['Command: %s' % cmds[self.cmd]]]) + self.putx([0, ['Command: %s' % cmds[self.cmd]]]) self.state = IDLE # TODO: Check/display device ID / name @@ -140,17 +137,17 @@ class Decoder(srd.Decoder): if self.cmdstate == 1: # Byte 1: Master sends command ID. self.start_sample = self.ss - self.putann([0, ['Command: %s' % cmds[self.cmd]]]) + self.putx([0, ['Command: %s' % cmds[self.cmd]]]) elif self.cmdstate == 2: # Byte 2: Slave sends the JEDEC manufacturer ID. - self.putann([0, ['Manufacturer ID: 0x%02x' % miso]]) + self.putx([0, ['Manufacturer ID: 0x%02x' % miso]]) elif self.cmdstate == 3: # Byte 3: Slave sends the memory type (0x20 for this chip). - self.putann([0, ['Memory type: 0x%02x' % miso]]) + self.putx([0, ['Memory type: 0x%02x' % miso]]) elif self.cmdstate == 4: # Byte 4: Slave sends the device ID. self.device_id = miso - self.putann([0, ['Device ID: 0x%02x' % miso]]) + self.putx([0, ['Device ID: 0x%02x' % miso]]) if self.cmdstate == 4: # TODO: Check self.device_id is valid & exists in device_names. @@ -168,14 +165,14 @@ class Decoder(srd.Decoder): # Byte 1: Master sends command ID. self.addr = 0 self.start_sample = self.ss - self.putann([0, ['Command: %s' % cmds[self.cmd]]]) + self.putx([0, ['Command: %s' % cmds[self.cmd]]]) elif self.cmdstate in (2, 3, 4): # Bytes 2/3/4: Master sends address of the sector to erase. # Note: Assumes SPI data is 8 bits wide (it is for MX25Lxx05D). # TODO: LSB-first of MSB-first? self.addr <<= 8 self.addr |= mosi - self.putann([0, ['Address byte %d: 0x%02x' % (self.cmdstate - 1, + self.putx([0, ['Address byte %d: 0x%02x' % (self.cmdstate - 1, miso)]]) # TODO: Count from 0 or 1? if self.cmdstate == 4: @@ -194,28 +191,28 @@ class Decoder(srd.Decoder): if self.cmdstate == 1: # Byte 1: Master sends command ID. self.start_sample = self.ss - self.putann([0, ['Command: %s' % cmds[self.cmd]]]) + self.putx([0, ['Command: %s' % cmds[self.cmd]]]) elif self.cmdstate in (2, 3): # Bytes 2/3: Master sends two dummy bytes. # TODO: Check dummy bytes? Check reply from device? - self.putann([0, ['Dummy byte: %s' % mosi]]) + self.putx([0, ['Dummy byte: %s' % mosi]]) elif self.cmdstate == 4: # Byte 4: Master sends 0x00 or 0x01. # 0x00: Master wants manufacturer ID as first reply byte. # 0x01: Master wants device ID as first reply byte. self.manufacturer_id_first = True if (mosi == 0x00) else False d = 'manufacturer' if (mosi == 0x00) else 'device' - self.putann([0, ['Master wants %s ID first' % d]]) + self.putx([0, ['Master wants %s ID first' % d]]) elif self.cmdstate == 5: # Byte 5: Slave sends manufacturer ID (or device ID). self.ids = [miso] d = 'Manufacturer' if self.manufacturer_id_first else 'Device' - self.putann([0, ['%s ID' % d]]) + self.putx([0, ['%s ID' % d]]) elif self.cmdstate == 6: # Byte 6: Slave sends device ID (or manufacturer ID). self.ids += [miso] d = 'Manufacturer' if self.manufacturer_id_first else 'Device' - self.putann([0, ['%s ID' % d]]) + self.putx([0, ['%s ID' % d]]) else: # TODO: Error? pass @@ -223,13 +220,13 @@ class Decoder(srd.Decoder): if self.cmdstate == 6: self.end_sample = self.es id = self.ids[1] if self.manufacturer_id_first else self.ids[0] - self.putann([0, ['Device: Macronix %s' % device_name[id]]]) + self.putx([0, ['Device: Macronix %s' % device_name[id]]]) self.state = IDLE else: self.cmdstate += 1 def handle_rdsr(self, mosi, miso): - self.putann([0, ['Command: %s (0x%02x)' % (cmds[self.cmd], miso)]]) + self.putx([0, ['Command: %s (0x%02x)' % (cmds[self.cmd], miso)]]) self.state = IDLE def decode(self, ss, es, data): @@ -251,8 +248,6 @@ class Decoder(srd.Decoder): self.cmdstate = 1 else: pass # TODO - else: - pass # Handle commands. # TODO: Use some generic way to invoke the resp. method.