|
whiskers 0.2.0
RP2350 BadUSB Tool
|
HAL disk functions.
This file contains all the functions required to initialize and manage the disk (SD card).
Note as per usual with HAL functions, the proper structs and underlying memory is set by the functions.
Here is an example snippet of code that initializes the disk, mounts it, and if no filesystem is found creates one.
#include "shared.h"Go to the source code of this file.
Functions | |
| void | disk_init (_DISK_INFO *di) |
| Sets all the variables required for the disk and then initializes the SD library. | |
| bool | disk_mount (_DISK_INFO *di) |
| Mounts the disk and checks for a FatFS. | |
| bool | disk_umount (_DISK_INFO *di) |
| Unmounts the disk regardless of filesystem status. | |
| bool | disk_format_ff (_DISK_INFO *di) |
| Creates a FatFS on the disk. | |
| bool | disk_is_physically_mounted () |
| Checks if a SD card is currently present in the device. | |
| bool disk_format_ff | ( | _DISK_INFO * | di | ) |
Creates a FatFS on the disk.
| *di | _DISK_INFO pointer to manage the FatFS and to set errno |
Creates a FatFS (Fat version determined by the library internally) spanning the entire working space of the disk. This will erase all of the data already on the disk.
| void disk_init | ( | _DISK_INFO * | di | ) |
Sets all the variables required for the disk and then initializes the SD library.
| *di | _DISK_INFO pointer to store the resulting SD pointers. |
Note that this function only sets hardware configuration values and doesn't actually mount the drive or do any FatFS related operations. This must be called first before any of the other functions.
| bool disk_is_physically_mounted | ( | ) |
Checks if a SD card is currently present in the device.
Note: the lower level implementation of this either uses the underlying SD library to check for a connection, or the physical chip select switch on the SD card slot. This is configured in shared.h under the HAL_SD_USE_HW_CD definition. Either way, it is reliable enough to use.
| bool disk_mount | ( | _DISK_INFO * | di | ) |
Mounts the disk and checks for a FatFS.
| *di | _DISK_INFO pointer to store the internal filesytem information and to set errno and the mounted status |
This function mounts the device and checks for a valid filesystem. If none is found then HAL_FS_NO_FS is set as the errno for no filesystem. Any other error that occurs is set as well. If no fileystem is found then one must be created.
| bool disk_umount | ( | _DISK_INFO * | di | ) |
Unmounts the disk regardless of filesystem status.
| *di | _DISK_INFO pointer to manage the FatFS and to set errno and mounted status. |