cancel
Showing results for 
Search instead for 
Did you mean: 

Hi , I have tested sd card in spi with fatfs , i need to add usb msc to access the sd from usb .

svii
Associate III

how can i interface the sd driver using spi  , made for user_diskio.c   only to run with usbd_storage_if.c

The function used by user_diskio.c for read and write

DRESULT USER_read (

BYTE pdrv,   /* Physical drive nmuber to identify the drive */

BYTE *buff,   /* Data buffer to store read data */

DWORD sector,  /* Sector address in LBA */

UINT count   /* Number of sectors to read */

)

{

 /* USER CODE BEGIN READ */

return SD_disk_read(pdrv, buff, sector, count);

 /* USER CODE END READ */

}

DRESULT USER_write (

BYTE pdrv,     /* Physical drive nmuber to identify the drive */

const BYTE *buff,  /* Data to be written */

DWORD sector,    /* Sector address in LBA */

UINT count     /* Number of sectors to write */

)

 /* USER CODE BEGIN WRITE */

 /* USER CODE HERE */

return SD_disk_write(pdrv, buff, sector, count);

 /* USER CODE END WRITE */

}

how can the above be used for usbd_storage_if.c

int8_t STORAGE_Read_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)

{

 return (USBD_OK);

}

int8_t STORAGE_Write_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)

{

 return (USBD_OK);

}

please share how this can be done , what could be the possible problems or limitations doing this , also refer if any projects using sd spi fatfs usb as well .Thanks in advance.

0 REPLIES 0