# Copyright (c) 2024 JJTech # # SPDX-License-Identifier: GPL-2.0-or-later import sigrokdecode as srd # type: ignore class Decoder(srd.Decoder): api_version = 3 id = 'hdq' name = 'HDQ' longname = 'HDQ (High-speed Data Queue)' desc = 'Texas Instruments Gas Gauge battery fuel gauge protocol' license = 'mit' inputs = ['logic'] outputs = ['hdq'] tags = ['Embedded/industrial'] channels = ( {'id': 'data', 'name': 'Data', 'desc': 'Data line'}, ) options = () annotations = ( ('bit', 'Value'), ) annotation_rows = ( ('bits', 'Values', (0,)), ) def __init__(self): print("INIT") self.reset() def reset(self): print("RESET") self.sample_rate = None self.previous_sample_num = 0 def metadata(self, key, value): print("METADATA") if key == srd.SRD_CONF_SAMPLERATE: self.sample_rate = value def start(self): print("START") self.out_ann = self.register(srd.OUTPUT_ANN) def decode(self): print("DECODE") assert self.sample_rate is not None self.wait({0: 'f'}) self.put(self.samplenum, self.samplenum, self.out_ann, [0, ['test', 'test', 'test']])