##
-## This file is part of the sigrok project.
+## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
##
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
import sigrokdecode as srd
-from .lists import *
+from common.sdcard import (cmd_names, acmd_names, accepted_voltages, card_status, sd_status)
class Decoder(srd.Decoder):
- api_version = 2
+ api_version = 3
id = 'sdcard_sd'
name = 'SD card (SD mode)'
longname = 'Secure Digital card (SD mode)'
('cmd', 'Commands', tuple(range(128))),
)
- def __init__(self, **kwargs):
+ def __init__(self):
self.state = 'GET COMMAND TOKEN'
self.token = []
- self.oldpins = None
- self.oldclk = 0
self.is_acmd = False # Indicates CMD vs. ACMD
self.cmd = None
self.arg = None
self.token, self.state = [], 'GET COMMAND TOKEN'
- def decode(self, ss, es, data):
- for (self.samplenum, pins) in data:
-
- # Ignore identical samples early on (for performance reasons).
- if self.oldpins == pins:
- continue
- self.oldpins, (cmd, clk, dat0, dat1, dat2, dat3) = pins, pins
-
+ def decode(self):
+ while True:
# Wait for a rising CLK edge.
- if not (self.oldclk == 0 and clk == 1):
- self.oldclk = clk
- continue
- self.oldclk = clk
+ (cmd, clk, dat0, dat1, dat2, dat3) = self.wait({1: 'r'})
# State machine.
if self.state == 'GET COMMAND TOKEN':