|
This page is dedicated to the design of code that allows access to
an IDE Hard Disc which is formatted with the FAT32 file system. The
code was designed to run on an Atmega AVR MCU but will probably port
to others easily as it is written in standard C. This library will allow
files and directories to be accessed, and builds upon the IDE
Device Driver.
FAT32 Interface Layer Block Diagram

|
The FAT32 global structure is used to store global variables which
relate to the location of FAT32 partition, also contains the LFN text
buffer. The FAT32 definitions are used where constants are needed to
refer to either types of files, and file structures.
The FAT32_Base functions provide need interaction with the lower IDE
Device Driver layer, and perform tasks such as File Allocation Table
traversing, LBA to Cluster number conversion, etc.
The FAT32_Access library is used by higher level routines such as directory
browsing, file reading, and FAT32 initialisation. There should be no
need for other functions outside the FAT32_Access library to directly
use the FAT32_Base rountines.
byte ReadData(UI32 startcluster, UI32 bytenum)
{
// Convert bytenum into a sector to read
sector = bytenum / 512;
// Convert bytenum and sector into an offset in
current sector buffer
offset = bytenum - (sector*512);
// Read file sector
FAT32_SectorReader(startcluster, sector);
// Extract byte from sector read
bytedata = IDE_SectorByte(offset);
// Return data found
return bytedata;
}
Source_FAT32Basic.zip
- Includes the FAT32 disc access and the IDERawRead functions...
IDE Raw Disc IO Page - The source library containing only these functions,
to allow accessing of 'raw' IDE sectors.
FAT32 File IO Library
Page - The source library for my advanced FAT32 file access code which
include fopen(), fgetc(), fscanf(), etc.. |