ButterflyMP3
|
Fat16 Functions. More...
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "types.h"
#include "avrfat16.h"
#include "utils.h"
Go to the source code of this file.
Defines | |
#define | FLG_ROOTDIR 0 |
Functions | |
uint8 | FAT_initFat16 (void) |
FAT_initFat16. | |
uint8 | FAT_readCluster (uint32 cluster, uint8 sector_offset) |
FAT_get_label. | |
uint32 | FAT_NextCluster (uint32 cluster) |
FAT_NextCluster. | |
uint8 | FAT_readFile (uint32 filenumber, uint32 dir_first_sector) |
FAT_read. | |
uint32 | FAT_getNextSong (uint32 filenumber, uint32 dir_lba) |
FAT_readRoot. | |
uint32 | FAT_getPrevSong (uint32 filenumber, uint32 dir_lba) |
GetPrevSong. | |
uint32 | FAT_getNumberedSong (char songNumber, uint32 dir_lba) |
GetNumberedSong. | |
uint8 | FAT_ChkSum (uint8 *pFcbName) |
FAT_ChkSum() | |
uint32 | FAT_cluster2lba (uint32 cluster) |
FAT_cluster2lba. | |
uint32 | FAT_lba2cluster (uint32 lba_addr) |
FAT_lba2cluster. | |
uint8 | FAT_scanDir_lba (uint32 lba_addr) |
FAT_scanDir_lba. | |
uint32 | FAT_getParentDir (uint32 lba_addr) |
FAT_getParentDir. | |
void | FAT_Scratch2Cluster () |
FAT_Scratch2Cluster. | |
Variables | |
uint32 | gCluster |
current sector (cluster) in song main.h |
Fat16 Functions.
Copyright (C) 2004 Nick Lott <brokentoaster@users.sf.net>
This is a simple implementation of the FAT16 file system. It is designed to be small for use with MP3 players and MMC cards. Currently it is readonly.NOTE: The code acknowledges only the first partition on the drive.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Target(s)...: ATmega169
Compiler....: AVR-GCC 3.3.1; avr-libc 1.0
Definition in file avrfat16.c.
#define FLG_ROOTDIR 0 |
Referenced by FAT_readFile().
Returns an unsigned byte check sum computed on an unsignedbyte array. The array must be 11 bytes long and is assumed to contain a name stored in the format of a MS-DOS directory entry.
pFcbName | Pointer to an unsigned byte array assumed to be 11 bytes long. An 8-bit unsigned checksum of the array pointed to by pFcbName. |
Definition at line 748 of file avrfat16.c.
Referenced by FAT_readFile().
FAT_cluster2lba.
Calculate the sector address of a cluster.
uint32 | pointing to cluster |
Definition at line 786 of file avrfat16.c.
References FAT16_cluster_begin_lba, and FAT16_sectors_per_cluster.
Referenced by FAT_getParentDir(), FAT_readFile(), and handle_interface().
FAT_readRoot.
Read the root directory of the disk and obtain details about FAT entry number <filenumber>
filenumber | 32bit uInt pointing to file of interst. |
filenumber | uint32 index of current file in directory |
dir_lba | uint32 lba of directory to search |
Definition at line 627 of file avrfat16.c.
References FAT16_entryMAX, and FAT_readFile().
Referenced by FAT_scanDir_lba(), handle_interface(), restore_player(), and streaming().
GetNumberedSong.
Get the file number of a song given a 2 digit BCD of the first two digits of the filename. eg given CHAR2BCD(8) as an argument the function will find the first file in the current directory whos name begins with "08" and ends with ".mp3". Can be removed from code by setting FAT_NumberedSong_EN to 0.
songNumber | char a BCD number 00 - 99 of song/sample |
dir_lba | uint32 lba of directory to search |
Definition at line 697 of file avrfat16.c.
References EOL, FAT16_entryMAX, FAT16_entryMIN, FAT16_longfilename, FAT_readFile(), PRINT, UART_Printfu08(), and UART_Puts().
Referenced by play_track_number().
FAT_getParentDir.
lba_addr | uint32 pointing to current directory starting sector |
return the first sector of the .. entry. assuming it is the second entry in the directory file. otherwise return 0 to do nothing.
Definition at line 867 of file avrfat16.c.
References FAT16_root_dir_first_sector, FAT_buffer, FAT_cluster2lba(), and FAT_read.
Referenced by handle_interface().
GetPrevSong.
filenumber | uint32 index of current file in directory |
dir_lba | uint32 lba of directory to search |
Definition at line 660 of file avrfat16.c.
References FAT16_entryMIN, and FAT_readFile().
Referenced by handle_interface().
uint8 FAT_initFat16 | ( | void | ) |
FAT_initFat16.
read MBR and bootsector and set fat variables
read MBR and bootsector and set global fat variables
Definition at line 84 of file avrfat16.c.
References EOL, FAT16_cluster_begin_lba, FAT16_dir_first_sector, FAT16_fat_begin_lba, FAT16_parent_dir_first_sector, FAT16_root_dir_first_sector, FAT16_sectors_per_cluster, FAT_buffer, FAT_read, PARTITION_START, PRINT, UART_Printfu08(), and UART_Printfu16().
Referenced by FAT_tester(), and init_mmc_fat().
FAT_lba2cluster.
Calculate the cluster address of a sector.
lba_addr | uint32 pointing to lba_addr in cluster |
Definition at line 805 of file avrfat16.c.
References FAT16_cluster_begin_lba, and FAT16_sectors_per_cluster.
Referenced by FAT_readFile().
FAT_NextCluster.
looks up a cluster in fat
cluster | current cluster |
Definition at line 264 of file avrfat16.c.
References FAT16_fat_begin_lba, FAT_buffer, and FAT_read.
Referenced by cue_file(), FAT_readFile(), and streaming().
FAT_get_label.
read a sector from a cluster
copys the volume label
destentaion | for label |
cluster | Clusterto read from |
sector_offset | Sector to read from within cluster |
Definition at line 241 of file avrfat16.c.
References FAT16_cluster_begin_lba, FAT16_sectors_per_cluster, and FAT_read.
Referenced by cue_file(), and streaming().
FAT_read.
FAT_readRoot.
Read any directory of the disk and obtain details about FAT entry number filenumber
error codes:
0x00 mp3file found
0x02 end of directory
0x59 deleted file
filenumber | 32bit uInt pointing to file of interst. |
dir_first_sector | 32bit uInt pointing to first cluster of directory |
Definition at line 322 of file avrfat16.c.
References EOL, FAT16_entryMAX, FAT16_filetype, FAT16_LDIR_Attr, FAT16_LDIR_Chksum, FAT16_LDIR_Ord, FAT16_LFNTitleLen, FAT16_longfilename, FAT16_root_dir_first_sector, FAT16_sectors_per_cluster, FAT_buffer, FAT_ChkSum(), FAT_cluster2lba(), FAT_lba2cluster(), FAT_NextCluster(), FAT_read, FAT_scratch, FILE_ATTR_ARCHIVE, FILE_ATTR_DIRECTORY, FILE_ATTR_HIDDEN, FILE_ATTR_LFN_MASK, FILE_ATTR_LFN_TEXT, FILE_TYPE_DIR, FILE_TYPE_FILE, FLG_ROOTDIR, LFN_BUFFER_LENGTH, LFN_TYPE_FILENAME, LFN_TYPE_INDEX, PRINT, strLen(), and UART_Printfu08().
Referenced by cue_file(), FAT_getNextSong(), FAT_getNumberedSong(), FAT_getPrevSong(), and handle_interface().
FAT_scanDir_lba.
scan a directory for songs, set max, min and currentdir variables
lba_addr | uint32 pointing to directory starting sector |
Definition at line 823 of file avrfat16.c.
References FAT16_dir_first_sector, FAT16_entryMAX, FAT16_entryMIN, FAT16_parent_dir_first_sector, and FAT_getNextSong().
Referenced by open_Dir().
void FAT_Scratch2Cluster | ( | void | ) |
FAT_Scratch2Cluster.
Extracts the first cluster from the scratchpad buffer left after the most recent call of FAT_readFile()
Definition at line 935 of file avrfat16.c.
References FAT_scratch, and gCluster.
Referenced by cue_file(), and handle_interface().
current sector (cluster) in song main.h
Definition at line 79 of file main.c.
Referenced by cue_file(), FAT_Scratch2Cluster(), handle_interface(), restore_player(), save_player_state(), and streaming().