aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/replicape.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-11-18 17:25:15 -0500
committerKevin O'Connor <kevin@koconnor.net>2018-11-21 12:12:31 -0500
commitbe58c7f8ec421967a174c0d4fd353d7da2eb48cf (patch)
tree78681ec1e1f072250c7ea38dd1aa3fc67535620f /klippy/extras/replicape.py
parent7cadd8d3f4f3d0299c0a27fa18dae78a4b3e5479 (diff)
downloadkutter-be58c7f8ec421967a174c0d4fd353d7da2eb48cf.tar.gz
kutter-be58c7f8ec421967a174c0d4fd353d7da2eb48cf.tar.xz
kutter-be58c7f8ec421967a174c0d4fd353d7da2eb48cf.zip
replicape: Use bus.py helper code for spi
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/replicape.py')
-rw-r--r--klippy/extras/replicape.py22
1 files changed, 5 insertions, 17 deletions
diff --git a/klippy/extras/replicape.py b/klippy/extras/replicape.py
index 3f5ee63f..ca156daa 100644
--- a/klippy/extras/replicape.py
+++ b/klippy/extras/replicape.py
@@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
-import pins, mcu
+import pins, mcu, bus
REPLICAPE_MAX_CURRENT = 3.84
REPLICAPE_SHIFT_REGISTER_BUS = 0x0101
@@ -136,7 +136,6 @@ class Replicape:
"power_fan0": (pca9685_pwm, 7), "power_fan1": (pca9685_pwm, 8),
"power_fan2": (pca9685_pwm, 9), "power_fan3": (pca9685_pwm, 10) }
# Setup stepper config
- self.spi_send_cmd = None
self.last_stepper_time = 0.
self.stepper_dacs = {}
shift_registers = [1, 0, 0, 1, 1]
@@ -175,19 +174,9 @@ class Replicape:
and self.stepper_dacs):
shift_registers[4] &= ~1
self.sr_enabled = tuple(reversed(shift_registers))
- self.host_mcu.register_config_callback(self._build_config)
- self.sr_oid = self.host_mcu.create_oid()
- str_sr_disabled = "".join(["%02x" % (x,) for x in self.sr_disabled])
- self.host_mcu.add_config_cmd(
- "config_spi_without_cs oid=%d bus=%d mode=0 rate=50000000"
- " shutdown_msg=%s" % (
- self.sr_oid, REPLICAPE_SHIFT_REGISTER_BUS, str_sr_disabled))
- self.host_mcu.add_config_cmd("spi_send oid=%d data=%s" % (
- self.sr_oid, str_sr_disabled), is_init=True)
- def _build_config(self):
- cmd_queue = self.host_mcu.alloc_command_queue()
- self.spi_send_cmd = self.host_mcu.lookup_command(
- "spi_send oid=%c data=%*s", cq=cmd_queue)
+ self.sr_spi = bus.MCU_SPI(self.host_mcu, REPLICAPE_SHIFT_REGISTER_BUS,
+ None, 0, 50000000, self.sr_disabled)
+ self.sr_spi.spi_send(self.sr_disabled)
def note_pwm_start_value(self, channel, start_value, shutdown_value):
self.mcu_pwm_start_value |= not not start_value
self.mcu_pwm_shutdown_value |= not not shutdown_value
@@ -219,8 +208,7 @@ class Replicape:
return
print_time = max(print_time, self.last_stepper_time + PIN_MIN_TIME)
clock = self.host_mcu.print_time_to_clock(print_time)
- # XXX - the spi_send message should be scheduled
- self.spi_send_cmd.send([self.sr_oid, sr], minclock=clock, reqclock=clock)
+ self.sr_spi.spi_send(sr, minclock=clock, reqclock=clock)
def setup_pin(self, pin_type, pin_params):
pin = pin_params['pin']
if pin not in self.pins: