2

I am wondering if there are any build in functions for the uC/FS to get the amount of memory left on my SD Card with FAT32 format.

Many thanks.

PS. I have looked around but don't seem to be able to find it on the manual.

Low Lifer
  • 225
  • 1
  • 2
  • 5

1 Answers1

2

In order to retrieve the amount of free space on a µC/FS volume, you use the FSVol_Query() function and calculate the amount of free space using the data returned in the FS_VOL_INFO structure.

FS_VOL_INFO  vol_info;
CPU_INT64U   size_rem;
FS_ERR       err;

FSVol_Query("sdcard:0:", &vol_info, err);
if (err != FS_ERR_NONE) {
    /* oops, something went wrong, handle error */
}

size_rem = vol_info.VolFreeSecCnt * vol_info.DevSecSize;

Where "sdcard:0:" should be replaced by the volume name of which you'd like to retrieve the amount of free space. The function is documented in section A-7-12 of the user manual.

If using the previous (V3.X) version, check the FS_GetVolumeInfo() function.

Eric Julien
  • 141
  • 1
  • 2
  • This is awesome, thank you so much Eric! I'm going to experiment with your suggestion. I'll let you know soon once I get it working =) – Low Lifer Feb 28 '13 at 22:01
  • Okay, just did a search, looks like I have the older version you speak of. Then just vol_info.NumFreeClusters * info.SectorPerCluster * info.BytesPerSector =D thank you!! – Low Lifer Feb 28 '13 at 22:05