)
def __init__(self):
+ self.reset()
+
+ def reset(self):
self.samplerate = None
self.ss = self.es = self.ss_byte = -1
self.bitcount = 0
self.out_bitrate = self.register(srd.OUTPUT_META,
meta=(int, 'Bitrate', 'Bitrate from Start bit to Stop bit'))
- # Assume that the initial SCL/SDA pin state is high (logic 1).
- # This is a good default, since both pins have pullups as per spec.
- self.initial_pins = [1, 1]
-
def putx(self, data):
self.put(self.ss, self.es, self.out_ann, data)
if not self.samplerate:
raise SamplerateError('Cannot decode without samplerate.')
- self.wait({})
-
while True:
# State machine.
if self.state == 'FIND START':
# a) Data sampling of receiver: SCL = rising, and/or
# b) START condition (S): SCL = high, SDA = falling, and/or
# c) STOP condition (P): SCL = high, SDA = rising
- conds = [{0: 'r'}, {0: 'h', 1: 'f'}, {0: 'h', 1: 'r'}]
- pins = self.wait(conds[:]) # TODO
+ pins = self.wait([{0: 'r'}, {0: 'h', 1: 'f'}, {0: 'h', 1: 'r'}])
# Check which of the condition(s) matched and handle them.
if self.matched[0]: