Skip to content

Commit d9b0c17

Browse files
committed
rg_system: Initialize and set high all SPI select lines as early as possible
Retro-Go initializes the SPI SD Card before anything else. If the LCD shares the bus and has a floating CS line, it could interfere with the initialization of the SD Card. So far it hasn't been a major issue (that I know of), but I can certainly see how it could be. Solution is to set all CS lines high as early as possible. See this link shared by mtojek: https://docs.espressif.com/projects/esp-idf/en/v5.0/esp32s2/api-reference/peripherals/sdspi_share.html (cherry picked from commit 8565070)
1 parent fdd72f6 commit d9b0c17

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/retro-go/rg_system.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,16 @@ static void platform_init(void)
359359
gpio_reset_pin(GPIO_NUM_14);
360360
gpio_reset_pin(GPIO_NUM_15);
361361
#endif
362+
// Setup all SPI CS lines here in case we have a shared bus. A floating device could cause
363+
// problems during the initialization of the first peripherals...
364+
#if defined(RG_SCREEN_HOST) && defined(RG_GPIO_LCD_CS)
365+
gpio_set_direction(RG_GPIO_LCD_CS, GPIO_MODE_OUTPUT);
366+
gpio_set_level(RG_GPIO_LCD_CS, 1);
367+
#endif
368+
#if defined(RG_STORAGE_SDSPI_HOST) && defined(RG_GPIO_SDSPI_CS)
369+
gpio_set_direction(RG_GPIO_SDSPI_CS, GPIO_MODE_OUTPUT);
370+
gpio_set_level(RG_GPIO_SDSPI_CS, 1);
371+
#endif
362372
#ifdef RG_GPIO_LED
363373
gpio_set_direction(RG_GPIO_LED, GPIO_MODE_OUTPUT);
364374
gpio_set_level(RG_GPIO_LED, 0);

0 commit comments

Comments
 (0)