8000 FIX : common_hal_reset_pin() by microdev1 · Pull Request #3888 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

FIX : common_hal_reset_pin() #3888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->number);
}

Expand Down
8 changes: 2 additions & 6 deletions ports/esp32s2/common-hal/busio/SPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,8 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
spi_bus_free(self->host_id);

common_hal_reset_pin(self->clock_pin);
if (self->MOSI_pin != NULL) {
common_hal_reset_pin(self->MOSI_pin);
}
if (self->MISO_pin != NULL) {
common_hal_reset_pin(self->MISO_pin);
}
common_hal_reset_pin(self->MOSI_pin);
common_hal_reset_pin(self->MISO_pin);
self->clock_pin = NULL;
self->MISO_pin = NULL;
self->MOSI_pin = NULL;
Expand Down
3 changes: 3 additions & 0 deletions ports/esp32s2/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ void reset_pin_number(gpio_num_t pin_number) {
}

void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->number);
}

Expand Down
3 changes: 3 additions & 0 deletions ports/litex/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
if (pin == NULL) {
return;
}
reset_pin_number(0, pin->number);
}

Expand Down
9 changes: 3 additions & 6 deletions ports/mimxrt10xx/common-hal/busio/SPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,9 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
never_reset_spi[self->clock->bank_idx - 1] = false;

common_hal_reset_pin(self->clock->pin);
if (self->mosi != NULL) {
common_hal_reset_pin(self->mosi->pin);
}
if (self->miso != NULL) {
common_hal_reset_pin(self->miso->pin);
}
common_hal_reset_pin(self->mosi->pin);
common_hal_reset_pin(self->miso->pin);

self->clock = NULL;
self->mosi = NULL;
self->miso = NULL;
Expand Down
10 changes: 4 additions & 6 deletions ports/mimxrt10xx/common-hal/busio/UART.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,10 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
LPUART_Deinit(self->uart);
gc_free(self->ringbuf);

if (self->rx) {
common_hal_reset_pin(self->rx->pin);
}
if (self->tx) {
common_hal_reset_pin(self->tx->pin);
}

common_hal_reset_pin(self->rx->pin);
common_hal_reset_pin(self->tx->pin);


self->rx = NULL;
self->tx = NULL;
Expand Down
3 changes: 3 additions & 0 deletions ports/mimxrt10xx/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ void reset_all_pins(void) {
// Since i.MX pins need extra register and reset information to reset properly,
// resetting pins by number alone has been removed.
void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
if (pin == NULL) {
return;
}
never_reset_pins[pin->mux_idx] = false;
claimed_pins[pin->mux_idx] = false;
*(uint32_t*)pin->mux_reg = pin->mux_reset;
Expand Down
3 changes: 3 additions & 0 deletions ports/nrf/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->number);
}

Expand Down
3 changes: 3 additions & 0 deletions ports/stm/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->port, pin->number);
}

Expand Down
4 changes: 1 addition & 3 deletions shared-module/displayio/FourWire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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->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) {
Expand Down
0