check for None spi when initializing FourWire

This commit is contained in:
foamyguy 2021-10-09 12:11:07 -05:00
parent f13db0d0e2
commit d3317b002e
2 changed files with 7 additions and 0 deletions

View File

@ -2062,6 +2062,10 @@ msgstr ""
msgid "SPI Re-initialization error" msgid "SPI Re-initialization error"
msgstr "" msgstr ""
#: shared-bindings/displayio/FourWire.c
msgid "SPI cannot be None"
msgstr ""
#: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/SPI.c
msgid "SPI configuration failed" msgid "SPI configuration failed"
msgstr "" msgstr ""

View File

@ -79,6 +79,9 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj);
mp_obj_t spi = args[ARG_spi_bus].u_obj; mp_obj_t spi = args[ARG_spi_bus].u_obj;
if (spi == mp_const_none) {
mp_raise_ValueError(translate("SPI cannot be None"));
}
displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus; displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus;
self->base.type = &displayio_fourwire_type; self->base.type = &displayio_fourwire_type;