SD SPI CS pin inverted logic possible?

Posts: 50
Joined: Tue Sep 07, 2021 6:59 pm

SD SPI CS pin inverted logic possible?

Postby dizcza » Sat Mar 18, 2023 7:42 pm

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.


Posts: 63
Joined: Mon Oct 17, 2022 7:38 pm

Re: SD SPI CS pin inverted logic possible?

Postby MicroController » Tue Mar 21, 2023 1:38 am

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.

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 50 guests