summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2020-07-28 17:37:11 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2020-08-30 07:23:58 +0200
commit6bddf39e7a2758cdd5b0e6e3ef1304346a22c565 (patch)
treea894a497c1b48e6391d003ba12be319f358e396f /decoders
parent7f2fb1b35d016a5b789891c1fa3c7408ac3ed18e (diff)
downloadlibsigrokdecode-6bddf39e7a2758cdd5b0e6e3ef1304346a22c565.tar.gz
libsigrokdecode-6bddf39e7a2758cdd5b0e6e3ef1304346a22c565.zip
sle44xx: optionally use samplerate to show processing durations
The protocol is clocked, so strictly does not depend on the samplerate. When the samplerate is available, the duration of internal processing (memory erase and write) can get annotated. It's an optional feature. The datasheet suggests that write and erase time are in the range of a few milliseconds. Normalize to ms units and provide 10us resolution.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/sle44xx/pd.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/decoders/sle44xx/pd.py b/decoders/sle44xx/pd.py
index 559bbc8..56d2d04 100644
--- a/decoders/sle44xx/pd.py
+++ b/decoders/sle44xx/pd.py
@@ -78,6 +78,7 @@ class Decoder(srd.Decoder):
self.reset()
def reset(self):
+ self.samplerate = None
self.bits = []
self.atr_bytes = []
self.cmd_bytes = []
@@ -101,6 +102,13 @@ class Decoder(srd.Decoder):
def putb(self, ss, es, cls , data):
self.put(ss, es, self.out_binary, [cls, data,])
+ def snums_to_usecs(self, snum_count):
+ if not self.samplerate:
+ return None
+ snums_per_usec = self.samplerate / 1e6
+ usecs = snum_count / snums_per_usec
+ return usecs
+
def lookup_proto_ann_txt(self, key, variables):
ann = {
'RESET_SYM': [Ann.RESET_SYM, 'Reset', 'R',],
@@ -200,6 +208,10 @@ class Decoder(srd.Decoder):
clk = self.proc_state['clk']
high = self.proc_state['io1']
text = '{clk} clocks, I/O {high}'.format(clk = clk, high = int(high))
+ usecs = self.snums_to_usecs(es - ss)
+ if usecs:
+ msecs = usecs / 1000
+ text = '{msecs:.2f} ms, {text}'.format(msecs = msecs, text = text)
cls, texts = self.lookup_proto_ann_txt(key, {'data': text})
self.putx(ss, es, cls, texts)