⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avrfat16.h

📁 butterfly MP3源代码
💻 H
字号:
/**	@file	avrfat16.h	@brief	Fat16 Functions	@author	Nick Lott 	@date	September 2004	Copyright (C) 2004 Nick Lott <brokentoaster@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**/#include "types.h"#include "uart.h"#define PARTITION_START		446	///< Start address of partition 1 in MBR//-----------------------------------------------------------------------------// FAT32 File Attributes and Types//-----------------------------------------------------------------------------#define FILE_ATTR_READ_ONLY   	0x01#define FILE_ATTR_HIDDEN 		0x02#define FILE_ATTR_SYSTEM 		0x04#define FILE_ATTR_SYSHID		0x06#define FILE_ATTR_VOLUME_ID 	0x08#define FILE_ATTR_DIRECTORY		0x10#define FILE_ATTR_ARCHIVE  		0x20#define FILE_ATTR_LFN_TEXT		0x0F#define FILE_ATTR_LFN_MASK		0x3F#define FILE_HEADER_BLANK		0x00#define FILE_HEADER_DELETED		0xE5#define FILE_TYPE_DIR			0x10#define FILE_TYPE_FILE			0x20#define FILE_TYPE_MP3			0x55#define FAT16_LDIR_Ord			0#define FAT16_LDIR_Name1		1#define FAT16_LDIR_Attr			11#define FAT16_LDIR_Type			12#define FAT16_LDIR_Chksum		13#define FAT16_LDIR_Name2		14#define FAT16_LDIR_FstClusLO	26#define FAT16_LDIR_Name3		28// For ID3 tags#define LFN_TYPE_INDEX        208#define LFN_TYPE_FILENAME     0x00        // No bits set#define LFN_TYPE_ID3_TITLE    0x01        // Bit 0#define LFN_TYPE_ID3_ARTIST   0x02        // Bit 1#define LFN_BUFFER_LENGTH     208#define LFN_TITLE_INDEX       0#define LFN_TITLE_LENGTH      100      // Title length including '\0'#define LFN_ARTIST_INDEX      100#define LFN_ARTIST_LENGTH     100      // Artist length including '\0'#define LFN_FREE_INDEX        200#define LFN_FREE_LEN          8        // Currently 8 free bytes in buffer if                                       // using ID3 tags not filenamesuint32 	FAT16_fat_begin_lba;uint32 	FAT16_cluster_begin_lba;uint8	FAT16_sectors_per_cluster;uint32	FAT16_dir_first_cluster;uint32	FAT16_root_dir_first_cluster;uint32	FAT16_parent_dir_first_cluster;uint8	FAT16_filetype;uint8 	FAT16_longfilename[LFN_BUFFER_LENGTH+1]; // buffer for long filenames / ID3 tagsuint8	FAT16_LFNTitleLen;uint8	FAT16_LFNArtistLen;uint16 	FAT16_entryMAX; 	// Maximum entry number in FAT table. (aka file number)uint16 	FAT16_entryMIN; 	// Minimum entry number in FAT table. (aka file number)uint8 *FAT_buffer; // 512 byte buffer for sector reads/writesuint8 *FAT_scratch; // 32 byte buffer for filenames and datauint8 (*FAT_read)(uint32 lba); // pointer to read block function uint8 (*FAT_write)(uint32 lba);// pointer to write block function uint8 FAT_initFat16(void); // read MBR and bootsector and set fat variablesuint8 FAT_readCluster(uint32 cluster, uint8 sector_offset); // read a sector from a clusteruint8 FAT_get_label(uint8 label[]); uint32 FAT_NextCluster(uint32 cluster); ////uint8 FAT_NextnCluster(uint16 cluster, uint16 fatBuf[], uint8 buffer_size);//uint8 FAT_getLongFilename(uint32 filenumber);uint32 FAT_getNextSong(uint32 filenumber,uint32 directory);uint32 FAT_getPrevSong(uint32 filenumber,uint32 directory);uint8 FAT_ChkSum(uint8 *pFcbName); //8Bit checksum of 11 Byte array/***   FAT_readRoot*	@param		filenumber 32bit uInt pointing to file of interst.*	@return		error code**	Read the root directory of the disk and obtain details *	about FAT entry number <filenumber>**/uint8	FAT_readRoot(uint32 filenumber);/***   FAT_read *	@param		filenumber 32bit uInt pointing to file of interst. *	@param		dir_first_entry 32bit uInt pointing to first cluster of directory *	@return		error code * *	Read any directory of the disk and obtain details  *	about FAT entry number <filenumber> **/uint8	FAT_readFile(uint32 filenumber, uint32 dir_first_cluster);/** *	FAT_scanDir *	@param	uint32 pointing to director start cluster *	@return	error code, 0 for okay * *	scan a directory for songs, set max, min and currentdir variables **/uint8 FAT_scanDir(uint32 directory);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -