X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fds1307%2Fpd.py;h=f8ebe195ec5008562745e4fb93a1cfaad88feb08;hb=4c58713b0d536f37b8630ebd142185aa56946335;hp=6d862afcc959f0dfb98638413b64123bf0caccfb;hpb=92b7b49f6964f57a7d6fc4473645c993cfa4ba52;p=libsigrokdecode.git diff --git a/decoders/ds1307/pd.py b/decoders/ds1307/pd.py index 6d862af..f8ebe19 100644 --- a/decoders/ds1307/pd.py +++ b/decoders/ds1307/pd.py @@ -15,13 +15,12 @@ ## 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 . ## import re import sigrokdecode as srd -from srdhelper import bcd2int +from common.srdhelper import bcd2int days_of_week = ( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', @@ -40,9 +39,9 @@ bits = ( rates = { 0b00: '1Hz', - 0b01: '4096kHz', - 0b10: '8192kHz', - 0b11: '32768kHz', + 0b01: '4096Hz', + 0b10: '8192Hz', + 0b11: '32768Hz', } DS1307_I2C_ADDRESS = 0x68 @@ -53,14 +52,15 @@ def regs_and_bits(): return tuple(l) class Decoder(srd.Decoder): - api_version = 2 + api_version = 3 id = 'ds1307' name = 'DS1307' longname = 'Dallas DS1307' - desc = 'Realtime clock module protocol.' + desc = 'Dallas DS1307 realtime clock module protocol.' license = 'gplv2+' inputs = ['i2c'] - outputs = ['ds1307'] + outputs = [] + tags = ['Clock/timing', 'IC'] annotations = regs_and_bits() + ( ('read-datetime', 'Read date/time'), ('write-datetime', 'Write date/time'), @@ -76,6 +76,9 @@ class Decoder(srd.Decoder): ) def __init__(self): + self.reset() + + def reset(self): self.state = 'IDLE' self.hours = -1 self.minutes = -1 @@ -119,7 +122,7 @@ class Decoder(srd.Decoder): ampm_mode = True if (b & (1 << 6)) else False if ampm_mode: self.putd(6, 6, [13, ['12-hour mode', '12h mode', '12h']]) - a = 'AM' if (b & (1 << 6)) else 'PM' + a = 'PM' if (b & (1 << 5)) else 'AM' self.putd(5, 5, [14, [a, a[0]]]) h = self.hours = bcd2int(b & 0x1f) self.putd(4, 0, [15, ['Hour: %d' % h, 'H: %d' % h, 'H']])