From b69a06b2ed2a85a282d59fab4a428cbfb8742f4e Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Sun, 6 Mar 2022 11:33:07 +0100 Subject: [PATCH] Also fix the read pin in the atmel and rp2040 ports --- .../common-hal/paralleldisplay/ParallelBus.c | 11 +++++++---- .../common-hal/paralleldisplay/ParallelBus.c | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c b/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c index 490c595e74..10407d3b3a 100644 --- a/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c @@ -69,9 +69,13 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu common_hal_digitalio_digitalinout_construct(&self->write, write); common_hal_digitalio_digitalinout_switch_to_output(&self->write, true, DRIVE_MODE_PUSH_PULL); - self->read.base.type = &digitalio_digitalinout_type; - common_hal_digitalio_digitalinout_construct(&self->read, read); - common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + self->read.base.type = &mp_type_NoneType; + if (read != NULL) { + self->read.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->read, read); + common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + never_reset_pin_number(read->number); + } self->data0_pin = data_pin; self->write_group = &PORT->Group[write->number / 32]; @@ -89,7 +93,6 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu never_reset_pin_number(command->number); never_reset_pin_number(chip_select->number); never_reset_pin_number(write->number); - never_reset_pin_number(read->number); for (uint8_t i = 0; i < 8; i++) { never_reset_pin_number(data_pin + i); } diff --git a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c index 2e0ae4def2..51187a3429 100644 --- a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c @@ -67,9 +67,13 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu common_hal_digitalio_digitalinout_construct(&self->chip_select, chip_select); common_hal_digitalio_digitalinout_switch_to_output(&self->chip_select, true, DRIVE_MODE_PUSH_PULL); - self->read.base.type = &digitalio_digitalinout_type; - common_hal_digitalio_digitalinout_construct(&self->read, read); - common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + self->read.base.type = &mp_type_NoneType; + if (read != NULL) { + self->read.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->read, read); + common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + never_reset_pin_number(read->number); + } self->data0_pin = data_pin; self->write = write_pin; @@ -86,7 +90,6 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu never_reset_pin_number(command->number); never_reset_pin_number(chip_select->number); never_reset_pin_number(write_pin); - never_reset_pin_number(read->number); for (uint8_t i = 0; i < 8; i++) { never_reset_pin_number(data_pin + i); } @@ -121,8 +124,12 @@ void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_o reset_pin_number(self->command.pin->number); reset_pin_number(self->chip_select.pin->number); reset_pin_number(self->write); - reset_pin_number(self->read.pin->number); - reset_pin_number(self->reset.pin->number); + if (self->read.base.type != &mp_type_NoneType) { + reset_pin_number(self->read.pin->number); + } + if (self->reset.base.type != &mp_type_NoneType) { + reset_pin_number(self->reset.pin->number); + } } bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) {