Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SdFat 2.22 with USER_SPI1 pin + another USER_SPI2 in SPI_Mode3 #480

Open
sobido opened this issue May 1, 2024 · 2 comments
Open

SdFat 2.22 with USER_SPI1 pin + another USER_SPI2 in SPI_Mode3 #480

sobido opened this issue May 1, 2024 · 2 comments

Comments

@sobido
Copy link

sobido commented May 1, 2024

Hi Bill
I have your Sfat2.22 on ESP32 DEV module on Arduino with special USER_SPI (GPIO_SPI_SCK, GPIO_SPI_MISO, GPIO_SPI_MOSI, GPIO_SPI_CS).
SD card access work fine as soon as I have only one SPI in use.
Now I need to add another User SPI (Gyro) like (GPIO_IMU_SCLK, GPIO_IMU_DOUT, GPIO_IMU_DIN, GPIO_IMU_CS).
Moreover this SPI need to be in SPI_Mode3.
I could not find a solution to use both at the same time. So far , I need to SPI2.end() before to get access to the SD Card in SPI1.

I tried to find a solution with also your Sdfat_Beta version, but don't know how to do that .
Do you have a suggestion please ?

@greiman
Copy link
Owner

greiman commented May 1, 2024

Moreover this SPI need to be in SPI_Mode3.

You can have devices with different modes on one bus. This is set by:
SPI.beginTransaction(settings);

See this.

@sobido
Copy link
Author

sobido commented May 1, 2024

Hi Thanks
I found finally a solution . Maybe not the more beautiful one, but seems to work:
I used your SdFat_Beta instead of SdFat ,and changing priorly the SPI_DRIVER_SELECT = 2 in the SdFat/SdFatConfig.h , and after using the softSpiDriver like in your "SoftwareSpi"example.
I just had to be aware that I define well my GPIO_IMU_SCLK, GPIO_IMU_DOUT, GPIO_IMU_DIN, GPIO_IMU_CS, and GPIO_SPI_CS as const unint8_t , and not as static gpio_num_t , as I did for all the rest of my gpio configuration.

I can now avoid any SPI.end() on my User.SPI Gyro or any sd.end() on the USER.SPI SDfat and have both User.SPI are working together.

Many Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants