From 87e574b787fc96a34fe7ea2fd20a4de06cde8c08 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Fri, 18 May 2012 15:28:52 +0200 Subject: [PATCH] srd: MX25Lxx05D: Fix SE command. --- decoders/mx25lxx05d/mx25lxx05d.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/decoders/mx25lxx05d/mx25lxx05d.py b/decoders/mx25lxx05d/mx25lxx05d.py index c6e950d..18c5917 100644 --- a/decoders/mx25lxx05d/mx25lxx05d.py +++ b/decoders/mx25lxx05d/mx25lxx05d.py @@ -168,16 +168,13 @@ class Decoder(srd.Decoder): self.start_sample = self.ss 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.putx([0, ['Address byte %d: 0x%02x' % (self.cmdstate - 1, - miso)]]) # TODO: Count from 0 or 1? + # Bytes 2/3/4: Master sends sectror address (24bits, MSB-first). + self.addr |= (mosi << ((4 - self.cmdstate) * 8)) + # self.putx([0, ['Sector address, byte %d: 0x%02x' % \ + # (4 - self.cmdstate, mosi)]]) if self.cmdstate == 4: - d = 'Erase sector %d' % self.addr + d = 'Erase sector %d (0x%06x)' % (self.addr, self.addr) self.put(self.start_sample, self.es, self.out_ann, [0, [d]]) # TODO: Max. size depends on chip, check that too if possible. if self.addr % 4096 != 0: -- 2.30.2