aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/bus.py18
-rw-r--r--klippy/extras/tmc_uart.py13
2 files changed, 16 insertions, 15 deletions
diff --git a/klippy/extras/bus.py b/klippy/extras/bus.py
index 0b50efc7..7c6ae440 100644
--- a/klippy/extras/bus.py
+++ b/klippy/extras/bus.py
@@ -79,8 +79,10 @@ class MCU_SPI:
self.mcu.add_config_cmd(self.config_fmt)
self.spi_send_cmd = self.mcu.lookup_command(
"spi_send oid=%c data=%*s", cq=self.cmd_queue)
- self.spi_transfer_cmd = self.mcu.lookup_command(
- "spi_transfer oid=%c data=%*s", cq=self.cmd_queue)
+ self.spi_transfer_cmd = self.mcu.lookup_query_command(
+ "spi_transfer oid=%c data=%*s",
+ "spi_transfer_response oid=%c response=%*s", oid=self.oid,
+ cq=self.cmd_queue)
def spi_send(self, data, minclock=0, reqclock=0):
if self.spi_send_cmd is None:
# Send setup message via mcu initialization
@@ -91,8 +93,7 @@ class MCU_SPI:
self.spi_send_cmd.send([self.oid, data],
minclock=minclock, reqclock=reqclock)
def spi_transfer(self, data):
- return self.spi_transfer_cmd.send_with_response(
- [self.oid, data], 'spi_transfer_response', self.oid)
+ return self.spi_transfer_cmd.send([self.oid, data])
# Helper to setup an spi bus from settings in a config section
def MCU_SPI_from_config(config, mode, pin_option="cs_pin",
@@ -155,8 +156,10 @@ class MCU_I2C:
self.mcu.add_config_cmd(self.config_fmt % (bus,))
self.i2c_write_cmd = self.mcu.lookup_command(
"i2c_write oid=%c data=%*s", cq=self.cmd_queue)
- self.i2c_read_cmd = self.mcu.lookup_command(
- "i2c_read oid=%c reg=%*s read_len=%u", cq=self.cmd_queue)
+ self.i2c_read_cmd = self.mcu.lookup_query_command(
+ "i2c_read oid=%c reg=%*s read_len=%u",
+ "i2c_read_response oid=%c response=%*s", oid=self.oid,
+ cq=self.cmd_queue)
self.i2c_modify_bits_cmd = self.mcu.lookup_command(
"i2c_modify_bits oid=%c reg=%*s clear_set_bits=%*s",
cq=self.cmd_queue)
@@ -170,8 +173,7 @@ class MCU_I2C:
self.i2c_write_cmd.send([self.oid, data],
minclock=minclock, reqclock=reqclock)
def i2c_read(self, write, read_len):
- return self.i2c_read_cmd.send_with_response(
- [self.oid, write, read_len], 'i2c_read_response', self.oid)
+ return self.i2c_read_cmd.send([self.oid, write, read_len])
def i2c_modify_bits(self, reg, clear_bits, set_bits,
minclock=0, reqclock=0):
clearset = clear_bits + set_bits
diff --git a/klippy/extras/tmc_uart.py b/klippy/extras/tmc_uart.py
index 7191c9b5..edcaab97 100644
--- a/klippy/extras/tmc_uart.py
+++ b/klippy/extras/tmc_uart.py
@@ -75,8 +75,10 @@ class MCU_TMC_uart_bitbang:
self.mcu.add_config_cmd(
"config_tmcuart oid=%d rx_pin=%s pull_up=%d tx_pin=%s bit_time=%d"
% (self.oid, self.rx_pin, self.pullup, self.tx_pin, bit_ticks))
- self.tmcuart_send_cmd = self.mcu.lookup_command(
- "tmcuart_send oid=%c write=%*s read=%c", cq=self.cmd_queue)
+ self.tmcuart_send_cmd = self.mcu.lookup_query_command(
+ "tmcuart_send oid=%c write=%*s read=%c",
+ "tmcuart_response oid=%c read=%*s", oid=self.oid,
+ cq=self.cmd_queue, async=True)
def register_instance(self, rx_pin_params, tx_pin_params,
select_pins_desc, addr):
if (rx_pin_params['pin'] != self.rx_pin
@@ -148,8 +150,7 @@ class MCU_TMC_uart_bitbang:
if self.analog_mux is not None:
self.analog_mux.activate(instance_id)
msg = self._encode_read(0xf5, addr, reg)
- params = self.tmcuart_send_cmd.send_with_async_response(
- [self.oid, msg, 10], 'tmcuart_response', self.oid)
+ params = self.tmcuart_send_cmd.send([self.oid, msg, 10])
return self._decode_read(reg, params['read'])
def reg_write(self, instance_id, addr, reg, val, print_time=None):
minclock = 0
@@ -158,9 +159,7 @@ class MCU_TMC_uart_bitbang:
if self.analog_mux is not None:
self.analog_mux.activate(instance_id)
msg = self._encode_write(0xf5, addr, reg | 0x80, val)
- self.tmcuart_send_cmd.send_with_async_response(
- [self.oid, msg, 0], 'tmcuart_response', self.oid,
- minclock=minclock)
+ self.tmcuart_send_cmd.send([self.oid, msg, 0], minclock=minclock)
# Lookup a (possibly shared) tmc uart
def lookup_tmc_uart_bitbang(config, max_addr):