Page 1 of 1

SD SPI CS pin inverted logic possible?

Posted: Sat Mar 18, 2023 7:42 pm
by dizcza
I'm kinda running out of pins with my WT32-SC01. The SPI bus is shared between the SD card and the LCD. I'd like to share the CS pin as well.

Is it possible to setup esp_vfs_fat_sdspi_mount with the CS inverted logic? I'll probably need to add an external logic inverter before the SD card CS pin to restore the inverted signal.

Image

Re: SD SPI CS pin inverted logic possible?

Posted: Tue Mar 21, 2023 1:38 am
by MicroController
I don't know what kind of LCD driver you're using. It seems that with the IDF's esp_lcd component you can try and set the cs_high_active flag in esp_lcd_panel_io_spi_config_t.

The SDSPI seems to manage CS by software, so you could modify sdspi_host.c and disable or swap the calls to cs_low(slot) and cs_high(slot).

In theory, this kind of multiplexing of CS should work. You'll have to test if it actually does though because there may be some "dummy" data/clocks sent before or after some SPI transactions while /CS is supposed to be high, which instead of being ignored would then be seen as garbage data by the respective other SPI slave.