Author | Matthew Schinkel, copyright © 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4k |
This library reads files & folders from a fat32 formatted sd card. This small version only supports the first partition, and only one file.
http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx http://www.pjrc.com/tech/8051/ide/fat32.html http://en.wikipedia.org/wiki/File_Allocation_Table
1. First format your device with fat32 before using this library. 2. Do not put other files onto the storage device. This library will overwrite and erase existing files on the storage device because only one file is supported, and no fragments are supported.
var bit fat32_small_open_for_read = FALSE
var bit fat32_small_open_for_write = FALSE
const byte FAT32_SMALL_VOL_ID_DATA[32] = {
const byte FAT32_SMALL_FILE_NAME_DATA[28] ={
const dword FAT32_SMALL_FILE_LOCATION = 0x03
var dword fat32_small_fat_begin
const byte FAT32_SMALL_FAT_DATA[12] = {
var dword fat32_small_file_size
var dword fat32_small_root_dir
var dword _file_sector_number
var byte fat32_small_sectors_per_cluster
var dword fat32_small_cluster_begin
var byte _fat32_small_file_size[4] at fat32_small_file_size
fat32_small_init()
fat32_small_set_file_size(dword in file_size)
fat32_small_file_open(dword in file_sector_number)
fat32_small_file_read(byte out data)
fat32_small_read_boot_sector()
fat32_small_file_write(byte in data)
fat32_small_file_close()
var bit fat32_small_open_for_read = FALSE
No documentation found
var bit fat32_small_open_for_write = FALSE
No documentation found
const byte FAT32_SMALL_VOL_ID_DATA[32] = {
root dir constant
const byte FAT32_SMALL_FILE_NAME_DATA[28] ={
file name entry constant
const dword FAT32_SMALL_FILE_LOCATION = 0x03
No documentation found
var dword fat32_small_fat_begin
the location of the file alocation table for current partition
const byte FAT32_SMALL_FAT_DATA[12] = {
start data for the fat (file allocation table)
var dword fat32_small_file_size
holds file size after file_read_info()
var dword fat32_small_root_dir
sector location of the root dir
var dword _file_sector_number
Open the file
var byte fat32_small_sectors_per_cluster
the number of sectors per cluster, usually 8
var dword fat32_small_cluster_begin
the location of the beginning of clusters (where files & folders data is)
var byte _fat32_small_file_size[4] at fat32_small_file_size
other vars
fat32_small_init()
initalize fat32
fat32_small_set_file_size(dword in file_size)
Set the size of the file.
fat32_small_file_open(dword in file_sector_number)
No documentation found
fat32_small_file_read(byte out data)
Read data from the file
fat32_small_read_boot_sector()
Reads a fat32 boot sector to get the location of the root directory and FAT Location on the media for the partition selected. Only one partition is supported.
fat32_small_file_write(byte in data)
Write data to the file
fat32_small_file_close()
Close the file