fat16.h

来自「基于642的sd卡读写程序」· C头文件 代码 · 共 81 行

H
81
字号

#include <csl_stdinc.h>
//-------------------------------------------------------------------------
typedef struct{
   	Uint8		PB_BootIndicator;
	Uint8		PB_StartHead;
	Uint16	PB_StartSector;
	Uint8		PB_SystemID;
	Uint8		PB_EndHead;
	Uint16	PB_EndSector;
	Uint32	PB_RelativeSector;
	Uint32	PB_TotalSector;		
} FAT_PB;
//-------------------------------------------------------------------------
typedef struct{
	Uint8		MBR_mbr[446];
	FAT_PB		MBR_pb[4];
	Uint16	MBR_Signature;
} FAT_MBR;
//-------------------------------------------------------------------------
typedef struct{
	Uint8		BS_jmpBoot[3];//
	Uint8		BS_OEMName[8];
	Uint16	    BPB_BytesPerSec;//11
	Uint8		BPB_SecPerClus;//13
	Uint16	    BPB_RsvdSecCnt;//14
	Uint8		BPB_NumFATs;//16
	Uint16	    BPB_RootEntCnt;//17
	Uint16	    BPB_TotSec16;//19
	Uint8		BPB_Media;//21
	Uint16	BPB_FATSz16;//22
	Uint16	BPB_SecPerTrk;//24
	Uint16	BPB_NumHeads;//26
	Uint32	BPB_HiddSec;//28
	Uint32	BPB_TotSec32;//32
	Uint8		BS_DrvNum;//36
	Uint8		BS_Reservedl;//37
	Uint8		BS_BootSig;//38
	Uint32	BS_VolID;//39
	Uint8		BS_VolLab[11];//43
	Uint8		BS_FilSysType[8];//54
	Uint8		ExecutableCode[448];//62
	Uint8		ExecutableMarker[2];//510
} FAT_BPB;
//-------------------------------------------------------------------------
typedef struct{
	Uint8		NAME[8];
	Uint8		TYPE[3];
} FILE_NAME;
//-------------------------------------------------------------------------
typedef struct{
	Uint16	Start;
	Uint32	Size;
} FILE_POSIT;
//-------------------------------------------------------------------------
typedef struct{
	FILE_NAME	FileName;
	Uint8		FileAttrib;
	Uint8		UnUsed[10];
	Uint8		FileUpdateTime[2];
	Uint8		FileUpdateData[2];
	FILE_POSIT	FilePosit;
} DIR;
//-------------------------------------------------------------------------
typedef struct{
	Uint16	ClusID;
	Uint16	SecOfClus;
	Uint16	ByteOfSec;
} DATA_POSIT;
//-------------------------------------------------------------------------
#define	SD_SUCC				0
#define	SD_FAIL				1
//-------------------------------------------------------------------------
Uint8 InitFat16(void);
Uint8 CreateFile(Uint8* Name,Uint32 Size);
Uint8 EreaseFile(Uint8 Name[11]);
Uint8 ReadFile(Uint8 Name[11],Uint32 Start,Uint32 len,Uint8 *p);
Uint8 WriteFile(Uint8 Name[11],Uint32 Start,Uint32 len,Uint8 *p);
Uint8 GetFileID(Uint8 Name[11],DIR *ID,Uint16 *pIndex);
//-------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?