📄 fat._h
字号:
#ifndef __fat_h
#define __fat_h
//******************************************************************
//* FUNCTION PROTOTYPES
//******************************************************************
void InitFat(void);
unsigned long Clust2LBA(unsigned long clust);
unsigned long GetNextCluster(unsigned long Clust);
int GetDir(unsigned long Cluster, unsigned int From, unsigned int Qte, unsigned int Type,unsigned int Display);
void DisplayFiles(unsigned char *LinePtr);
//******************************************************************
//* FAT Definitions
//******************************************************************
#define CLUST_RSRVD 0x0ffffff6 /* reserved cluster range */
#define CLUST_BAD 0x0ffffff7 /* a cluster with a defect */
#define CLUST_EOFS 0x0ffffff8 /* start of eof cluster range */
#define CLUST_EOFE 0x0fffffff /* end of eof cluster range */
#define SLOT_EMPTY 0x00 // slot has never been used
#define SLOT_E5 0x05 // the real value is 0xe5
#define SLOT_DELETED 0xe5 // file in this slot deleted
#define ATTR_NORMAL 0x00 // normal file
#define ATTR_READONLY 0x01 // file is readonly
#define ATTR_HIDDEN 0x02 // file is hidden
#define ATTR_SYSTEM 0x04 // file is a system file
#define ATTR_VOLUME 0x08 // entry is a volume label
#define ATTR_LONG_FILENAME 0x0f // this is a long filename entry
#define ATTR_DIRECTORY 0x10 // entry is a directory name
#define ATTR_ARCHIVE 0x20 // file is new or modified
#define TRUE 1
#define FALSE 0
#define FILE 0
#define DIR 1
#define PLAY 2
//******************************************************************
//* FAT struct
//******************************************************************
struct PartRecord // length 16 bytes from 446 bytes
{
unsigned char IsActive; // 0x80 indicates active partition
unsigned char StartHead; // starting head for partition
unsigned int StartCylSect; // starting cylinder and sector
unsigned char PartType; // partition type (see above)
unsigned char EndHead; // ending head for this partition
unsigned int EndCylSect; // ending cylinder and sector
unsigned long StartLBA; // first LBA sector for this partition
unsigned long Size; // size of this partition (bytes or sectors ?)
};
struct BootRecord
{
unsigned char jmp[3];
unsigned char name[8];
unsigned int BytesPerSec; // bytes per sector
unsigned char SecPerClust; // sectors per cluster
unsigned int ResSectors; // number of reserved sectors
unsigned char FATs; // number of FATs
unsigned int RootDirEnts; // number of root directory entries
unsigned int Sectors; // total number of sectors
unsigned char Media; // media descriptor
unsigned int FATsecs; // number of sectors per FAT
unsigned int SecPerTrack; // sectors per track
unsigned int Heads; // number of heads
unsigned long HiddenSecs; // # of hidden sectors
unsigned long HugeSectors; // # of sectors if bpbSectors == 0
unsigned long FATSize; // like bpbFATsecs for FAT32
unsigned int ExtFlags; // extended flags:
unsigned int FSVers; // filesystem version
unsigned long RootClust; // start cluster for root directory
unsigned int FSInfo; // filesystem info structure sector
unsigned int Backup; // backup boot sector
};
//Short file name structure
struct DirEntry
{
unsigned char Name[8]; // filename, blank filled
unsigned char Extension[3]; // extension, blank filled
unsigned char Attributes; // file attributes
unsigned char LowerCase; // NT VFAT lower case flags
unsigned char CHundredth; // hundredth of seconds in CTime
unsigned char CTime[2]; // create time
unsigned char CDate[2]; // create date
unsigned char ADate[2]; // access date
unsigned int FirstClustHi; // high bytes of cluster number
unsigned char MTime[2]; // last update time
unsigned char MDate[2]; // last update date
unsigned int FirstClustLo; // starting cluster of file
unsigned long FileSize; // size of file in bytes
};
//Long file name structure
struct WinEntry
{
unsigned char Cnt; //Start offset of text in name
unsigned int Part1[5]; //First 5 bytes of name, size is word because of UNICODE
unsigned char Attr; //Attributes;
unsigned char Reserved1;
unsigned char Chksum;
unsigned int Part2[6]; //Next 6 bytes of name
unsigned int Reserved2;
unsigned int Part3[2]; //Last 2 bytes, total 13 bytes
};
//MP3 player structure
struct FileInfo
{
unsigned char Name[256]; // 100 first char on the longfilename
unsigned char Extension[3]; // extension
unsigned char Attr; // file attributes
unsigned long FirstClust; // starting cluster of file
unsigned long FileSize; // size of file in bytes
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -