Fix lost board.SPI and board.I2C after being used by display.
Fixes #3581. Pins were marked as never_reset by common_hal_displayio_fourwire_construct() and common_hal_sharpdisplay_framebuffer_construct(), but these marks were never removed, so at the end of a session after displayio.release_displays(), {spi|i2c}_singleton would be set to NULL but the pins would not be reset. In the next session, board.SPI() and board.I2C() were unable to reconstruct the object because the pins were still in use. For symmetry with creation of the singleton, add deinitialization before setting it to NULL in reset_board_busses(). This makes the pins resettable, so that reset_port(), moved behind it, then resets them.
This commit is contained in:
parent
1117edae63
commit
f4f80e07ca
4
main.c
4
main.c
|
@ -234,10 +234,12 @@ void cleanup_after_vm(supervisor_allocation* heap) {
|
||||||
common_hal_canio_reset();
|
common_hal_canio_reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
reset_port();
|
// reset_board_busses() first because it may release pins from the never_reset state, so that
|
||||||
|
// reset_port() can reset them.
|
||||||
#if CIRCUITPY_BOARD
|
#if CIRCUITPY_BOARD
|
||||||
reset_board_busses();
|
reset_board_busses();
|
||||||
#endif
|
#endif
|
||||||
|
reset_port();
|
||||||
reset_board();
|
reset_board();
|
||||||
reset_status_led();
|
reset_status_led();
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,8 +145,11 @@ void reset_board_busses(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!display_using_i2c) {
|
if (i2c_singleton != NULL) {
|
||||||
i2c_singleton = NULL;
|
if (!display_using_i2c) {
|
||||||
|
common_hal_busio_i2c_deinit(i2c_singleton);
|
||||||
|
i2c_singleton = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if BOARD_SPI
|
#if BOARD_SPI
|
||||||
|
@ -169,9 +172,10 @@ void reset_board_busses(void) {
|
||||||
// make sure SPI lock is not held over a soft reset
|
// make sure SPI lock is not held over a soft reset
|
||||||
if (spi_singleton != NULL) {
|
if (spi_singleton != NULL) {
|
||||||
common_hal_busio_spi_unlock(spi_singleton);
|
common_hal_busio_spi_unlock(spi_singleton);
|
||||||
}
|
if (!display_using_spi) {
|
||||||
if (!display_using_spi) {
|
common_hal_busio_spi_deinit(spi_singleton);
|
||||||
spi_singleton = NULL;
|
spi_singleton = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if BOARD_UART
|
#if BOARD_UART
|
||||||
|
|
Loading…
Reference in New Issue