# fat32_small

FAT32-small sample for reading fat32 filesystem

Author | Matthew Schinkel, copyright © 2009, all rights reserved.
Adapted-by |
Compiler | >=2.4k

Description

    This library reads files & folders from a fat32 formatted
                 sd card. This small version only supports the first partition,
                 and only one file.

Sources

    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

Notes

    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.

Dependencies

- storage_drivers

## Summary

### Global variables/contants

- `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`

### Procedures

- `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()`

### Functions

## API details

### Global variables/contants

- `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

### Procedures

- `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

### Functions

## Related samples

Here are the list of samples which use this library:

16f877 | 16f877_fat32_small_pata_hard_disk.jal
16f877a | 16f877a_fat32_small_pata_hard_disk.jal
18f452 | 18f452_fat32_small_sd_card.jal
18f452 | 18f452_fat32_small_pata_hard_disk.jal
18f4525 | 18f4525_fat32_small_sd_card.jal
18f4525 | 18f4525_fat32_small_pata_hard_disk.jal
18f4550 | 18f4550_fat32_small_sd_card.jal
18f4620 | 18f4620_fat32_small_pata_hard_disk.jal
18f4620 | 18f4620_fat32_small_sd_card.jal
18f67j50 | 18f67j50_fat32_small_pata_hard_disk.jal
18f67j50 | 18f67j50_fat32_small_sd_card.jal