FAT file system driver that provides an interface for accessing a FAT file system located on a memory device.
More...
Functions |
uint8_t | fat_get_nbpartition (void) |
| This function returns the number of partition present on selected drive.
|
bool | fat_mount (void) |
| This function mounts a partition.
|
bool | fat_format (uint8_t u8_fat_type) |
| This function formats the drive.
|
bool | fat_serialnumber (bool b_action, uint8_t _MEM_TYPE_SLOW_ *a_u8_sn) |
| This function reads or writes a serial number.
|
LIMITATIONS OF FILE SYSTEM |
#define | FS_NB_FAT 2 |
Value used in "Fs_management_fast.u16_entry_pos_sel_file" |
#define | FS_NO_SEL 0xFFFF |
| Signal that a file entry isn't selected.
|
#define | FS_END_FIND 0xFFFE |
| Signal that a file entry is the last file entry accessibled by system.
|
Functions to verify navigator state |
}@
|
bool | fat_check_device (void) |
| This function checks device state.
|
bool | fat_check_mount (void) |
| This function checks if the partition is mounted.
|
bool | fat_check_noopen (void) |
| This function checks if a file is not opened on current navigator.
|
bool | fat_check_open (void) |
| This function checks if a file is opened on current navigator.
|
bool | fat_check_select (void) |
| This function checks if a file is selected on current navigator.
|
bool | fat_check_mount_noopen (void) |
| This function checks if the partition is mounted and no file is opened.
|
bool | fat_check_mount_select_noopen (void) |
| This function checks if the partition is mounted and if no file is opened and a file is selected.
|
bool | fat_check_mount_select_open (void) |
| This function checks if the partition is mounted and if a file is opened.
|
bool | fat_check_mount_select (void) |
| This function checks if the partition is mounted and if a file is selected.
|
bool | fat_check_is_file (void) |
| This function checks if the selected file entry is a file and not a directory.
|
Functions to read or to write a file or a directory |
bool | fat_read_file (uint8_t mode) |
| This function gets or clears a cluster list at the current position in the selected file.
|
bool | fat_write_file (uint8_t mode, uint32_t u32_nb_sector_write) |
bool | fat_read_dir (void) |
| This function fill the internal cache with a sector from current directory.
|
bool | fat_initialize_dir (void) |
Detailed Description
Supports FAT12, FAT16 and FAT32.
Data Structure Documentation
Definition at line 265 of file fat.h.
Data Fields |
struct Fs_rootdir |
seg |
|
uint32_t |
u32_cluster |
|
Definition at line 268 of file fat.h.
Data Fields |
uint16_t |
u16_pos |
|
uint16_t |
u16_size |
|
Definition at line 276 of file fat.h.
Data Fields |
uint8_t |
b_mode_nav |
|
uint8_t |
b_mode_nav_single |
|
Fs_rootdir |
rootdir |
|
FS_STRING |
sz_filterext |
|
uint16_t |
u16_entry_pos_sel_dir |
|
uint16_t |
u16_flat_pos_offset |
|
uint16_t |
u16_offset_FSInfo |
|
uint16_t |
u16_pos_filterlist |
|
uint16_t |
u16_pos_sel_file |
|
uint32_t |
u32_cluster_sel_dir |
|
uint32_t |
u32_CountofCluster |
|
uint32_t |
u32_fat_size |
|
uint32_t |
u32_offset_data |
|
uint32_t |
u32_ptr_fat |
|
uint8_t |
u8_BPB_SecPerClus |
|
uint8_t |
u8_flat_dir_level |
|
uint8_t |
u8_lun |
|
uint8_t |
u8_partition |
|
struct Fs_management_fast |
Definition at line 302 of file fat.h.
Data Fields |
uint16_t |
u16_entry_pos_sel_file |
|
uint8_t |
u8_type_fat |
|
struct Fs_management_entry |
Definition at line 309 of file fat.h.
Data Fields |
uint32_t |
u32_cluster |
|
uint32_t |
u32_pos_in_file |
|
uint32_t |
u32_size |
|
uint8_t |
u8_attr |
|
uint8_t |
u8_open_mode |
|
uint8_t |
u8_txt_format |
|
Definition at line 325 of file fat.h.
Data Fields |
uint32_t |
u32_addr |
|
uint32_t |
u32_size_or_pos |
|
Definition at line 331 of file fat.h.
Data Fields |
uint32_t |
u32_pos |
|
uint32_t |
u32_val |
|
struct Fs_clusterlist_cache |
Definition at line 341 of file fat.h.
Data Fields |
bool |
b_cache_file |
|
uint32_t |
u32_addr |
|
uint32_t |
u32_cluster |
|
uint32_t |
u32_size |
|
uint32_t |
u32_start |
|
uint8_t |
u8_level_use |
|
uint8_t |
u8_lun |
|
Definition at line 353 of file fat.h.
Data Fields |
uint32_t |
u32_addr |
|
uint32_t |
u32_clusterlist_pos |
|
uint32_t |
u32_clusterlist_start |
|
uint8_t |
u8_dirty |
if the sector is a sector from a cluster list THEN |
uint8_t |
u8_lun |
|
Macro Definition Documentation
* - File system vocabulary :
* MBR : Master Boot Record (constains four PE)
* PE : Partition Entry (constains a location informations about PBR)
* PBR : Partition Boot Record
* BPB : BIOS Parameter Block (see Hardware White Paper FAT)
* PBR = BPB
* FAT : File Allocation Table
*
Definition at line 73 of file fat.h.
#define fat_check_nav_access_disk |
( |
|
b | ) |
(true) |
#define fat_check_nav_access_file |
( |
|
b | ) |
(true) |
#define fat_copy_nav ( arg ) (arg++) |
#define Fat_file_close |
( |
| ) |
(fs_g_nav_entry.u8_open_mode =0 ) |
#define Fat_file_is_open |
( |
| ) |
(fs_g_nav_entry.u8_open_mode !=0 ) |
#define Fat_file_isnot_open |
( |
| ) |
(fs_g_nav_entry.u8_open_mode ==0 ) |
#define fat_invert_nav ( arg ) (arg++) |
#define FS_512B_MASK (512-1) |
#define FS_512B_SHIFT_BIT 9 |
#define FS_BOOT_SIGN 0x29 |
#define FS_BR_SIGNATURE_HIGH 0xAA |
#define FS_BR_SIGNATURE_LOW 0x55 |
#define FS_BUF_SECTOR_EMPTY 0xFF |
#define FS_CACHE_SIZE 512 |
#define FS_CLUST_ACT_CLR 0x03 |
#define FS_CLUST_ACT_ONE 0x02 |
#define FS_CLUST_ACT_SEG 0x01 |
#define FS_CLUST_VAL_EOL 0x0FFFFFFF |
#define FS_CLUST_VAL_READ false |
#define FS_CLUST_VAL_WRITE true |
#define FS_END_FIND 0xFFFE |
#define FS_ENTRY_DEL 0xE5 |
#define FS_ENTRY_END 0x00 |
#define FS_ENTRY_LFN_LAST 0x40 |
#define FS_FAT12_MAX_CLUSTERS 4085 |
#define FS_FAT16_MAX_CLUSTERS 65525 |
#define FS_MBR_OFFSET_PART_ENTRY |
( |
|
num | ) |
((uint16_t)((uint16_t)(0x1BE)+(0x10 * num))) |
#define FS_PART_BOOTABLE 0x80 |
#define FS_PART_HARD_DISK 0x81 |
#define FS_PART_NO_BOOTABLE 0x00 |
#define FS_PART_NO_REMOVE_MEDIA 0xF8 |
#define FS_PART_REMOVE_MEDIA 0xF0 |
#define FS_PART_TYPE_FAT12 0x01 |
#define FS_PART_TYPE_FAT16_INF32M 0x04 |
#define FS_PART_TYPE_FAT16_SUP32M 0x06 |
#define FS_PART_TYPE_FAT16_SUP32M_BIS 0x0E |
#define FS_PART_TYPE_FAT32 0x0B |
#define FS_PART_TYPE_FAT32_BIS 0x0C |
#define FS_SHIFT_B_TO_FILE_ENTRY 5 |
#define FS_SIZE_FILE_ENTRY 32 |
#define FS_SIZE_LFN_ENTRY 13 |
#define FS_SIZE_SFNAME 11 |
#define FS_SIZE_SFNAME_EXT_ONLY 3 |
#define FS_SIZE_SFNAME_WITHOUT_EXT 8 |
#define FS_TYPE_FAT_UNM 0 |
Definition at line 84 of file fat.h.
Definition at line 89 of file fat.h.
Definition at line 94 of file fat.h.
Typedef Documentation
Function Documentation
bool fat_allocfreespace |
( |
void |
| ) |
|
void fat_cache_clear |
( |
void |
| ) |
|
void fat_cache_clusterlist_reset |
( |
void |
| ) |
|
bool fat_cache_flush |
( |
void |
| ) |
|
- Returns:
- false in case of error, see global value "fs_g_status" for more detail
-
true otherwise
Definition at line 1859 of file fat.c.
void fat_cache_mark_sector_as_dirty |
( |
void |
| ) |
|
bool fat_cache_read_sector |
( |
bool |
b_load | ) |
|
- Parameters:
-
b_load | true, load the cache with the memory sector corresponding
false, Don't change the sector cache but change the memory address of cache
|
- Returns:
- false in case of error, see global value "fs_g_status" for more detail
-
true otherwise
//! Global variable used
//! IN :
//! fs_g_nav.u8_lun drive number to read
//! fs_gu32_addrsector address to read (unit sector)
//!
Definition at line 1793 of file fat.c.
void fat_cache_reset |
( |
void |
| ) |
|
bool fat_check_device |
( |
void |
| ) |
|
- Returns:
- true device ready
-
false otherwise
//! This function updates all navigator datas when the device state change.
//!
Definition at line 94 of file fat.c.
bool fat_check_eof_name |
( |
uint16_t |
character | ) |
|
- Parameters:
-
character | value of character to check |
- Returns:
- true, it is a character to signal a end of name (0,'\','/')
-
false, otherwise
Definition at line 1762 of file fat.c.
bool fat_check_is_file |
( |
void |
| ) |
|
- Returns:
- true It is a file and not a directory
-
false otherwise
Definition at line 286 of file fat.c.
bool fat_check_mount |
( |
void |
| ) |
|
- Returns:
- true partition mounted
-
false otherwise
Definition at line 157 of file fat.c.
bool fat_check_mount_noopen |
( |
void |
| ) |
|
- Returns:
- true partition mounted and no file is opened
-
false otherwise
Definition at line 230 of file fat.c.
bool fat_check_mount_select |
( |
void |
| ) |
|
- Returns:
- true partition mounted and a file is selected
-
false otherwise
Definition at line 273 of file fat.c.
bool fat_check_mount_select_noopen |
( |
void |
| ) |
|
- Returns:
- true partition mounted and no file is opened and a file is selected
-
false otherwise
Definition at line 243 of file fat.c.
bool fat_check_mount_select_open |
( |
void |
| ) |
|
- Returns:
- true partition mounted and a file is opened
-
false otherwise
Definition at line 258 of file fat.c.
bool fat_check_noopen |
( |
void |
| ) |
|
- Returns:
- true no file opened
-
false otherwise
Definition at line 178 of file fat.c.
bool fat_check_open |
( |
void |
| ) |
|
- Returns:
- true a file is opened
-
false otherwise
Definition at line 198 of file fat.c.
bool fat_check_select |
( |
void |
| ) |
|
- Returns:
- true a file is selected
-
false otherwise
Definition at line 214 of file fat.c.
uint8_t fat_checkcluster |
( |
void |
| ) |
|
- Returns:
- value status
FS_CLUS_OK Value correct
FS_CLUS_BAD Value bad
FS_CLUS_END It is a end of list
//! Global variable used
//! IN :
//! fs_g_cluster.u32_val value to check
//!
Definition at line 844 of file fat.c.
bool fat_clear_cluster |
( |
void |
| ) |
|
void fat_clear_entry_info_and_ptr |
( |
void |
| ) |
|
void fat_clear_info_fat_mod |
( |
void |
| ) |
|
bool fat_cluster_list |
( |
uint8_t |
opt_action, |
|
|
bool |
b_for_file |
|
) |
| |
- Parameters:
-
b_for_file | If true then it is a file cluster list else a directory cluster list
|
opt_action | Choose action on the cluster list
FS_CLUST_ACT_SEG Get continue memory segment corresponding at cluster list
FS_CLUST_ACT_ONE Get only one memory sector (512B) corresponding at cluster list
FS_CLUST_ACT_CLR Clear the cluster list
|
- Returns:
- false in case of error, see global value "fs_g_status" for more detail
-
true otherwise
//! Global variables used
//! IN :
//! fs_g_seg.u32_addr The first cluster of the cluster list
//! fs_g_seg.u32_size_or_pos Start position in the cluster list (unit 512B)
//! OUT:
//! fs_g_seg.u32_addr The memory segment address corresponding at the beginning of cluster list (only for action FS_CLUST_ACT_SEG & FS_CLUST_ACT_ONE)
//! fs_g_seg.u32_size_or_pos The memory segment size corresponding at cluster list readed or cleared (unit 512B)
//!
Definition at line 367 of file fat.c.
bool fat_cluster_readnext |
( |
void |
| ) |
|
Read global value "fs_g_status" in case of error : FS_ERR_HW Hardware driver error FS_LUN_WP Drive is read only
- Returns:
- false in case of error, see global value "fs_g_status" for more detail
-
true otherwise
//! Global variables used
//! IN :
//! fs_g_u16_pos_fat previous cluster position in FAT
//! OUT:
//! fs_g_u16_pos_fat readed cluster position in FAT
//! fs_g_cluster.u32_val value of cluster readed
//!
Definition at line 797 of file fat.c.
bool fat_cluster_val |
( |
bool |
b_mode | ) |
|
- Parameters:
-
b_mode | false, to read a cluster value
true, to write a cluster value |
- Returns:
- false in case of error, see global value "fs_g_status" for more detail
-
true otherwise
//! Global variables used
//! IN :
//! fs_g_cluster.u32_pos cluster number to read or write
//! fs_g_cluster.u32_val value to write
//! OUT:
//! fs_g_cluster.u32_val value readed
//! fs_g_u16_pos_fat position in FAT of the cluster to read or write
//! value init in case of the fat_cluster_readnext() routine is used after
//!
Definition at line 606 of file fat.c.
bool fat_create_entry_file_name |
( |
FS_STRING |
sz_name | ) |
|
bool fat_delete_file |
( |
bool |
b_cluster_list | ) |
|
bool fat_entry_check |
( |
bool |
b_type | ) |
|
- Parameters:
-
b_type | entry type to compare (FS_FILE or FS_DIR) |
- Returns:
- true, the entry is a short entry and correspond to b_type
-
false, otherwise
//! Global variable used
//! IN :
//! fs_g_sector The directory sector corresponding at the current position
//! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry)
//!
Definition at line 1242 of file fat.c.
bool fat_entry_checkext |
( |
FS_STRING |
sz_filter | ) |
|
- Parameters:
-
sz_filter | extension filter is a ASCII string (ex: "mp3,w*" ) |
- Returns:
- true, the file name have a good extension
-
false, otherwise
//! Global variable used
//! IN :
//! fs_g_sector The directory sector corresponding at the current position
//! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry)
//!
Definition at line 1293 of file fat.c.
bool fat_entry_is_dir |
( |
void |
| ) |
|
- Returns:
- true, this entry is a directory
-
false, otherwise
Definition at line 1384 of file fat.c.
bool fat_entry_label |
( |
bool |
b_action, |
|
|
FS_STRING |
sz_label |
|
) |
| |
bool fat_entry_longname |
( |
FS_STRING |
sz_name, |
|
|
uint8_t |
u8_size_max, |
|
|
bool |
b_mode, |
|
|
bool |
b_match_case |
|
) |
| |
- Parameters:
-
b_mode | action mode:
FS_NAME_GET to get the long name of selected file
FS_NAME_CHECK to compare the long name of selected file
|
sz_name | if FS_NAME_GET then buffer to store the long name file (ASCII or UNICODE )
if FS_NAME_CHECK then name to compare with long name (ASCII or UNICODE), it must be terminate by NULL or '*' value
|
b_match_case | false, ignore the case (only used in "FS_NAME_CHECK" action mode) |
u8_size_max | buffer size (unit ASCII or UNICODE ) (ignored in "FS_NAME_CHECK" mode) |
- Returns:
- false is not the end of long name, or in case of error, see global value "fs_g_status" for more detail
-
true, the name is correct or read is finish
//! Global variable used
//! IN :
//! fs_g_sector The directory sector corresponding at the current position
//! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry)
//!
Definition at line 1606 of file fat.c.
bool fat_entry_shortname |
( |
FS_STRING |
sz_name, |
|
|
uint8_t |
u8_size_max, |
|
|
bool |
b_mode |
|
) |
| |
- Parameters:
-
b_mode | action mode:
FS_NAME_GET to get the short name of selected file
FS_NAME_CHECK to compare the short name of selected file
|
sz_name | if FS_NAME_GET then buffer to store the short name file (ASCII or UNICODE )
if FS_NAME_CHECK then name to compare with short name (ASCII or UNICODE), it must be terminate by NULL or '*' value
|
u8_size_max | buffer size (unit ASCII or UNICODE ) (ignored in "FS_NAME_CHECK" mode) |
- Returns:
- false, in case of error, see global value "fs_g_status" for more detail
-
true, the name is correct or read OK
//! Global variable used
//! IN :
//! fs_g_sector The directory sector corresponding at the current position
//! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry)
//!
Definition at line 1475 of file fat.c.
bool fat_format |
( |
uint8_t |
u8_fat_type | ) |
|
void fat_get_date |
( |
FS_STRING |
sz_date, |
|
|
bool |
type_date |
|
) |
| |
- Parameters:
-
type_date | choose the date type (FS_DATE_LAST_WRITE or FS_DATE_CREATION) |
sz_date | table to store the date
storage format (ASCII) = "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, seconde, miliseconde |
Definition at line 1219 of file fat_unusual.c.
void fat_get_entry_info |
( |
void |
| ) |
|
//! Global variable used
//! IN :
//! fs_g_sector The directory sector corresponding at the current position
//! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry)
//! OUT:
//! fs_g_nav_entry. u32_cluster, u8_attr, u32_size
//!
Definition at line 1352 of file fat.c.
uint8_t fat_get_nbpartition |
( |
void |
| ) |
|
This function returns the number of partition present on selected drive.
- Returns:
- u8_number number of partition
Definition at line 302 of file fat.c.
- Returns:
- a pointer on the internal cache
Definition at line 1772 of file fat.c.
uint32_t fat_getfreespace |
( |
void |
| ) |
|
- Returns:
- the number of sector free
if 0, then error or full
Definition at line 2130 of file fat_unusual.c.
uint8_t fat_getfreespace_percent |
( |
void |
| ) |
|
- Returns:
- percent of free space (1 to 100) if 0, then error or full
//! More speed than fat_getfreespace() routine but error delta 1%
//!
Definition at line 2195 of file fat_unusual.c.
bool fat_initialize_dir |
( |
void |
| ) |
|
This function mounts a partition.
- Returns:
- false in case of error, see global value "fs_g_status" for more detail
-
true otherwise
//! Global variables used
//! IN :
//! fs_g_nav.u8_lun Indicate the drive to mount
//! fs_g_nav.u8_partition Indicate the partition to mount (if FS_MULTI_PARTITION = true )
//! OUT:
//! fs_g_nav update structure
//! If the FS_MULTI_PARTITION option is disabled
//! then the mount routine selects the first partition supported by file system. <br>
//!
Definition at line 106 of file fat_unusual.c.
bool fat_read_dir |
( |
void |
| ) |
|
- Returns:
- false in case of error, see global value "fs_g_status" for more detail
-
true otherwise
//! Global variable used
//! IN :
//! fs_g_nav.u32_cluster_sel_dir First cluster of current directory
//! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory (unit entry)
//!
Definition at line 1194 of file fat.c.
uint32_t fat_read_fat32_FSInfo |
( |
void |
| ) |
|
bool fat_read_file |
( |
uint8_t |
mode | ) |
|
- Parameters:
-
mode | Choose action
FS_CLUST_ACT_SEG Get memory segment corresponding at the position in selected file
FS_CLUST_ACT_ONE Store in internal cache the sector corresponding at the position in selected file
FS_CLUST_ACT_CLR Clear the cluster list corresponding at the position in selected file
|
- Returns:
- false in case of error, see global value "fs_g_status" for more detail
-
true otherwise
//! Global variable used
//! IN :
//! fs_g_nav_entry.u32_cluster First cluster of selected file
//! fs_g_nav_entry.u32_pos_in_file Position in file (unit byte)
//!
Definition at line 1034 of file fat.c.
bool fat_serialnumber |
( |
bool |
b_action, |
|
|
uint8_t _MEM_TYPE_SLOW_ * |
a_u8_sn |
|
) |
| |
void fat_set_date |
( |
const FS_STRING |
sz_date, |
|
|
bool |
type_date |
|
) |
| |
bool fat_update_fat2 |
( |
void |
| ) |
|
void fat_write_entry_file |
( |
void |
| ) |
|
bool fat_write_fat32_FSInfo |
( |
uint32_t |
u32_nb_free_cluster | ) |
|
bool fat_write_file |
( |
uint8_t |
mode, |
|
|
uint32_t |
u32_nb_sector_write |
|
) |
| |
Variable Documentation
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_gu32_addrsector |