import sigrokdecode as srd from .lists import * ( ANN_RS1, ANN_RS2, ANN_RS3, ANN_xEQ1, ANN_xEQ2, ANN_xEQ3, ANN_WARN ) = range(7) class Decoder(srd.Decoder): api_version = 3 id = 'tmc429' name = 'TMC429' longname = 'Trinamic TMC429' desc = 'Trinamic TMC429 3-axis motion controller.' license = 'gplv3+' inputs = ['spi'] outputs = [] tags = ['IC'] annotations = ( ('RS1', 'Left rerence switch 1'), ('RS2', 'Left rerence switch 2'), ('RS3', 'Left rerence switch 3'), ('xEQ1', 'Motro 1 reached target posistion'), ('xEQ2', 'Motro 2 reached target posistion'), ('xEQ3', 'Motro 3 reached target posistion'), ('warning', 'Warnings') ) annotation_rows = ( ('recieve', 'Recieve', (ANN_RS1, ANN_RS2, ANN_RS3, ANN_xEQ1, ANN_xEQ2, ANN_xEQ3)), ('warning', 'Warnings', (ANN_WARN)) ) def __init__(self): self.reset() def reset(self): #self.ss_cmd, self.es_cmd = 0, 0 self.mosi_bytes = [] def start(self): self.out_ann = self.register(srd.OUTPUT_ANN) # def putx(self, data): # self.put(self.ss_cmd, self.es_cmd, self.out_ann, data) def put_warn(self, pos, msg): self.put(pos[0], pos[1], self.out_ann, [2, [msg]]) def decode(self, ss, es, data): if(data[0] == 'BITS'): # check length of datapacket if(len(data[1]) < 16): # datapacket to short #TODO: add error return # trim to the last 16 bits #TODO: add warning it packet is to long while(len(data[1]) == 16): data[1].pop(0) data[2].pop(0) self.decodeRecieve(data[2]) def decodeRecieve(self, data): # read left rerence switches if(data[2][0]): self.put(data[2][1], data[2][2], self.out_ann, [ANN_RS3, ['RS3']]) if(data[4][0]): self.put(data[4][1], data[4][2], self.out_ann, [ANN_RS2, ['RS2']]) if(data[6][0]): self.put(data[6][1], data[6][2], self.out_ann, [ANN_RS1, ['RS1']])