FatFS Multi Logic Device Support with single SPI Bus and Multiple CS pins
Hello..
I have a few problems, can you help me?
I am using FatFS on stm32f103RB MCU. I have a Single SPI bus and 2 CS pins for 2 SD Card.
used STM32CUBEIDE. No problem when I use 1 SD card and 1 CS pin. But Problem occurs when I use 2 SD Cards. Problem is SD Card 2 not mounting
DSTATUS USER_initialize (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
/* USER CODE BEGIN INIT */
return SD_disk_initialize(pdrv);
/* USER CODE END INIT */
}I am using the "pdrv" parameter here for CS pin control. But "pdrv" parameter allway 0. For this reason, SD Card 0 remains selected.
I mount like this:
FATFS fs0,fs1; // file systems
FIL fil0,fil1; // Files
// mount the device with fs
fresult = f_mount(&fs0, "0:/", 1);
fresult = f_mount(&fs1, "1:/", 1);
// create files
fresult = f_open(&fil0, "0:/test_file_for_sd0.txt", FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
fresult = f_open(&fil1, "1:/test_file_for_sd1.txt", FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
// Write text
f_puts("Test DATA to SD 0", &fil0);
f_puts("Test DATA to SD 1", &fil1);
// Close files
fresult = f_close(&fil0);
fresult = f_close(&fil1);my FatFS library parameters :
I will be very happy if you can help :)
Thanks..
