tmc_uart: Support print_time in set_register()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-06-21 21:26:26 -04:00
parent 9feb05ce41
commit 0b02d7a1f2
1 changed files with 6 additions and 3 deletions

View File

@ -149,12 +149,14 @@ class MCU_TMC_uart_bitbang:
params = self.tmcuart_send_cmd.send_with_response( params = self.tmcuart_send_cmd.send_with_response(
[self.oid, msg, 10], 'tmcuart_response', self.oid) [self.oid, msg, 10], 'tmcuart_response', self.oid)
return self._decode_read(reg, params['read']) return self._decode_read(reg, params['read'])
def reg_write(self, instance_id, addr, reg, val): def reg_write(self, instance_id, addr, reg, val, print_time=0.):
minclock = self.mcu.print_time_to_clock(print_time)
if self.analog_mux is not None: if self.analog_mux is not None:
self.analog_mux.activate(instance_id) self.analog_mux.activate(instance_id)
msg = self._encode_write(0xf5, 0x00, reg | 0x80, val) msg = self._encode_write(0xf5, 0x00, reg | 0x80, val)
self.tmcuart_send_cmd.send_with_response( self.tmcuart_send_cmd.send_with_response(
[self.oid, msg, 0], 'tmcuart_response', self.oid) [self.oid, msg, 0], 'tmcuart_response', self.oid,
minclock=minclock)
# Lookup a (possibly shared) tmc uart # Lookup a (possibly shared) tmc uart
def lookup_tmc_uart_bitbang(config): def lookup_tmc_uart_bitbang(config):
@ -208,7 +210,8 @@ class MCU_TMC_uart:
ifcnt = self.ifcnt ifcnt = self.ifcnt
if ifcnt is None: if ifcnt is None:
self.ifcnt = ifcnt = self.get_register("IFCNT") self.ifcnt = ifcnt = self.get_register("IFCNT")
self.mcu_uart.reg_write(self.instance_id, self.addr, reg, val) self.mcu_uart.reg_write(self.instance_id, self.addr, reg, val,
print_time)
self.ifcnt = self.get_register("IFCNT") self.ifcnt = self.get_register("IFCNT")
if self.ifcnt == (ifcnt + 1) & 0xff: if self.ifcnt == (ifcnt + 1) & 0xff:
return return