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

📄 fat_8h-source.html

📁 avr应用测试程序
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Procyon AVRlib: fat.h Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.2 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div><h1>fat.h</h1><a href="fat_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file fat.h \brief FAT16/32 file system driver. */</span>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name    : 'fat.h'</span>00005 <span class="comment">// Title        : FAT16/32 file system driver</span>00006 <span class="comment">// Author       : Pascal Stang</span>00007 <span class="comment">// Date         : 11/07/2000</span>00008 <span class="comment">// Revised      : 12/12/2000</span>00009 <span class="comment">// Version      : 0.3</span>00010 <span class="comment">// Target MCU   : ATmega103 (should work for Atmel AVR Series)</span>00011 <span class="comment">// Editor Tabs  : 4</span>00012 <span class="comment">//</span>00013 <span class="comment">// NOTE: This code is currently below version 1.0, and therefore is considered</span>00014 <span class="comment">// to be lacking in some functionality or documentation, or may not be fully</span>00015 <span class="comment">// tested.  Nonetheless, you can expect most functions to work.</span>00016 <span class="comment">//</span><span class="comment"></span>00017 <span class="comment">/// \ingroup general</span>00018 <span class="comment">/// \defgroup fat FAT16/32 File System Interface (fat.c)</span>00019 <span class="comment">/// \code #include "fat.h" \endcode</span>00020 <span class="comment">/// \par Overview</span>00021 <span class="comment">///     This FAT16/32 interface allows you to detect and mount FAT16/32</span>00022 <span class="comment">///     partitions, browse directories and files, and read file data.</span>00023 <span class="comment">///     The interface is designed to operate with the avrlib IDE/ATA driver.</span>00024 <span class="comment">///     Reading FAT efficiently requires at least 512+ bytes of RAM so this</span>00025 <span class="comment">///     interface may not be suitable for processors with less than 1K of RAM.</span>00026 <span class="comment">///     This interface will properly follow a file's cluster chain so files</span>00027 <span class="comment">///     need not be defragmented.</span>00028 <span class="comment">///</span>00029 <span class="comment">/// \note This code is based in part on work done by Jesper Hansen for his</span>00030 <span class="comment">///     excellent YAMPP MP3 player project.</span>00031 <span class="comment"></span><span class="comment">//</span>00032 <span class="comment">// This code is distributed under the GNU Public License</span>00033 <span class="comment">//      which can be found at http://www.gnu.org/licenses/gpl.txt</span>00034 <span class="comment">//</span>00035 <span class="comment">//*****************************************************************************</span>00036 00037 <span class="preprocessor">#ifndef FAT_H</span>00038 <span class="preprocessor"></span><span class="preprocessor">#define FAT_H</span>00039 <span class="preprocessor"></span>00040 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>00041 00042 00043 <span class="comment">// Some useful cluster numbers</span>00044 <span class="preprocessor">#define MSDOSFSROOT     0               // cluster 0 means the root dir</span>00045 <span class="preprocessor"></span><span class="preprocessor">#define CLUST_FREE      0               // cluster 0 also means a free cluster</span>00046 <span class="preprocessor"></span><span class="preprocessor">#define MSDOSFSFREE     CLUST_FREE</span>00047 <span class="preprocessor"></span><span class="preprocessor">#define CLUST_FIRST     2               // first legal cluster number</span>00048 <span class="preprocessor"></span><span class="preprocessor">#define CLUST_RSRVD     0xfffffff6      // reserved cluster range</span>00049 <span class="preprocessor"></span><span class="preprocessor">#define CLUST_BAD       0xfffffff7      // a cluster with a defect</span>00050 <span class="preprocessor"></span><span class="preprocessor">#define CLUST_EOFS      0xfffffff8      // start of eof cluster range</span>00051 <span class="preprocessor"></span><span class="preprocessor">#define CLUST_EOFE      0xffffffff      // end of eof cluster range</span>00052 <span class="preprocessor"></span>00053 <span class="preprocessor">#define FAT12_MASK      0x00000fff      // mask for 12 bit cluster numbers</span>00054 <span class="preprocessor"></span><span class="preprocessor">#define FAT16_MASK      0x0000ffff      // mask for 16 bit cluster numbers</span>00055 <span class="preprocessor"></span><span class="preprocessor">#define FAT32_MASK      0x0fffffff      // mask for FAT32 cluster numbers</span>00056 <span class="preprocessor"></span>00057 00058 <span class="comment">// Partition Type used in the partition record</span>00059 <span class="preprocessor">#define PART_TYPE_UNKNOWN       0x00</span>00060 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_FAT12         0x01</span>00061 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_XENIX         0x02</span>00062 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_DOSFAT16      0x04</span>00063 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_EXTDOS        0x05</span>00064 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_FAT16         0x06</span>00065 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_NTFS          0x07</span>00066 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_FAT32         0x0B</span>00067 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_FAT32LBA      0x0C</span>00068 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_FAT16LBA      0x0E</span>00069 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_EXTDOSLBA     0x0F</span>00070 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_ONTRACK       0x33</span>00071 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_NOVELL        0x40</span>00072 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_PCIX          0x4B</span>00073 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_PHOENIXSAVE   0xA0</span>00074 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_CPM           0xDB</span>00075 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_DBFS          0xE0</span>00076 <span class="preprocessor"></span><span class="preprocessor">#define PART_TYPE_BBT           0xFF</span>00077 <span class="preprocessor"></span>00078 <span class="keyword">struct </span>partrecord <span class="comment">// length 16 bytes</span>00079 {           00080     BYTE    prIsActive;                 <span class="comment">// 0x80 indicates active partition</span>00081     BYTE    prStartHead;                <span class="comment">// starting head for partition</span>00082     WORD    prStartCylSect;             <span class="comment">// starting cylinder and sector</span>00083     BYTE    prPartType;                 <span class="comment">// partition type (see above)</span>00084     BYTE    prEndHead;                  <span class="comment">// ending head for this partition</span>00085     WORD    prEndCylSect;               <span class="comment">// ending cylinder and sector</span>00086     DWORD   prStartLBA;                 <span class="comment">// first LBA sector for this partition</span>00087     DWORD   prSize;                     <span class="comment">// size of this partition (bytes or sectors ?)</span>00088 };00089 00090         00091 <span class="keyword">struct </span>partsector00092 {00093     CHAR    psPartCode[512-64-2];       <span class="comment">// pad so struct is 512b</span>00094     BYTE    psPart[64];                 <span class="comment">// four partition records (64 bytes)</span>00095     BYTE    psBootSectSig0;             <span class="comment">// two signature bytes (2 bytes)</span>00096     BYTE    psBootSectSig1;00097 <span class="preprocessor">#define BOOTSIG0        0x55</span>00098 <span class="preprocessor"></span><span class="preprocessor">#define BOOTSIG1        0xaa</span>00099 <span class="preprocessor"></span>};00100 00101 00102 00103 <span class="comment">// Format of a boot sector.  This is the first sector on a DOS floppy disk</span>00104 <span class="comment">// or the first sector of a partition on a hard disk.  But, it is not the</span>00105 <span class="comment">// first sector of a partitioned hard disk.</span>00106 <span class="keyword">struct </span>bootsector33 {00107     BYTE    bsJump[3];                  <span class="comment">// jump inst E9xxxx or EBxx90</span>00108     CHAR    bsOemName[8];               <span class="comment">// OEM name and version</span>00109     CHAR    bsBPB[19];                  <span class="comment">// BIOS parameter block</span>00110     CHAR    bsDriveNumber;              <span class="comment">// drive number (0x80)</span>00111     CHAR    bsBootCode[479];            <span class="comment">// pad so struct is 512b</span>00112     BYTE    bsBootSectSig0;             <span class="comment">// boot sector signature byte 0x55</span>00113     BYTE    bsBootSectSig1;             <span class="comment">// boot sector signature byte 0xAA</span>00114 <span class="preprocessor">#define BOOTSIG0        0x55</span>00115 <span class="preprocessor"></span><span class="preprocessor">#define BOOTSIG1        0xaa</span>00116 <span class="preprocessor"></span>};00117 00118 <span class="keyword">struct </span>extboot {00119     CHAR    exDriveNumber;              <span class="comment">// drive number (0x80)</span>00120     CHAR    exReserved1;                <span class="comment">// reserved</span>00121     CHAR    exBootSignature;            <span class="comment">// ext. boot signature (0x29)</span>00122 <span class="preprocessor">#define EXBOOTSIG       0x29</span>00123 <span class="preprocessor"></span>    CHAR    exVolumeID[4];              <span class="comment">// volume ID number</span>00124     CHAR    exVolumeLabel[11];          <span class="comment">// volume label</span>00125     CHAR    exFileSysType[8];           <span class="comment">// fs type (FAT12 or FAT16)</span>00126 };00127 00128 <span class="keyword">struct </span>bootsector50 {00129     BYTE    bsJump[3];                  <span class="comment">// jump inst E9xxxx or EBxx90</span>00130     CHAR    bsOemName[8];               <span class="comment">// OEM name and version</span>00131     CHAR    bsBPB[25];                  <span class="comment">// BIOS parameter block</span>00132     CHAR    bsExt[26];                  <span class="comment">// Bootsector Extension</span>

⌨️ 快捷键说明

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