Instead of implementing two main loops for operation in the presence and
in the absence of a clock line, use a common main loop which operates on
pre-determined wait conditions.
for i in range(1, len(self.optional_channels)):
if self.has_channel(i):
conds.append({i: 'e'})
- while True:
- self.handle_bits(self.wait(conds)[1:])
else:
# Sample on the rising or falling CLK edge (depends on config).
- while True:
- pins = self.wait({0: self.options['clock_edge'][0]})
- self.handle_bits(pins[1:])
+ edge = self.options['clock_edge'][0]
+ conds = [{0: edge}]
+
+ while True:
+ pins = self.wait(conds)
+ self.handle_bits(pins[1:])