Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FATFileSystem
Revision 27:8d192c180436, committed 2016-04-16
- Comitter:
- DieterGraef
- Date:
- Sat Apr 16 13:01:50 2016 +0000
- Parent:
- 26:8f15aa3b052b
- Child:
- 28:1510a09e5308
- Commit message:
- Changed hard locking mechanism to watchdog , solved issue with the sleep mode of SD cards
Changed in this revision
| SDFileSystem.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SDFileSystem.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SDFileSystem.cpp Wed Apr 13 08:51:27 2016 +0000
+++ b/SDFileSystem.cpp Sat Apr 16 13:01:50 2016 +0000
@@ -24,8 +24,8 @@
: FATFileSystem(name), m_Cd(PC_13)
{
//Initialize the member variables
+ void* h;
uint8_t initstat;
- void* h;
m_CardType = CARD_NONE;
m_Crc = true;
m_LargeFrames = false;
@@ -188,18 +188,32 @@
checkSocket();
//Return the disk status
- return m_Status;
+ return m_Status; //Check the card socket
+ checkSocket();
+ if (m_Status){return m_Status;}
+ m_CardStatus=BSP_SD_GetStatus();
+ //Return the disk status
+ return m_CardStatus;
}
int SDFileSystem::disk_read(uint8_t* buffer, uint32_t sector, uint32_t count)
{
int retval;
+ uint32_t wdog;
//Make sure the card is initialized before proceeding
if (m_Status & STA_NOINIT)
return RES_NOTRDY;
+ wdog=HAL_GetTick();
__DSB();
__ISB();
- while(BSP_SD_Get_Busy()==1){;}
+ while(BSP_SD_Get_Busy()==1)
+ {
+ if((HAL_GetTick()-wdog)>64)
+ {
+ BSP_SD_Clear_Busy();
+ return RES_ERROR;
+ }
+ }
BSP_SD_Set_Busy();
//Read a single block, or multiple blocks
if (count > 1) {
@@ -224,12 +238,21 @@
int SDFileSystem::disk_write(const uint8_t* buffer, uint32_t sector, uint32_t count)
{
int retval;
+ uint32_t wdog;
//Make sure the card is initialized before proceeding
if (m_Status & STA_NOINIT)
return RES_NOTRDY;
+ wdog=HAL_GetTick();
__DSB();
__ISB();
- while(BSP_SD_Get_Busy()==1){;}
+ while(BSP_SD_Get_Busy()==1)
+ {
+ if((HAL_GetTick()-wdog)>64)
+ {
+ BSP_SD_Clear_Busy();
+ return RES_ERROR;
+ }
+ }
BSP_SD_Set_Busy();
//Make sure the card isn't write protected before proceeding
if (m_Status & STA_PROTECT)
--- a/SDFileSystem.h Wed Apr 13 08:51:27 2016 +0000
+++ b/SDFileSystem.h Sat Apr 16 13:01:50 2016 +0000
@@ -183,6 +183,7 @@
bool m_WriteValidation;
int m_Status;
HAL_SD_CardInfoTypedef m_CardInfo;
+ HAL_SD_TransferStateTypedef m_CardStatus;
//Internal methods
void onCardRemoval();
void checkSocket();