Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top