From 1be24b8fc7a801d442eea6e2dd42ee6a7230ba37 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 30 Dec 2018 18:12:07 -0500 Subject: [PATCH] bus: Don't raise a "duplicate pin" warning on None pins If "None" is used for an spi cs pin, then it should not reserve "None" for other uses. Signed-off-by: Kevin O'Connor --- klippy/extras/bus.py | 1 + klippy/pins.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/klippy/extras/bus.py b/klippy/extras/bus.py index c7e270ca..9721a591 100644 --- a/klippy/extras/bus.py +++ b/klippy/extras/bus.py @@ -62,6 +62,7 @@ def MCU_SPI_from_config(config, mode, pin_option="cs_pin", cs_pin_params = ppins.lookup_pin(cs_pin) pin = cs_pin_params['pin'] if pin == 'None': + ppins.reset_pin_sharing(cs_pin_params) pin = None # Load bus parameters speed = config.getint('spi_speed', default_speed, minval=100000) diff --git a/klippy/pins.py b/klippy/pins.py index b424c4b9..6c82f0d1 100644 --- a/klippy/pins.py +++ b/klippy/pins.py @@ -252,6 +252,9 @@ class PrinterPins: can_pullup = pin_type in ['endstop'] pin_params = self.lookup_pin(pin_desc, can_invert, can_pullup) return pin_params['chip'].setup_pin(pin_type, pin_params) + def reset_pin_sharing(self, pin_params): + share_name = "%s:%s" % (pin_params['chip_name'], pin_params['pin']) + del self.active_pins[share_name] def register_chip(self, chip_name, chip): chip_name = chip_name.strip() if chip_name in self.chips: