aboutsummaryrefslogtreecommitdiffstats
path: root/os/various/fatfs_bindings/fatfs_diskio.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/various/fatfs_bindings/fatfs_diskio.c')
-rw-r--r--os/various/fatfs_bindings/fatfs_diskio.c63
1 files changed, 16 insertions, 47 deletions
diff --git a/os/various/fatfs_bindings/fatfs_diskio.c b/os/various/fatfs_bindings/fatfs_diskio.c
index 9fa41e2..f80c85c 100644
--- a/os/various/fatfs_bindings/fatfs_diskio.c
+++ b/os/various/fatfs_bindings/fatfs_diskio.c
@@ -9,38 +9,7 @@
#include "ffconf.h"
#include "diskio.h"
#include "usbh/dev/msd.h"
-
-#if HAL_USE_MMC_SPI && HAL_USE_SDC
-#error "cannot specify both MMC_SPI and SDC drivers"
-#endif
-
-#if HAL_USE_MMC_SPI
-extern MMCDriver MMCD1;
-#elif HAL_USE_SDC
-extern SDCDriver SDCD1;
-#elif HAL_USBH_USE_MSD
-
-#else
-#error "MMC_SPI, SDC or USBH_MSD driver must be specified"
-#endif
-
-/*-----------------------------------------------------------------------*/
-/* Correspondence between physical drive number and physical drive. */
-#if HAL_USE_MMC_SPI
-#define MMC 0
-#endif
-
-#if HAL_USE_SDC
-#define SDC 0
-#endif
-
-#if HAL_USBH_USE_MSD
-#if defined(MMC) || defined(SDC)
-#define MSDLUN0 1
-#else
-#define MSDLUN0 0
-#endif
-#endif
+#include "fatfs_devices.h"
/*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
@@ -53,7 +22,7 @@ DSTATUS disk_initialize (
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MMCD1) != BLK_READY)
@@ -62,7 +31,7 @@ DSTATUS disk_initialize (
stat |= STA_PROTECT;
return stat;
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&SDCD1) != BLK_READY)
@@ -72,7 +41,7 @@ DSTATUS disk_initialize (
return stat;
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MSBLKD[0]) != BLK_READY)
@@ -96,7 +65,7 @@ DSTATUS disk_status (
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MMCD1) != BLK_READY)
@@ -105,7 +74,7 @@ DSTATUS disk_status (
stat |= STA_PROTECT;
return stat;
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&SDCD1) != BLK_READY)
@@ -115,7 +84,7 @@ DSTATUS disk_status (
return stat;
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MSBLKD[0]) != BLK_READY)
@@ -140,7 +109,7 @@ DRESULT disk_read (
{
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
if (blkGetDriverState(&MMCD1) != BLK_READY)
return RES_NOTRDY;
if (mmcStartSequentialRead(&MMCD1, sector))
@@ -155,7 +124,7 @@ DRESULT disk_read (
return RES_ERROR;
return RES_OK;
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
if (blkGetDriverState(&SDCD1) != BLK_READY)
return RES_NOTRDY;
if (sdcRead(&SDCD1, sector, buff, count))
@@ -163,7 +132,7 @@ DRESULT disk_read (
return RES_OK;
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MSBLKD[0]) != BLK_READY)
return RES_NOTRDY;
@@ -189,7 +158,7 @@ DRESULT disk_write (
{
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
if (blkGetDriverState(&MMCD1) != BLK_READY)
return RES_NOTRDY;
if (mmcIsWriteProtected(&MMCD1))
@@ -206,7 +175,7 @@ DRESULT disk_write (
return RES_ERROR;
return RES_OK;
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
if (blkGetDriverState(&SDCD1) != BLK_READY)
return RES_NOTRDY;
if (sdcWrite(&SDCD1, sector, buff, count))
@@ -214,7 +183,7 @@ DRESULT disk_write (
return RES_OK;
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MSBLKD[0]) != BLK_READY)
return RES_NOTRDY;
@@ -239,7 +208,7 @@ DRESULT disk_ioctl (
{
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
switch (cmd) {
case CTRL_SYNC:
return RES_OK;
@@ -257,7 +226,7 @@ DRESULT disk_ioctl (
return RES_PARERR;
}
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
switch (cmd) {
case CTRL_SYNC:
return RES_OK;
@@ -282,7 +251,7 @@ DRESULT disk_ioctl (
}
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
switch (cmd) {
case CTRL_SYNC:
return RES_OK;