update common_hal_reset_pin()

This commit is contained in:
microDev 2020-12-28 20:04:00 +05:30
parent 1b7fbaf31e
commit dc332baa87
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
10 changed files with 28 additions and 21 deletions

View File

@ -169,6 +169,9 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
} }
void common_hal_reset_pin(const mcu_pin_obj_t* pin) { void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->number); reset_pin_number(pin->number);
} }

View File

@ -248,12 +248,8 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
spi_bus_free(self->host_id); spi_bus_free(self->host_id);
common_hal_reset_pin(self->clock_pin); common_hal_reset_pin(self->clock_pin);
if (self->MOSI_pin != NULL) { common_hal_reset_pin(self->MOSI_pin);
common_hal_reset_pin(self->MOSI_pin); common_hal_reset_pin(self->MISO_pin);
}
if (self->MISO_pin != NULL) {
common_hal_reset_pin(self->MISO_pin);
}
self->clock_pin = NULL; self->clock_pin = NULL;
self->MISO_pin = NULL; self->MISO_pin = NULL;
self->MOSI_pin = NULL; self->MOSI_pin = NULL;

View File

@ -89,6 +89,9 @@ void reset_pin_number(gpio_num_t pin_number) {
} }
void common_hal_reset_pin(const mcu_pin_obj_t* pin) { void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->number); reset_pin_number(pin->number);
} }

View File

@ -42,6 +42,9 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
} }
void common_hal_reset_pin(const mcu_pin_obj_t* pin) { void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
if (pin == NULL) {
return;
}
reset_pin_number(0, pin->number); reset_pin_number(0, pin->number);
} }

View File

@ -220,12 +220,9 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
never_reset_spi[self->clock->bank_idx - 1] = false; never_reset_spi[self->clock->bank_idx - 1] = false;
common_hal_reset_pin(self->clock->pin); common_hal_reset_pin(self->clock->pin);
if (self->mosi != NULL) { common_hal_reset_pin(self->mosi->pin);
common_hal_reset_pin(self->mosi->pin); common_hal_reset_pin(self->miso->pin);
}
if (self->miso != NULL) {
common_hal_reset_pin(self->miso->pin);
}
self->clock = NULL; self->clock = NULL;
self->mosi = NULL; self->mosi = NULL;
self->miso = NULL; self->miso = NULL;

View File

@ -295,12 +295,10 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
LPUART_Deinit(self->uart); LPUART_Deinit(self->uart);
gc_free(self->ringbuf); gc_free(self->ringbuf);
if (self->rx) {
common_hal_reset_pin(self->rx->pin); common_hal_reset_pin(self->rx->pin);
} common_hal_reset_pin(self->tx->pin);
if (self->tx) {
common_hal_reset_pin(self->tx->pin);
}
self->rx = NULL; self->rx = NULL;
self->tx = NULL; self->tx = NULL;

View File

@ -67,6 +67,9 @@ void reset_all_pins(void) {
// Since i.MX pins need extra register and reset information to reset properly, // Since i.MX pins need extra register and reset information to reset properly,
// resetting pins by number alone has been removed. // resetting pins by number alone has been removed.
void common_hal_reset_pin(const mcu_pin_obj_t* pin) { void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
if (pin == NULL) {
return;
}
never_reset_pins[pin->mux_idx] = false; never_reset_pins[pin->mux_idx] = false;
claimed_pins[pin->mux_idx] = false; claimed_pins[pin->mux_idx] = false;
*(uint32_t*)pin->mux_reg = pin->mux_reset; *(uint32_t*)pin->mux_reg = pin->mux_reset;

View File

@ -134,6 +134,9 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
} }
void common_hal_reset_pin(const mcu_pin_obj_t* pin) { void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->number); reset_pin_number(pin->number);
} }

View File

@ -125,6 +125,9 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
} }
void common_hal_reset_pin(const mcu_pin_obj_t* pin) { void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->port, pin->number); reset_pin_number(pin->port, pin->number);
} }

View File

@ -76,9 +76,7 @@ void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t* self) {
common_hal_reset_pin(self->command.pin); common_hal_reset_pin(self->command.pin);
common_hal_reset_pin(self->chip_select.pin); common_hal_reset_pin(self->chip_select.pin);
if (self->reset.pin) { common_hal_reset_pin(self->reset.pin);
common_hal_reset_pin(self->reset.pin);
}
} }
bool common_hal_displayio_fourwire_reset(mp_obj_t obj) { bool common_hal_displayio_fourwire_reset(mp_obj_t obj) {