Skip to content

Commit

Permalink
rg_display: Fixed occasional crash in spi_deinit
Browse files Browse the repository at this point in the history
  • Loading branch information
ducalex committed Dec 19, 2024
1 parent 22c9ad0 commit a829357
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 0 additions & 8 deletions components/retro-go/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@
#define RG_BUILD_DATE __DATE__ " " __TIME__
#endif

// #ifndef RG_ENABLE_NETPLAY
// #define RG_ENABLE_NETPLAY 0
// #endif

// #ifndef RG_ENABLE_PROFILING
// #define RG_ENABLE_PROFILING 0
// #endif

#ifndef RG_APP_LAUNCHER
#define RG_APP_LAUNCHER "launcher"
#endif
Expand Down
8 changes: 6 additions & 2 deletions components/retro-go/drivers/display/ili9341.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ static void spi_init(void)

static void spi_deinit(void)
{
spi_bus_remove_device(spi_dev);
spi_bus_free(RG_SCREEN_HOST);
// When transactions are still in flight, spi_bus_remove_device fails and spi_bus_free then crashes.
// The real solution would be to wait for transactions to be done, but this is simpler for now...
if (spi_bus_remove_device(spi_dev) == ESP_OK)
spi_bus_free(RG_SCREEN_HOST);
else
RG_LOGE("Failed to properly terminate SPI driver!");
}

#define ILI9341_CMD(cmd, data...) \
Expand Down

0 comments on commit a829357

Please sign in to comment.