aboutsummaryrefslogtreecommitdiff
path: root/cc3200/fatfs/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'cc3200/fatfs/src/drivers')
-rw-r--r--cc3200/fatfs/src/drivers/sd_diskio.c129
-rw-r--r--cc3200/fatfs/src/drivers/sd_diskio.h1
2 files changed, 59 insertions, 71 deletions
diff --git a/cc3200/fatfs/src/drivers/sd_diskio.c b/cc3200/fatfs/src/drivers/sd_diskio.c
index 3b17aa6b8..358f33fbb 100644
--- a/cc3200/fatfs/src/drivers/sd_diskio.c
+++ b/cc3200/fatfs/src/drivers/sd_diskio.c
@@ -302,19 +302,6 @@ void sd_disk_deinit (void) {
//*****************************************************************************
//
-//! Gets the disk status.
-//!
-//! This function gets the current status of the drive.
-//!
-//! \return Returns the current status of the specified drive
-//
-//*****************************************************************************
-DSTATUS sd_disk_status (void) {
- return sd_disk_info.bStatus;
-}
-
-//*****************************************************************************
-//
//! Reads sector(s) from the disk drive.
//!
//!
@@ -365,6 +352,7 @@ DRESULT sd_disk_read (BYTE* pBuffer, DWORD ulSectorNumber, UINT SectorCount) {
pBuffer += 4;
}
CardSendCmd(CMD_STOP_TRANS, 0);
+ while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC));
Res = RES_OK;
}
}
@@ -384,61 +372,62 @@ DRESULT sd_disk_read (BYTE* pBuffer, DWORD ulSectorNumber, UINT SectorCount) {
//
//*****************************************************************************
DRESULT sd_disk_write (const BYTE* pBuffer, DWORD ulSectorNumber, UINT SectorCount) {
- DRESULT Res = RES_ERROR;
- unsigned long ulSize;
-
- if (SectorCount > 0) {
- // Return if disk not initialized
- if (sd_disk_info.bStatus & STA_NOINIT) {
- return RES_NOTRDY;
- }
-
- // SDSC uses linear address, SDHC uses block address
- if (sd_disk_info.ulCapClass == CARD_CAP_CLASS_SDSC) {
- ulSectorNumber = ulSectorNumber * SD_SECTOR_SIZE;
- }
-
- // Set the block count
- MAP_SDHostBlockCountSet(SDHOST_BASE, SectorCount);
-
- // Compute the number of words
- ulSize = (SD_SECTOR_SIZE * SectorCount) / 4;
-
- // Check if 1 block or multi block transfer
- if (SectorCount == 1) {
- // Send single block write command
- if (CardSendCmd(CMD_WRITE_SINGLE_BLK, ulSectorNumber) == 0) {
- // Write the data
- while (ulSize--) {
- MAP_SDHostDataWrite (SDHOST_BASE, (*(unsigned long *)pBuffer));
- pBuffer += 4;
- }
- // Wait for data transfer complete
- while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC));
- Res = RES_OK;
- }
- }
- else {
- // Set the card write block count
- if (sd_disk_info.ucCardType == CARD_TYPE_SDCARD) {
- CardSendCmd(CMD_APP_CMD,sd_disk_info.usRCA << 16);
- CardSendCmd(CMD_SET_BLK_CNT, SectorCount);
- }
-
- // Send multi block write command
- if (CardSendCmd(CMD_WRITE_MULTI_BLK, ulSectorNumber) == 0) {
- // Write the data buffer
- while (ulSize--) {
- MAP_SDHostDataWrite(SDHOST_BASE, (*(unsigned long *)pBuffer));
- pBuffer += 4;
- }
- // Wait for transfer complete
- while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC));
- CardSendCmd(CMD_STOP_TRANS, 0);
- Res = RES_OK;
- }
- }
- }
-
- return Res;
+ DRESULT Res = RES_ERROR;
+ unsigned long ulSize;
+
+ if (SectorCount > 0) {
+ // Return if disk not initialized
+ if (sd_disk_info.bStatus & STA_NOINIT) {
+ return RES_NOTRDY;
+ }
+
+ // SDSC uses linear address, SDHC uses block address
+ if (sd_disk_info.ulCapClass == CARD_CAP_CLASS_SDSC) {
+ ulSectorNumber = ulSectorNumber * SD_SECTOR_SIZE;
+ }
+
+ // Set the block count
+ MAP_SDHostBlockCountSet(SDHOST_BASE, SectorCount);
+
+ // Compute the number of words
+ ulSize = (SD_SECTOR_SIZE * SectorCount) / 4;
+
+ // Check if 1 block or multi block transfer
+ if (SectorCount == 1) {
+ // Send single block write command
+ if (CardSendCmd(CMD_WRITE_SINGLE_BLK, ulSectorNumber) == 0) {
+ // Write the data
+ while (ulSize--) {
+ MAP_SDHostDataWrite (SDHOST_BASE, (*(unsigned long *)pBuffer));
+ pBuffer += 4;
+ }
+ // Wait for data transfer complete
+ while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC));
+ Res = RES_OK;
+ }
+ }
+ else {
+ // Set the card write block count
+ if (sd_disk_info.ucCardType == CARD_TYPE_SDCARD) {
+ CardSendCmd(CMD_APP_CMD,sd_disk_info.usRCA << 16);
+ CardSendCmd(CMD_SET_BLK_CNT, SectorCount);
+ }
+
+ // Send multi block write command
+ if (CardSendCmd(CMD_WRITE_MULTI_BLK, ulSectorNumber) == 0) {
+ // Write the data buffer
+ while (ulSize--) {
+ MAP_SDHostDataWrite(SDHOST_BASE, (*(unsigned long *)pBuffer));
+ pBuffer += 4;
+ }
+ // Wait for transfer complete
+ while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC));
+ CardSendCmd(CMD_STOP_TRANS, 0);
+ while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC));
+ Res = RES_OK;
+ }
+ }
+ }
+
+ return Res;
}
diff --git a/cc3200/fatfs/src/drivers/sd_diskio.h b/cc3200/fatfs/src/drivers/sd_diskio.h
index f1cb2a0bf..b5a1944ec 100644
--- a/cc3200/fatfs/src/drivers/sd_diskio.h
+++ b/cc3200/fatfs/src/drivers/sd_diskio.h
@@ -21,7 +21,6 @@ extern DiskInfo_t sd_disk_info;
DSTATUS sd_disk_init (void);
void sd_disk_deinit (void);
-DSTATUS sd_disk_status (void);
DRESULT sd_disk_read (BYTE* pBuffer, DWORD ulSectorNumber, UINT bSectorCount);
DRESULT sd_disk_write (const BYTE* pBuffer, DWORD ulSectorNumber, UINT bSectorCount);