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

📄 fat.h

📁 用ATmega8 做的MP3播放器
💻 H
字号:
/*
 * Copyright (c) 2003-2004 K. John '2B|!2B' Crispin
 * Copyright (c) 2005      Stephan Dobretsberger
 *
 * 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, MA02111-1307USA
 *
 * Feedback, Bugs, ... mail stephan.dobretsberger@gmx.at
 *
 */

#ifndef __FAT_H__
#define __FAT_H__


//#define FAT_WRITE in the following file

/*------------------ FAT LAYER --------------*/

//starts the fat
void FAT_startup(void);

// this function gets the addr in the data region for the next cluster of a file
void FAT_get_next_clus_addr(u16* sectorh, u16* sectorl);


/*------------------ FIO LAYER --------------*/
// this datastructutre stores the address of the current directory that we are in
// and the file that we are currently processing
typedef struct _DIR
{ u16 dir_currenth ;
  u16 dir_currentl;
  u16 dir_current_entry;
} DIR;

// all the info we need for a file
typedef struct _FILE
{ u16 file_current_clusterh;
  u16 file_current_clusterl;
  u08 file_current_sector;
  u16 file_first_clusterh;
  u16 file_first_clusterl;
  u16 file_sizeh;
  u16 file_sizel;
  u16 file_full_sizeh;
  u16 file_full_sizel;
  u16 file_offset;

  u08 name[11];
#ifdef LFN_SUPPORT
  u08 lfn_name[(LFN_MAX_BLOCK * 13) + 1];
#endif
} FILE;

// this value should never be bigger than 512
#define FAT_RD_BUF_SIZE 0x20
// plus one for '\0

#define FAT_PRINT     0x01
#define FAT_FILENAME  0x02
#define FAT_DIRNAME   0x03
#define FAT_FILENUM   0x04
#define FAT_DIRNUM    0x05
bool fat_dir_ctl(u08 mode, FILE *stream, DIR *dir, u08* name, u08 count);


/*------------------ FIO API LAYER --------------*/

bool fopen(u08 *filename, u08 mode, FILE *stream);
bool fopenc(u08 count, u08 mode, u08* mask, FILE *stream);
void fclose(FILE *stream);
bool feof(FILE *stream);
bool fisopen(FILE *stream);
u08* fgetfilename(FILE *stream);

// this function does not update the FILE structures size parameters
bool fplay_sector(FILE *stream);

u08* fget(FILE *stream, u16 size);

// passing NULL as *dir param will make the api use the default internal *directory struct
bool dir_enter(u08 *dirname, DIR *dir);
bool dir_leave(DIR *dir);
void dir_list(DIR *dir);
void dir_root(DIR *dir);

#endif

⌨️ 快捷键说明

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