From 3dda38c8abcb741b5d81b82f59bd18094690be94 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Sun, 19 Feb 2017 12:59:31 +0100 Subject: [PATCH] Fix pin free check to ignore None objects. Fixes #89 --- shared-bindings/microcontroller/Pin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index d564d6d10e..6ef219dfbb 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -55,7 +55,7 @@ void assert_pin(mp_obj_t obj, bool none_ok) { } void assert_pin_free(const mcu_pin_obj_t* pin) { - if (pin != NULL && !common_hal_mcu_pin_is_free(pin)) { + if (pin != NULL && pin != MP_OBJ_TO_PTR(mp_const_none) && !common_hal_mcu_pin_is_free(pin)) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Pin %q in use", pin->name)); } }