?? bfsa_api.h
字號:
// ----------------------------------------------------------------------------
// ATMEL Microcontroller Software Support - ROUSSET -
// ----------------------------------------------------------------------------
// DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
// DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
// File Name : bfsa_api.h
// Object : API interface for the Basic File System FAT12
// for AT91SAM7S boards.
// Creation : JCB 15/apr/2005
// Modif :
// --------------------------------------------------------------------------
#ifndef __bfsa_api__
#define __bfsa_api__
// **************************************************
// API defines
// **************************************************
// Files attributes : DIR_Attr fatgen103.doc
#define BFSA_ATTR_READ_ONLY 0x01
#define BFSA_ATTR_HIDDEN 0x02
#define BFSA_ATTR_SYSTEM 0x04
#define BFSA_ATTR_VOLUME_ID 0x08
#define BFSA_ATTR_DIRECTORY 0x10
#define BFSA_ATTR_ARCHIVE 0x20
#define BFSA_ATTR_LONG_NAME BFSA_ATTR_READ_ONLY | BFSA_ATTR_HIDDEN | BFSA_ATTR_SYSTEM | BFSA_ATTR_VOLUME_ID
// FAT type
#define BFSA_FAT12 0x00
#define BFSA_FAT16 0x01
#define BFSA_FAT32 0x02
#define BFSA_FATUNKNOWN 0x03
// Directory
#define BFSA_MAX_PATH_LEN 102 // Path directory max len (10*10+1 : 10 directories deep)
// File
#define BFSA_MAX_FILENAME_LEN 8+1+3+1 // File name max len (8 char + '.' + 3 char + '\0') // AT91F_DBGU_scanf
#define sizeofBFSA_fatBuff 1024
// **************************************************
// API structures
// **************************************************
typedef struct
{
UCHAR FATtype; //BFSA_FAT12, BFSA_FAT16, BFSA_FAT32
UCHAR mediaType; //BPB[21]
USHORT bytesPerSector; //count of bytes per sector
UCHAR SectPerCluster; //number of sector per allocation unit
USHORT FATSectStart;
USHORT SectPerFAT;
USHORT numFAT; //BPB[16]
USHORT RootStart; //sector where the root directory structure starts
USHORT numRootSectors;
USHORT ClusterStart; //sector where the allocation space starts
USHORT MaxCluster;
} MEDIA_INFO;
// Date of file
typedef struct
{
USHORT Day:5; // Day in the month
USHORT Month:4; // Month in the year
USHORT Years80:7; // Years since 1980
} FILE_DATE;
// Time of file
typedef struct
{
USHORT Seconds:5; // Seconds / 2
USHORT Minutes:6; // Minutes
USHORT Hours:5; // Hours
} FILE_TIME;
typedef struct
{
UCHAR fileName[9]; //file name : NULL terminated string
UCHAR extension[4]; //file extension : NULL terminated string
UCHAR attributes; //file attributes BFSA_ATTR_xxx
FILE_DATE date;
FILE_TIME time;
USHORT startCluster;
ULONG length;
} FILE_OBJECT;
// **************************************************
// API functions
// **************************************************
extern ULONG BFSA_init(void);
extern ULONG BFSA_list(FILE_OBJECT* pfobj,ULONG nbFileObj,ULONG *nbFileObjFound);
extern ULONG BFSA_cd(char* path);
extern ULONG BFSA_path(char*path);
extern ULONG BFSA_write(char* filename,char* dataBuffer,ULONG dataSize,UCHAR append);
extern ULONG BFSA_read(char* filename,char* dataBuffer,ULONG dataSize,ULONG offset);
extern ULONG BFSA_delete(char* filename);
extern ULONG BFSA_mkdir(char* filename);
extern ULONG BFSA_readMediaInfo(MEDIA_INFO *media);
extern ULONG BFSA_rename(char* curFilename, char* newFilename);
extern ULONG BFSA_chmod(char* filename,unsigned char newAttrib);
extern ULONG BFSA_dir( void );
extern ULONG BFSA_format( void );
union fatBuff
{
unsigned char BFSA_fatBuff[sizeofBFSA_fatBuff];
unsigned int bufInt; // alignment problem
};
extern union fatBuff BFSABuffer; // BFSA_media.SectPerFAT*BFSA_media.bytesPerSector
#endif //__bfsa_api__
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -