📄 bfsa_internal.h
字号:
// ----------------------------------------------------------------------------
// ATMEL Microcontroller Software Support - ROUSSET -
// ----------------------------------------------------------------------------
// DISCLAIMER: CONDITIONS AS PER SIGNED LIMITED LICENSE AGREEMENT (AT91
// SOFTWARE AND USER DOCUMENTATION)
// ALL SOFTWARE IS PROVIDED AS IS, WITH ALL FAULTS, AND WITH NO WARRANTY
// WHATSOEVER. ATMEL EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED,
// OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.
// ----------------------------------------------------------------------------
// File Name : bfsa_internal.h
// Object : internal functions and definition for the Basic File System FAT12
// Creation : FB 10/feb/2005
// Modif : JCB 15/apr/2005
// --------------------------------------------------------------------------
#ifndef __bfsa_internal__
#define __bfsa_internal__
// **************************************************
// Internal definitions
// **************************************************
#define LOW_BYTE(x) (unsigned char)(x&0x00FFU)
#define HIGH_BYTE(x) (unsigned char)((x&0xFF00U)>>8)
// Finding the Starting Sector : subtract 2 from the cluster number and multiply
// the result by the disk's sectors per cluster.
#define FIRST_SECTOR_DATACLUSTER(x) (((x-2)*BFSA_media.SectPerCluster) + BFSA_media.ClusterStart)
// **************************************************
// Internal definitions
// **************************************************
typedef struct _CUR_DIR
{
char absolutePath[BFSA_MAX_PATH_LEN];
USHORT DirStart; // Sector where the directory structure starts
UCHAR IsRoot;
}CURRENT_DIR, *pCURRENT_DIR;
// **************************************************
// FAT 12/16
// **************************************************
#define BPB_SIZE 62
#define DIRECTORY_ENTRIE_SIZE 32
#define EOC16 0xFFFF // End of cluster FAT16
#define EOC12 0x0FFF // End of cluster FAT12
#define BAD16 0xFFF7 // Bad cluster FAT16 Cluster contains bad sectors
#define BAD12 0x0FF7 // Bad cluster FAT12 Cluster contains bad sectors
#define FREE 0x0000 // Free cluster
/**************************************************/
/* Special value for DIR_Name[0] */
#define FREE_ENTRY_DIR_AND_NO_ALLOCATED 0x00
// directory entry is free (same as for 0xE5),
// and there are no allocated directory entries after this one
#define FREE_ENTRY_DIR_2 0x05
/* The actual file name character for this byte is 0xE5 */
#define FREE_ENTRY_DIR 0xE5 /* directory entry is free */
/**************************************************/
// **************************************************
// Global data
// **************************************************
extern CURRENT_DIR BFSA_current_dir;
extern MEDIA_INFO BFSA_media;
extern UCHAR* FlashBaseAdd;
extern const ULONG FlashSize;
// **************************************************
// Internal Functions
// **************************************************
extern void readFAT(void);
extern ULONG writeFAT(void);
extern USHORT readFatEntry(USHORT cluster);
extern ULONG writeFatEntry(USHORT cluster,USHORT value);
extern USHORT findFreeCluster(void);
extern ULONG getNextCluster(USHORT uCurrent);
extern ULONG addNewEntry(UCHAR newEntry[32],USHORT dirCluster, UCHAR isRoot);
extern void deleteEntry(char* fileName);
extern int findEntry(char *fileName);
extern ULONG readBPB(UCHAR *pucBuff, USHORT uSize);
extern UCHAR isValidFileName(char *fileName);
extern USHORT findFile(const char* fileName);
extern ULONG deleteFile(char* filename);
extern ULONG listFile(FILE_OBJECT* pfobj,ULONG nbFileObj,ULONG *nbFileObjFound,USHORT dirCluster);
extern void padFileName(const char *filename, char* strFileName);
#endif //__bfsa_internal__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -