fatfs v0.04a Apr 01, 2007:
- Supported multiple partitions on a plysical drive. (FatFs) - Fixed an endian sensitive code in f_mkfs(). (FatFs) - Added a capability of extending the file size to f_lseek(). - Added minimization level 3. - Fixed a problem that can collapse a sector when recreate an - existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs)
| @ -3,11 +3,9 @@ | ||||
| <head> | ||||
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||||
| <meta http-equiv="Content-Style-Type" content="text/css"> | ||||
| <link rel="start" title="Site Top" href="../../"> | ||||
| <link rel="up" title="Freewares" href="../../fsw_e.html"> | ||||
| <link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html"> | ||||
| <link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default"> | ||||
| <title>ELM - Generic FAT Files System Module</title> | ||||
| <title>ELM - Generic FAT File System Module</title> | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| @ -16,47 +14,22 @@ | ||||
| 
 | ||||
| <div class="abst"> | ||||
| <img src="img/layers.png" class="rset" width="245" height="255" alt="layer"> | ||||
| <p>FatFs module is an experimental project to implement a FAT file system to small embdded systems. The FatFs module is written in compliance with ANSI C, therefore it is independent of hardware architecture. It can be incorporated into most small microcontrollers, such as 8051, PIC, AVR, H8, Z80 and etc..., without any change. I created two modules in different configurations in consideration of various use. To use the FatFs module, low level disk I/O functions for each media must be provided by user.</p> | ||||
| <p>FatFs module is an experimental project to implement a FAT file system to small embdded systems. The FatFs module is written in compliance with ANSI C, therefore it is independent of hardware architecture. It can be incorporated into most 8-bit microcontrollers, such as 8051, PIC, AVR, H8, Z80 and etc..., without any change. I created two modules in different configurations in consideration of various use.</p> | ||||
| 
 | ||||
| <h4>Features of FatFs Module</h4> | ||||
| <ul> | ||||
|  <li>Separated buffer for FAT/DIR and each file, suitable for fast multiple file accsess.</li> | ||||
|  <li>Supports FAT12, FAT16(+FAT64) and FAT32 <small>(FAT64: FAT16 in 64KB/cluster)</small></li> | ||||
|  <li>Supports multiple drives.</li> | ||||
|  <li>Supports 8.3 format file name and NT lower capital flags</li> | ||||
|  <li>Supports two partitioning rules: FDISK (only 1st primariy partition) and SFD</li> | ||||
|  <li>Optimized for 8/16 bit microcontrollers.</li> | ||||
| </ul> | ||||
| <ol> | ||||
|  <li>Separated buffer for FAT structure and each file, suitable for fast multiple file accsess.</li> | ||||
|  <li>Supports multiple drives/partitions.</li> | ||||
|  <li>Supports FAT12, FAT16(+FAT64) and FAT32. <small>(FAT64: FAT16 in 64KB/cluster)</small></li> | ||||
|  <li>Supports 8.3 format file name and NT lower case flag. (LFN is not supported)</li> | ||||
|  <li>Supports two partitioning rules: FDISK and Super-floppy.</li> | ||||
|  <li>Optimized for 8/16-bit microcontrollers.</li> | ||||
| </ol> | ||||
| <h4>Features of Tiny-FatFs Module (different to FatFs)</h4> | ||||
| <ul> | ||||
|  <li>Very low memory consumption, suitable for small memory system (RAM:1KB)</li> | ||||
| <ol> | ||||
|  <li>Very low memory consumption, suitable for small memory system. (RAM:1KB)</li> | ||||
|  <li>Supports only single drive.</li> | ||||
| </ul> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>Memory Usage</h3> | ||||
| <p>There are some configuration options to eliminate unused functions to reduce module size. Following tables are the memory consumption in unit of byte on avr-gcc.</p> | ||||
| 
 | ||||
| <div class="lset"> | ||||
| <table class="lst2"> | ||||
|  <caption>FatFs</caption> | ||||
|  <tr><th>Section</th><th>Std cfg.</th><th>Min cfg.</th></tr> | ||||
|  <tr><td>Program (R/W cfg.)</td><td>8574</td><td>6094</td></tr> | ||||
|  <tr><td>Program (R/O cfg.)</td><td>4268</td><td>3494</td></tr> | ||||
|  <tr><td>Static Work Area</td><td colspan="2">2 + 2*<drives></td> | ||||
|  <tr><td>Dynamic Work Area</td><td colspan="2">550*<drives> + 544*<files></td> | ||||
| </table> | ||||
| </div> | ||||
| <table class="lst2"> | ||||
|  <caption>Tiny-FatFs</caption> | ||||
|  <tr><th>Section</th><th>Std cfg.</th><th>Min cfg.</th></tr> | ||||
|  <tr><td>Program (R/W cfg.)</td><td>7164</td><td>4890</td></tr> | ||||
|  <tr><td>Program (R/O cfg.)</td><td>3660</td><td>2946</td></tr> | ||||
|  <tr><td>Static Work Area</td><td colspan="2">4</td></tr> | ||||
|  <tr><td>Dynamic Work Area</td><td colspan="2">542 + 28*<files></td></tr> | ||||
| </table> | ||||
| </ol> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -86,12 +59,13 @@ | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>Disk I/O Interface</h3> | ||||
| <p>Since the FatFs/Tiny-FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read/write physical disk and to get current time. These functions must be provided by user.</p> | ||||
| <p>Since the FatFs/Tiny-FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read/write physical disk and to get current time. These functions must be provided by user. The low level disk I/O module that have this interace must be provided by user. The sample projects are also available.</p> | ||||
| <ul> | ||||
| <li><a href="en/dinit.html">disk_initialize</a> - Initialize disk drive</li> | ||||
| <li><a href="en/dstat.html">disk_status</a> - Get disk status</li> | ||||
| <li><a href="en/dread.html">disk_read</a> - Read sector(s)</li> | ||||
| <li><a href="en/dwrite.html">disk_write</a> - Write sector(s)</li> | ||||
| <li><a href="en/dioctl.html">disk_ioctl</a> - Control device dependent features</li> | ||||
| <li><a href="en/fattime.html">get_fattime</a> - Get current time</li> | ||||
| </ul> | ||||
| </div> | ||||
| @ -108,8 +82,5 @@ | ||||
| </ul> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <hr> | ||||
| <p class="foot"><a href="../../cc_e.html">Return</a></p> | ||||
| </body> | ||||
| </html> | ||||
|  | ||||
| @ -3,8 +3,6 @@ | ||||
| <head> | ||||
| <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> | ||||
| <meta http-equiv="Content-Style-Type" content="text/css"> | ||||
| <link rel="start" title="Site Top" href="../../index_j.html"> | ||||
| <link rel="up" title="Freewares" href="../../fsw.html"> | ||||
| <link rel="alternate" hreflang="en" title="English version" href="00index_e.html"> | ||||
| <link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default"> | ||||
| <title>ELM - 汎用FATファイルシステム・モジュール</title> | ||||
| @ -16,46 +14,21 @@ | ||||
| 
 | ||||
| <div class="abst"> | ||||
| <img src="img/layers.png" class="rset" width="245" height="255" alt="layer"> | ||||
| <p>小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, AVR, H8, Z80などほとんどのマイコンでそのまま使用可能です。いろいろな使用形態を考慮して、高機能版(<strong>FatFs</strong>)と省メモリ版(<strong>Tiny-FatFs</strong>)の2通りを作成してみました。実際に使用するには、各記録メディア(CFC, MMC, SDC, ATA, USB, SCSI等)に対応したディスクI/Oモジュール(サンプルあり)を用意する必要があります。</p> | ||||
| <p>小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, H8, Z80などほとんどの8ビット・マイコンでそのまま使用可能です。いろいろな使用形態を考慮して、高機能版(<strong>FatFs</strong>)と省メモリ版(<strong>Tiny-FatFs</strong>)の2通りを作成してみました。</p> | ||||
| <h4>FatFsの特徴</h4> | ||||
| <ul> | ||||
| <ol> | ||||
|  <li>ファイル・システム用とファイルI/O用バッファを分離し、複数ファイルの高速アクセスに適する</li> | ||||
|  <li>複数のドライブ・パーテーションをサポート</li> | ||||
|  <li>FAT12, FAT16(+FAT64), FAT32に対応 <small>(FAT64: FAT16 in 64KB/cluster)</small></li> | ||||
|  <li>複数ドライブをサポート</li> | ||||
|  <li>8.3形式ファイル名とNT小文字フラグに対応</li> | ||||
|  <li>FDISKフォーマット(基本区画)およびSFDフォーマット(512B/sectorのみ)に対応</li> | ||||
|  <li>8.3形式ファイル名とNT小文字フラグに対応(LFN未対応)</li> | ||||
|  <li>FDISKフォーマットおよびSFDフォーマットに対応</li> | ||||
|  <li>8/16ビットマイコン向けにコードを最適化</li> | ||||
| </ul> | ||||
| </ol> | ||||
| <h4>Tiny-FatFsの特徴(FatFsとの相違)</h4> | ||||
| <ul> | ||||
| <ol> | ||||
|  <li>RAMの使用量を削減し、小メモリ・システム(RAM:1KB)にも対応</li> | ||||
|  <li>単一ドライブのみサポート</li> | ||||
| </ul> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>メモリ使用量</h3> | ||||
| <p>いくつかのコンフィギュレーション・オプションにより、不要な関数を削ってモジュール・サイズを削減できます。次に実際のメモリ使用量[バイト]を示します(avrgccの例)。</p> | ||||
| 
 | ||||
| <div class="lset"> | ||||
| <table class="lst2"> | ||||
|  <caption>FatFs</caption> | ||||
|  <tr><th>セクション</th><th>標準</th><th>最小</th></tr> | ||||
|  <tr><td>プログラム(R/W構成)</td><td>8574</td><td>6094</td></tr> | ||||
|  <tr><td>プログラム(R/O構成)</td><td>4268</td><td>3494</td></tr> | ||||
|  <tr><td>静的ワークエリア</td><td colspan="2">2 + 2*<drives></td> | ||||
|  <tr><td>動的ワークエリア</td><td colspan="2">550*<drives> + 544*<files></td> | ||||
| </table> | ||||
| </div> | ||||
| <table class="lst2"> | ||||
|  <caption>Tiny-FatFs</caption> | ||||
|  <tr><th>セクション</th><th>標準</th><th>最小</th></tr> | ||||
|  <tr><td>プログラム(R/W構成)</td><td>7164</td><td>4890</td></tr> | ||||
|  <tr><td>プログラム(R/O構成)</td><td>3660</td><td>2946</td></tr> | ||||
|  <tr><td>静的ワークエリア</td><td colspan="2">4</td></tr> | ||||
|  <tr><td>動的ワークエリア</td><td colspan="2">542 + 28*<files></td></tr> | ||||
| </table> | ||||
| </ol> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -85,12 +58,13 @@ | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>下位レイヤI/F</h3> | ||||
| <p>FatFs/Tiny-FatFsモジュールは、物理ドライブへのアクセスや現在時刻を得るため、下位レイヤに次のインターフェースを要求します。</p> | ||||
| <p>FatFs/Tiny-FatFsモジュールは、物理ドライブへのアクセスや現在時刻を得るため、下位レイヤに次のインターフェースを要求します。これらのインターフェースを持つそれぞれの記録メディアに対応したディスクI/Oモジュールは、ユーザにより用意する必要があります。(サンプルもあり)</p> | ||||
| <ul> | ||||
| <li><a href="ja/dinit.html">disk_initialize</a> - ディスク・ドライブの初期化</li> | ||||
| <li><a href="ja/dstat.html">disk_status</a> - ディスク・ドライブの状態取得</li> | ||||
| <li><a href="ja/dread.html">disk_read</a> - ディスクからの読み込み</li> | ||||
| <li><a href="ja/dwrite.html">disk_write</a> - ディスクへの書き込み</li> | ||||
| <li><a href="ja/dioctl.html">disk_ioctl</a> - その他のドライブ制御</li> | ||||
| <li><a href="ja/fattime.html">get_fattime</a> - 日付・時刻の取得</li> | ||||
| </ul> | ||||
| </div> | ||||
| @ -108,7 +82,5 @@ | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <hr> | ||||
| <p class="foot"><a href="../../cc.html">戻る</a></p> | ||||
| </body> | ||||
| </html> | ||||
|  | ||||
| @ -7,7 +7,8 @@ a:active {color: darkmagenta; position: relative; top: 1px; left: 1px;} | ||||
| abbr {border-width: 1px;} | ||||
| 
 | ||||
| p {margin: 0 0 0.3em 1em;} | ||||
| em {} | ||||
| em {font-style: normal; font-weight: bold; margin: 0 0.1em;} | ||||
| pre em {font-style: italic; font-weight: normal;} | ||||
| strong {} | ||||
| pre {margin: 1em; line-height: 1.2em; background-color: white;} | ||||
| tt {margin: 0 0.2em;} | ||||
| @ -48,6 +49,7 @@ table {margin: 4px; border-collapse: collapse; border-style: solid; border-width | ||||
| th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;} | ||||
| td {background-color: white; border-style: solid; border-width: 1px; border-color: black; padding: 0 3px; vertical-align: top; line-height: 1.3em;} | ||||
| table.lst td:first-child {font-family: monospace;} | ||||
| table.lst2 td {font-family: monospace;} | ||||
| table caption {font-family: sans-serif; font-weight: bold;} | ||||
| 
 | ||||
| p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;} | ||||
|  | ||||
| @ -10,7 +10,8 @@ a:active {color: darkmagenta; position: relative; top: 1px; left: 1px;} | ||||
| abbr {border-width: 1px;} | ||||
| 
 | ||||
| p {text-indent: 1em; margin: 0 0 0.3em 0.5em;} | ||||
| em {} | ||||
| em {font-style: normal; font-weight: bold; margin: 0 0.1em;} | ||||
| pre em {font-style: italic; font-weight: normal;} | ||||
| strong {} | ||||
| pre {margin: 1em; line-height: 1.2em; letter-spacing: 0; background-color: white;} | ||||
| tt {margin: 0 0.2em; letter-spacing: 0;} | ||||
| @ -51,6 +52,7 @@ table {margin: 4px; border-collapse: collapse; border-style: solid; border-width | ||||
| th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top;} | ||||
| td {background-color: white; border-style: solid; border-width: 1px; border-color: black; padding: 0 3px; vertical-align: top; line-height: 1.3em;} | ||||
| table.lst td:first-child {font-family: monospace; white-space: nowrap;} | ||||
| table.lst2 td {font-family: monospace; white-space: nowrap;} | ||||
| table caption {font-family: sans-serif; font-weight: bold;} | ||||
| 
 | ||||
| p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;} | ||||
|  | ||||
| @ -9,7 +9,7 @@ | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| <h1>FatFs Module Application Note (for R0.04)</h1> | ||||
| <h1>FatFs Module Application Note</h1> | ||||
| <hr> | ||||
| 
 | ||||
| <div class="para"> | ||||
| @ -17,17 +17,37 @@ | ||||
| <p>The FatFs module is assuming following terms on portability.</p> | ||||
| <ul> | ||||
| <li>ANSI C<br> | ||||
| The FatFs module is a middleware that written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C. However it handles system portable FAT structures. You must take the <strong>endian</strong> into consideration. This setting is defined in ff.h (tff.h). It must be changed for your platform first or the compiler will abort with an error.</li> | ||||
| <li>Size of char/short/long is 8/16/32 bit.<br> | ||||
| This will not be a problem on most C compilers. When any conflict of integer definitions between integer.h and existing definitions is occured, you must resolve the confrict with care.</li> | ||||
| The FatFs module is a middleware that written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C. However it handles the system portable FAT structures. You must take the <strong>endian</strong> into consideration. This setting is defined in ff.h (tff.h). It must be changed for your platform first or the compiler will abort with an error.</li> | ||||
| <li>Size of char/short/long are 8/16/32 bit.<br> | ||||
| These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict of the definitions between the integer.h and existing definitions is occured, you must resolve the confrict with care.</li> | ||||
| </ul> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>Memory Usage (R0.04a)</h3> | ||||
| <p>These are the memory usage on some target systems. The memory sizes are in unit of byte, D means number of logical drives and F means number of open files. All samples are optimezed in code size.</p> | ||||
| <table class="lst2"> | ||||
| <tr><th></th><th>AVR</th><th>H8/300H</th><th>MSP430</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th></tr> | ||||
| <tr><td>Compiler</td><td>gcc</td><td>CH38</td><td>CL430</td><td>CC870C</td><td>CA850</td><td>SHC</td></tr> | ||||
| <tr><td>_MCU_ENDIAN</td><td>1</td><td>2</td><td>2</td><td>1</td><td>1</td><td>2</td></tr> | ||||
| <tr><td>FatFs Code<br>(Full, R/W cfg.)</td><td>8672</td><td>8746</td><td></td><td></td><td>6384</td><td>7390</td></tr> | ||||
| <tr><td>FatFs Code<br>(Full, R/O cfg.)</td><td>4230</td><td>4100</td><td></td><td></td><td>3012</td><td>3510</td></tr> | ||||
| <tr><td>FatFs Code<br>(Mininum, R/W cfg.)</td><td>5706</td><td>5678</td><td></td><td></td><td>4042</td><td>4882</td></tr> | ||||
| <tr><td>FatFs Code<br>(Minimum, R/O cfg.)</td><td>3016</td><td>3116</td><td></td><td></td><td>2198</td><td>2702</td></tr> | ||||
| <tr><td>FatFs Work (Static)</td><td>D*2 + 2</td><td>D*4 + 2</td><td></td><td></td><td>D*4 + 2</td><td>D*4 + 2</td></tr> | ||||
| <tr><td>FatFs Work (Dynamic)</td><td>D*550 + F*544</td><td>D*550 + F*550</td><td></td><td></td><td>D*550 + F*550</td><td>D*550 + F*550</td></tr> | ||||
| <tr><td>Tiny-FatFs Code<br>(Full, R/W cfg.)</td><td>7188</td><td>7206</td><td>6590</td><td>8799</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs Code<br>(Full, R/O cfg.)</td><td>3592</td><td>3560</td><td>3162</td><td>4353</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs Code<br>(Minimum, R/W cfg.)</td><td>4670</td><td>4772</td><td>4322</td><td>6073</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs Code<br>(Minimum, R/O cfg.)</td><td>2576</td><td>2714</td><td>2378</td><td>3324</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs Wrok (Static)</td><td>4</td><td>6</td><td>4</td><td>4</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs Work (Dynamic)</td><td>542 + F*28</td><td>542 + F*32</td><td>542 + F*28</td><td>542 + F*28</td><td></td><td></td></tr> | ||||
| </table> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>FatFs vs. Tiny-FatFs</h3> | ||||
| <p>For most applications, such as portable audio and data logger, Tiny-FatFs is the best choice. However because the Tiny-FatFs does not support FAT32 in default, there is a limitation that can handle only tiny storage upto 2GB(4GB in FAT64). The FAT32 support can be added by <tt>_USE_FAT32</tt> option with an additional code size.</p> | ||||
| <p>FatFs is suitable for accessing multiple files fast, and for multiple drive system.</p> | ||||
| <p>For most applications, such as portable audio and data logger, Tiny-FatFs is the best choice. However because the Tiny-FatFs does not support FAT32 in default, there is a limitation that can handle only tiny storage upto 2GB(4GB in FAT64). The FAT32 support can be added by <tt>_USE_FAT32</tt> option with an additional code size. The FatFs is suitable for fast multiple files access, and for multiple drive system.</p> | ||||
| <div class="rset"> | ||||
| <table class="lst2"> | ||||
| <tr><th>Memory Size</th><th>FAT Type</th></tr> | ||||
| @ -36,7 +56,7 @@ This will not be a problem on most C compilers. When any conflict of integer def | ||||
| <tr><td>>= 4GB</td><td>FAT32</td></tr> | ||||
| </table> | ||||
| </div> | ||||
| <p>Rignt table shows the correspondence between memory size and FAT type for SD memroy card and they are shipped with this format. The data area is justified to the erase block and the memory card works the best performance. For that reason, the memory card should not be reformated with PC. When cluster size or FAT type is changed, the write performance can be worse.</p> | ||||
| <p>Rignt table shows the correspondence between memory size and FAT type for SD memroy card and they are shipped with this format. The data area is justified to the erase block boundary and the memory card works with the best performance. For that reason, the memory card should not be reformated with PC. When cluster size or FAT type is changed, the write performance can be decreased.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -52,10 +72,10 @@ This will not be a problem on most C compilers. When any conflict of integer def | ||||
| <p>Figure 3. Sector aligned read<br> | ||||
| <img src="../img/f3.png" width="490" height="119"> | ||||
| </p> | ||||
| <p>The file I/O buffer means a sector buffer to read/write partial data on the sector. For FatFs, member buffer[] in the file object is used. For Tiny-FatFs, member win[] in the file system object is used.</p> | ||||
| <p>The file I/O buffer means a sector buffer to read/write a partial data on the sector. On the FatFs, member buffer[] in the file object is used. On the Tiny-FatFs, member win[] in the file system object is used.</p> | ||||
| <p>Tiny-FatFs processes all data transfer and access to the FAT/directory with only one sector buffer, so that FAT sector cached into the buffer is lost and it must reloaded at every cluster boundary. FatFs has a FAT/directory buffer separated from file I/O buffer, the frequency of FAT accesses is only 1/341, 1/256 or 1/128 (when cluster is contiguous) compared to Tiny-FatFs. Thus the Tiny-FatFs is sacrificing its performance in compensation for very small memory footprint.</p> | ||||
| <p>Figure 1 shows that partial sector data is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that aligned to sector boundary is transferred into memory directly. Figure 3 shows that entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. At the direct transfer, maximum extent of sectors are read with disk_read function at a time but it never across cluster boundary even if it is contiguous.</p> | ||||
| <p>Therefore taking effort to sector aligned read/write accesss reduces memcpy and read/write performance will be improved. Besides the effect, cached FAT sector on the Tiny-FatFs is not flushed during read/write access, so that it can achieve same performance as FatFs and its small memory footprint simultanesously.</p> | ||||
| <p>Figure 1 shows that partial sector data is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that aligned to sector boundary is transferred into memory directly. Figure 3 shows that entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. At the unbuffered transfer, maximum extent of sectors are read with disk_read function at a time but it never across cluster boundary even if it is contiguous.</p> | ||||
| <p>Therefore taking effort to sector aligned read/write accesss eliminates memcpy and the read/write performance will be improved. Besides the effect, cached FAT sector is not flushed during read/write access on the Tiny-FatFs, so that it can achieve same performance as FatFs and its small memory footprint simultanesously.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -64,24 +84,22 @@ This will not be a problem on most C compilers. When any conflict of integer def | ||||
| <p>When write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable data error, the FAT structure can be destroyed. Following images shows the critical section on the FatFs module.</p> | ||||
| <div class="lset"> | ||||
| Figure 4. Long critical section<br> | ||||
| <img src="../img/f4.png" width="320" height="470" alt="fig.4"> | ||||
| <img src="../img/f4.png" width="320" height="436" alt="fig.4"> | ||||
| </div> | ||||
| <div class="lset"> | ||||
| Figure 5. Minimized critical section<br> | ||||
| <img src="../img/f5.png" width="320" height="470" alt="fig.5"> | ||||
| <img src="../img/f5.png" width="320" height="436" alt="fig.5"> | ||||
| </div> | ||||
| <br class="clr"> | ||||
| <p>An interruption in the red section can cause a cross link; as a result, the file/directory is lost. There is one or more possibility listed below when an interruption in the yellow section is occured.</p> | ||||
| <p>An interruption in the red section can cause a cross link; as a result, the file/directory being changed will be lost. There is one or more possibility listed below when an interruption in the yellow section is occured.</p> | ||||
| <ul> | ||||
| <li>File data being rewrited is collapted.</li> | ||||
| <li>A file being appended returns initial state.</li> | ||||
| <li>A file created as new is gone.</li> | ||||
| <li>A file created as new remains with length of zero.</li> | ||||
| <li>A file created in overwrite remains with length of zero.</li> | ||||
| <li>A file created in overwrite returns initial state.</li> | ||||
| <li>A file created as new or in overwrite remains with length of zero.</li> | ||||
| <li>Efficiency of disk use gets worse due to lost chain.</li> | ||||
| </ul> | ||||
| <p>Every case does not affect the files that not in write operation. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode and using f_sync function properly.</p> | ||||
| <p>Each case does not affect the files that not in write operation. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode and using f_sync function properly.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -89,7 +107,7 @@ Figure 5. Minimized critical section<br> | ||||
| <h3>Problems and Ideas</h3> | ||||
| <ul> | ||||
| <li>Abstraction of file object<br> | ||||
| Currently the file object structure is held by application layer. This is not a problem for Tiny-FatFs, it consumes the task stack only 26 bytes per file. But FatFs requires 550 bytes per file. When manage the file objects in file handle, stack consumption at application module will able to be reduced. In this case, the work area for file objects is managed in FatFs module. This has a disadvantage that direct access to the file object structure cannot be used and additional file functions, such as feof and ftell, will be needed.</li> | ||||
| Currently the file object structure is held by application layer. This is not a problem for Tiny-FatFs, it consumes the task stack only 26 bytes per file. But FatFs requires 550 bytes per file. When managed the file objects in file handle, stack consumption at application module will able to be reduced. In this case, the work area for file objects is managed in FatFs module. This has a disadvantage that direct access to the file object structure cannot be used and additional file functions, such as feof and ftell, will be needed.</li> | ||||
| <li>Efficient sector buffer management<br> | ||||
| The FatFs module has only one sector buffer per logical drive. There is an ineffciency on random file access with many files simultanesously. When additional memory for the sector buffer is available, the file access performance will able to be improved with an advanced cache mechanism.</li> | ||||
| <li>FSInfo sector<br> | ||||
| @ -97,7 +115,7 @@ On FAT32 file system, the cluster search to create a file as new or get number o | ||||
| <li>Long file name<br> | ||||
| There is an extended feature to handle long file name (LFN) up to 255 characters, in addition to 8.3 format file name, on FAT file system. To support this, 512 byte string buffer for file name and UCS-2 - Shift_JIS mutual conversion table are required. Therefore memory consumption of code and work area will be increased drastically. The FatFs module does not support this feature. The LFN on the FAT file system is a patent of Microsoft. When support it on the commercial products, you have to be licensed.</li> | ||||
| <li>Porting to RTOS<br> | ||||
| When use FatFs module from only one task, no consideration is needed. However when use it from two or more tasks simultanesously, any exclusion control will be required. Porting of FatFs module to μITRON  is in progress by <a href="http://www.toppers.jp/">TOPPERS Project</a>.</li> | ||||
| When use FatFs module from only one task, no consideration is needed. However when make access to a logical drive from two or more tasks simultanesously, any exclusion control will be required. The FatFs module is also ported to a free RTOS based on μITRON by <a href="http://www.toppers.jp/en/index.html">TOPPERS Project</a>.</li> | ||||
| </ul> | ||||
| <br> | ||||
| <p>These are the problems and ideas on current revision of FatFs module. However the main target of FatFs module is 8 bit microcontrollers. These extensions requires much resource and the FatFs will unable to be ported to the 8 bit system. This may be the most serious problem on future plan.</p> | ||||
|  | ||||
| @ -31,10 +31,10 @@ FRESULT f_chmod ( | ||||
| <dd>Attribute flags to be set in one or more combination of the following flags. The specified flags are set and others are cleard.<br> | ||||
| <table class="lst"> | ||||
| <tr><th>Attribute</th><th>Description</th></td> | ||||
| <tr><td>AR_RDO</td><td>Read only</td></td> | ||||
| <tr><td>AR_ARC</td><td>Archive</td></td> | ||||
| <tr><td>AR_SYS</td><td>System</td></td> | ||||
| <tr><td>AR_HID</td><td>Hidden</td></td> | ||||
| <tr><td>AM_RDO</td><td>Read only</td></td> | ||||
| <tr><td>AM_ARC</td><td>Archive</td></td> | ||||
| <tr><td>AM_SYS</td><td>System</td></td> | ||||
| <tr><td>AM_HID</td><td>Hidden</td></td> | ||||
| </table> | ||||
| </dd> | ||||
| <dt>AttributeMask</dt> | ||||
| @ -61,7 +61,7 @@ FRESULT f_chmod ( | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>The medium is write protected.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -35,7 +35,7 @@ FRESULT f_close ( | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>The file object has been closed successfuly.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error has occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
|  | ||||
							
								
								
									
										65
									
								
								doc/en/dioctl.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,65 @@ | ||||
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||||
| <html lang="en"> | ||||
| <head> | ||||
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | ||||
| <meta http-equiv="Content-Style-Type" content="text/css"> | ||||
| <link rel="up" title="FatFs" href="../00index_e.html"> | ||||
| <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> | ||||
| <title>FatFs - disk_ioctl</title> | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h2>disk_ioctl</h2> | ||||
| <p>The disk_ioctl function cntrols device specified features and miscellaneous functions other than disk read/write.</p> | ||||
| <pre> | ||||
| DRESULT disk_ioctl ( | ||||
|   BYTE <em>Drive</em>,      /* Drive number */ | ||||
|   BYTE <em>Command</em>,    /* Control command code */ | ||||
|   void* <em>Buffer</em>     /* Data transfer buffer */ | ||||
| ); | ||||
| </pre> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>Parameters</h4> | ||||
| <dl class="par"> | ||||
| <dt>Drive</dt> | ||||
| <dd>Specifies drive number (0-9).</dd> | ||||
| <dt>Command</dt> | ||||
| <dd>Specifies the command code.</dd> | ||||
| <dt>Buffer</dt> | ||||
| <dd>Pointer to the parameter buffer depends on the command code. When it is not used, specify a NULL pointer.</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>Return Value</h4> | ||||
| <dl class="ret"> | ||||
| <dt>RES_OK (0)</dt> | ||||
| <dd>The function succeeded.</dd> | ||||
| <dt>RES_ERROR</dt> | ||||
| <dd>Any error occured.</dd> | ||||
| <dt>RES_PARERR</dt> | ||||
| <dd>Invalid command code.</dd> | ||||
| <dt>RES_NOTRDY</dt> | ||||
| <dd>The disk dirve has not been initialized.</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>Description</h4> | ||||
| <p>The FatFs module uses only device independent commands described below. Any device dependent function is not used. In read-only configuration, This function is not needed.</p> | ||||
| <table class="lst"> | ||||
| <tr><th>Command</th><th>Description</td></tr> | ||||
| <tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by Buffer.</td></tr> | ||||
| <tr><td>CTRL_SYNC</td><td>Make sure that the drive has finished to write data. When the module has a write back cache, write back the dirty sector immediately.</td></tr> | ||||
| </table> | ||||
| </div> | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_e.html">Return</a></p> | ||||
| </body> | ||||
| </html> | ||||
| @ -41,7 +41,7 @@ DRESULT disk_read ( | ||||
| <div class="para"> | ||||
| <h4>Return Value</h4> | ||||
| <dl class="ret"> | ||||
| <dt>RES_OK</dt> | ||||
| <dt>RES_OK (0)</dt> | ||||
| <dd>The function succeeded.</dd> | ||||
| <dt>RES_ERROR</dt> | ||||
| <dd>Any error occured during the read operation.</dd> | ||||
|  | ||||
| @ -41,7 +41,7 @@ DRESULT disk_write ( | ||||
| <div class="para"> | ||||
| <h4>Return Values</h4> | ||||
| <dl class="ret"> | ||||
| <dt>RES_OK</dt> | ||||
| <dt>RES_OK (0)</dt> | ||||
| <dd>The function succeeded.</dd> | ||||
| <dt>RES_ERROR</dt> | ||||
| <dd>Any error occured during the write operation.</dd> | ||||
|  | ||||
| @ -9,13 +9,13 @@ | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| <h2>File and Path name on the FatFs module</h2> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <p>The format of file and path name on the FatFs module is similer to MS-DOS. However does not have a concept of current directory, all objects on the drive are specified in full path from the roor directory.</p> | ||||
| <h2>File and Path name on the FatFs module</h2> | ||||
| <p>The format of file and path name on the FatFs module is similer to MS-DOS. However it does not have a concept of current directory, all objects on the drive are specified in full path from the roor directory.</p> | ||||
| <pre> | ||||
| 
 | ||||
|  "<em>Drive#</em>:<em>directory</em>/<em>file</em>" | ||||
|  "[<em>logical drive#</em>:][/]<em>directory</em>/<em>file</em>" | ||||
| 
 | ||||
|  "file1.txt"           a file on drive 0 | ||||
|  "/file1.txt"          (same as above) | ||||
| @ -27,9 +27,31 @@ | ||||
|  "2:"                  the root directory on drive 2 | ||||
| 
 | ||||
| </pre> | ||||
| <p>The FatFs module supports only 8.3 format file name and long file name is currentry not supported. For directory separator, a '/' is used, not a '\'.</p> | ||||
| <p>The FatFs module has work areas that called file system object for each logical drive. The logical drive number is specified in a numeral with a colon. When drive number is omitted, it means the default drive (0). The logical drive is bound to the physical drive that has same drive number.</p> | ||||
| <p>As for the Tiny-FatFs, it has only one logical drive and always works as drive 0. Any drive number cannot be contained in the path name.</p> | ||||
| <p>The FatFs module supports only 8.3 format file name and long file name is currentry not supported. For directory separator, a '/' is used, not a '\'. Heading '/' is ignored and can be omitted.</p> | ||||
| <p>The logical drive number is specified in a numeral with a colon. When drive number is omitted, it means the default drive (0). As for the Tiny-FatFs, it has only one logical drive and always works as drive 0. Any drive number cannot be contained in the path name.</p> | ||||
| </div> | ||||
| 
 | ||||
| <p><br></p> | ||||
| <div class="para"> | ||||
| <h2>Correspondence between logical/physical drive</h2> | ||||
| <p>In default, the FatFs module has work areas that called file system object for each logical drive. The logical drive is bound simply to the physical drive that has same drive number, and first partition is mounted. When <tt>_MULTI_PARTITION</tt> is specified in configuration option, each individual logical drive can be bound to any physical drive/partition. In this case, a drive number resolution table must be defined as follows:</p> | ||||
| <pre> | ||||
| Example: Logical drive 0-2 are assigned to three pri-partitions on the physical drive 0 (fixed disk) | ||||
|          Logical drive 3 is assigned to physical drive 0 (removable disk) | ||||
| 
 | ||||
| const PARTITION Drives[] = { | ||||
|     {0, 0},     /* Logical drive 0 ==> Physical drive 0, 1st partition */ | ||||
|     {0, 1},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */ | ||||
|     {0, 2},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */ | ||||
|     {1, 0}      /* Logical drive 3 ==> Physical drive 1 */ | ||||
| }; | ||||
| </pre> | ||||
| <p>There are some consideration when use <tt>_MULTI_PARTITION</tt> configuration.</p> | ||||
| <ul> | ||||
| <li>Only pri-partition (0-3) can be mounted.</li> | ||||
| <li>When the drive have no partition table (super floppy format), partition number is ignored.</li> | ||||
| <li>The drive that has two or more logical drive must be fixed drive.</li> | ||||
| </li> | ||||
| </div> | ||||
| 
 | ||||
| </body> | ||||
|  | ||||
| @ -45,7 +45,7 @@ FRESULT f_getfree ( | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
| @ -74,7 +74,7 @@ FRESULT f_getfree ( | ||||
|     // Get free space | ||||
|     printf("%lu KB total disk space.\n" | ||||
|            "%lu KB available on the disk.\n", | ||||
|            (fs->max_clust - 2) * fs->sects_clust / 2, | ||||
|            (DWORD)(fs->max_clust - 2) * fs->sects_clust / 2, | ||||
|            clust * fs->sects_clust / 2); | ||||
| </pre> | ||||
| </div> | ||||
|  | ||||
| @ -38,7 +38,7 @@ FRESULT f_lseek ( | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>The function succeeded.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
| @ -49,8 +49,13 @@ FRESULT f_lseek ( | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_lseek function moves the file read/write pointer of an open file object. The offset can be specified in only origin from top of the file and cannot moved to above end of the file. When an offset above the file size was specified, the read/write pointer moves to end of the file.</p> | ||||
| </div> | ||||
| <p>The f_lseek function moves the file R/W pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file is extended to the offset and the data in the extended area is undefined. After the function succeeded, member fptr in the file object should be checked in order to make sure the R/W pointer has been moved correctry. In case of fptr is less than Offset, any of the followings has been occured.</p> | ||||
| <ul> | ||||
| <li>In read-only mode, the Offset was clipped in file size.</li> | ||||
| <li>The drive gets full during the file extending process.</li> | ||||
| <li>There is any error in the FAT structure.</li> | ||||
| </ul> | ||||
| <p>This function is not supported in minimization level of >= 3.</p></div> | ||||
| 
 | ||||
| 
 | ||||
| <div class="para"> | ||||
| @ -62,7 +67,7 @@ FRESULT f_lseek ( | ||||
|     // Forward 3000 bytes | ||||
|     res = f_lseek(&file, file.fptr + 3000); | ||||
| 
 | ||||
|     // Rewind 2000 bytes | ||||
|     // Rewind 2000 bytes (take care on overflow) | ||||
|     res = f_lseek(&file, file.fptr - 2000); | ||||
| 
 | ||||
|     // Move to end of the file | ||||
|  | ||||
| @ -41,13 +41,15 @@ FRESULT f_mkdir ( | ||||
| <dt>FR_INVALID_DRIVE</dt> | ||||
| <dd>The drive number is invalid.</dd> | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>The function was denied due to any of following reasons: any file or directory that has same name is existing, cannot be created due to directory table or disk is full.</dd> | ||||
| <dd>The directory cannot be created due to directory table or disk is full.</dd> | ||||
| <dt>FR_EXIST</dt> | ||||
| <dd>A file or directory that has same name is already existing.</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>The medium is write protected.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -45,8 +45,10 @@ FRESULT f_mkfs ( | ||||
| <dd>The drive cannot work due to any reason.</dd> | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>The drive is write protected.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>The function failed due to a write error in the low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_MKFS_ABORTED</dt> | ||||
| <dd>The function aborted before start in format due to a reason as follows. | ||||
| <ul> | ||||
| @ -60,7 +62,8 @@ FRESULT f_mkfs ( | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_mkfs function creates a FAT file system on the drive. There are two partitioning rules, FDISK and SFD, for removable media. It can be selected with a parameter and FDISK format is recommended for most case. The FAT type, FAT12/FAT16/FAT32, is determined by only how many clusters on the drive and nothing else, according to FAT specification. Thus which FAT type is selected, is depends on the drive size and specified cluster size.</p> | ||||
| <p>The f_mkfs function creates a FAT file system on the drive. There are two partitioning rules, FDISK and SFD, for removable media. It can be selected with a parameter and FDISK format is recommended for most case. This function currently does not support multiple partition, so that existing partitions on the physical dirve will be deleted and re-created a partition occupies entire disk space.</p> | ||||
| <p>The FAT type, FAT12/FAT16/FAT32, is determined by only how many clusters on the drive and nothing else, according to FAT specification. Thus which FAT type is selected, is depends on the drive size and specified cluster size. The cluster size affects performance of file system and large cluster increases the performance, so that 64 sectors per cluster is recommended except for small drive.</p> | ||||
| <p>This function is supported on only FatFs with _USE_MKFS option.<p> | ||||
| </div> | ||||
| 
 | ||||
|  | ||||
| @ -45,7 +45,7 @@ FRESULT f_mount ( | ||||
| <div class="para"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_mount function registers/unregisters a work area to the FatFs module. The work area must be given to the logical drive with this function before using any file function. To unregister a work area, specify a NULL to the <em>FileSystemObject</em>, and then the work area can be discarded.</p> | ||||
| <p>This function only initializes the work area and registers its address to the internal table, any access to the disk I/O layer does not occure. Actual mounting process is performed in any other file funcitons when it is needed.<p> | ||||
| <p>This function only initializes the work area and registers its address to the internal table, any access to the disk I/O layer does not occure. Actual mounting process is performed in any other file funcitons with path name when it is needed.<p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -36,8 +36,9 @@ FRESULT f_open ( | ||||
| <tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with FA_WRITE for read-write access.</td></tr> | ||||
| <tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file.<br>Combine with FA_READ for read-write access.</td></tr> | ||||
| <tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing.</td></tr> | ||||
| <tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it is truncated and overwritten.</td></tr> | ||||
| <tr><td>FA_OPEN_ALWAYS</td><td>Opens the file, if it is existing. If not, the function creates the new file.</td></tr> | ||||
| <tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails if the file is already existing.</td></tr> | ||||
| <tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it is truncated and overwritten.</td></tr> | ||||
| </table> | ||||
| </dd> | ||||
| </dl> | ||||
| @ -57,6 +58,8 @@ FRESULT f_open ( | ||||
| <dd>The file name is invalid.</dd> | ||||
| <dt>FR_INVALID_DRIVE</dt> | ||||
| <dd>The drive number is invalid.</dd> | ||||
| <dt>FR_EXIST</dt> | ||||
| <dd>The file is already existing.</dd> | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>The required access was denied due to any of following reasons: write mode open of a file that has read-only attribute, file creation under existing a same name directory or read-only file, cannot be created due to the directory table or disk full.</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| @ -64,7 +67,7 @@ FRESULT f_open ( | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>Write mode open or creation under the medium is write protected.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
| @ -77,7 +80,7 @@ FRESULT f_open ( | ||||
| <h4>Description</h4> | ||||
| <p>The created file object is used for subsequent calls to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function.</p> | ||||
| <p>Before using any file function, work area (file system object) must be given to each logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p> | ||||
| <p>Flags <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_OPEN_ALWAYS</tt> are not supported in read-only configuration.</p> | ||||
| <p>The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not supported in read-only configuration.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -48,7 +48,7 @@ FRESULT f_opendir ( | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
| @ -59,7 +59,7 @@ FRESULT f_opendir ( | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_opendir function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure. This function is not supported in minimization level 2.</p> | ||||
| <p>The f_opendir function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure. This function is not supported in minimization level of >=2.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -46,7 +46,7 @@ FRESULT f_read ( | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>The function denied due to the file has been opened in write only mode.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error has occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
|  | ||||
| @ -15,8 +15,8 @@ | ||||
| <p>The f_readdir function reads directory entries.</p> | ||||
| <pre> | ||||
| FRESULT f_readdir ( | ||||
|   DIR* <em>DirObject</em>,    /* Pointer to the directory object strcture */ | ||||
|   FILINFO* <em>FileInfo</em>  /* Pointer to the blank file information structure */ | ||||
|   DIR* <em>DirObject</em>,    /* Pointer to the directory object structure */ | ||||
|   FILINFO* <em>FileInfo</em>  /* Pointer to the file information structure */ | ||||
| ); | ||||
| </pre> | ||||
| </div> | ||||
| @ -40,7 +40,7 @@ FRESULT f_readdir ( | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
| <dd>The directory object is invalid.</dd> | ||||
| </dl> | ||||
| @ -49,7 +49,7 @@ FRESULT f_readdir ( | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_readdir function reads directory entries in sequence. All items in the directory can be read by calling f_readdir function repeatedly. When all directory items have been read and no item to read, the function returns a null string into <tt>f_name[]</tt> member without any error. For details of the file informations, refer to the <tt>FILINFO</tt>. This function is not supported in minimization level of 2.</p> | ||||
| <p>The f_readdir function reads directory entries in sequence. All items in the directory can be read by calling f_readdir function repeatedly. When all directory items have been read and no item to read, the function returns a null string into <tt>f_name[]</tt> member without any error. For details of the file informations, refer to the <tt>FILINFO</tt>. This function is not supported in minimization level of >=2.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -52,7 +52,7 @@ FRESULT f_rename ( | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>The medium is write protected.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -16,23 +16,23 @@ | ||||
| <h4>FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _DIR { | ||||
|     WORD    id;          /* Owner file system mount ID (inverted) */ | ||||
|     WORD    index;       /* Current index */ | ||||
|     FATFS*  fs;          /* Pointer to the owner file system object */ | ||||
|     DWORD   sclust;      /* Start cluster */ | ||||
|     DWORD   clust;       /* Current cluster */ | ||||
|     DWORD   sect;        /* Current sector */ | ||||
|     WORD    index;       /* Current index */ | ||||
|     WORD    id;          /* Sum of owner file system mount ID */ | ||||
| } DIR; | ||||
| </pre> | ||||
| <h4>Tiny-FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _DIR { | ||||
|     WORD    id;          /* Owner file system mount ID (inverted) */ | ||||
|     WORD    index;       /* Current index */ | ||||
|     FATFS*  fs;          /* Pointer to the owner file system object */ | ||||
|     CLUST   sclust;      /* Start cluster */ | ||||
|     CLUST   clust;       /* Current cluster */ | ||||
|     DWORD   sect;        /* Current sector */ | ||||
|     WORD    index;       /* Current index */ | ||||
|     WORD    id;          /* Sum of owner file system mount ID */ | ||||
| } DIR; | ||||
| </pre> | ||||
| </div> | ||||
|  | ||||
| @ -16,10 +16,6 @@ | ||||
| <h4>FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _FATFS { | ||||
|     BYTE    fs_type;        /* FAT type (0:Not mouted) */ | ||||
|     BYTE    sects_clust;    /* Sectors per cluster */ | ||||
|     BYTE    n_fats;         /* Number of FAT copies */ | ||||
|     BYTE    drive;          /* Physical drive number */ | ||||
|     WORD    id;             /* File system mount ID */ | ||||
|     WORD    n_rootdir;      /* Number of root directory entries */ | ||||
|     DWORD   winsect;        /* Current sector appearing in the win[] */ | ||||
| @ -29,7 +25,12 @@ typedef struct _FATFS { | ||||
|     DWORD   dirbase;        /* Root directory start sector (cluster# for FAT32) */ | ||||
|     DWORD   database;       /* Data start sector */ | ||||
|     DWORD   last_clust;     /* Last allocated cluster */ | ||||
|     BYTE    fs_type;        /* FAT type (0:Not mounted) */ | ||||
|     BYTE    sects_clust;    /* Sectors per cluster */ | ||||
|     BYTE    n_fats;         /* Number of FAT copies */ | ||||
|     BYTE    drive;          /* Physical drive number */ | ||||
|     BYTE    winflag;        /* win[] dirty flag (1:must be written back) */ | ||||
|     BYTE    pad1; | ||||
|     BYTE    win[512];       /* Disk access window for Directory/FAT */ | ||||
| } FATFS; | ||||
| </pre> | ||||
| @ -37,10 +38,6 @@ typedef struct _FATFS { | ||||
| <h4>Tiny-FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _FATFS { | ||||
|     BYTE    fs_type;        /* FAT type (0:Not mouted) */ | ||||
|     BYTE    sects_clust;    /* Sectors per cluster */ | ||||
|     BYTE    n_fats;         /* Number of FAT copies */ | ||||
|     BYTE    winflag;        /* win[] dirty flag (1:must be written back) */ | ||||
|     WORD    id;             /* File system mount ID */ | ||||
|     WORD    n_rootdir;      /* Number of root directory entries */ | ||||
|     DWORD   winsect;        /* Current sector appearing in the win[] */ | ||||
| @ -50,6 +47,10 @@ typedef struct _FATFS { | ||||
|     CLUST   sects_fat;      /* Sectors per fat */ | ||||
|     CLUST   max_clust;      /* Maximum cluster# + 1 */ | ||||
|     CLUST   last_clust;     /* Last allocated cluster */ | ||||
|     BYTE    fs_type;        /* FAT type (0:Not mounted) */ | ||||
|     BYTE    sects_clust;    /* Sectors per cluster */ | ||||
|     BYTE    n_fats;         /* Number of FAT copies */ | ||||
|     BYTE    winflag;        /* win[] dirty flag (1:must be written back) */ | ||||
|     BYTE    win[512];       /* Disk access window for Directory/FAT/File */ | ||||
| } FATFS; | ||||
| </pre> | ||||
|  | ||||
| @ -17,6 +17,9 @@ | ||||
| <h4>FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _FIL { | ||||
|     WORD    id;             /* Owner file system mount ID (inverted) */ | ||||
|     BYTE    flag;           /* File status flags */ | ||||
|     BYTE    sect_clust;     /* Left sectors in cluster */ | ||||
|     FATFS*  fs;             /* Pointer to the owner file system object */ | ||||
|     DWORD   fptr;           /* File R/W pointer */ | ||||
|     DWORD   fsize;          /* File size */ | ||||
| @ -25,9 +28,6 @@ typedef struct _FIL { | ||||
|     DWORD   curr_sect;      /* Current sector */ | ||||
|     DWORD   dir_sect;       /* Sector containing the directory entry */ | ||||
|     BYTE*   dir_ptr;        /* Ponter to the directory entry in the window */ | ||||
|     WORD    id;             /* Sum of owner file system mount ID */ | ||||
|     BYTE    flag;           /* File status flags */ | ||||
|     BYTE    sect_clust;     /* Left sectors in cluster */ | ||||
|     BYTE    buffer[512];    /* File R/W buffer */ | ||||
| } FIL; | ||||
| </pre> | ||||
| @ -35,6 +35,9 @@ typedef struct _FIL { | ||||
| <h4>Tiny-FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _FIL { | ||||
|     WORD    id;             /* Owner file system mount ID (inverted) */ | ||||
|     BYTE    flag;           /* File status flags */ | ||||
|     BYTE    sect_clust;     /* Left sectors in cluster */ | ||||
|     FATFS*  fs;             /* Pointer to owner file system */ | ||||
|     DWORD   fptr;           /* File R/W pointer */ | ||||
|     DWORD   fsize;          /* File size */ | ||||
| @ -43,9 +46,6 @@ typedef struct _FIL { | ||||
|     DWORD   curr_sect;      /* Current sector */ | ||||
|     DWORD   dir_sect;       /* Sector containing the directory entry */ | ||||
|     BYTE*   dir_ptr;        /* Ponter to the directory entry in the window */ | ||||
|     WORD    id;             /* Sum of owner file system mount ID */ | ||||
|     BYTE    flag;           /* File status flags */ | ||||
|     BYTE    sect_clust;     /* Left sectors in cluster */ | ||||
| } FIL; | ||||
| </pre> | ||||
| </div> | ||||
|  | ||||
| @ -25,7 +25,7 @@ FRESULT f_stat ( | ||||
| <h4>Parameters</h4> | ||||
| <dl class="par"> | ||||
| <dt>FileName</dt> | ||||
| <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">file or directory</a> to get its information. Do not specify root directory.</dd> | ||||
| <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">file or directory</a> to get its information.</dd> | ||||
| <dt>FileInfo</dt> | ||||
| <dd>Pointer to the blank <tt>FILINFO</tt> structure to store the information.</dd> | ||||
| </dl> | ||||
| @ -48,7 +48,7 @@ FRESULT f_stat ( | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -35,7 +35,7 @@ FRESULT f_sync ( | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>The function succeeded.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error has occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
|  | ||||
| @ -49,7 +49,7 @@ FRESULT f_unlink ( | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>The medium is write protected.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error occured in low level disk I/O.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>The logical drive has no work area.</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -46,7 +46,7 @@ FRESULT f_write ( | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>The function denied due to the file has been opened in read only mode.</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>Any error has occured in low level disk I/O layer.</dd> | ||||
| <dd>The function failed due to a disk error or an internal error.</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								doc/img/f1.png
									
									
									
									
									
								
							
							
						
						| Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB | 
							
								
								
									
										
											BIN
										
									
								
								doc/img/f2.png
									
									
									
									
									
								
							
							
						
						| Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB | 
							
								
								
									
										
											BIN
										
									
								
								doc/img/f3.png
									
									
									
									
									
								
							
							
						
						| Before Width: | Height: | Size: 1017 B After Width: | Height: | Size: 1.0 KiB | 
							
								
								
									
										
											BIN
										
									
								
								doc/img/f4.png
									
									
									
									
									
								
							
							
						
						| Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB | 
							
								
								
									
										
											BIN
										
									
								
								doc/img/f5.png
									
									
									
									
									
								
							
							
						
						| Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.4 KiB | 
| @ -9,7 +9,7 @@ | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| <h1>FatFsモジュール アプリケーション・ノート (for R0.04)</h1> | ||||
| <h1>FatFsモジュール アプリケーション・ノート</h1> | ||||
| <hr> | ||||
| 
 | ||||
| <div class="para"> | ||||
| @ -19,14 +19,35 @@ | ||||
| <li>処理系はANSI C準拠であること。<br> | ||||
| FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠のコンパイラなら特に処理系依存な点はありません。ただし、FATというシステム間でポータブルな構造体を操作するため、プロセッサのエンディアンの違いは意識する必要があります。これは ff.h(tff.h) で定義されているので、最初にこれを適切に設定します(忘れている場合はエラーを出す)。</li> | ||||
| <li>char/short/long のサイズは、それぞれ  8/16/32ビットであること。<br> | ||||
| 整数の型とサイズに関してはまっとうなコンパイラなら問題ないと思います。integer.h内の typedefと既存の定義が衝突した場合は矛盾がないように注意しなければなりません。</li> | ||||
| integer.h内でtypedefされています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合は矛盾がないように注意しなければなりません。</li> | ||||
| </ul> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>メモリ使用量 (R0.04a)</h3> | ||||
| <p>各種環境でのモジュールのメモリ使用量の例を示します。数値の単位はバイトで、Dは論理ドライブ数、Fは同時オープン・ファイル数を示します。最適化オプションは、全てコード・サイズとしています。</p> | ||||
| <table class="lst2"> | ||||
| <tr><th></th><th>AVR</th><th>H8/300H</th><th>MSP430</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th></tr> | ||||
| <tr><td>コンパイラ</td><td>gcc</td><td>CH38</td><td>CL430</td><td>CC870C</td><td>CA850</td><td>SHC</td></tr> | ||||
| <tr><td>_MCU_ENDIAN</td><td>1</td><td>2</td><td>2</td><td>1</td><td>1</td><td>2</td></tr> | ||||
| <tr><td>FatFs コード<br>(標準, R/W構成)</td><td>8672</td><td>8746</td><td></td><td></td><td>6384</td><td>7390</td></tr> | ||||
| <tr><td>FatFs コード<br>(標準, R/O構成)</td><td>4232</td><td>4100</td><td></td><td></td><td>3012</td><td>3510</td></tr> | ||||
| <tr><td>FatFs コード<br>(最小, R/W構成)</td><td>5706</td><td>5678</td><td></td><td></td><td>4042</td><td>4882</td></tr> | ||||
| <tr><td>FatFs コード<br>(最小, R/O構成)</td><td>3018</td><td>3116</td><td></td><td></td><td>2198</td><td>2702</td></tr> | ||||
| <tr><td>FatFs 静的ワーク</td><td>D*2 + 2</td><td>D*4 + 2</td><td></td><td></td><td>D*4 + 2</td><td>D*4 + 2</td></tr> | ||||
| <tr><td>FatFs 動的ワーク</td><td>D*550 + F*544</td><td>D*550 + F*550</td><td></td><td></td><td>D*550 + F*550</td><td>D*550 + F*550</td></tr> | ||||
| <tr><td>Tiny-FatFs コード<br>(標準, R/W構成)</td><td>7188</td><td>7206</td><td>6590</td><td>8799</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs コード<br>(標準, R/O構成)</td><td>3592</td><td>3560</td><td>3162</td><td>4353</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs コード<br>(最小, R/W構成)</td><td>4670</td><td>4772</td><td>4322</td><td>6073</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs コード<br>(最小, R/O構成)</td><td>2576</td><td>2714</td><td>2378</td><td>3324</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs 静的ワーク</td><td>4</td><td>6</td><td>4</td><td>4</td><td></td><td></td></tr> | ||||
| <tr><td>Tiny-FatFs 動的ワーク</td><td>542 + F*28</td><td>542 + F*32</td><td>542 + F*28</td><td>542 + F*28</td><td></td><td></td></tr> | ||||
| </table> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>FatFs vs. Tiny-FatFs</h3> | ||||
| <p>ポータブル・オーディオやデータ・ロガーなど、よくある用途ではTiny-FatFsで十分です。しかし、Tiny-FatFsはデフォルトではFAT32に対応していないので、使用できるディスクは2GB(FAT64で4GB)までという制約があります。<tt>_USE_FAT32</tt>オプションでFAT32がサポートされますが、コード・サイズが膨らみます。</p> | ||||
| <p>フル機能のFatFsは、複数ファイルを高速アクセスする場合や、複数ドライブの対応が必要な場合に有効です。</p> | ||||
| <p>ポータブル・オーディオやデータ・ロガーなど、よくある用途ではTiny-FatFsで十分です。しかし、Tiny-FatFsは標準構成ではFAT32に対応していないので、使用できるディスクは2GB(FAT64で4GB)までという制約があります。<tt>_USE_FAT32</tt>オプションでFAT32を追加できますが、その分コード・サイズが膨らみます。フル機能のFatFsは、複数ファイルを高速アクセスする場合や、複数ドライブの対応が必要な場合に有効です。</p> | ||||
| <div class="rset"> | ||||
| <table class="lst2"> | ||||
| <tr><th>メモリ容量</th><th>FATタイプ</th></tr> | ||||
| @ -55,33 +76,31 @@ FatFs | ||||
| <br class="clr"> | ||||
| <p>ここでファイルI/Oバッファとは、データ・セクタの一部を読み書きするための1セクタ長のバッファで、FatFsではそのファイル・オブジェクト内の、Tiny-FatFsではワークエリア内のバッファのことを指しています。</p> | ||||
| <p>Tiny-FatFsでは、全てのデータ転送とFATやディレクトリへのアクセスをただ一つのセクタ・バッファで行っているため、データ転送によりFATのキャッシュが失われ、クラスタ境界を通過するたびにFATセクタを読み直す必要があります。FatFsの場合は、データ用バッファはFAT用とは別なので、FATセクタを読む頻度はTiny-FatFsの 1/341, 1/256 または 1/128で済みます(クラスタが連続している場合)。つまり、Tiny-FatFsは性能低下の代償を払ってRAM使用量を削減しているわけです。</p> | ||||
| <p>転送領域のうちセクタ全体を含む部分は(図2)のようにファイルI/Oバッファを介さず、ディスクとの間で直接転送されます。完全なセクタ・アライメント・アクセスの場合(図3)は、ファイルI/Oバッファは全く使用されません。直接転送では、可能ならdisk_read()に複数セクタを指定して最大限のマルチ・セクタ転送が行われます。ただし、クラスタ境界をまたぐときは、たとえセクタが連続していたとしても転送は分割されます。</p> | ||||
| <p>このように、極力セクタ・アライメント・アクセスになるように配慮すれば、無駄なデータ転送が減って性能が向上します。さらに、Tiny-FatFsではFATのキャッシュが生きるようになり、FatFsと同じ性能と省メモリ特性が同時に得られます。</p> | ||||
| <p>転送領域のうちセクタ全体を含む部分は(図2)のようにファイルI/Oバッファを介さず、ディスクとの間で直接転送されます。完全なセクタ・アライメント・アクセスの場合(図3)は、ファイルI/Oバッファは全く使用されません。直接転送では、可能ならdisk_read()に複数セクタを指定して最大限のマルチ・セクタ転送が行われます。ただし、クラスタ境界をまたぐときはクラスタが隣接していたとしても転送は分割されます。</p> | ||||
| <p>このように、極力セクタ・アライメント・アクセスになるように配慮すれば、無駄なメモリ・コピーが減って性能が向上します。さらに、Tiny-FatFsではFATのキャッシュが生きるようになり、省メモリ特性とFatFsの性能とが同時に得られます。</p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h3>クリチカル・セクション</h3> | ||||
| <p>ディスク上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータエラー等の障害が発生すると、更新が中途半端な状態で中断され、その結果としてFAT構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル・セクションと、その間の障害により起きうるエラーの状態を示します。</p> | ||||
| <p>ディスク上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータ・エラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFAT構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル・セクションと、その間の障害により起きうるエラーの状態を示します。</p> | ||||
| <div class="lset"> | ||||
| 図4. 長いクリチカル・セクション<br> | ||||
| <img src="../img/f4.png" width="320" height="470" alt="fig.4"> | ||||
| <img src="../img/f4.png" width="320" height="436" alt="fig.4"> | ||||
| </div> | ||||
| <div class="lset"> | ||||
| 図5. 短くしたクリチカル・セクション<br> | ||||
| <img src="../img/f5.png" width="320" height="470" alt="fig.5"> | ||||
| <img src="../img/f5.png" width="320" height="436" alt="fig.5"> | ||||
| </div> | ||||
| <br class="clr"> | ||||
| <p>赤で示したセクションを実行中に障害が発生した場合、クロスリンクが発生して操作対象のファイル・ディレクトリが失われる可能性があります。黄色で示したセクションを実行中に障害が発生した場合、つぎのうちいずれかまたは複数の結果が生じる可能性が考えられます。</p> | ||||
| <p>赤で示したセクションを実行中に障害が発生した場合、クロス・リンクが発生して操作対象のファイル・ディレクトリが失われる可能性があります。黄色で示したセクションを実行中に障害が発生した場合、つぎのうちいずれかまたは複数の結果が生じる可能性があります。</p> | ||||
| <ul> | ||||
| <li>書き換え中のファイルのデータ構造が破壊される。</li> | ||||
| <li>書き換え中のファイルの内容が破壊される。</li> | ||||
| <li>追記中のファイルがオープン前の状態に戻る。</li> | ||||
| <li>新規に作成されたファイルが消える。</li> | ||||
| <li>新規に作成されたファイルの長さがゼロになって残る。</li> | ||||
| <li>上書きで作成されたファイルの長さがゼロになって残る。</li> | ||||
| <li>上書きで作成されたファイルが作成前の状態に戻る。</li> | ||||
| <li>新規または上書きで作成されたファイルの長さがゼロになって残る。</li> | ||||
| <li>ロストチェーンの発生によりディスクの利用効率が悪化する。</li> | ||||
| </ul> | ||||
| <p>いずれも書き込み中でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のように最小化することができます。</p> | ||||
| <p>いずれも書き込み中や操作対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のようにリスクを最小化することができます。</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -89,18 +108,18 @@ FatFs | ||||
| <h3>現リビジョンの問題点とその改善案</h3> | ||||
| <ul> | ||||
| <li>ファイル・オブジェクトの抽象化<br> | ||||
| 現在はファイル・オブジェクトの実体をアプリケーション側で管理しているので、アプリケーション・モジュールでのスタック消費量が多くなります(Tiny-FatFsでは問題にはならない)。これをハンドルで管理するなどより抽象化すればアプリケーション・モジュールでのスタック消費量を減らせます。この場合、FatFs内でファイル・オブジェクトの領域を静的に確保しておくか、malloc()することになります。ただし、このようにするとファイル・オブジェクトを直接参照できなくなり、feofやftellなどムダな関数が新たに必要になります。</li> | ||||
| 現在はファイル・オブジェクトの実体をアプリケーション側で管理しているので、アプリケーション・モジュールでのスタック消費量が多くなります(Tiny-FatFsでは問題にならない)。これをハンドルで管理するなどより抽象化すればアプリケーション・モジュールでのスタック消費量を減らせるし、他のファイル・システムへの対応も容易になります。この場合、FatFs内でファイル・オブジェクトの領域を静的に確保しておくか、malloc()することになります。ただし、このようにするとファイル・オブジェクトを直接参照できなくなり、feofやftellなどムダな関数が新たに必要になります。</li> | ||||
| <li>セクタ・バッファ管理の改善<br> | ||||
| 現在はセクタ・バッファを固定して使用しているため、無駄なディスクアクセスが多く効率が悪い。メモリの潤沢なシステムでは、複数のセクタ・バッファを使用してディスク・キャッシュを構成すれば性能を向上させることができます。</li> | ||||
| <li>FSInfoへの対応<br> | ||||
| FAT32ではその膨大なクラスタ数のため、ファイル新規作成や空きスペース取得時のクラスタ・サーチにかなりの時間を要します。このため、最終割り当てクラスタ番号や残りクラスタ数がFSInfoセクタに記録されていて、延々とクラスタ・サーチするのを避けられるようになっています。現在はFSInfoに未対応なので、空きスペース取得時や、ディスク使用量が多い状態でのファイル作成(作成後の最初の書き込み)処理時間は問題になるレベルです。</li> | ||||
| <li>長いファイル名への対応<br> | ||||
| FATの拡張仕様では従来の8.3形式ファイル名に加え、255文字までの長いファイル名を扱えるようになっていますが、現リビジョンでは未対応で8.3形式しか使用できません。これに対応するには、ファイル名だけでも500バイト以上のバッファが必要になったり、UCS-2とShift_JISの相互変換(巨大な変換テーブル)が必要となるなど、メモリの消費が爆発的に増えてしまいます。なお、長いファイル名の機能はMicrosoft社の特許になっているため、これを製品に使うにはライセンス契約が必要です。</li> | ||||
| FATの拡張仕様ではMS-DOSの8.3形式ファイル名に加え、255文字までの長いファイル名(LFN)を扱えるようになっていますが、現リビジョンでは未対応で8.3形式しか使用できません。これに対応するには、ファイル名だけでも500バイト以上のバッファが必要になったり、UCS-2とShift_JISの相互変換(巨大な変換テーブルを使う)が必要となるなど、メモリの消費が爆発的に増えてしまいます。なお、LFNの機能はMicrosoft社の特許になっているため、これを製品に使うにはライセンス契約が必要です。</li> | ||||
| <li>RTOSへの対応<br> | ||||
| FatFsモジュールを使用するタスクを一つに限るなら特に意識する必要はありませんが、複数のタスクから使用するには、何らかの排他制御が必要になってきます。FatFsモジュールのRTOSへの対応作業は、<a href="http://www.toppers.jp/">TOPPERSプロジェクト</a>で行われています。</li> | ||||
| FatFsモジュールを使用するタスクを一つに限るなら特に意識する必要はありませんが、同じ論理ドライブに複数のタスクから同時アクセスするには、何らかの排他制御が必要になってきます。FatFsモジュールのRTOSへの対応作業は、<a href="http://www.toppers.jp/">TOPPERSプロジェクト</a>で行われています。</li> | ||||
| </ul> | ||||
| <br> | ||||
| <p>そして、これらの機能拡張を行うとそれだけ多くのリソースが要求されるようになり、このプロジェクトが対象としている8/16ビット・マイコンのシステムに載せられなくなってしまうという問題もあります(これが一番の問題かも知れません)。</p> | ||||
| <p>そして、これらの機能拡張を行うとそれだけ多くのリソースが要求されるようになり、このプロジェクトの対象とする8/16ビット・マイコンのシステムに載せられなくなってしまうという問題もあります(これが一番の問題かも知れません)。</p> | ||||
| </div> | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_j.html">戻る</a></p> | ||||
|  | ||||
| @ -38,7 +38,7 @@ FRESULT f_chmod ( | ||||
| </table> | ||||
| </dd> | ||||
| <dt>AttributeMask</dt> | ||||
| <dd>変更する属性のマスク。指定した属性が設定または解除され、指定されなかった属性は保持されます。<tt>Attribute</tt>と同じ値を使います。</dd> | ||||
| <dd>変更する属性のマスク。指定した属性が設定または解除され、指定されなかった属性は状態が保持されます。<tt>Attribute</tt>と同じ値を使います。</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| @ -61,7 +61,7 @@ FRESULT f_chmod ( | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>メディアが書き込み禁止状態。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスクアクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>その論理ドライブにワーク・エリアが与えられていない。</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -35,7 +35,7 @@ FRESULT f_close ( | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>正常終了。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
|  | ||||
							
								
								
									
										64
									
								
								doc/ja/dioctl.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,64 @@ | ||||
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||||
| <html lang="ja"> | ||||
| <head> | ||||
| <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> | ||||
| <meta http-equiv="Content-Style-Type" content="text/css"> | ||||
| <link rel="up" title="FatFs" href="../00index_j.html"> | ||||
| <link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default"> | ||||
| <title>FatFs - disk_ioctl</title> | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h2>disk_ioctl</h2> | ||||
| <p>セクタの読み書き以外のディスク・ドライブ自体に対する様々な制御をします。</p> | ||||
| <pre> | ||||
| DRESULT disk_ioctl ( | ||||
|   BYTE <em>Drive</em>,      /* 物理ドライブ番号 */ | ||||
|   BYTE <em>Command</em>,    /* 制御コマンド */ | ||||
|   void* <em>Buffer</em>     /* データ受け渡しバッファ */ | ||||
| ); | ||||
| </pre> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>引数</h4> | ||||
| <dl class="par"> | ||||
| <dt>Drive</dt> | ||||
| <dd>物理ドライブ番号(0-9)を指定します。</dd> | ||||
| <dt>Command</dt> | ||||
| <dd>制御コマンド・コードを指定します。</dd> | ||||
| <dt>Buffer</dt> | ||||
| <dd>制御コマンドに依存したパラメータを授受するバッファを指すポインタを指定します。バッファを使用しないコマンドの場合は、NULLを指定します。</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>戻り値</h4> | ||||
| <dl class="ret"> | ||||
| <dt>RES_OK (0)</dt> | ||||
| <dd>正常終了。</dd> | ||||
| <dt>RES_ERROR</dt> | ||||
| <dd>何らかのエラーが発生した。</dd> | ||||
| <dt>RES_PARERR</dt> | ||||
| <dd>コマンドが不正。</dd> | ||||
| <dt>RES_NOTRDY</dt> | ||||
| <dd>ドライブが動作可能状態ではない、または初期化されていない。</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>解説</h4> | ||||
| <p>物理ドライブの種類によりサポートされるコマンドは異なりますが、FatFsモジュールでは、ドライブの種類に依存した制御は行いません。次のドライブ共通コマンドを使用します。リード・オンリー構成ではこの関数は必要とされません。</p> | ||||
| <table class="lst"> | ||||
| <tr><th>コマンド</th><th>解説</td></tr> | ||||
| <tr><td>GET_SECTOR_COUNT</td><td>Bufferの指すDWORD変数にドライブ上の総セクタ数を返します。</td></tr> | ||||
| <tr><td>CTRL_SYNC</td><td>ディスクへのデータの書き込みが完了するのを待ちます。ライト・バック・キャッシュを持っている場合は、書き込まれていないデータを即時書き戻します。</td></tr> | ||||
| </table> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_j.html">戻る</a></p> | ||||
| </body> | ||||
| </html> | ||||
| @ -41,7 +41,7 @@ DRESULT disk_read ( | ||||
| <div class="para"> | ||||
| <h4>戻り値</h4> | ||||
| <dl class="ret"> | ||||
| <dt>RES_OK</dt> | ||||
| <dt>RES_OK (0)</dt> | ||||
| <dd>正常終了。</dd> | ||||
| <dt>RES_ERROR</dt> | ||||
| <dd>読み込み中にエラーが発生した。</dd> | ||||
|  | ||||
| @ -34,11 +34,11 @@ DSTATUS disk_status ( | ||||
| <p>物理ドライブの状態が次のフラグの組み合わせの値で返されます。</p> | ||||
| <dl class="ret"> | ||||
| <dt>STA_NOINIT</dt> | ||||
| <dd>ドライブが初期化されていないことを示すフラグ。電源ONまたはメディアの取り外しでセットされ、disk_initialize() の正常終了でクリア、失敗でセットされます。</dd> | ||||
| <dd>ドライブが初期化されていないことを示すフラグ。システム・リセットやメディアの取り外し等でセットされ、disk_initialize() の正常終了でクリア、失敗でセットされます。</dd> | ||||
| <dt>STA_NODISK</dt> | ||||
| <dd>メディアがセットされていないことを示すフラグ。メディアが取り外されている間はセットされ、メディアがセットされている間はクリアされます。固定ディスクでは常にクリアされています。</dd> | ||||
| <dt>STA_PROTECTED</dt> | ||||
| <dd>メディアがライト・プロテクトされていることを示すフラグ。ライト・プロテクト・ノッチをサポートしないメディアでは常にクリアされています。</dd> | ||||
| <dd>メディアがライト・プロテクトされていることを示すフラグ。ライト・プロテクト機能をサポートしないメディアでは常にクリアされています。</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
|  | ||||
| @ -27,7 +27,7 @@ DRESULT disk_write ( | ||||
| <h4>引数</h4> | ||||
| <dl class="par"> | ||||
| <dt>Drive</dt> | ||||
| <dd>書き込むドライブ番号を指定します。</dd> | ||||
| <dd>物理ドライブ番号(0-9)を指定します。</dd> | ||||
| <dt>Buffer</dt> | ||||
| <dd>ディスクに書き込むデータを指定します。</dd> | ||||
| <dt>SectorNumber</dt> | ||||
| @ -41,7 +41,7 @@ DRESULT disk_write ( | ||||
| <div class="para"> | ||||
| <h4>戻り値</h4> | ||||
| <dl class="ret"> | ||||
| <dt>RES_OK</dt> | ||||
| <dt>RES_OK (0)</dt> | ||||
| <dd>正常終了。</dd> | ||||
| <dt>RES_ERROR</dt> | ||||
| <dd>書き込み中にエラーが発生した。</dd> | ||||
|  | ||||
| @ -9,27 +9,47 @@ | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| <h2>ファイル・ディレクトリの指定方法</h2> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h2>ファイル・ディレクトリの指定方法</h2> | ||||
| <p>FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はMS-DOSとほぼ同じです。ただし、MS-DOSのようなカレント・ディレクトリの概念は無いので、常にルート・ディレクトリから辿る絶対パスでの指定となります。パス名の指定方法と例は次の通りです。</p> | ||||
| <pre> | ||||
| 
 | ||||
|  "[<em>論理ドライブ番号</em>:][/]<em>ディレクトリ名</em>/<em>ファイル名</em>" | ||||
| 
 | ||||
|  "file1.txt"           ファイル(drive0) | ||||
|  "file1.txt"           ファイル(ドライブ0) | ||||
|  "/file1.txt"          ↑と同じ | ||||
|  "dir1/dir2/file1.txt" ファイル(drive0) | ||||
|  "2:dir3/file2.txt"    ファイル(drive2) | ||||
|  "2:/dir5"             ディレクトリ(drive2) | ||||
|  ""                    ルート・ディレクトリ(drive2) | ||||
|  "dir1/dir2/file1.txt" ファイル(ドライブ0) | ||||
|  "2:dir3/file2.txt"    ファイル(ドライブ2) | ||||
|  "2:/dir5"             ディレクトリ(ドライブ2) | ||||
|  ""                    ルート・ディレクトリ(ドライブ0) | ||||
|  "/"                   ↑と同じ | ||||
|  "2:"                  ルート・ディレクトリ(drive2) | ||||
|  "2:"                  ルート・ディレクトリ(ドライブ2) | ||||
| 
 | ||||
| </pre> | ||||
| <p>FatFsモジュールは8.3形式ファイル名にのみ対応しています。長いファイル名には対応していないので、ファイル名やディレクトリ名は8.3形式の範囲内で指定します。ディレクトリ・セパレータには'/'を使用します。パス名先頭の'/'は、あってもなくても同じです。</p> | ||||
| <p>論理ドライブ番号は、'0'~'9'の一文字の数字とコロンで指定します。省略した場合は"0:"を指定したことになります。FatFsでは論理ドライブ毎にファイル・システム・オブジェクトというワーク・エリアを持っています。現在のところ、論理ドライブは同じ番号の物理ドライブに結びつけられています。</p> | ||||
| <p>Tiny-FatFsでは一つのファイル・システム・オブジェクトしか持てず、常に論理ドライブ0として動作します。また、パス名中に論理ドライブ番号を使用できません。</p> | ||||
| <p>FatFsモジュールは8.3形式ファイル名にのみ対応しています。長いファイル名には対応していないので、ファイル名やディレクトリ名は8.3形式の範囲内で指定します。ディレクトリ・セパレータには'/'を使用します。パス名先頭の'/'は、あってもなくても同じです。論理ドライブ番号は、'0'~'9'の一文字の数字とコロンで指定します。省略した場合は"0:"を指定したことになります。Tiny-FatFsでは一つのファイル・システム・オブジェクトしか持てず、常に論理ドライブ0として動作します。また、パス名中に論理ドライブ番号を使用できません。</p> | ||||
| </div> | ||||
| <p><br></p> | ||||
| <div class="para"> | ||||
| <h2>論理ドライブと物理ドライブの対応</h2> | ||||
| <p>標準構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、先頭の区画がマウントされます。構成オプションで<tt>_MULTI_PARTITION</tt>を指定すると、論理ドライブに対して個別に物理ドライブ番号・区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p> | ||||
| <pre> | ||||
| 例:論理ドライブ0~2を物理ドライブ0(固定ディスク)の3つの基本区画に割り当て、 | ||||
|    論理ドライブ3を物理ドライブ1(リムーバブル・ディスク)に割り当てる場合。 | ||||
| 
 | ||||
| const PARTITION Drives[] = { | ||||
|     {0, 0},     /* Logical drive 0 ==> Physical drive 0, 1st partition */ | ||||
|     {0, 1},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */ | ||||
|     {0, 2},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */ | ||||
|     {1, 0}      /* Logical drive 3 ==> Physical drive 1 */ | ||||
| }; | ||||
| </pre> | ||||
| <p>複数区画指定を使用する場合、次の点に注意しなければなりません。 | ||||
| <ul> | ||||
| <li>指定可能な区画は基本区画(0~3)のみ。</li> | ||||
| <li>物理ドライブがSFD形式(区画テーブル無し)の場合、区画指定は無視される。</li> | ||||
| <li>複数の論理ドライブを持つ物理ドライブは、固定ディスクでなければならない。</li> | ||||
| </li> | ||||
| 
 | ||||
| </div> | ||||
| 
 | ||||
| </body> | ||||
|  | ||||
| @ -28,7 +28,7 @@ FRESULT f_getfree ( | ||||
| <dt>Path</dt> | ||||
| <dd>情報を得る論理ドライブのルートディレクトリの<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd> | ||||
| <dt>Clusters</dt> | ||||
| <dd>空きクラスタ数を格納するDWORD変数へのポインタを指定します。</dd> | ||||
| <dd>空きクラスタ数を格納する<tt>DWORD</tt>変数へのポインタを指定します。</dd> | ||||
| <dt>FileSystemObject</dt> | ||||
| <dd>対象ドライブのファイル・システム・オブジェクトを指すポインタを格納するポインタへのポインタを指定します。</dd> | ||||
| </dl> | ||||
| @ -39,13 +39,13 @@ FRESULT f_getfree ( | ||||
| <h4>戻り値</h4> | ||||
| <dl class="ret"> | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>正常終了。<tt><em>*Clusters</em></tt>に空きクラスタ数が返されます。</dd> | ||||
| <dd>正常終了。<tt>*Clusters</tt>に空きクラスタ数が返されます。</dd> | ||||
| <dt>FR_INVALID_DRIVE</dt> | ||||
| <dd>ドライブ番号が不正。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>その論理ドライブにワーク・エリアが与えられていない。</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
| @ -74,7 +74,7 @@ FRESULT f_getfree ( | ||||
|     // Get free space | ||||
|     printf("%lu KB total disk space.\n" | ||||
|            "%lu KB available on the disk.\n", | ||||
|            (fs->max_clust - 2) * fs->sects_clust / 2, | ||||
|            (DWORD)(fs->max_clust - 2) * fs->sects_clust / 2, | ||||
|            clust * fs->sects_clust / 2); | ||||
| </pre> | ||||
| </div> | ||||
|  | ||||
| @ -38,31 +38,37 @@ FRESULT f_lseek ( | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>正常終了。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
| <dd>無効なファイルオブジェクト。</dd> | ||||
| <dd>無効なファイル・オブジェクト。</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>解説</h4> | ||||
| <p>ファイルR/Wポインタを移動します。オフセットの指定はファイル先頭からのみです。ファイル末尾以降への移動はできません。ファイル・サイズ以上のオフセットを指定した場合、R/Wポインタはファイル・サイズと同じになります。</p> | ||||
| <p>ファイルR/Wポインタ(ファイル・オブジェクト内のfptrメンバで、次に読み出し・書き込みされるバイトのオフセットを示す)を移動します。オフセットの原点はファイル先頭からです。書き込みモードでファイル・サイズより大きな値を指定すると、そこまでファイルが拡張され、拡張された部分のデータは未定義となります。大容量データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイルを拡張しておくと良いです。f_lseek関数が正常終了したあとは、ファイルR/Wポインタが正しく移動したかfptrをチェックするべきです。ファイルR/Wポインタが指定より小さいときは、次の原因が考えられます。</p> | ||||
| <ul> | ||||
| <li>非書き込みモードのため、ファイル・サイズでクリップされた。</li> | ||||
| <li>ファイル拡張中にディスクが満杯になった。</li> | ||||
| <li>FAT構造にエラーがある。</li> | ||||
| </ul> | ||||
| <p>_FS_MINIMIZE >= 3ではこの関数はサポートされません。</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>使用例</h4> | ||||
| <pre> | ||||
|     // ファイル先頭から5000バイト目へ移動 | ||||
|     // ファイル・オフセット5000へ移動 | ||||
|     res = f_lseek(&file, 5000); | ||||
| 
 | ||||
|     // 3000バイト進める | ||||
|     res = f_lseek(&file, file.fptr + 3000); | ||||
| 
 | ||||
|     // 2000バイト戻す | ||||
|     // 2000バイト戻す(オーバーフローに注意) | ||||
|     res = f_lseek(&file, file.fptr - 2000); | ||||
| 
 | ||||
|     // ファイル追記の準備 | ||||
|  | ||||
| @ -41,13 +41,15 @@ FRESULT f_mkdir ( | ||||
| <dt>FR_INVALID_DRIVE</dt> | ||||
| <dd>ドライブ番号が不正。</dd> | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>同名のディレクトリやファイルの存在、ディスクやディレクトリ・エントリが満杯の場合など。</dd> | ||||
| <dd>ディスクやディレクトリ・エントリが満杯の場合など。</dd> | ||||
| <dt>FR_EXIST</dt> | ||||
| <dd>同名のディレクトリやファイルが存在する。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>メディアが書き込み禁止状態。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>その論理ドライブにワーク・エリアが与えられていない。</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -15,9 +15,9 @@ | ||||
| <p>ドライブ上にFATファイル・システムを作成(フォーマット)します。</p> | ||||
| <pre> | ||||
| FRESULT f_mkfs ( | ||||
|   BYTE  <em>Drive</em>,            /* Logical drive number */ | ||||
|   BYTE  <em>PartitioningRule</em>, /* Partitioning rule */ | ||||
|   BYTE  <em>AllocSize</em>         /* Allocation unit size */ | ||||
|   BYTE  <em>Drive</em>,              /* Logical drive number */ | ||||
|   BYTE  <em>PartitioningRule</em>,   /* Partitioning rule */ | ||||
|   BYTE  <em>AllocSize</em>           /* Allocation unit size */ | ||||
| ); | ||||
| </pre> | ||||
| </div> | ||||
| @ -45,14 +45,16 @@ FRESULT f_mkfs ( | ||||
| <dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd> | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>メディアが書き込み禁止状態。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>その論理ドライブにワーク・エリアが割り当てられていない。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_MKFS_ABORTED</dt> | ||||
| <dd>次の理由で処理が中断された。 | ||||
| <dd>次の理由で開始前に処理が中断された。 | ||||
| <ul> | ||||
| <li>ディスク・サイズが小さすぎる。</li> | ||||
| <li>何らかの引数が無効。</li> | ||||
| <li>そのクラスタ・サイズが使えない。クラスタ数が0xFF7と0xFFF7近辺になると発生する可能性がある。</li> | ||||
| <li>そのクラスタ・サイズが使えない。クラスタ数が0xFF7と0xFFF7近辺になるとき発生する可能性がある。</li> | ||||
| </ul> | ||||
| </dd> | ||||
| </dl> | ||||
| @ -60,8 +62,9 @@ FRESULT f_mkfs ( | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>説明</h4> | ||||
| <p>f_mkfs関数はFATファイル・システムをドライブ上に作成します。リムーバブル・メディアのパーテーショニング・ルールとしては、FDISK形式とSFD形式がありますが、多くの場合はFDISK形式が推奨されます。FATタイプ(FAT12/FAT16/FAT32)は、ディスク上のクラスタ数によってのみ決定される決まりになっていて、それ以外の要因はありません。したがって、どのFATタイプになるかは、ディスク・サイズとクラスタ・サイズに依存します。</p> | ||||
| <p>この関数は、FatFsで_USE_MKFSを選択したときにサポートされます。<p> | ||||
| <p>f_mkfs関数はFATファイル・システムをドライブ上に作成します。リムーバブル・メディアのパーテーショニング・ルールとしては、FDISK形式とSFD形式がありますが、FDISK形式が一般的です。この関数は<em>複数区画には対応していない</em>ので、その物理ドライブの既存の区画は全て削除され、全体が一つの区画になります。</p> | ||||
| <p>FATタイプ(FAT12/FAT16/FAT32)は、ディスク上の<em>クラスタ数によってのみ決定</em>される[FAT仕様書より]決まりになっていて、それ以外の要因はありません。したがって、どのFATタイプになるかは、ディスク・サイズとクラスタ・サイズに依存します。クラスタ・サイズは大きいほど性能が上がるので、特に小容量のドライブでなければ64セクタを選択しておけばよいです。</p> | ||||
| <p>この関数は、FatFsで構成オプション<tt>_USE_MKFS</tt>を選択したときにサポートされます。また、Tiny-FatFsではサポートされません。<p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -44,8 +44,8 @@ FRESULT f_mount ( | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>‰ð<EFBFBD>à</h4> | ||||
| <p>論理ドライブにそのワーク・エリアを登録したり抹消したりします。何らかのファイル関数を使用する前にこの関数でその論理ドライブのワーク・エリアを与えておかなければなりません。<em>FileSystemObject</em>にNULLポインタを指定するとその論理ドライブのワーク・エリアの登録は抹消され、登録されていたワーク・エリアは破棄できます。</p> | ||||
| <p>この関数内では物理ドライブへのアクセスは行われず、ワーク・エリアを初期化して内部配列にそのアドレスを登録するだけです。実際のマウント動作は他のファイル関数の中で必要に応じて行われます。</p> | ||||
| <p>FatFsモジュールではそれぞれの論理ドライブにファイル・システム・オブジェクトというワーク・エリアが必要です。この関数は論理ドライブにそのワーク・エリアを登録したり抹消したりします。何らかのファイル関数を使用する前にこの関数でその論理ドライブのワーク・エリアを与えておかなければなりません。<tt>FileSystemObject</tt>にヌル・ポインタを指定するとその論理ドライブのワーク・エリアの登録は抹消され、登録されていたワーク・エリアは破棄できます。</p> | ||||
| <p>この関数内では物理ドライブへのアクセスは発生せず、ワーク・エリアを初期化して内部配列にそのアドレスを登録するだけです。実際のマウント動作は、他のファイル関数(パス名を指定するもの)の中で必要に応じて行われます。</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -33,11 +33,12 @@ FRESULT f_open ( | ||||
| <dd>ファイルのアクセス方法やオープン方法を決めるフラグです。このパラメータには次の組み合わせを指定します。<br> | ||||
| <table class="lst"> | ||||
| <tr><th>値</th><th>意味</th></td> | ||||
| <tr><td>FA_READ</td><td>読み出しモードでオープンします。読み書きする場合は<tt>FA_WRITE</tt>と共に指定します。</td></tr> | ||||
| <tr><td>FA_WRITE</td><td>書き込みモードでオープンします。読み書きする場合は<tt>FA_READ</tt>と共に指定します。</td></tr> | ||||
| <tr><td>FA_READ</td><td>読み出しモードで開きます。読み書きする場合は<tt>FA_WRITE</tt>と共に指定します。</td></tr> | ||||
| <tr><td>FA_WRITE</td><td>書き込みモードで開きます。読み書きする場合は<tt>FA_READ</tt>と共に指定します。</td></tr> | ||||
| <tr><td>FA_OPEN_EXISTING</td><td>既存のファイルを開きます。ファイルが無いときはエラーになります。</td></tr> | ||||
| <tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。既存のファイルがある場合は、サイズを0にしてから開きます。</td></tr> | ||||
| <tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。</td></tr> | ||||
| <tr><td>FA_CREATE_NEW</td><td>ファイルを作成します。同名のファイルがある場合は、エラーになります。</td></tr> | ||||
| <tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。同名のファイルがある場合は、サイズを0にしてから開きます。</td></tr> | ||||
| </table> | ||||
| </dd> | ||||
| </dl> | ||||
| @ -48,7 +49,7 @@ FRESULT f_open ( | ||||
| <h4>戻り値</h4> | ||||
| <dl class="ret"> | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>正常終了。以降、<tt><em>FileObject</em></tt>構造体を使ってこのファイルを操作できます。</dd> | ||||
| <dd>正常終了。以降、<tt>FileObject</tt>構造体を使ってこのファイルを操作できます。</dd> | ||||
| <dt>FR_NO_FILE</dt> | ||||
| <dd>ファイルが見つからない。</dd> | ||||
| <dt>FR_NO_PATH</dt> | ||||
| @ -57,6 +58,8 @@ FRESULT f_open ( | ||||
| <dd>ファイル名が不正。</dd> | ||||
| <dt>FR_INVALID_DRIVE</dt> | ||||
| <dd>ドライブ番号が不正。</dd> | ||||
| <dt>FR_EXIST</dt> | ||||
| <dd>同名のファイルが既にある。</dd> | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>アクセスが拒否された。リード・オンリー・ファイルの書き込みモード・オープン、同名のディレクトリまたはリード・オンリー・ファイルがある状態でのファイル作成、ディスクまたはディレクトリ・テーブルが満杯でファイルを作成できないなど。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| @ -64,7 +67,7 @@ FRESULT f_open ( | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>メディアが書き込み禁止状態で書き込み系オープンをした。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>その論理ドライブにワーク・エリアが割り当てられていない。</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
| @ -77,7 +80,7 @@ FRESULT f_open ( | ||||
| <h4>解説</h4> | ||||
| <p>作成されたファイル・オブジェクトは、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html">f_close()</a>を使用します。</p> | ||||
| <p>ファイル操作関数を使用する前にまず、<a href="mount.html">f_mount()</a>を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与えなければなりません。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p> | ||||
| <p>リードオンリー構成では、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p> | ||||
| <p>リードオンリー構成では、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -48,7 +48,7 @@ FRESULT f_opendir ( | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>論理ドライブにワーク・エリアが与えられていない。</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
| @ -59,7 +59,7 @@ FRESULT f_opendir ( | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>解説</h4> | ||||
| <p>ディレクトリをオープンします。正常終了したら、<tt><em>DirObject</em></tt>構造体を使ってこのディレクトリの項目を順次読み出せます。<tt><em>DirObject</em></tt>構造体は使用後は任意の時点で破棄できます。<tt>_FS_MINIMIZE == 2</tt>ではこの関数はサポートされません。</p> | ||||
| <p>ディレクトリをオープンします。正常終了したら、<tt>DirObject</tt>構造体を使ってこのディレクトリの項目を順次読み出せます。<tt>DirObject</tt>構造体は使用後は任意の時点で破棄できます。<tt>_FS_MINIMIZE >= 2</tt>ではこの関数はサポートされません。</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -31,7 +31,7 @@ FRESULT f_read ( | ||||
| <dt>Buffer</dt> | ||||
| <dd>読み出したデータを格納するバッファを指すポインタを指定します。</dd> | ||||
| <dt>ByteToRead</dt> | ||||
| <dd>読み出すバイト数を指定します。</dd> | ||||
| <dd>読み出すバイト数(0~65535)を指定します。</dd> | ||||
| <dt>ByteRead</dt> | ||||
| <dd>実際に読み出されたバイト数を格納する変数を指すポインタを指定します。</dd> | ||||
| </dt> | ||||
| @ -44,9 +44,9 @@ FRESULT f_read ( | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>正常終了。</dd> | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>書き込み専用モードで開いたファイルから読み込もうとした。</dd> | ||||
| <dd>非読み込みモードで開いたファイルから読み込もうとした。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
|  | ||||
| @ -40,7 +40,7 @@ FRESULT f_readdir ( | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
| <dd>無効なディレクトリ・オブジェクト。</dd> | ||||
| </dl> | ||||
| @ -49,7 +49,7 @@ FRESULT f_readdir ( | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h4>解説</h4> | ||||
| <p>ディレクトリ・エントリーを順次読み出します。この関数を繰り返し実行することによりディレクトリの全ての項目を読み出すことができます。全ての項目を読み出し、読み出す項目がもう無いときは、<tt>f_name[]</tt>メンバにヌル文字列が返されます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。<tt>_FS_MINIMIZE == 2</tt>ではこの関数はサポートされません。</p> | ||||
| <p>ディレクトリ項目を順次読み出します。この関数を繰り返し実行することによりディレクトリの全ての項目を読み出すことができます。全ての項目を読み出し、読み出す項目がもう無いときは、<tt>f_name[]</tt>メンバにヌル文字列が返されます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。<tt>_FS_MINIMIZE >= 2</tt>ではこの関数はサポートされません。</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -27,7 +27,7 @@ FRESULT f_rename ( | ||||
| <dt>OldName</dt> | ||||
| <dd>変更対象のファイルまたはディレクトリの<a href="filename.html">フルパス名</a>の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd> | ||||
| <dt>NewName</dt> | ||||
| <dd>新しいファイルまたはディレクトリのフルパス名の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。既に存在するものと同じ名前は使えません。また、ドライブ番号は指定できず、<em>OldName</em>で指定されたドライブ上として扱われます。<br> | ||||
| <dd>新しいファイルまたはディレクトリのフルパス名の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。既に存在するものと同じ名前は使えません。また、ドライブ番号は指定できず、<tt>OldName</tt>で指定されたドライブ上のオブジェクトとして扱われます。<br> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| @ -46,13 +46,15 @@ FRESULT f_rename ( | ||||
| <dt>FR_INVALID_DRIVE</dt> | ||||
| <dd>ドライブ番号が不正。</dd> | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>新しい名前が作れない。</dd> | ||||
| <dd>新しい名前のオブジェクトが作れない。</dd> | ||||
| <dt>FR_EXIST</dt> | ||||
| <dd>NewNameと同じ名前のオブジェクトが既にある。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>メディアが書き込み禁止状態。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>論理ドライブにワークエリアが割り当てられていない。</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -16,23 +16,23 @@ | ||||
| <h4>FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _DIR { | ||||
|     WORD    id;          /* Owner file system mount ID (inverted) */ | ||||
|     WORD    index;       /* Current index */ | ||||
|     FATFS*  fs;          /* Pointer to the owner file system object */ | ||||
|     DWORD   sclust;      /* Start cluster */ | ||||
|     DWORD   clust;       /* Current cluster */ | ||||
|     DWORD   sect;        /* Current sector */ | ||||
|     WORD    index;       /* Current index */ | ||||
|     WORD    id;          /* Sum of owner file system mount ID */ | ||||
| } DIR; | ||||
| </pre> | ||||
| <h4>Tiny-FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _DIR { | ||||
|     WORD    id;          /* Owner file system mount ID (inverted) */ | ||||
|     WORD    index;       /* Current index */ | ||||
|     FATFS*  fs;          /* Pointer to the owner file system object */ | ||||
|     CLUST   sclust;      /* Start cluster */ | ||||
|     CLUST   clust;       /* Current cluster */ | ||||
|     DWORD   sect;        /* Current sector */ | ||||
|     WORD    index;       /* Current index */ | ||||
|     WORD    id;          /* Sum of owner file system mount ID */ | ||||
| } DIR; | ||||
| </pre> | ||||
| </div> | ||||
|  | ||||
| @ -16,10 +16,6 @@ | ||||
| <h4>FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _FATFS { | ||||
|     BYTE    fs_type;        /* FAT type (0:Not mouted) */ | ||||
|     BYTE    sects_clust;    /* Sectors per cluster */ | ||||
|     BYTE    n_fats;         /* Number of FAT copies */ | ||||
|     BYTE    drive;          /* Physical drive number */ | ||||
|     WORD    id;             /* File system mount ID */ | ||||
|     WORD    n_rootdir;      /* Number of root directory entries */ | ||||
|     DWORD   winsect;        /* Current sector appearing in the win[] */ | ||||
| @ -29,7 +25,12 @@ typedef struct _FATFS { | ||||
|     DWORD   dirbase;        /* Root directory start sector (cluster# for FAT32) */ | ||||
|     DWORD   database;       /* Data start sector */ | ||||
|     DWORD   last_clust;     /* Last allocated cluster */ | ||||
|     BYTE    fs_type;        /* FAT type (0:Not mounted) */ | ||||
|     BYTE    sects_clust;    /* Sectors per cluster */ | ||||
|     BYTE    n_fats;         /* Number of FAT copies */ | ||||
|     BYTE    drive;          /* Physical drive number */ | ||||
|     BYTE    winflag;        /* win[] dirty flag (1:must be written back) */ | ||||
|     BYTE    pad1; | ||||
|     BYTE    win[512];       /* Disk access window for Directory/FAT */ | ||||
| } FATFS; | ||||
| </pre> | ||||
| @ -37,10 +38,6 @@ typedef struct _FATFS { | ||||
| <h4>Tiny-FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _FATFS { | ||||
|     BYTE    fs_type;        /* FAT type (0:Not mouted) */ | ||||
|     BYTE    sects_clust;    /* Sectors per cluster */ | ||||
|     BYTE    n_fats;         /* Number of FAT copies */ | ||||
|     BYTE    winflag;        /* win[] dirty flag (1:must be written back) */ | ||||
|     WORD    id;             /* File system mount ID */ | ||||
|     WORD    n_rootdir;      /* Number of root directory entries */ | ||||
|     DWORD   winsect;        /* Current sector appearing in the win[] */ | ||||
| @ -50,6 +47,10 @@ typedef struct _FATFS { | ||||
|     CLUST   sects_fat;      /* Sectors per fat */ | ||||
|     CLUST   max_clust;      /* Maximum cluster# + 1 */ | ||||
|     CLUST   last_clust;     /* Last allocated cluster */ | ||||
|     BYTE    fs_type;        /* FAT type (0:Not mounted) */ | ||||
|     BYTE    sects_clust;    /* Sectors per cluster */ | ||||
|     BYTE    n_fats;         /* Number of FAT copies */ | ||||
|     BYTE    winflag;        /* win[] dirty flag (1:must be written back) */ | ||||
|     BYTE    win[512];       /* Disk access window for Directory/FAT/File */ | ||||
| } FATFS; | ||||
| </pre> | ||||
|  | ||||
| @ -16,6 +16,9 @@ | ||||
| <h4>FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _FIL { | ||||
|     WORD    id;             /* Owner file system mount ID (inverted) */ | ||||
|     BYTE    flag;           /* File status flags */ | ||||
|     BYTE    sect_clust;     /* Left sectors in cluster */ | ||||
|     FATFS*  fs;             /* Pointer to the owner file system object */ | ||||
|     DWORD   fptr;           /* File R/W pointer */ | ||||
|     DWORD   fsize;          /* File size */ | ||||
| @ -24,9 +27,6 @@ typedef struct _FIL { | ||||
|     DWORD   curr_sect;      /* Current sector */ | ||||
|     DWORD   dir_sect;       /* Sector containing the directory entry */ | ||||
|     BYTE*   dir_ptr;        /* Ponter to the directory entry in the window */ | ||||
|     WORD    id;             /* Sum of owner file system mount ID */ | ||||
|     BYTE    flag;           /* File status flags */ | ||||
|     BYTE    sect_clust;     /* Left sectors in cluster */ | ||||
|     BYTE    buffer[512];    /* File R/W buffer */ | ||||
| } FIL; | ||||
| </pre> | ||||
| @ -34,6 +34,9 @@ typedef struct _FIL { | ||||
| <h4>Tiny-FatFs</h4> | ||||
| <pre> | ||||
| typedef struct _FIL { | ||||
|     WORD    id;             /* Owner file system mount ID (inverted) */ | ||||
|     BYTE    flag;           /* File status flags */ | ||||
|     BYTE    sect_clust;     /* Left sectors in cluster */ | ||||
|     FATFS*  fs;             /* Pointer to owner file system */ | ||||
|     DWORD   fptr;           /* File R/W pointer */ | ||||
|     DWORD   fsize;          /* File size */ | ||||
| @ -42,9 +45,6 @@ typedef struct _FIL { | ||||
|     DWORD   curr_sect;      /* Current sector */ | ||||
|     DWORD   dir_sect;       /* Sector containing the directory entry */ | ||||
|     BYTE*   dir_ptr;        /* Ponter to the directory entry in the window */ | ||||
|     WORD    id;             /* Sum of owner file system mount ID */ | ||||
|     BYTE    flag;           /* File status flags */ | ||||
|     BYTE    sect_clust;     /* Left sectors in cluster */ | ||||
| } FIL; | ||||
| </pre> | ||||
| </div> | ||||
|  | ||||
| @ -25,7 +25,7 @@ FRESULT f_stat ( | ||||
| <h4>引数</h4> | ||||
| <dl class="par"> | ||||
| <dt>FileName</dt> | ||||
| <dd>情報を得るファイルまたはディレクトリ名の<tt>'\0'</tt>で終わる文字列を指すポインタを指定します。ルートディレクトリの指定は禁止です。</dd> | ||||
| <dd>情報を得るファイルまたはディレクトリ名の<tt>'\0'</tt>で終わる文字列を指すポインタを指定します。</dd> | ||||
| <dt>FileInfo</dt> | ||||
| <dd>読み出したファイル情報を格納するファイル情報構造体へのポインタを指定します。</dd> | ||||
| </dl> | ||||
| @ -48,7 +48,7 @@ FRESULT f_stat ( | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>論理ドライブにワークエリアが割り当てられていない。</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -35,7 +35,7 @@ FRESULT f_sync ( | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>正常終了。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
|  | ||||
| @ -49,7 +49,7 @@ FRESULT f_unlink ( | ||||
| <dt>FR_WRITE_PROTECTED</dt> | ||||
| <dd>メディアが書き込み禁止状態。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_ENABLED</dt> | ||||
| <dd>論理ドライブにワーク・エリアが割り当てられていない。</dd> | ||||
| <dt>FR_NO_FILESYSTEM</dt> | ||||
|  | ||||
| @ -31,7 +31,7 @@ FRESULT f_write ( | ||||
| <dt>Buffer</dt> | ||||
| <dd>書き込むデータを格納したバッファを指すポインタを指定します。</dd> | ||||
| <dt>ByteToWrite</dt> | ||||
| <dd>書き込むバイト数を指定します。</dd> | ||||
| <dd>書き込むバイト数(0~65535)を指定します。</dd> | ||||
| <dt>ByteWritten</dt> | ||||
| <dd>書き込まれたバイト数を格納する変数を指すポインタを指定します。</dd> | ||||
| </dl> | ||||
| @ -44,9 +44,9 @@ FRESULT f_write ( | ||||
| <dt>FR_OK (0)</dt> | ||||
| <dd>正常終了。</dd> | ||||
| <dt>FR_DENIED</dt> | ||||
| <dd>読み込み専用モードで開いたファイルに書き込もうとした。</dd> | ||||
| <dd>非書き込みモードで開いたファイルに書き込もうとした。</dd> | ||||
| <dt>FR_RW_ERROR</dt> | ||||
| <dd>ディスク・アクセスでエラーが発生した。</dd> | ||||
| <dd>ディスク・エラーまたは内部エラーによる失敗。</dd> | ||||
| <dt>FR_NOT_READY</dt> | ||||
| <dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd> | ||||
| <dt>FR_INVALID_OBJECT</dt> | ||||
|  | ||||
							
								
								
									
										35
									
								
								doc/updates.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,35 @@ | ||||
| R0.04a, Apr 01, 2007 | ||||
|   Supported multiple partitions on a plysical drive. (FatFs) | ||||
|   Fixed an endian sensitive code in f_mkfs(). (FatFs) | ||||
|   Added a capability of extending file size to f_lseek(). | ||||
|   Added minimization level 3. | ||||
|   Fixed a problem that can collapse a sector when recreate an existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs) | ||||
| 
 | ||||
| R0.04, Feb 04, 2007 | ||||
|   Supported multiple drive system. (FatFs) | ||||
|   Changed some APIs for multiple drive system. | ||||
|   Added f_mkfs(). (FatFs) | ||||
|   Added _USE_FAT32 option. (Tiny-FatFs) | ||||
| 
 | ||||
| R0.03a, Dec 11, 2006 | ||||
|   Improved cluster scan algolithm to write files fast. | ||||
|   Fixed f_mkdir() creates incorrect directory on FAT32. | ||||
| 
 | ||||
| R0.02a, Jun 10, 2006 | ||||
|   Added a configuration option _FS_MINIMUM. | ||||
| 
 | ||||
| R0.02, Jun 01, 2006 | ||||
|   Added FAT12. | ||||
|   Removed unbuffered mode. | ||||
|   Fixed a problem on small (<32M) patition. | ||||
| 
 | ||||
| R0.03, Sep 22, 2006 | ||||
|   Added f_rename(). | ||||
|   Changed option _FS_MINIMUM to _FS_MINIMIZE. | ||||
| 
 | ||||
| R0.01, Apr 29, 2006 | ||||
|   First release | ||||
| 
 | ||||
| R0.00, Feb 26, 2006 | ||||
|   Prototype (not released) | ||||
| 
 | ||||
| @ -1,4 +1,4 @@ | ||||
| FatFs/Tiny-FatFs Module Source Files R0.04   (C)ChaN, 2007 | ||||
| FatFs/Tiny-FatFs Module Source Files R0.04a   (C)ChaN, 2007 | ||||
| 
 | ||||
| 
 | ||||
| FILES | ||||
| @ -26,28 +26,30 @@ CONFIGURATION OPTIONS | ||||
|   _MCU_ENDIAN | ||||
| 
 | ||||
|   This is the most impotant option that depends on the processor architecture. | ||||
|   When target device corresponds to either or both of following terms, the | ||||
|   When the target device corresponds to either or both of following terms, the | ||||
|   _MCU_ENDIAN must be set to 2 to force FatFs to access FAT structure in | ||||
|   byte-by-byte. If not the case, this can be set to 1 for good code efficiency. | ||||
|   The initial value is 0 (must be set to 1 or 2 properly). | ||||
|   byte-by-byte. | ||||
| 
 | ||||
|   - Muti-byte integers (short, long) are stored in Big-Endian. | ||||
|   - Address miss-aligned memory access results in an incorrect behavior. | ||||
| 
 | ||||
|   If not the case, this can be set to 1 for good code efficiency. The initial | ||||
|   value is 0. (must be set to 1 or 2 properly) | ||||
| 
 | ||||
| 
 | ||||
|   _FS_READONLY | ||||
| 
 | ||||
|   When application program does not require any write function, _FS_READONLY | ||||
|   can be set to 1 to eliminate writing code to reduce module size. This | ||||
|   can be set to 1 to eliminate writing code to reduce the module size. This | ||||
|   setting should be reflected to configurations of low level disk I/O module | ||||
|   if available. The initial value is 0 (R/W). | ||||
|   if available. The initial value is 0. (Read and Write) | ||||
| 
 | ||||
| 
 | ||||
|   _FS_MINIMIZE | ||||
| 
 | ||||
|   When application program requires only file read/write function, _FS_MINIMIZE | ||||
|   can be defined to eliminate some functions to reduce the module size. The | ||||
|   initial value is 0 (full function). | ||||
|   initial value is 0. (full function) | ||||
| 
 | ||||
| 
 | ||||
|   _DRIVES | ||||
| @ -59,43 +61,43 @@ CONFIGURATION OPTIONS | ||||
| 
 | ||||
|   When _FAT32 is set to 1, the FAT32 support is added with an additional | ||||
|   code size. This is for only Tiny-FatFs and not supported on FatFs. FatFs | ||||
|   always supports all FAT type. The initial value is 0 (disabled). | ||||
|   always supports all FAT type. The initial value is 0. (disabled) | ||||
| 
 | ||||
| 
 | ||||
|   _USE_SJIS | ||||
| 
 | ||||
|   When _USE_SJIS is defined, Shift-JIS code set can be used as a file name, | ||||
|   otherwire second byte of double-byte characters will be collapted. This is | ||||
|   initially defined. | ||||
|   When _USE_SJIS is set to 1, Shift-JIS code set can be used as a file name, | ||||
|   otherwire second byte of double-byte characters will be collapted. | ||||
|   The initial value is 1. | ||||
| 
 | ||||
| 
 | ||||
|   _USE_MKFS | ||||
| 
 | ||||
|   When _USE_MKFS is defined and _FS_READONLY is set to 0, f_mkfs function | ||||
|   When _USE_MKFS is set to 1 and _FS_READONLY is set to 0, f_mkfs function | ||||
|   is enabled. This is for only FatFs module and not supported on Tiny-FatFs. | ||||
|   This is initialy undefined (not available). | ||||
|   The initial value is 0. (f_mkfs is not available) | ||||
| 
 | ||||
| 
 | ||||
|   Following table shows which function is removed by configuratin options. | ||||
| 
 | ||||
|                _FS_MINIMIZE  _FS_MINIMIZE  _FS_READONLY  _USE_MKFS | ||||
|                     (1)           (2)          (1)        (undef) | ||||
|    f_mount | ||||
|    f_open | ||||
|    f_close | ||||
|    f_read | ||||
|    f_lseek | ||||
|    f_write                                     x | ||||
|    f_sync                                      x | ||||
|    f_opendir                      x | ||||
|    f_readdir                      x | ||||
|    f_stat            x            x | ||||
|    f_getfree         x            x            x | ||||
|    f_unlink          x            x            x | ||||
|    f_mkdir           x            x            x | ||||
|    f_chmod           x            x            x | ||||
|    f_rename          x            x            x | ||||
|    f_mkfs                                      x            x | ||||
|                 _FS_MINIMIZE   _FS_READONLY  _USE_MKFS  | ||||
|                 (1)  (2)  (3)       (1)         (0)     | ||||
|    f_mount                                              | ||||
|    f_open                                               | ||||
|    f_close                                              | ||||
|    f_read                                               | ||||
|    f_write                           x                  | ||||
|    f_sync                            x                  | ||||
|    f_lseek                 x                            | ||||
|    f_opendir          x    x                            | ||||
|    f_readdir          x    x                            | ||||
|    f_stat        x    x    x                            | ||||
|    f_getfree     x    x    x         x                  | ||||
|    f_unlink      x    x    x         x                  | ||||
|    f_mkdir       x    x    x         x                  | ||||
|    f_chmod       x    x    x         x                  | ||||
|    f_rename      x    x    x         x                  | ||||
|    f_mkfs                            x          x       | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -112,9 +114,10 @@ REVISION HISTORY | ||||
| 
 | ||||
|   Feb 26, 2006  R0.00  Prototype | ||||
| 
 | ||||
|   Apr 29, 2006  R0.01  First stable version | ||||
|   Apr 29, 2006  R0.01  First release. | ||||
| 
 | ||||
|   Jun 01, 2006  R0.02  Added FAT12. Removed unbuffered mode. | ||||
|   Jun 01, 2006  R0.02  Added FAT12. | ||||
|                        Removed unbuffered mode. | ||||
|                        Fixed a problem on small (<32M) patition. | ||||
| 
 | ||||
|   Jun 10, 2006  R0.02a Added a configuration option _FS_MINIMUM. | ||||
| @ -125,6 +128,15 @@ REVISION HISTORY | ||||
|   Dec 11, 2006  R0.03a Improved cluster scan algolithm to write files fast. | ||||
|                        Fixed f_mkdir() creates incorrect directory on FAT32. | ||||
| 
 | ||||
|   Feb 04, 2007  R0.04  Supported multiple drive system. | ||||
|   Feb 04, 2007  R0.04  Supported multiple drive system. (FatFs) | ||||
|                        Changed some APIs for multiple drive system. | ||||
|                        Added f_mkfs(). | ||||
|                        Added f_mkfs(). (FatFs) | ||||
|                        Added _USE_FAT32 option. (Tiny-FatFs) | ||||
| 
 | ||||
|   Apr 01, 2007  R0.04a Supported multiple partitions on a plysical drive. (FatFs) | ||||
|                        Fixed an endian sensitive code in f_mkfs(). (FatFs) | ||||
|                        Added a capability of extending the file size to f_lseek(). | ||||
|                        Added minimization level 3. | ||||
|                        Fixed a problem that can collapse a sector when recreate an | ||||
|                        existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs) | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										45
									
								
								src/diskio.h
									
									
									
									
									
								
							
							
						
						| @ -1,5 +1,5 @@ | ||||
| /*-----------------------------------------------------------------------
 | ||||
| /  Low level disk interface modlue include file  R0.04    (C)ChaN, 2007 | ||||
| /  Low level disk interface modlue include file  R0.04a   (C)ChaN, 2007 | ||||
| /-----------------------------------------------------------------------*/ | ||||
| 
 | ||||
| #ifndef _DISKIO | ||||
| @ -8,8 +8,18 @@ | ||||
| 
 | ||||
| #include "integer.h" | ||||
| 
 | ||||
| typedef unsigned char	DSTATUS; | ||||
| typedef unsigned char	DRESULT; | ||||
| 
 | ||||
| /* Status of Disk Functions */ | ||||
| typedef BYTE	DSTATUS; | ||||
| 
 | ||||
| /* Results of Disk Functions */ | ||||
| typedef enum { | ||||
| 	RES_OK = 0,		/* 0: Successful */ | ||||
| 	RES_ERROR,		/* 1: R/W Error */ | ||||
| 	RES_WRPRT,		/* 2: Write Protected */ | ||||
| 	RES_NOTRDY,		/* 3: Not Ready */ | ||||
| 	RES_PARERR		/* 4: Invalid Parameter */ | ||||
| } DRESULT; | ||||
| 
 | ||||
| 
 | ||||
| /*---------------------------------------*/ | ||||
| @ -25,13 +35,6 @@ DRESULT disk_ioctl (BYTE, BYTE, void*); | ||||
| void	disk_timerproc (void); | ||||
| 
 | ||||
| 
 | ||||
| /* Results of Disk Functions (DRESULT) */ | ||||
| 
 | ||||
| #define RES_OK			0		/* Successful */ | ||||
| #define	RES_ERROR		1		/* R/W Error */ | ||||
| #define	RES_WRPRT		2		/* Write Protected */ | ||||
| #define	RES_NOTRDY		3		/* Not Ready */ | ||||
| #define	RES_PARERR		4		/* Invalid Parameter */ | ||||
| 
 | ||||
| 
 | ||||
| /* Disk Status Bits (DSTATUS) */ | ||||
| @ -43,16 +46,18 @@ void	disk_timerproc (void); | ||||
| 
 | ||||
| /* Command code for disk_ioctrl() */ | ||||
| 
 | ||||
| #define GET_SECTORS		1 | ||||
| #define CTRL_POWER		2 | ||||
| #define CTRL_LOCK		3 | ||||
| #define CTRL_EJECT		4 | ||||
| #define MMC_GET_CSD		10 | ||||
| #define MMC_GET_CID		11 | ||||
| #define MMC_GET_OCR		12 | ||||
| #define ATA_GET_REV		20 | ||||
| #define ATA_GET_MODEL	21 | ||||
| #define ATA_GET_SN		22 | ||||
| #define GET_SECTOR_COUNT	1 | ||||
| #define GET_SECTOR_SIZE		2 | ||||
| #define CTRL_SYNC			3 | ||||
| #define CTRL_POWER			4 | ||||
| #define CTRL_LOCK			5 | ||||
| #define CTRL_EJECT			6 | ||||
| #define MMC_GET_CSD			10 | ||||
| #define MMC_GET_CID			11 | ||||
| #define MMC_GET_OCR			12 | ||||
| #define ATA_GET_REV			20 | ||||
| #define ATA_GET_MODEL		21 | ||||
| #define ATA_GET_SN			22 | ||||
| 
 | ||||
| 
 | ||||
| #define _DISKIO | ||||
|  | ||||
							
								
								
									
										177
									
								
								src/ff.h
									
									
									
									
									
								
							
							
						
						| @ -1,5 +1,5 @@ | ||||
| /*--------------------------------------------------------------------------/
 | ||||
| /  FatFs - FAT file system module include file  R0.04        (C)ChaN, 2007 | ||||
| /  FatFs - FAT file system module include file  R0.04a       (C)ChaN, 2007 | ||||
| /---------------------------------------------------------------------------/ | ||||
| / FatFs module is an experimenal project to implement FAT file system to | ||||
| / cheap microcontrollers. This is a free software and is opened for education, | ||||
| @ -33,33 +33,40 @@ | ||||
| /* The _FS_MINIMIZE option defines minimization level to remove some functions.
 | ||||
| /  0: Full function. | ||||
| /  1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod and f_rename are removed. | ||||
| /  2: f_opendir and f_readdir are removed in addition to level 1. */ | ||||
| /  2: f_opendir and f_readdir are removed in addition to level 1. | ||||
| /  3: f_lseek is removed in addition to level 2. */ | ||||
| 
 | ||||
| #define _DRIVES		2 | ||||
| /* Number of logical drives to be used */ | ||||
| #define _DRIVES		1 | ||||
| /* Number of logical drives to be used. This affects the size of internal table. */ | ||||
| 
 | ||||
| #define	_USE_SJIS | ||||
| /* When _USE_SJIS is defined, Shift-JIS code transparency is enabled, otherwise
 | ||||
| #define	_USE_SJIS	1 | ||||
| /* When _USE_SJIS is set to 1, Shift-JIS code transparency is enabled, otherwise
 | ||||
| /  only US-ASCII(7bit) code can be accepted as file/directory name. */ | ||||
| 
 | ||||
| /* #define	_USE_MKFS */ | ||||
| /* When _USE_MKFS is defined and _FS_READONLY is set to 0, f_mkfs function
 | ||||
|    is enabled. */ | ||||
| #define	_USE_MKFS	0 | ||||
| /* When _USE_MKFS is set to 1 and _FS_READONLY is set to 0, f_mkfs function is
 | ||||
| /  enabled. */ | ||||
| 
 | ||||
| #define	_MULTI_PARTITION	0 | ||||
| /* When _MULTI_PARTITION is set to 0, each logical drive is bound to same
 | ||||
| /  physical drive number and can mount only 1st primaly partition. When it is | ||||
| /  set to 1, each logical drive can mount a partition listed in Drives[]. */ | ||||
| 
 | ||||
| #include "integer.h" | ||||
| 
 | ||||
| 
 | ||||
| /* Result type for fatfs application interface */ | ||||
| typedef unsigned char	FRESULT; | ||||
| 
 | ||||
| /* Definitions corresponds to multiple sector size (not tested) */ | ||||
| #define	S_MAX_SIZ	512			/* Do not change */ | ||||
| #if S_MAX_SIZ > 512 | ||||
| #define	S_SIZ	(fs->s_size) | ||||
| #else | ||||
| #define	S_SIZ	512 | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* File system object structure */ | ||||
| typedef struct _FATFS { | ||||
| 	BYTE	fs_type;		/* FAT type */ | ||||
| 	BYTE	sects_clust;	/* Sectors per cluster */ | ||||
| 	BYTE	n_fats;			/* Number of FAT copies */ | ||||
| 	BYTE	drive;			/* Physical drive number */ | ||||
| 	WORD	id;				/* File system mount ID */ | ||||
| 	WORD	n_rootdir;		/* Number of root directory entries */ | ||||
| 	DWORD	winsect;		/* Current sector appearing in the win[] */ | ||||
| @ -69,24 +76,35 @@ typedef struct _FATFS { | ||||
| 	DWORD	dirbase;		/* Root directory start sector (cluster# for FAT32) */ | ||||
| 	DWORD	database;		/* Data start sector */ | ||||
| 	DWORD	last_clust;		/* Last allocated cluster */ | ||||
| #if S_MAX_SIZ > 512 | ||||
| 	WORD	s_size;			/* Sector size */ | ||||
| #endif | ||||
| 	BYTE	fs_type;		/* FAT sub type */ | ||||
| 	BYTE	sects_clust;	/* Sectors per cluster */ | ||||
| 	BYTE	n_fats;			/* Number of FAT copies */ | ||||
| 	BYTE	drive;			/* Physical drive number */ | ||||
| 	BYTE	winflag;		/* win[] dirty flag (1:must be written back) */ | ||||
| 	BYTE	win[512];		/* Disk access window for Directory/FAT */ | ||||
| 	BYTE	pad1; | ||||
| 	BYTE	win[S_MAX_SIZ];	/* Disk access window for Directory/FAT */ | ||||
| } FATFS; | ||||
| 
 | ||||
| 
 | ||||
| /* Directory object structure */ | ||||
| typedef struct _DIR { | ||||
| 	WORD	id;			/* Owner file system mount ID */ | ||||
| 	WORD	index;		/* Current index */ | ||||
| 	FATFS*	fs;			/* Pointer to the owner file system object */ | ||||
| 	DWORD	sclust;		/* Start cluster */ | ||||
| 	DWORD	clust;		/* Current cluster */ | ||||
| 	DWORD	sect;		/* Current sector */ | ||||
| 	WORD	index;		/* Current index */ | ||||
| 	WORD	id;			/* Sum of owner file system mount ID */ | ||||
| } DIR; | ||||
| 
 | ||||
| 
 | ||||
| /* File object structure */ | ||||
| typedef struct _FIL { | ||||
| 	WORD	id;				/* Owner file system mount ID */ | ||||
| 	BYTE	flag;			/* File status flags */ | ||||
| 	BYTE	sect_clust;		/* Left sectors in cluster */ | ||||
| 	FATFS*	fs;				/* Pointer to the owner file system object */ | ||||
| 	DWORD	fptr;			/* File R/W pointer */ | ||||
| 	DWORD	fsize;			/* File size */ | ||||
| @ -97,10 +115,7 @@ typedef struct _FIL { | ||||
| 	DWORD	dir_sect;		/* Sector containing the directory entry */ | ||||
| 	BYTE*	dir_ptr;		/* Ponter to the directory entry in the window */ | ||||
| #endif | ||||
| 	WORD	id;				/* Sum of owner file system mount ID */ | ||||
| 	BYTE	flag;			/* File status flags */ | ||||
| 	BYTE	sect_clust;		/* Left sectors in cluster */ | ||||
| 	BYTE	buffer[512];	/* File R/W buffer */ | ||||
| 	BYTE	buffer[S_MAX_SIZ];	/* File R/W buffer */ | ||||
| } FIL; | ||||
| 
 | ||||
| 
 | ||||
| @ -115,6 +130,48 @@ typedef struct _FILINFO { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* Definitions corresponds to multi partition */ | ||||
| 
 | ||||
| #if _MULTI_PARTITION != 0	/* Multiple partition cfg */ | ||||
| 
 | ||||
| typedef struct _PARTITION { | ||||
| 	BYTE pd;	/* Physical drive # (0-255) */ | ||||
| 	BYTE pt;	/* Partition # (0-3) */ | ||||
| } PARTITION; | ||||
| extern | ||||
| const PARTITION Drives[];			/* Logical drive# to physical location conversion table */ | ||||
| #define LD2PD(drv) (Drives[drv].pd)	/* Get physical drive# */ | ||||
| #define LD2PT(drv) (Drives[drv].pt)	/* Get partition# */ | ||||
| 
 | ||||
| #else						/* Single partition cfg */ | ||||
| 
 | ||||
| #define LD2PD(drv) (drv)		/* Physical drive# is equal to logical drive# */ | ||||
| #define LD2PT(drv) 0			/* Always mounts the 1st partition */ | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* File function return code (FRESULT) */ | ||||
| 
 | ||||
| typedef enum { | ||||
| 	FR_OK = 0,			/* 0 */ | ||||
| 	FR_NOT_READY,		/* 1 */ | ||||
| 	FR_NO_FILE,			/* 2 */ | ||||
| 	FR_NO_PATH,			/* 3 */ | ||||
| 	FR_INVALID_NAME,	/* 4 */ | ||||
| 	FR_INVALID_DRIVE,	/* 5 */ | ||||
| 	FR_DENIED,			/* 6 */ | ||||
| 	FR_EXIST,			/* 7 */ | ||||
| 	FR_RW_ERROR,		/* 8 */ | ||||
| 	FR_WRITE_PROTECTED,	/* 9 */ | ||||
| 	FR_NOT_ENABLED,		/* 10 */ | ||||
| 	FR_NO_FILESYSTEM,	/* 11 */ | ||||
| 	FR_INVALID_OBJECT,	/* 12 */ | ||||
| 	FR_MKFS_ABORTED		/* 13 */ | ||||
| } FRESULT; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /*-----------------------------------------------------*/ | ||||
| /* FatFs module application interface                  */ | ||||
| 
 | ||||
| @ -143,30 +200,13 @@ DWORD get_fattime (void);	/* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* File function return code (FRESULT) */ | ||||
| 
 | ||||
| #define	FR_OK						0 | ||||
| #define	FR_NOT_READY				1 | ||||
| #define	FR_NO_FILE					2 | ||||
| #define	FR_NO_PATH					3 | ||||
| #define	FR_INVALID_NAME				4 | ||||
| #define FR_INVALID_DRIVE			5 | ||||
| #define	FR_DENIED					6 | ||||
| #define	FR_DISK_FULL				7 | ||||
| #define	FR_RW_ERROR					8 | ||||
| #define	FR_WRITE_PROTECTED			9 | ||||
| #define	FR_NOT_ENABLED				10 | ||||
| #define	FR_NO_FILESYSTEM			11 | ||||
| #define FR_INVALID_OBJECT			12 | ||||
| #define FR_MKFS_ABORTED				13 | ||||
| 
 | ||||
| 
 | ||||
| /* File access control and file status flags (FIL.flag) */ | ||||
| 
 | ||||
| #define	FA_READ				0x01 | ||||
| #define	FA_OPEN_EXISTING	0x00 | ||||
| #if _FS_READONLY == 0 | ||||
| #define	FA_WRITE			0x02 | ||||
| #define	FA_CREATE_NEW		0x04 | ||||
| #define	FA_CREATE_ALWAYS	0x08 | ||||
| #define	FA_OPEN_ALWAYS		0x10 | ||||
| #define FA__WRITTEN			0x20 | ||||
| @ -175,7 +215,7 @@ DWORD get_fattime (void);	/* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20 | ||||
| #define FA__ERROR			0x80 | ||||
| 
 | ||||
| 
 | ||||
| /* FAT type signature (FATFS.fs_type) */ | ||||
| /* FAT sub type (FATFS.fs_type) */ | ||||
| 
 | ||||
| #define FS_FAT12	1 | ||||
| #define FS_FAT16	2 | ||||
| @ -194,6 +234,57 @@ DWORD get_fattime (void);	/* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* Offset of FAT structure members */ | ||||
| 
 | ||||
| #define BS_jmpBoot			0 | ||||
| #define BS_OEMName			3 | ||||
| #define BPB_BytsPerSec		11 | ||||
| #define BPB_SecPerClus		13 | ||||
| #define BPB_RsvdSecCnt		14 | ||||
| #define BPB_NumFATs			16 | ||||
| #define BPB_RootEntCnt		17 | ||||
| #define BPB_TotSec16		19 | ||||
| #define BPB_Media			21 | ||||
| #define BPB_FATSz16			22 | ||||
| #define BPB_SecPerTrk		24 | ||||
| #define BPB_NumHeads		26 | ||||
| #define BPB_HiddSec			28 | ||||
| #define BPB_TotSec32		32 | ||||
| #define BS_55AA				510 | ||||
| 
 | ||||
| #define BS_DrvNum			36 | ||||
| #define BS_BootSig			38 | ||||
| #define BS_VolID			39 | ||||
| #define BS_VolLab			43 | ||||
| #define BS_FilSysType		54 | ||||
| 
 | ||||
| #define BPB_FATSz32			36 | ||||
| #define BPB_ExtFlags		40 | ||||
| #define BPB_FSVer			42 | ||||
| #define BPB_RootClus		44 | ||||
| #define BPB_FSInfo			48 | ||||
| #define BPB_BkBootSec		50 | ||||
| #define BS_DrvNum32			64 | ||||
| #define BS_BootSig32		66 | ||||
| #define BS_VolID32			67 | ||||
| #define BS_VolLab32			71 | ||||
| #define BS_FilSysType32		82 | ||||
| 
 | ||||
| #define MBR_Table			446 | ||||
| 
 | ||||
| #define	DIR_Name			0 | ||||
| #define	DIR_Attr			11 | ||||
| #define	DIR_NTres			12 | ||||
| #define	DIR_CrtTime			14 | ||||
| #define	DIR_CrtDate			16 | ||||
| #define	DIR_FstClusHI		20 | ||||
| #define	DIR_WrtTime			22 | ||||
| #define	DIR_WrtDate			24 | ||||
| #define	DIR_FstClusLO		26 | ||||
| #define	DIR_FileSize		28 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* Multi-byte word access macros  */ | ||||
| 
 | ||||
| #if _MCU_ENDIAN == 1	/* Use word access */ | ||||
| @ -208,10 +299,10 @@ DWORD get_fattime (void);	/* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20 | ||||
| #define	ST_WORD(ptr,val)	*(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8) | ||||
| #define	ST_DWORD(ptr,val)	*(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24) | ||||
| #else | ||||
| #error Don't forget to set _MCU_ENDIAN properly! | ||||
| #error Do not forget to set _MCU_ENDIAN properly! | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #define _FATFS | ||||
| #endif | ||||
| #endif /* _FATFS */ | ||||
|  | ||||
| @ -1,23 +1,25 @@ | ||||
| #ifndef _INTEGER | ||||
| 
 | ||||
| typedef int				INT; | ||||
| typedef signed int		INT; | ||||
| typedef unsigned int	UINT; | ||||
| 
 | ||||
| typedef char			CHAR; | ||||
| /* These types are assumed as 8-bit integer */ | ||||
| typedef signed char		CHAR; | ||||
| typedef unsigned char	UCHAR; | ||||
| typedef unsigned char	BYTE; | ||||
| 
 | ||||
| typedef short			SHORT; | ||||
| /* These types are assumed as 16-bit integer */ | ||||
| typedef signed short	SHORT; | ||||
| typedef unsigned short	USHORT; | ||||
| typedef unsigned short	WORD; | ||||
| 
 | ||||
| typedef long			LONG; | ||||
| /* These types are assumed as 32-bit integer */ | ||||
| typedef signed long		LONG; | ||||
| typedef unsigned long	ULONG; | ||||
| typedef unsigned long	DWORD; | ||||
| 
 | ||||
| typedef unsigned char	BOOL; | ||||
| #define FALSE	0 | ||||
| #define TRUE	1 | ||||
| /* Boolean type */ | ||||
| typedef enum { FALSE = 0, TRUE } BOOL; | ||||
| 
 | ||||
| #define _INTEGER | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										129
									
								
								src/tff.h
									
									
									
									
									
								
							
							
						
						| @ -1,5 +1,5 @@ | ||||
| /*--------------------------------------------------------------------------/
 | ||||
| /  Tiny-FatFs - FAT file system module include file  R0.04    (C)ChaN, 2007 | ||||
| /  Tiny-FatFs - FAT file system module include file  R0.04a   (C)ChaN, 2007 | ||||
| /---------------------------------------------------------------------------/ | ||||
| / FatFs module is an experimenal project to implement FAT file system to | ||||
| / cheap microcontrollers. This is a free software and is opened for education, | ||||
| @ -33,21 +33,21 @@ | ||||
| /* The _FS_MINIMIZE option defines minimization level to remove some functions.
 | ||||
| /  0: Full function. | ||||
| /  1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod and f_rename are removed. | ||||
| /  2: f_opendir and f_readdir are removed in addition to level 1. */ | ||||
| /  2: f_opendir and f_readdir are removed in addition to level 1. | ||||
| /  3: f_lseek is removed in addition to level 2. */ | ||||
| 
 | ||||
| /* #define _FAT32	0 */ | ||||
| /* When enable FAT32 support, set _FAT32 to 1. */ | ||||
| #define _FAT32	0 | ||||
| /* To add FAT32 support, set _FAT32 to 1. */ | ||||
| 
 | ||||
| #define	_USE_SJIS | ||||
| /* When _USE_SJIS is defined, Shift-JIS code transparency is enabled, otherwise
 | ||||
| #define	_USE_SJIS	1 | ||||
| /* When _USE_SJIS is set to 1, Shift-JIS code transparency is enabled, otherwise
 | ||||
| /  only US-ASCII(7bit) code can be accepted as file/directory name. */ | ||||
| 
 | ||||
| 
 | ||||
| #include "integer.h" | ||||
| 
 | ||||
| 
 | ||||
| /* Result type for fatfs application interface */ | ||||
| typedef unsigned char	FRESULT; | ||||
| /* Type definition for cluster number */ | ||||
| #if _FAT32 == 0 | ||||
| typedef WORD	CLUST; | ||||
| #else | ||||
| @ -57,10 +57,6 @@ typedef DWORD	CLUST; | ||||
| 
 | ||||
| /* File system object structure */ | ||||
| typedef struct _FATFS { | ||||
| 	BYTE	fs_type;		/* FAT type */ | ||||
| 	BYTE	sects_clust;	/* Sectors per cluster */ | ||||
| 	BYTE	n_fats;			/* Number of FAT copies */ | ||||
| 	BYTE	winflag;		/* win[] dirty flag (1:must be written back) */ | ||||
| 	WORD	id;				/* File system mount ID */ | ||||
| 	WORD	n_rootdir;		/* Number of root directory entries */ | ||||
| 	DWORD	winsect;		/* Current sector appearing in the win[] */ | ||||
| @ -70,23 +66,30 @@ typedef struct _FATFS { | ||||
| 	CLUST	sects_fat;		/* Sectors per fat */ | ||||
| 	CLUST	max_clust;		/* Maximum cluster# + 1 */ | ||||
| 	CLUST	last_clust;		/* Last allocated cluster */ | ||||
| 	BYTE	fs_type;		/* FAT sub type */ | ||||
| 	BYTE	sects_clust;	/* Sectors per cluster */ | ||||
| 	BYTE	n_fats;			/* Number of FAT copies */ | ||||
| 	BYTE	winflag;		/* win[] dirty flag (1:must be written back) */ | ||||
| 	BYTE	win[512];		/* Disk access window for Directory/FAT/File */ | ||||
| } FATFS; | ||||
| 
 | ||||
| 
 | ||||
| /* Directory object structure */ | ||||
| typedef struct _DIR { | ||||
| 	WORD	id;			/* Owner file system mount ID */ | ||||
| 	WORD	index;		/* Current index */ | ||||
| 	FATFS*	fs;			/* Pointer to the owner file system object */ | ||||
| 	CLUST	sclust;		/* Start cluster */ | ||||
| 	CLUST	clust;		/* Current cluster */ | ||||
| 	DWORD	sect;		/* Current sector */ | ||||
| 	WORD	index;		/* Current index */ | ||||
| 	WORD	id;			/* Sum of owner file system mount ID */ | ||||
| } DIR; | ||||
| 
 | ||||
| 
 | ||||
| /* File object structure */ | ||||
| typedef struct _FIL { | ||||
| 	WORD	id;				/* Owner file system mount ID */ | ||||
| 	BYTE	flag;			/* File status flags */ | ||||
| 	BYTE	sect_clust;		/* Left sectors in cluster */ | ||||
| 	FATFS*	fs;				/* Pointer to owner file system */ | ||||
| 	DWORD	fptr;			/* File R/W pointer */ | ||||
| 	DWORD	fsize;			/* File size */ | ||||
| @ -97,9 +100,6 @@ typedef struct _FIL { | ||||
| 	DWORD	dir_sect;		/* Sector containing the directory entry */ | ||||
| 	BYTE*	dir_ptr;		/* Ponter to the directory entry in the window */ | ||||
| #endif | ||||
| 	WORD	id;				/* Sum of owner file system mount ID */ | ||||
| 	BYTE	flag;			/* File status flags */ | ||||
| 	BYTE	sect_clust;		/* Left sectors in cluster */ | ||||
| } FIL; | ||||
| 
 | ||||
| 
 | ||||
| @ -113,6 +113,25 @@ typedef struct _FILINFO { | ||||
| } FILINFO; | ||||
| 
 | ||||
| 
 | ||||
| /* File function return code (FRESULT) */ | ||||
| 
 | ||||
| typedef enum { | ||||
| 	FR_OK = 0,			/* 0 */ | ||||
| 	FR_NOT_READY,		/* 1 */ | ||||
| 	FR_NO_FILE,			/* 2 */ | ||||
| 	FR_NO_PATH,			/* 3 */ | ||||
| 	FR_INVALID_NAME,	/* 4 */ | ||||
| 	FR_INVALID_DRIVE,	/* 5 */ | ||||
| 	FR_DENIED,			/* 6 */ | ||||
| 	FR_EXIST,			/* 7 */ | ||||
| 	FR_RW_ERROR,		/* 8 */ | ||||
| 	FR_WRITE_PROTECTED,	/* 9 */ | ||||
| 	FR_NOT_ENABLED,		/* 10 */ | ||||
| 	FR_NO_FILESYSTEM,	/* 11 */ | ||||
| 	FR_INVALID_OBJECT	/* 12 */ | ||||
| } FRESULT; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /*-----------------------------------------------------*/ | ||||
| /* FatFs module application interface                  */ | ||||
| @ -141,29 +160,13 @@ DWORD get_fattime (void);	/* 31-25: Year(0-127 +1980), 24-21: Month(1-12), 20-16 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* File function return code (FRESULT) */ | ||||
| 
 | ||||
| #define	FR_OK						0 | ||||
| #define	FR_NOT_READY				1 | ||||
| #define	FR_NO_FILE					2 | ||||
| #define	FR_NO_PATH					3 | ||||
| #define	FR_INVALID_NAME				4 | ||||
| #define FR_INVALID_DRIVE			5 | ||||
| #define	FR_DENIED					6 | ||||
| #define	FR_DISK_FULL				7 | ||||
| #define	FR_RW_ERROR					8 | ||||
| #define	FR_WRITE_PROTECTED			9 | ||||
| #define	FR_NOT_ENABLED				10 | ||||
| #define	FR_NO_FILESYSTEM			11 | ||||
| #define FR_INVALID_OBJECT			12 | ||||
| 
 | ||||
| 
 | ||||
| /* File access control and file status flags (FIL.flag) */ | ||||
| 
 | ||||
| #define	FA_READ				0x01 | ||||
| #define	FA_OPEN_EXISTING	0x00 | ||||
| #if _FS_READONLY == 0 | ||||
| #define	FA_WRITE			0x02 | ||||
| #define	FA_CREATE_NEW		0x04 | ||||
| #define	FA_CREATE_ALWAYS	0x08 | ||||
| #define	FA_OPEN_ALWAYS		0x10 | ||||
| #define FA__WRITTEN			0x20 | ||||
| @ -171,7 +174,7 @@ DWORD get_fattime (void);	/* 31-25: Year(0-127 +1980), 24-21: Month(1-12), 20-16 | ||||
| #define FA__ERROR			0x80 | ||||
| 
 | ||||
| 
 | ||||
| /* FAT type signature (FATFS.fs_type) */ | ||||
| /* FAT sub type (FATFS.fs_type) */ | ||||
| 
 | ||||
| #define FS_FAT12	1 | ||||
| #define FS_FAT16	2 | ||||
| @ -190,6 +193,57 @@ DWORD get_fattime (void);	/* 31-25: Year(0-127 +1980), 24-21: Month(1-12), 20-16 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* Offset of FAT structure members */ | ||||
| 
 | ||||
| #define BS_jmpBoot			0 | ||||
| #define BS_OEMName			3 | ||||
| #define BPB_BytsPerSec		11 | ||||
| #define BPB_SecPerClus		13 | ||||
| #define BPB_RsvdSecCnt		14 | ||||
| #define BPB_NumFATs			16 | ||||
| #define BPB_RootEntCnt		17 | ||||
| #define BPB_TotSec16		19 | ||||
| #define BPB_Media			21 | ||||
| #define BPB_FATSz16			22 | ||||
| #define BPB_SecPerTrk		24 | ||||
| #define BPB_NumHeads		26 | ||||
| #define BPB_HiddSec			28 | ||||
| #define BPB_TotSec32		32 | ||||
| #define BS_55AA				510 | ||||
| 
 | ||||
| #define BS_DrvNum			36 | ||||
| #define BS_BootSig			38 | ||||
| #define BS_VolID			39 | ||||
| #define BS_VolLab			43 | ||||
| #define BS_FilSysType		54 | ||||
| 
 | ||||
| #define BPB_FATSz32			36 | ||||
| #define BPB_ExtFlags		40 | ||||
| #define BPB_FSVer			42 | ||||
| #define BPB_RootClus		44 | ||||
| #define BPB_FSInfo			48 | ||||
| #define BPB_BkBootSec		50 | ||||
| #define BS_DrvNum32			64 | ||||
| #define BS_BootSig32		66 | ||||
| #define BS_VolID32			67 | ||||
| #define BS_VolLab32			71 | ||||
| #define BS_FilSysType32		82 | ||||
| 
 | ||||
| #define MBR_Table			446 | ||||
| 
 | ||||
| #define	DIR_Name			0 | ||||
| #define	DIR_Attr			11 | ||||
| #define	DIR_NTres			12 | ||||
| #define	DIR_CrtTime			14 | ||||
| #define	DIR_CrtDate			16 | ||||
| #define	DIR_FstClusHI		20 | ||||
| #define	DIR_WrtTime			22 | ||||
| #define	DIR_WrtDate			24 | ||||
| #define	DIR_FstClusLO		26 | ||||
| #define	DIR_FileSize		28 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* Multi-byte word access macros  */ | ||||
| 
 | ||||
| #if _MCU_ENDIAN == 1	/* Use word access */ | ||||
| @ -204,10 +258,11 @@ DWORD get_fattime (void);	/* 31-25: Year(0-127 +1980), 24-21: Month(1-12), 20-16 | ||||
| #define	ST_WORD(ptr,val)	*(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8) | ||||
| #define	ST_DWORD(ptr,val)	*(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24) | ||||
| #else | ||||
| #error Don't forget to set _MCU_ENDIAN properly! | ||||
| #error Do not forget to set _MCU_ENDIAN properly! | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| #define _FATFS | ||||
| #endif | ||||
| #endif /* _FATFS */ | ||||
|  | ||||