]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/sdcard_sd/pd.py
sdcard_sd: Remove a list that needs manual maintenance.
[libsigrokdecode.git] / decoders / sdcard_sd / pd.py
index 98f4725e70edc90f8eacf73015060b5338e4e9dc..32a25aea185c22933bb1f2271b0a29de5d9f6068 100644 (file)
@@ -23,6 +23,8 @@ from common.sdcard import (cmd_names, acmd_names, accepted_voltages, card_status
 
 responses = '1 1b 2 3 6 7'.split()
 
+Pin = SrdIntEnum.from_str('Pin', 'CMD CLK DAT0 DAT1 DAT2 DAT3')
+
 a = ['CMD%d' % i for i in range(64)] + ['ACMD%d' % i for i in range(64)] + \
     ['R' + r.upper() for r in responses] + \
     ['F_' + f for f in 'START TRANSM CMD ARG CRC END'.split()] + \
@@ -179,7 +181,7 @@ class Decoder(srd.Decoder):
         # Handle command.
         s = 'ACMD' if self.is_acmd else 'CMD'
         self.cmd_str = '%s%d (%s)' % (s, self.cmd, self.cmd_name(self.cmd))
-        if self.cmd in (0, 2, 3, 6, 7, 8, 9, 10, 13, 41, 51, 55):
+        if hasattr(self, 'handle_%s%d' % (s.lower(), self.cmd)):
             self.state = St['HANDLE_CMD%d' % self.cmd]
         else:
             self.state = St.HANDLE_CMD999
@@ -344,7 +346,7 @@ class Decoder(srd.Decoder):
         self.putf(8, 134, [Ann.F_ARG, ['Argument', 'Arg', 'A']])
         self.putf(135, 135, [Ann.F_END, ['End bit', 'End', 'E']])
         self.putf(8, 134, [Ann.DECODED_F, ['CID/CSD register', 'CID/CSD', 'C']])
-        self.putf(0, 135, [55, ['R2']])
+        self.putf(0, 135, [Ann.R2, ['R2']])
         self.token, self.state = [], St.GET_COMMAND_TOKEN
 
     def handle_response_r3(self, cmd):
@@ -422,7 +424,7 @@ class Decoder(srd.Decoder):
     def decode(self):
         while True:
             # Wait for a rising CLK edge.
-            (cmd, clk, dat0, dat1, dat2, dat3) = self.wait({1: 'r'})
+            (cmd, clk, dat0, dat1, dat2, dat3) = self.wait({Pin.CLK: 'r'})
 
             # State machine.
             if self.state == St.GET_COMMAND_TOKEN: