}
class Decoder(srd.Decoder):
- api_version = 2
+ api_version = 3
id = 'avr_pdi'
name = 'AVR PDI'
longname = 'Atmel Program and Debug Interface'
- desc = 'Atmel proprietary interface for the ATxmega MCU.'
+ desc = 'Atmel ATxmega Program and Debug Interface (PDI) protocol.'
license = 'gplv2+'
inputs = ['logic']
- outputs = ['pdi']
+ outputs = []
+ tags = ['Debug/trace']
channels = (
{'id': 'reset', 'name': 'RESET', 'desc': 'RESET / PDI_CLK'},
{'id': 'data', 'name': 'DATA', 'desc': 'PDI_DATA'},
Ann.PARITY_ERR, Ann.STOP_OK, Ann.STOP_ERR, Ann.BREAK)),
('pdi_fields', 'PDI fields', (Ann.OPCODE, Ann.DATA_PROG, Ann.DATA_DEV,
Ann.PDI_BREAK)),
- ('pdi_cmds', 'PDI Cmds', (Ann.ENABLE, Ann.DISABLE, Ann.COMMAND)),
+ ('pdi_cmds', 'PDI commands', (Ann.ENABLE, Ann.DISABLE, Ann.COMMAND)),
)
binary = (
('bytes', 'PDI protocol bytes'),
)
def __init__(self):
+ self.reset()
+
+ def reset(self):
self.samplerate = None
- # Detect input changes and clock edges.
- self.prev_pins = None
- self.prev_clock = None
self.clear_state()
def clear_state(self):
# Reset internal state for the next frame.
self.bits = []
- def find_clk_edge(self, samplenum, clock_pin, data_pin):
- # Ignore the sample if the clock pin has not changed.
- if clock_pin == self.prev_clock:
- return
- self.prev_clock = clock_pin
-
+ def handle_clk_edge(self, clock_pin, data_pin):
# Sample the data line on rising clock edges. Always, for TX and for
# RX bytes alike.
if clock_pin == 1:
# periods (avoid interpreting the DATA line when the "enabled" state
# has not yet been determined).
self.ss_last_fall = self.ss_curr_fall
- self.ss_curr_fall = samplenum
+ self.ss_curr_fall = self.samplenum
if self.ss_last_fall is None:
return
bit_val = self.data_sample
self.handle_bits(bit_ss, bit_es, bit_val)
- def decode(self, ss, es, data):
- for samplenum, pins in data:
-
- # Ignore identical samples.
- if self.prev_pins == pins:
- continue
- self.prev_pins = pins
-
- # Have DATA processed at appropriate clock edges.
- clock_pin, data_pin = pins[0], pins[1]
- self.find_clk_edge(samplenum, clock_pin, data_pin)
+ def decode(self):
+ while True:
+ self.handle_clk_edge(*self.wait({0: 'e'}))