ASF docs  3.1.3
Some important library documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
FAT file system

FAT file system driver that provides an interface for accessing a FAT file system located on a memory device. More...

Data Structures

union  Fs_rootdir
 Union to define a root directory. More...
struct  Fs_rootdir.seg
struct  Fs_management
 Struture to save the variables frequently used by file system mounted. More...
struct  Fs_management_fast
 Struture to save the variables very frequently used by file system mounted. More...
struct  Fs_management_entry
 Struture to save the frequently variables of file system mounted. More...
struct  Fs_segment
 Struture to define a segment. More...
struct  Fs_cluster
 Struture to store cluster information. More...
struct  Fs_clusterlist_cache
 Struture to store the cluster list cache. More...
struct  Fs_sector_cache
 Struture to store the information about sector cache (=last sector read or write on disk) More...

Macros

#define _GLOBEXT_   extern
#define Is_fat12   (FS_TYPE_FAT_12 == fs_g_nav_fast.u8_type_fat)
#define Is_fat16   (FS_TYPE_FAT_16 == fs_g_nav_fast.u8_type_fat)
#define Is_fat32   (FS_TYPE_FAT_32 == fs_g_nav_fast.u8_type_fat)
#define Is_unicode   (g_b_unicode)
#define FS_MBR_OFFSET_PART_ENTRY(num)   ((uint16_t)((uint16_t)(0x1BE)+(0x10 * num)))
 Position (unit byte) in the MBR of a partition entry.
#define FS_BUF_SECTOR_EMPTY   0xFF
 Signal that sector cache is not valid.

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.

Variables

_GLOBEXT_ bool g_b_unicode
 Variables to select string format (initialised in nav_reset())
_GLOBEXT_ bool g_b_string_length
 Variables to select LENGTH string mode (initialised in nav_reset())
_GLOBEXT_ bool g_b_no_check_disk
 Variables to enable/disable the disk check before each action on disk.
_GLOBEXT_ _MEM_TYPE_FAST_
Fs_segment 
fs_g_seg
 Variable frequently used by many function (optimization, no parameter in function)
_GLOBEXT_ _MEM_TYPE_FAST_
Fs_cluster 
fs_g_cluster
 To take time in functions: fat_getfreespace, fat_cluster_list, fat_cluster_val, fat_checkcluster.

Macro to access at fields in BPB sector (only used in fat_mount() function)

The name prefixed by "BPB_" are defined in "Hardware White Paper FAT"

#define LOW_16_BPB_BytsPerSec   fs_g_sector[11]
#define HIGH_16_BPB_BytsPerSec   fs_g_sector[12]
#define U8_BPB_SecPerClus   fs_g_sector[13]
#define LOW_16_BPB_RootEntCnt   fs_g_sector[17]
#define HIGH_16_BPB_RootEntCnt   fs_g_sector[18]
#define LOW_16_BPB_FATSz16   fs_g_sector[22]
#define HIGH_16_BPB_FATSz16   fs_g_sector[23]
#define LOW0_32_BPB_FATSz32   fs_g_sector[36]
#define LOW1_32_BPB_FATSz32   fs_g_sector[37]
#define LOW2_32_BPB_FATSz32   fs_g_sector[38]
#define LOW3_32_BPB_FATSz32   fs_g_sector[39]
#define LOW_16_BPB_TotSec16   fs_g_sector[19]
#define HIGH_16_BPB_TotSec16   fs_g_sector[20]
#define LOW0_32_BPB_TotSec32   fs_g_sector[32]
#define LOW1_32_BPB_TotSec32   fs_g_sector[33]
#define LOW2_32_BPB_TotSec32   fs_g_sector[34]
#define LOW3_32_BPB_TotSec32   fs_g_sector[35]
#define LOW_16_BPB_ResvSecCnt   fs_g_sector[14]
#define HIGH_16_BPB_ResvSecCnt   fs_g_sector[15]
#define U8_BPB_NumFATs   fs_g_sector[16]
#define LOW0_32_BPB_RootClus   fs_g_sector[44]
#define LOW1_32_BPB_RootClus   fs_g_sector[45]
#define LOW2_32_BPB_RootClus   fs_g_sector[46]
#define LOW3_32_BPB_RootClus   fs_g_sector[47]
#define LOW_16_BPB_FSInfo   fs_g_sector[48]
#define HIGH_16_BPB_FSInfo   fs_g_sector[49]

Constante used to sign a MBR or PBR sectors

#define FS_BR_SIGNATURE_LOW   0x55
#define FS_BR_SIGNATURE_HIGH   0xAA

Constants used in MBR sector

#define FS_PART_BOOTABLE   0x80
#define FS_PART_NO_BOOTABLE   0x00
#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_PART_REMOVE_MEDIA   0xF0
#define FS_PART_NO_REMOVE_MEDIA   0xF8
#define FS_PART_HARD_DISK   0x81
#define FS_BOOT_SIGN   0x29

Maximum of FAT cluster

#define FS_FAT12_MAX_CLUSTERS   4085
#define FS_FAT16_MAX_CLUSTERS   65525

Constants used in the first byte of file entry

#define FS_ENTRY_END   0x00
#define FS_ENTRY_DEL   0xE5
#define FS_ENTRY_LFN_LAST   0x40

Constantes used to manage the file entry

#define FS_SIZE_FILE_ENTRY   32
#define FS_SHIFT_B_TO_FILE_ENTRY   5
#define FS_SIZE_LFN_ENTRY   13
#define FS_SIZE_SFNAME   11
#define FS_SIZE_SFNAME_WITHOUT_EXT   8
#define FS_SIZE_SFNAME_EXT_ONLY   3

LIMITATIONS OF FILE SYSTEM

#define FS_NB_FAT   2

The unit sector of 512B is many used in file System stack

#define FS_512B   512
#define FS_512B_MASK   (512-1)
#define FS_512B_SHIFT_BIT   9
#define FS_SIZE_OF_SECTOR   FS_512B
#define FS_MASK_SIZE_OF_SECTOR   FS_512B_MASK
#define FS_SHIFT_B_TO_SECTOR   FS_512B_SHIFT_BIT
#define FS_CACHE_SIZE   512

Status of the fat_checkcluster() function

#define FS_CLUS_OK   0
#define FS_CLUS_BAD   1
#define FS_CLUS_END   2

Options of the fat_cluster_list() function

#define FS_CLUST_ACT_SEG   0x01
#define FS_CLUST_ACT_ONE   0x02
#define FS_CLUST_ACT_CLR   0x03

Options of the fat_cluster_val() function

#define FS_CLUST_VAL_READ   false
#define FS_CLUST_VAL_WRITE   true
#define FS_CLUST_VAL_EOL   0x0FFFFFFF

FAT type ID, used in "Fs_management_fast.u8_type_fat"

#define FS_TYPE_FAT_UNM   0
 Partition not mounted.
#define FS_TYPE_FAT_12   1
#define FS_TYPE_FAT_16   2
#define FS_TYPE_FAT_32   3

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.

Macro to check the file open mode

#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_file_close()   (fs_g_nav_entry.u8_open_mode =0 )

Variables initialised in drive_mount()

_GLOBEXT_ _MEM_TYPE_SLOW_
Fs_management 
fs_g_nav
_GLOBEXT_ _MEM_TYPE_FAST_
Fs_management_fast 
fs_g_nav_fast
_GLOBEXT_ _MEM_TYPE_SLOW_
Fs_management_entry 
fs_g_nav_entry

Variables used to manage the sector cache

typedef uint8_t _MEM_TYPE_SLOW_ * PTR_CACHE
_GLOBEXT_ _MEM_TYPE_SLOW_ uint8_t fs_g_sector [FS_CACHE_SIZE]
 Use "FAT sector cache" to store a sector from a file (see file_putc(), file_getc(), file_read_buf(), file_write_buf())
_GLOBEXT_ _MEM_TYPE_SLOW_
Fs_sector_cache 
fs_g_sectorcache
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_gu32_addrsector
 Store the address of futur cache (unit 512B)

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 compute free space on a partition

uint32_t fat_getfreespace (void)
 This function returns the space free in the partition.
uint8_t fat_getfreespace_percent (void)
 This function returns the space free in percent.
bool fat_write_fat32_FSInfo (uint32_t u32_nb_free_cluster)
uint32_t fat_read_fat32_FSInfo (void)

Functions to manage the cluster list

bool fat_cluster_list (uint8_t opt_action, bool b_for_file)
 This function gets or clears a cluster list.
void fat_cache_clusterlist_reset (void)
 This function resets the cluster list caches.
bool fat_cluster_val (bool b_mode)
 This function returns or modifys a cluster value in FAT.
bool fat_cluster_readnext (void)
 This function is optimized to read a continue cluster list on FAT16 and FAT32.
uint8_t fat_checkcluster (void)
 This function checks the cluster value.
bool fat_allocfreespace (void)
void fat_clear_info_fat_mod (void)
bool fat_clear_cluster (void)
bool fat_update_fat2 (void)

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)

Functions to manage the entry field (fat.c)

bool fat_entry_check (bool b_type)
 This function checks the entry.
bool fat_entry_checkext (FS_STRING sz_filter)
 This function checks the file extension.
void fat_get_entry_info (void)
 This function reads information about selected file.
bool fat_entry_is_dir (void)
 This function checks if the entry file is a directory.
void fat_clear_entry_info_and_ptr (void)
 This function resets the selection pointers.
void fat_write_entry_file (void)
bool fat_entry_shortname (FS_STRING sz_name, uint8_t u8_size_max, bool b_mode)
 This function returns or compares the short name entry.
bool fat_entry_longname (FS_STRING sz_name, uint8_t u8_size_max, bool b_mode, bool b_match_case)
 This function returns or compares the long name entry.
bool fat_check_eof_name (uint16_t character)
 Check end of name.
PTR_CACHE fat_get_ptr_entry (void)
 This function returns a cache pointer on the current entry.

Functions to manage the entry field (fat_unusual.c)

bool fat_create_entry_file_name (FS_STRING sz_name)
void fat_get_date (FS_STRING sz_date, bool type_date)
 This function reads the information about a date.
void fat_set_date (const FS_STRING sz_date, bool type_date)
bool fat_delete_file (bool b_cluster_list)
bool fat_entry_label (bool b_action, FS_STRING sz_label)

Functions to manage the cache

bool fat_cache_read_sector (bool b_load)
 This function loads a memory sector in internal cache sector.
void fat_cache_reset (void)
 This function resets the sector cache.
void fat_cache_clear (void)
void fat_cache_mark_sector_as_dirty (void)
bool fat_cache_flush (void)
 This function flushs the sector cache on the memory if necessary.

Functions to control access disk

#define fat_check_nav_access_disk(b)   (true)
#define fat_check_nav_access_file(b)   (true)

Functions to manage navigator switch

#define fat_invert_nav   ( arg ) (arg++)
#define fat_copy_nav   ( arg ) (arg++)

Detailed Description

Supports FAT12, FAT16 and FAT32.


Data Structure Documentation

union Fs_rootdir

Definition at line 265 of file fat.h.

Data Fields
struct Fs_rootdir seg
uint32_t u32_cluster
struct Fs_rootdir.seg

Definition at line 268 of file fat.h.

Data Fields
uint16_t u16_pos
uint16_t u16_size
struct Fs_management

Definition at line 276 of file fat.h.

+ Collaboration diagram for Fs_management:
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
struct Fs_segment

Definition at line 325 of file fat.h.

Data Fields
uint32_t u32_addr
uint32_t u32_size_or_pos
struct Fs_cluster

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
struct Fs_sector_cache

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

#define _GLOBEXT_   extern
  * - 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)

Definition at line 533 of file fat.h.

#define fat_check_nav_access_file (   b)    (true)

Definition at line 534 of file fat.h.

#define fat_copy_nav   ( arg ) (arg++)

Definition at line 546 of file fat.h.

#define Fat_file_close ( )    (fs_g_nav_entry.u8_open_mode =0 )

Definition at line 385 of file fat.h.

#define Fat_file_is_open ( )    (fs_g_nav_entry.u8_open_mode !=0 )

Definition at line 383 of file fat.h.

#define Fat_file_isnot_open ( )    (fs_g_nav_entry.u8_open_mode ==0 )

Definition at line 384 of file fat.h.

#define fat_invert_nav   ( arg ) (arg++)

Definition at line 545 of file fat.h.

#define FS_512B   512

Definition at line 225 of file fat.h.

#define FS_512B_MASK   (512-1)

Definition at line 226 of file fat.h.

#define FS_512B_SHIFT_BIT   9

Definition at line 227 of file fat.h.

#define FS_BOOT_SIGN   0x29

Definition at line 185 of file fat.h.

#define FS_BR_SIGNATURE_HIGH   0xAA

Definition at line 155 of file fat.h.

#define FS_BR_SIGNATURE_LOW   0x55

Definition at line 154 of file fat.h.

#define FS_BUF_SECTOR_EMPTY   0xFF

Definition at line 235 of file fat.h.

#define FS_CACHE_SIZE   512

Definition at line 231 of file fat.h.

#define FS_CLUS_BAD   1

Definition at line 241 of file fat.h.

#define FS_CLUS_END   2

Definition at line 242 of file fat.h.

#define FS_CLUS_OK   0

Definition at line 240 of file fat.h.

#define FS_CLUST_ACT_CLR   0x03

Definition at line 250 of file fat.h.

#define FS_CLUST_ACT_ONE   0x02

Definition at line 249 of file fat.h.

#define FS_CLUST_ACT_SEG   0x01

Definition at line 248 of file fat.h.

#define FS_CLUST_VAL_EOL   0x0FFFFFFF

Definition at line 257 of file fat.h.

#define FS_CLUST_VAL_READ   false

Definition at line 255 of file fat.h.

#define FS_CLUST_VAL_WRITE   true

Definition at line 256 of file fat.h.

#define FS_END_FIND   0xFFFE

Definition at line 377 of file fat.h.

#define FS_ENTRY_DEL   0xE5

Definition at line 199 of file fat.h.

#define FS_ENTRY_END   0x00

Definition at line 198 of file fat.h.

#define FS_ENTRY_LFN_LAST   0x40

Definition at line 200 of file fat.h.

#define FS_FAT12_MAX_CLUSTERS   4085

Definition at line 191 of file fat.h.

#define FS_FAT16_MAX_CLUSTERS   65525

Definition at line 192 of file fat.h.

#define FS_MASK_SIZE_OF_SECTOR   FS_512B_MASK

Definition at line 229 of file fat.h.

#define FS_MBR_OFFSET_PART_ENTRY (   num)    ((uint16_t)((uint16_t)(0x1BE)+(0x10 * num)))

Definition at line 117 of file fat.h.

#define FS_NB_FAT   2

Definition at line 217 of file fat.h.

#define FS_NO_SEL   0xFFFF

Definition at line 376 of file fat.h.

#define FS_PART_BOOTABLE   0x80

Definition at line 161 of file fat.h.

#define FS_PART_HARD_DISK   0x81

Definition at line 184 of file fat.h.

#define FS_PART_NO_BOOTABLE   0x00

Definition at line 162 of file fat.h.

#define FS_PART_NO_REMOVE_MEDIA   0xF8

Definition at line 183 of file fat.h.

#define FS_PART_REMOVE_MEDIA   0xF0

Definition at line 182 of file fat.h.

#define FS_PART_TYPE_FAT12   0x01

Definition at line 176 of file fat.h.

#define FS_PART_TYPE_FAT16_INF32M   0x04

Definition at line 177 of file fat.h.

#define FS_PART_TYPE_FAT16_SUP32M   0x06

Definition at line 178 of file fat.h.

#define FS_PART_TYPE_FAT16_SUP32M_BIS   0x0E

Definition at line 179 of file fat.h.

#define FS_PART_TYPE_FAT32   0x0B

Definition at line 180 of file fat.h.

#define FS_PART_TYPE_FAT32_BIS   0x0C

Definition at line 181 of file fat.h.

#define FS_SHIFT_B_TO_FILE_ENTRY   5

Definition at line 207 of file fat.h.

#define FS_SHIFT_B_TO_SECTOR   FS_512B_SHIFT_BIT

Definition at line 230 of file fat.h.

#define FS_SIZE_FILE_ENTRY   32

Definition at line 206 of file fat.h.

#define FS_SIZE_LFN_ENTRY   13

Definition at line 208 of file fat.h.

#define FS_SIZE_OF_SECTOR   FS_512B

Definition at line 228 of file fat.h.

#define FS_SIZE_SFNAME   11

Definition at line 209 of file fat.h.

#define FS_SIZE_SFNAME_EXT_ONLY   3

Definition at line 211 of file fat.h.

#define FS_SIZE_SFNAME_WITHOUT_EXT   8

Definition at line 210 of file fat.h.

#define FS_TYPE_FAT_12   1

Definition at line 368 of file fat.h.

#define FS_TYPE_FAT_16   2

Definition at line 369 of file fat.h.

#define FS_TYPE_FAT_32   3

Definition at line 370 of file fat.h.

#define FS_TYPE_FAT_UNM   0

Definition at line 367 of file fat.h.

#define HIGH_16_BPB_BytsPerSec   fs_g_sector[12]

Definition at line 124 of file fat.h.

#define HIGH_16_BPB_FATSz16   fs_g_sector[23]

Definition at line 129 of file fat.h.

#define HIGH_16_BPB_FSInfo   fs_g_sector[49]

Definition at line 148 of file fat.h.

#define HIGH_16_BPB_ResvSecCnt   fs_g_sector[15]

Definition at line 141 of file fat.h.

#define HIGH_16_BPB_RootEntCnt   fs_g_sector[18]

Definition at line 127 of file fat.h.

#define HIGH_16_BPB_TotSec16   fs_g_sector[20]

Definition at line 135 of file fat.h.

#define Is_fat12   (FS_TYPE_FAT_12 == fs_g_nav_fast.u8_type_fat)

Definition at line 84 of file fat.h.

#define Is_fat16   (FS_TYPE_FAT_16 == fs_g_nav_fast.u8_type_fat)

Definition at line 89 of file fat.h.

#define Is_fat32   (FS_TYPE_FAT_32 == fs_g_nav_fast.u8_type_fat)

Definition at line 94 of file fat.h.

#define Is_unicode   (g_b_unicode)

Definition at line 101 of file fat.h.

#define LOW0_32_BPB_FATSz32   fs_g_sector[36]

Definition at line 130 of file fat.h.

#define LOW0_32_BPB_RootClus   fs_g_sector[44]

Definition at line 143 of file fat.h.

#define LOW0_32_BPB_TotSec32   fs_g_sector[32]

Definition at line 136 of file fat.h.

#define LOW1_32_BPB_FATSz32   fs_g_sector[37]

Definition at line 131 of file fat.h.

#define LOW1_32_BPB_RootClus   fs_g_sector[45]

Definition at line 144 of file fat.h.

#define LOW1_32_BPB_TotSec32   fs_g_sector[33]

Definition at line 137 of file fat.h.

#define LOW2_32_BPB_FATSz32   fs_g_sector[38]

Definition at line 132 of file fat.h.

#define LOW2_32_BPB_RootClus   fs_g_sector[46]

Definition at line 145 of file fat.h.

#define LOW2_32_BPB_TotSec32   fs_g_sector[34]

Definition at line 138 of file fat.h.

#define LOW3_32_BPB_FATSz32   fs_g_sector[39]

Definition at line 133 of file fat.h.

#define LOW3_32_BPB_RootClus   fs_g_sector[47]

Definition at line 146 of file fat.h.

#define LOW3_32_BPB_TotSec32   fs_g_sector[35]

Definition at line 139 of file fat.h.

#define LOW_16_BPB_BytsPerSec   fs_g_sector[11]

Definition at line 123 of file fat.h.

#define LOW_16_BPB_FATSz16   fs_g_sector[22]

Definition at line 128 of file fat.h.

#define LOW_16_BPB_FSInfo   fs_g_sector[48]

Definition at line 147 of file fat.h.

#define LOW_16_BPB_ResvSecCnt   fs_g_sector[14]

Definition at line 140 of file fat.h.

#define LOW_16_BPB_RootEntCnt   fs_g_sector[17]

Definition at line 126 of file fat.h.

#define LOW_16_BPB_TotSec16   fs_g_sector[19]

Definition at line 134 of file fat.h.

#define U8_BPB_NumFATs   fs_g_sector[16]

Definition at line 142 of file fat.h.

#define U8_BPB_SecPerClus   fs_g_sector[13]

Definition at line 125 of file fat.h.


Typedef Documentation

typedef uint8_t _MEM_TYPE_SLOW_* PTR_CACHE

Definition at line 427 of file fat.h.


Function Documentation

bool fat_allocfreespace ( void  )
void fat_cache_clear ( void  )
void fat_cache_clusterlist_reset ( void  )

Definition at line 881 of file fat.c.

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_loadtrue, 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  )

Definition at line 1828 of file fat.c.

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:
charactervalue 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  )

Definition at line 1393 of file fat.c.

void fat_clear_info_fat_mod ( void  )
bool fat_cluster_list ( uint8_t  opt_action,
bool  b_for_file 
)
Parameters:
b_for_fileIf true then it is a file cluster list else a directory cluster list
opt_actionChoose 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_modefalse, 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_typeentry 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_filterextension 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_modeaction mode:
FS_NAME_GET to get the long name of selected file
FS_NAME_CHECK to compare the long name of selected file
sz_nameif 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_casefalse, ignore the case (only used in "FS_NAME_CHECK" action mode)
u8_size_maxbuffer 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_modeaction mode:
FS_NAME_GET to get the short name of selected file
FS_NAME_CHECK to compare the short name of selected file
sz_nameif 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_maxbuffer 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_datechoose the date type (FS_DATE_LAST_WRITE or FS_DATE_CREATION)
sz_datetable 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.

PTR_CACHE fat_get_ptr_entry ( void  )
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  )
bool fat_mount ( 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:
modeChoose 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_FAST_ Fs_cluster fs_g_cluster

Definition at line 412 of file fat.h.

_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_management fs_g_nav

Definition at line 403 of file fat.h.

_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_management_entry fs_g_nav_entry

Definition at line 405 of file fat.h.

_GLOBEXT_ _MEM_TYPE_FAST_ Fs_management_fast fs_g_nav_fast

Definition at line 404 of file fat.h.

_GLOBEXT_ _MEM_TYPE_SLOW_ uint8_t fs_g_sector[FS_CACHE_SIZE]

Definition at line 424 of file fat.h.

_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_sector_cache fs_g_sectorcache

Definition at line 425 of file fat.h.

_GLOBEXT_ _MEM_TYPE_FAST_ Fs_segment fs_g_seg

Definition at line 409 of file fat.h.

_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_gu32_addrsector

Definition at line 426 of file fat.h.

_GLOBEXT_ bool g_b_no_check_disk

Definition at line 399 of file fat.h.

_GLOBEXT_ bool g_b_string_length

Definition at line 396 of file fat.h.

_GLOBEXT_ bool g_b_unicode

Definition at line 394 of file fat.h.