📄 cf_fat.h
字号:
#include <inttypes.h>
#define FS_ERR_NOERR 0x00
#define FS_ERR_MEDIAERR 0x01
#define FS_ERR_UNFORMAT 0x02
#define FS_ERR_NOTFAT 0x03
#define FS_ERR_UNKNOWNFAT 0x04
#define FS_ERR_NOTFOUND 0x81
#define FS_ERR_SEEKERR 0x82
#define FS_ERR_NORAM 0xff
#define FS_TYPE_FAT12 0x00
#define FS_TYPE_FAT16 0x01
#define FS_TYPE_FAT32 0x02
#define FS_TYPE_OTHER 0xff
#define FS_FAT32_EOF 0x0ffffff8
#define FS_FAT16_EOF 0xfff8
#define FS_FAT12_EOF 0xff8
typedef struct
{
uint8_t Type;
uint8_t StartLBA;
uint8_t SectorsPerCluster;
uint8_t LShift;
uint16_t SectorsBeforeFAT;
uint8_t FATs;
uint16_t FAT16RootEntries;
uint32_t TotalSectors;
uint16_t SectorsPerFAT;
uint32_t FAT32RootStartCluster;
} FS_TBPB;
typedef struct
{
uint32_t StartLBA;
uint8_t LShift;
uint32_t DataStartLBA;
} FS_TFAT;
typedef struct
{
uint8_t Attrib;
uint32_t StartCluster;
uint32_t StartLBA;
uint32_t CurrentCluster;
uint32_t CurrentLBA;
uint32_t *ClusterChain;
uint32_t Offset;
uint32_t Length;
} FS_TFile;
FS_TBPB FS_BPB;
FS_TFAT FS_FAT;
FS_TFile FS_RootDir, FS_CurrentDir;
uint8_t FS_Initialize(void);
uint8_t FS_ChangeDir(char *DirName);
uint8_t FS_Open(FS_TFile *F, char *FileName);
void FS_Close(FS_TFile *F);
uint8_t FS_Seek(FS_TFile *F, uint32_t off);
uint32_t FS_Read(FS_TFile *F, char *buf, uint32_t count);
void FS_FastBlockRead(FS_TFile *F, char *buf, uint8_t sectors);
void FS_GetClusterChain(FS_TFile *F, uint32_t *chain);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -