From 44d058f3524e8c34bb72bd2f0c0c02740c190c7a Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Wed, 1 Jan 2020 18:09:51 +0100 Subject: spiflash: Use SrdIntEnum for annotation classes. Also, automate construction of the Ann SrdIntEnum. This avoids having to remember to manually keep two lists in sync. --- decoders/spiflash/pd.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'decoders/spiflash/pd.py') diff --git a/decoders/spiflash/pd.py b/decoders/spiflash/pd.py index 33fe229..26f3a24 100644 --- a/decoders/spiflash/pd.py +++ b/decoders/spiflash/pd.py @@ -1,7 +1,7 @@ ## ## This file is part of the libsigrokdecode project. ## -## Copyright (C) 2011-2016 Uwe Hermann +## Copyright (C) 2011-2020 Uwe Hermann ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -18,16 +18,14 @@ ## import sigrokdecode as srd +import re +from common.srdhelper import SrdIntEnum from .lists import * L = len(cmds) -# Don't forget to keep this in sync with 'cmds' in lists.py. -class Ann: - WRSR, PP, READ, WRDI, RDSR, WREN, FAST_READ, SE, RDSCUR, WRSCUR, \ - RDSR2, CE, ESRY, DSRY, WRITE1, WRITE2, REMS, RDID, RDP_RES, CP, ENSO, DP, \ - READ2X, EXSO, CE2, STATUS, BE, REMS2, \ - BIT, FIELD, WARN = range(L + 3) +a = [re.sub('\/', '_', c[0]).replace('2READ', 'READ2X') for c in cmds.values()] + ['BIT', 'FIELD', 'WARN'] +Ann = SrdIntEnum.from_list('Ann', a) def cmd_annotation_classes(): return tuple([tuple([cmd[0].lower(), cmd[1]]) for cmd in cmds.values()]) -- cgit v1.2.3-70-g09d2