System Routines initialize the File System or Drive. More...
Functions | |
fsStatus | finit (const char *drive) |
Initialize File System and drive related driver. | |
fsStatus | funinit (const char *drive) |
Uninitialize File System. | |
fsStatus | fmount (const char *drive) |
Mount drive. | |
fsStatus | funmount (const char *drive) |
Unmount drive. | |
uint32_t | fversion (void) |
Retrieve the File System component version. | |
System Routines initialize the File System or Drive.
The following diagram shows the basic flow of how to call the system routines to get access to a drive and a drive's media:
The routines are thread safe.
Code Example
fsStatus finit | ( | const char * | drive | ) |
Initialize File System and drive related driver.
[in] | drive | a string specifying the memory or storage device. |
The function finit initializes the software library resources required for a certain drive, including the File System and the related driver. It must be called before invoking any other function accessing the file system of the drive. Calling finit does not access the actual media on the specified drive. Before working with the drive's media, a call to fmount is required. fmount checks if the media is present and formatted. finit fails if the File System Component in general or the driver cannot be initialized.
Once the drive is successfully initialized, all subsequent calls of finit will return execution status fsOK, leaving internal drive state unchanged.
The argument drive specifies the Drives, Memory Devices and Drivers to be initialized. Every drive that is used in the system must be initialized separately using this function. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
fsStatus fmount | ( | const char * | drive | ) |
Mount drive.
[in] | drive | a string specifying the memory or storage device. |
The function fmount is used to mount the File System of the specified Drives, Memory Devices and Drivers. It initializes memory media, media management layer and the file system on top of it. Mounting means that it will be checked if the drive's media is attached and formatted. After a successful mount, drive is ready for file I/O operations (such as fread, fwrite, etc.).
The argument drive specifies the Drives, Memory Devices and Drivers to be mounted. Every drive that is used in the system must be mounted separately using this function. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
The drive that requires formatting also requires operational memory media and therefore fmount shall be called before attempting to format the drive. The memory media is operational when fmount successfully examines the drive and returns with execution status fsOK or fsNoFileSystem. Execution status fsNoFileSystem is returned when the file system on the memory media is not present or is unrecognized.
fsStatus funinit | ( | const char * | drive | ) |
Uninitialize File System.
[in] | drive | a string specifying the memory or storage device. |
The funinit function uninitializes the File System. This is necessary if during application run time the drive volume needs to be disabled (for example for lowering power consumption). To reinitialize the drive afterwards, finit needs to be called again.
The execution of funinit is unconditional and will always uninitialize available drive resources.
The argument drive specifies the Drives, Memory Devices and Drivers to be uninitialized. Every drive that is used in the system must be uninitialized separately using this function. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
fsStatus funmount | ( | const char * | drive | ) |
Unmount drive.
[in] | drive | a string specifying the memory or storage device. |
The function funmount is used to unmount a File System volume. When called, it flushes the data from internal file system buffers, closes all opened file handlers associated with the specified drive and disconnects the memory media. In case when removable memory media is not present only file handlers associated with the specified drive are closed.
The argument drive specifies the Drives, Memory Devices and Drivers to be unmounted. Every drive that is used in the system must be unmounted separately using this function. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
uint32_t fversion | ( | void | ) |
Retrieve the File System component version.
The function fversion retrieves the version of the File System component. Returned version is encoded in BCD format 0xMMmmbbbb where MM represents major version, mm minor version and bbbb build version.
Code Example