X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fusb_power_delivery%2Fpd.py;h=58e4e1722711c3a62144265fae4e9ee366bbad83;hp=702c22a525bf7e04aa7be4576a92cb797bb4d173;hb=df167c0f8ea1b28595e64894a555236c29c3c3de;hpb=a886ba3b903d2e900020affe743bb486e8880464 diff --git a/decoders/usb_power_delivery/pd.py b/decoders/usb_power_delivery/pd.py index 702c22a..58e4e17 100644 --- a/decoders/usb_power_delivery/pd.py +++ b/decoders/usb_power_delivery/pd.py @@ -201,10 +201,10 @@ class Decoder(srd.Decoder): inputs = ['logic'] outputs = ['usb_pd'] channels = ( - {'id': 'cc1', 'name': 'CC1', 'desc': 'Control channel 1'}, + {'id': 'cc1', 'name': 'CC1', 'desc': 'Configuration Channel 1'}, ) optional_channels = ( - {'id': 'cc2', 'name': 'CC2', 'desc': 'Control channel 2'}, + {'id': 'cc2', 'name': 'CC2', 'desc': 'Configuration Channel 2'}, ) options = ( {'id': 'fulltext', 'desc': 'full text decoding of the packet', @@ -278,11 +278,18 @@ class Decoder(srd.Decoder): elif t1 == 3: t2 = (pdo >> 28) & 3 if t2 == 0: - t_name = 'Programmable' - p = 'TODO: PPS support' + t_name = 'Programmable|PPS' + minv = ((pdo >> 8) & 0xff) * 0.1 + maxv = ((pdo >> 17) & 0xff) * 0.1 + ma = ((pdo >> 0) & 0xff) * 0.05 + p = '%g/%gV %gA' % (minv, maxv, ma) + if (pdo >> 27) & 0x1: + p += ' [limited]' + self.stored_pdos[idx] = '%s %g/%gV' % (t_name, minv, maxv) else: t_name = 'Reserved APDO: '+bin(t2) - p = '' + p = '[raw: %s]' % (bin(pdo)) + self.stored_pdos[idx] = '%s %s' % (t_name, p) flags = '' for f in sorted(PDO_FLAGS.keys(), reverse = True): if pdo & f: @@ -538,8 +545,7 @@ class Decoder(srd.Decoder): if not self.samplerate: raise SamplerateError('Cannot decode without samplerate.') while True: - pins = self.wait([{0: 'e'}, {1: 'e'}, {'skip': 100*1000}]) - + pins = self.wait([{0: 'e'}, {1: 'e'}, {'skip': int(self.samplerate/1e3)}]) # First sample of the packet, just record the start date if not self.startsample: