Author Topic: How to detect if SD card formatting has finished  (Read 2617 times)

Offline martinh

  • Newbie
  • *
  • Posts: 25
    • View Profile
How to detect if SD card formatting has finished
« on: March 27, 2014, 11:26:20 AM »
Hi Mark,

Referring to uTasker_utFAT.pdf/V0.09 I would like to add the re-format and fformat features to a LPC2468 project.
The function utFormat() returns UTFAT_SUCCESS if the formatting/re-formatting has started successfully.
But as formatting can take some time, is there a way to find out if formatting has finished so that new files can be written?

utDeleteFile() deletes single files. I suppose this function cannot be used to delete several files in the root by specifying files using wildcards? Something like *.* or obj*.* ?

Regards,
Martin

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2962
    • View Profile
    • uTasker
Re: How to detect if SD card formatting has finished
« Reply #1 on: March 27, 2014, 06:18:49 PM »
Hi Martin

During the formatting process you can check the state by calling

const UTDISK *ptrDiskInfo = fnGetDiskInfo(DISK_D);
(this pointer only needs to get 'gotten' once).
and then checking ptrDiskInfo->usDiskFlags
ptrDiskInfo->usDiskFlags & DISK_UNFORMATTED will be true whiles formatting.
It is ready for use again when re-mounted, therefore
ptrDiskInfo->usDiskFlags & DISK_MOUNTED becomes true.

At this point there can be a debug output "Disk D mounted" but there is no specific system event.
If you prefer not to poll the state you could add an event at this point that sends a message or interrupt event to a task that would like to work with the card.
Usually formatting/reformatting is a "manual" thing but it could of course be automated and then an event could be useful.


utDelete() requires an exact file name. To perform wild-card deletes it would be necessary to add a loop in the application to filter matching files and then call each with the exact name.

Regards

Mark





« Last Edit: March 27, 2014, 06:20:49 PM by mark »

Offline martinh

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: How to detect if SD card formatting has finished
« Reply #2 on: March 28, 2014, 08:34:37 AM »
Hi Mark,

I suppose I will prefer polling.
Thank you so much for your immediate reply!

Regards,

Martin