fatfs v0.07a Apr 14, 2009:
- Separated out OS dependent code on reentrant cfg. - Added multiple sector size support.
This commit is contained in:
parent
b94c8f3bf3
commit
3bb1c09ac4
@ -16,26 +16,27 @@
|
||||
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||
<p>FatFs is a generic file system module to implement the FAT file system to small embedded systems. The FatFs is written in compliance with ANSI C, therefore it is independent of hardware architecture. It can be incorporated into cheap microcontrollers, such as 8051, PIC, AVR, SH, Z80, H8, ARM and etc..., without any change.</p>
|
||||
|
||||
<h4>Features of FatFs</h4>
|
||||
<ol>
|
||||
<li>Separated buffer for FAT structure and each file, suitable for fast multiple file access.</li>
|
||||
<li>Supports multiple drives and partitions.</li>
|
||||
<li>Supports FAT12, FAT16 and FAT32.</li>
|
||||
<li>Supports 8.3 format file name. (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 (different to FatFs)</h4>
|
||||
<ol>
|
||||
<li>Very low memory consumption, suitable for small memory system. (1KB RAM)</li>
|
||||
<li>Supports only single drive.</li>
|
||||
</ol>
|
||||
<h4>Features</h4>
|
||||
<ul>
|
||||
<li>FAT12, FAT16 and FAT32.</li>
|
||||
<li>Multiple volumes (physical drives and partitions).</li>
|
||||
<li>Two partitioning rules: FDISK and Super-floppy.</li>
|
||||
<li>Various configuration options:
|
||||
<ul>
|
||||
<li>Long file name (LFN) support.</li>
|
||||
<li>Selectable code pages including DBCS.</li>
|
||||
<li>Multitask support.</li>
|
||||
<li>Multiple sector size support.</li>
|
||||
<li>Read-only, minimized API, buffer configuration and etc...</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h3>Application Interface</h3>
|
||||
<p>FatFs/Tiny-FatFs module provides following functions.</p>
|
||||
<p>FatFs module provides following functions.</p>
|
||||
<ul>
|
||||
<li><a href="en/mount.html">f_mount</a> - Register/Unregister a Work Area</li>
|
||||
<li><a href="en/open.html">f_open</a> - Open/Create a File</li>
|
||||
@ -56,10 +57,10 @@
|
||||
<li><a href="en/rename.html">f_rename</a> - Rename/Move a File or Directory</li>
|
||||
<li><a href="en/mkfs.html">f_mkfs</a> - Create a File System on the Drive</li>
|
||||
<li><a href="en/forward.html">f_forward</a> - Forward file data to the stream directly</li>
|
||||
<li><a href="en/gets.html">fgets</a> - Read a string</li>
|
||||
<li><a href="en/putc.html">fputc</a> - Write a character</li>
|
||||
<li><a href="en/puts.html">fputs</a> - Write a string</li>
|
||||
<li><a href="en/printf.html">fprintf</a> - Write a formatted string</li>
|
||||
<li><a href="en/gets.html">f_gets</a> - Read a string</li>
|
||||
<li><a href="en/putc.html">f_putc</a> - Write a character</li>
|
||||
<li><a href="en/puts.html">f_puts</a> - Write a string</li>
|
||||
<li><a href="en/printf.html">f_printf</a> - Write a formatted string</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
@ -67,7 +68,7 @@
|
||||
|
||||
<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. The low level disk I/O module with this interface must be provided by user. The sample drivers are also available in the next resources.</p>
|
||||
<p>Since the 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. The low level disk I/O module is not a part of FatFs module and it must be provided by user. The sample drivers are also available in the resources.</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>
|
||||
@ -81,20 +82,22 @@
|
||||
|
||||
<div class="para">
|
||||
<h3>Resources</h3>
|
||||
<p>The FatFs/Tiny-FatFs module is a free software and is opened for education, research and development. You can use, modify and/or republish it for personal, non-profit or commercial use without any restriction under your responsibility.</p>
|
||||
<p>The FatFs module is a free software and is opened for education, research and development. You can use, modify and/or republish it for personal, non-profit or commercial use without any restriction under your responsibility.</p>
|
||||
<ul>
|
||||
<li><a href="en/appnote.html">FatFs module application note</a></li>
|
||||
<li><a href="http://elm-chan.org/fsw/ff/ffsample.zip">Sample projects</a> (AVR, LPC2000, H8/300H, TLCS-870/C, PIC and V850ES) <span class="mfd">Oct 22, 2008</span></li>
|
||||
<li><a href="ff007a.zip">FatFs R0.07a</a> | <a href="updates.txt">Updates</a> | <a href="patches.txt">Patches</a> <span class="mfd">Apr 14, 2009</span></li>
|
||||
<li><a href="http://elm-chan.org/fsw/ff/bd/">FatFs User Forum</a></li>
|
||||
<li><a href="en/appnote.html">FatFs module application note</a> <span class="mfd">Apr 14, 2009</span></li>
|
||||
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/">ARM-Projects by Martin THOMAS</a> (examples for LPC2000 and AT91SAM)</li>
|
||||
<li><a href="img/rwtest.png">Benchmark 1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
|
||||
<li><a href="img/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li>
|
||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</li>
|
||||
<li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to Use MMC/SDC</a></li>
|
||||
<li>Previous versions: <a href="ff007.zip">R0.07</a> | <a href="ff006.zip">R0.06</a> | <a href="ff001-005a.zip">Earlyer than R0.06</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
<p class="foot"><a href="../../cc_e.html">Return</a></p>
|
||||
<p class="foot"><a href="../../fsw_e.html">Return</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -15,26 +15,27 @@
|
||||
<div class="abst">
|
||||
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||
<p>小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, SH, Z80, H8, ARMなど安価なマイコンでそのまま使用可能です。</p>
|
||||
<h4>FatFsの特徴</h4>
|
||||
<ol>
|
||||
<li>ファイル・システム用とファイルI/O用バッファを分離し、複数ファイルの高速アクセスに適する</li>
|
||||
<li>複数ドライブ、複数パーテーションをサポート</li>
|
||||
<h4>FatFsモジュールの特徴</h4>
|
||||
<ul>
|
||||
<li>FAT12, FAT16, FAT32に対応</li>
|
||||
<li>8.3形式ファイル名に対応(LFNは未対応)</li>
|
||||
<li>2種類のパーテーショニング形式(FDISKおよびSFD)に対応</li>
|
||||
<li>8/16ビットマイコン向けにコードを最適化</li>
|
||||
</ol>
|
||||
<h4>Tiny-FatFsの特徴(FatFsとの相違)</h4>
|
||||
<ol>
|
||||
<li>RAMの使用量を削減し、小メモリ・システム(RAM:1KB)にも対応</li>
|
||||
<li>単一ドライブのみサポート</li>
|
||||
</ol>
|
||||
<li>複数のボリューム(物理ドライブ・区画)に対応</li>
|
||||
<li>2種類の区画フォーマット(FDISKとSuper-floppy)に対応</li>
|
||||
<li>多くの構成オプション:
|
||||
<ul>
|
||||
<li>長いファイル名(LFN)</li>
|
||||
<li>複数のコード・ページ</li>
|
||||
<li>マルチタスク対応</li>
|
||||
<li>マルチ・セクタ・サイズ対応</li>
|
||||
<li>リードオンリー、一部機能の削除、バッファ構成等...</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h3>上位レイヤI/F</h3>
|
||||
<p>FatFs/Tiny-FatFsモジュールは、次のファイル操作関数を提供しています。</p>
|
||||
<p>FatFsモジュールは、次のファイル操作関数を提供しています。</p>
|
||||
<ul>
|
||||
<li><a href="ja/mount.html">f_mount</a> - ワークエリアの登録・削除</li>
|
||||
<li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li>
|
||||
@ -55,17 +56,17 @@
|
||||
<li><a href="ja/rename.html">f_rename</a> - ファイル/ディレクトリの名前変更・移動</li>
|
||||
<li><a href="ja/mkfs.html">f_mkfs</a> - ディスクのフォーマット</li>
|
||||
<li><a href="ja/forward.html">f_forward</a> - ファイル・データをストリーム関数に直接転送する</li>
|
||||
<li><a href="ja/gets.html">fgets</a> - 文字列の読み込み</li>
|
||||
<li><a href="ja/putc.html">fputc</a> - 文字の書き込み</li>
|
||||
<li><a href="ja/puts.html">fputs</a> - 文字列の書き込み</li>
|
||||
<li><a href="ja/printf.html">fprintf</a> - 書式化文字列の書き込み</li>
|
||||
<li><a href="ja/gets.html">f_gets</a> - 文字列の読み込み</li>
|
||||
<li><a href="ja/putc.html">f_putc</a> - 文字の書き込み</li>
|
||||
<li><a href="ja/puts.html">f_puts</a> - 文字列の書き込み</li>
|
||||
<li><a href="ja/printf.html">f_printf</a> - 書式化文字列の書き込み</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h3>下位レイヤI/F</h3>
|
||||
<p>FatFs/Tiny-FatFsモジュールは、物理ドライブへのアクセスや現在時刻を得るため、下位レイヤに次のインターフェースを要求します。これらのインターフェースを持つそれぞれの記録メディアに対応したディスクI/Oモジュールは、ユーザにより用意する必要があります。資料にサンプル・ドライバあり。</p>
|
||||
<p>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>
|
||||
@ -79,20 +80,22 @@
|
||||
|
||||
<div class="para">
|
||||
<h3>資料</h3>
|
||||
<p>FatFs/Tiny-FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人・非商用・商用)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。</p>
|
||||
<p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人・非商用・商用)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。</p>
|
||||
<ul>
|
||||
<li><a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a></li>
|
||||
<li><a href="http://elm-chan.org/fsw/ff/ffsample.zip">サンプル・プロジェクト</a> (AVR, LPC2000, H8/300H, TLCS-870/C, PIC, V850ES) <span class="mfd">2008. 10. 22</span></li>
|
||||
<li><a href="ff007a.zip">FatFs R0.07a</a> | <a href="updates.txt">変更点</a> | <a href="patches.txt">パッチ</a> <span class="mfd">2009. 4. 14</span></li>
|
||||
<li><a href="http://elm-chan.org/fsw/ff/bd/">ユーザ・フォーラム</a></li>
|
||||
<li><a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a> <span class="mfd">2009. 4. 14</span></li>
|
||||
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/">ARM-Projects by Martin THOMAS</a> (LPC2000 and AT91SAM)</li>
|
||||
<li><a href="img/rwtest.png">パフォーマンス・テスト1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
|
||||
<li><a href="img/rwtest2.png">パフォーマンス・テスト2</a> (LPC2368/72MHz with MMC via MCI)</li>
|
||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解には必読)</li>
|
||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解・実装に必要な唯一のリファレンス)</li>
|
||||
<li><a href="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li>
|
||||
<li>以前のバージョン: <a href="ff007.zip">R0.07</a> | <a href="ff006.zip">R0.06</a> | <a href="ff001-005a.zip">R0.06以前</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
<p class="foot"><a href="../../cc.html">戻る</a></p>
|
||||
<p class="foot"><a href="../../fsw.html">戻る</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
* {margin: 0; padding: 0; border-width: 0;}
|
||||
body {margin: 8px; background-color: #e0ffff; font-color: black; line-height: 133%; max-width: 1024px;}
|
||||
body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}
|
||||
a:link {color: blue;}
|
||||
a:visited {color: darkmagenta;}
|
||||
a:hover {background-color: #a0ffff;}
|
||||
@ -10,7 +10,7 @@ p {margin: 0 0 0.3em 1em;}
|
||||
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;}
|
||||
pre {margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; background-color: white;}
|
||||
tt {margin: 0 0.2em;}
|
||||
ol {margin: 0 2em;}
|
||||
ul {margin: 0 2em;}
|
||||
@ -45,7 +45,7 @@ small {font-size: 80%;}
|
||||
.indent {margin-left: 2em;}
|
||||
|
||||
/* Tables */
|
||||
table {margin: 4px; border-collapse: collapse; border-style: solid; border-width: 2px; border-color: black; }
|
||||
table {margin: 0.5em 1em; border-collapse: collapse; border-style: solid; border-width: 2px; border-color: black; }
|
||||
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;}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Common style sheet for Tech Notes */
|
||||
|
||||
* {margin: 0; padding: 0; border-width: 0;}
|
||||
body {margin: 8px; background-color: #e0ffff; font-color: black; line-height: 150%; letter-spacing: 1px; max-width: 1024px;}
|
||||
body {margin: 8px; background-color: #e0ffff; font-color: black; font-family:"MS P明朝", serif; line-height: 150%; letter-spacing: 1px; max-width: 1024px;}
|
||||
a:link {color: blue;}
|
||||
a:visited {color: darkmagenta;}
|
||||
a:hover {background-color: #a0ffff;}
|
||||
@ -13,7 +13,7 @@ p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
|
||||
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;}
|
||||
pre {margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; background-color: white;}
|
||||
tt {margin: 0 0.2em; letter-spacing: 0;}
|
||||
ol {margin: 0 2em;}
|
||||
ul {margin: 0 2em;}
|
||||
@ -40,15 +40,15 @@ h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0
|
||||
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
|
||||
hr.hds {clear: both; margin-bottom: 1em;}
|
||||
|
||||
h2 {font-size: 1.5em; font-family: sans-serif; margin: 0 0 0.5em;}
|
||||
h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;}
|
||||
h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;}
|
||||
h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}
|
||||
h2 {font-size: 1.5em; font-family: "MS Pゴシック",sans-serif; margin: 0 0 0.5em;}
|
||||
h3 {font-size: 1.5em; font-family: "MS Pゴシック",sans-serif; margin: 1.5em 0 0.5em;}
|
||||
h4 {font-size: 1.2em; font-family: "MS Pゴシック",sans-serif; margin: 1em 0 0.2em;}
|
||||
h5 {font-size: 1em; font-family: "MS Pゴシック",sans-serif; margin: 0.5em 0 0em;}
|
||||
small {font-size: 80%;}
|
||||
.indent {margin-left: 2em;}
|
||||
|
||||
/* Tables */
|
||||
table {margin: 4px; border-collapse: collapse; border-style: solid; border-width: 2px; border-color: black; letter-spacing: 0;}
|
||||
table {margin: 0.5em 1em; border-collapse: collapse; border-style: solid; border-width: 2px; border-color: black; letter-spacing: 0;}
|
||||
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;}
|
||||
|
||||
@ -17,71 +17,121 @@
|
||||
<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 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 and int is 16 or 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>
|
||||
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.</li>
|
||||
<li>Size of integer types<br>
|
||||
The FatFs module assumes that size of char/short/long are 8/16/32-bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>Memory Usage (R0.06)</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>
|
||||
<h3>Memory Usage (R0.07)</h3>
|
||||
<table class="lst2">
|
||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>MSP430</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th><th>ARM7</th></tr>
|
||||
<tr><td>Compiler</td><td>gcc(WinAVR)</td><td>CH38</td><td>gcc(C30)</td><td>CL430</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>gcc(WinARM)</td></tr>
|
||||
<tr><td>_MCU_ENDIAN</td><td>1</td><td>2</td><td>2</td><td>2</td><td>1</td><td>1</td><td>2</td><td>2</td></tr>
|
||||
<tr class="lst3"><td>FatFs Code (Full, R/W)</td><td>9280</td><td>9348</td><td>9387</td><td></td><td></td><td>6728</td><td>7538</td><td>11820</td></tr>
|
||||
<tr><td>FatFs Code (Min, R/W)</td><td>5814</td><td>5798</td><td>5913</td><td></td><td></td><td>4094</td><td>4742</td><td></td></tr>
|
||||
<tr><td>FatFs Code (Full, R/O)</td><td>4402</td><td>4236</td><td>4371</td><td></td><td></td><td>3054</td><td>3474</td><td></td></tr>
|
||||
<tr><td>FatFs Code (Min, R/O)</td><td>3066</td><td>3158</td><td>3213</td><td></td><td></td><td>2172</td><td>2630</td><td></td></tr>
|
||||
<tr><td>FatFs Work (Static)</td><td>D*2+2</td><td>D*4+2</td><td>D*2+2</td><td></td><td></td><td>D*4+2</td><td>D*4+2</td><td></td></tr>
|
||||
<tr><td>FatFs Work (Dynamic)</td><td>D*554+F*544</td><td>D*554+F*550</td><td>D*554+F*544</td><td></td><td></td><td>D*554+F*550</td><td>D*554+F*550</td><td>D*554+F*550</td></tr>
|
||||
<tr class="lst3"><td>Tiny-FatFs Code (Full, R/W)</td><td>7628</td><td>7668</td><td>7560</td><td>7108</td><td>9501</td><td>5978</td><td>6640</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Code (Min, R/W)</td><td>4684</td><td>4820</td><td>4698</td><td>4390</td><td>6322</td><td>3678</td><td>4236</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Code (Full, R/O)</td><td>3634</td><td>3600</td><td>3618</td><td>3382</td><td>4554</td><td>2722</td><td>3072</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Code (Min, R/O)</td><td>2524</td><td>2700</td><td>2601</td><td>2398</td><td>3390</td><td>1862</td><td>2300</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Wrok (Static)</td><td>4</td><td>6</td><td>4</td><td>4</td><td>4</td><td>6</td><td>6</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Work (Dynamic)</td><td>544+F*28</td><td>544+F*32</td><td>544+F*28</td><td>544+F*28</td><td>544+F*28</td><td>544+F*32</td><td>544+F*32</td><td>544+F*32</td></tr>
|
||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th><th>ARM7TDMI</th><th>IA-32</th></tr>
|
||||
<tr><td>Compiler</td><td>gcc(WinAVR)</td><td>CH38</td><td>gcc(C30)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>gcc(WinARM)</td><td>MSC</td></tr>
|
||||
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>1</td></tr>
|
||||
<tr class="lst3"><td>ROM (Full, R/W)</td><td>11136</td><td>10356</td><td>10838</td><td>15167</td><td>7682</td><td>8654</td><td>10628</td><td>7232</td></tr>
|
||||
<tr><td>ROM (Min, R/W)</td><td>7072</td><td>6696</td><td>7007</td><td>9800</td><td>4634</td><td>5570</td><td>6564</td><td>4647</td></tr>
|
||||
<tr><td>ROM (Full, R/O)</td><td>5218</td><td>4626</td><td>4949</td><td>6786</td><td>3528</td><td>3826</td><td>4676</td><td>3267</td></tr>
|
||||
<tr><td>ROM (Min, R/O)</td><td>3626</td><td>3418</td><td>3536</td><td>4941</td><td>2558</td><td>2874</td><td>3272</td><td>2397</td></tr>
|
||||
<tr><td>RAM (Static)</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
|
||||
<tr><td>RAM (Dynamic)<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
|
||||
<tr><td>RAM (Dynamic)<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td></tr>
|
||||
</table>
|
||||
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, D means number of volumes and F means number of open files. All samples are optimezed in code size.</p>
|
||||
<pre>
|
||||
_FS_READONLY 0 (R/W), 1 (R/O)
|
||||
_FS_MINIMIZE 0 (Full function), 3 (Minimized function)
|
||||
_USE_STRFUNC 0 (Disable string functions)
|
||||
_USE_MKFS 0 (Disable f_mkfs function)
|
||||
_USE_FORWARD 0 (Disable f_forward function)
|
||||
_CODE_PAGE 932 (Japanese Shift-JIS)
|
||||
_USE_LFN 0 (Disable LFN)
|
||||
_MULTI_PARTITION 0 (Single partition per drive)
|
||||
_FS_REENTRANT 0 (Disable reentrancy)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>Module Size Reduction</h3>
|
||||
<p>Follwing table shows which function is removed by configuration options for the module size reduction.</p>
|
||||
<table class="lst2">
|
||||
<tr><td rowspan="2">Function</td><td colspan="3">_FS_MINIMIZE</td><td>_FS_READONLY</td><td>_USE_STRFUNC</td><td>_USE_MKFS</td><td>_USE_FORWARD</td></tr>
|
||||
<tr><td>1</td><td>2</td><td>3</td><td>1</td><td>0</td><td>0</td><td>0</td></tr>
|
||||
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_write</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_sync</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_lseek</td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_opendir</td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_readdir</td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_stat</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getfree</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_truncate</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_unlink</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_mkdir</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_chmod</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_utime</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_rename</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_mkfs</td><td></td><td></td><td></td><td>x</td><td></td><td>x</td><td></td></tr>
|
||||
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td></tr>
|
||||
<tr><td>f_putc</td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td></tr>
|
||||
<tr><td>f_puts</td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td></tr>
|
||||
<tr><td>f_printf</td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td></tr>
|
||||
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td>x</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. 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>
|
||||
<tr><td><= 64MB</td><td>FAT12</td></tr>
|
||||
<tr><td>128MB - 2GB</td><td>FAT16</td></tr>
|
||||
<tr><td>>= 4GB</td><td>FAT32</td></tr>
|
||||
<h3>Long File Name</h3>
|
||||
<p>The FatFs module supports long file name (LFN) from revision 0.07. The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir function. To enable LFN feature, set <tt>_USE_LFN</tt> to 1 or 2, and add an OEM-Unicode bidirectional code conversion function ff_convert to the project. This function is available in <tt>cc*.c</tt>. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt>_MAX_LFN</tt> corresponding to the available memory size. The size of long file name will reach up to 255 characters so that the <tt>_MAX_LFN</tt> should be set to 255 for full featured LFN operation. When the size of working buffer is insufficient for the given file name, the file function will fail with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant feature, <tt>_USE_LFN</tt> must be set to 2. In this case, the file funciton allocates the working buffer on the stack. The working buffer occupies <tt>_MAX_LFN * 2 + 1</tt> bytes so that the caller's stack must be a sufficient size considering the working buffer.</p>
|
||||
<table class="lst2 rset">
|
||||
<caption>LFN cfg on ARM7DMI</caption>
|
||||
<tr><th>Code page</th><th>ROM size [bytes]</th></tr>
|
||||
<tr><td>SBCS</td><td>+4719</td></tr>
|
||||
<tr><td>932(Shift-JIS)</td><td>+63755</td></tr>
|
||||
<tr><td>936(GBK)</td><td>+178943</td></tr>
|
||||
<tr><td>949(Korean)</td><td>+141003</td></tr>
|
||||
<tr><td>950(Big5)</td><td>+112631</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 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>
|
||||
<p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows the difference in module size when LFN is enabled with some code pages. We are the Japanese, Chinese and Korean have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN will not able to be implemented to most 8-bit microcontrollers including AVR. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p>
|
||||
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. When enable it on the commercial products, a license from Microsoft may be required depends on the final destination.</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>Re-entrancy</h3>
|
||||
<p>The file operations to the different volume can always work simultaneously regardless of re-entrancy setting. The re-entrancy to the same volume can be enabled with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant must be added to the project. The sample code with documentation is available in <tt>syncobj.c</tt>.</p>
|
||||
<p>When a file function is called while the volume is in use by any other task, the access is blocked until the task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported on some RTOS.</p>
|
||||
<p>There is an exception on f_mount and f_mkfs function. These functions are not re-entrant to the same volume. When use these functions, all other task must close the corresponding file on the volume and avoid to access the volume.</p>
|
||||
<p>Note that this section describes on the re-entrancy of the FatFs module itself. There is no assumtion on the re-entrancy of low level disk I/O module.</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>Duplicated file access</h3>
|
||||
<p>FatFs module does not support the shareing controls of duplicated file access. It is permitted when open method to the file is only read mode. The duplicated open in write mode to a file is always prohibited and open file must not be renamed, deleted, otherwise the FAT structure on the volume can be collapted.</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>Performance effective file access</h3>
|
||||
<p>For good performance on reading/writing files on the small embedded system, application program should consider what process is done in the FatFs module. The file data on the disk is transferred by f_read function in these sequence.</p>
|
||||
<p>For good performance on reading/writing files on the small embedded system, application programmer should consider what process is done in the FatFs module. The file data on the disk is transferred in following sequence by f_read function.</p>
|
||||
<p>Figure 1. Sector miss-aligned read (short)<br>
|
||||
<img src="../img/f1.png" width="490" height="73">
|
||||
<img src="../img/f1.png" width="490" height="73" alt="">
|
||||
</p>
|
||||
<p>Figure 2. Sector miss-aligned read (long)<br>
|
||||
<img src="../img/f2.png" width="490" height="140">
|
||||
<img src="../img/f2.png" width="490" height="140" alt="">
|
||||
</p>
|
||||
<p>Figure 3. Sector aligned read<br>
|
||||
<img src="../img/f3.png" width="490" height="119">
|
||||
<img src="../img/f3.png" width="490" height="119" alt="">
|
||||
</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 file 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 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>
|
||||
<p>The file I/O buffer means a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer on the file system object. The buffer configuration option <tt>_FS_TINY</tt> determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer on the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p>
|
||||
<p>Figure 1 shows that partial sector data is transferred via the file I/O buffer. On long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with disk_read function at a time but the multi sector transfer never across the cluster boundary even if it is contiguous.</p>
|
||||
<p>Therefore taking effort to sector aligned read/write accesss avoids buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer on the tiny configuration so that it can achieve same performance as non tiny configuration with small memory footprint.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h3>Critical section</h3>
|
||||
<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>
|
||||
<h3>Critical Section</h3>
|
||||
<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 disk error, the FAT structure can be collapted. 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="436" alt="fig.4">
|
||||
@ -91,7 +141,7 @@ Figure 5. Minimized critical section<br>
|
||||
<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 being changed will be 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 may 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>
|
||||
@ -99,24 +149,7 @@ Figure 5. Minimized critical section<br>
|
||||
<li>A file created as new or in overwritten remains with length of zero.</li>
|
||||
<li>Efficiency of disk use gets worse due to lost chain.</li>
|
||||
</ul>
|
||||
<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>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<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 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>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 the FAT file system. To support this feature, 512 byte string buffer for file name and Unicode - Local code mutual conversion table which occupies 256KB is required. Therefore memory consumption of code and work area will be increased drastically. The FatFs module currently does not support this feature. The LFN on the FAT file system is a patent of Microsoft. When use 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 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>
|
||||
<p>Each case does not affect the files that not in write mode open. 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 or using f_sync function properly.</p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
@ -60,8 +60,10 @@ FRESULT f_chmod (
|
||||
<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>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
@ -72,7 +74,7 @@ FRESULT f_chmod (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_chmod function changes the attribute of a file or directory. This function is not supported in read-only configuration and minimization level of >=1.</p>
|
||||
<p>The f_chmod function changes the attribute of a file or directory. This function is not available in read-only configuration and minimization level of >=1.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -34,8 +34,10 @@ FRESULT f_close (
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>The file object has been closed successfuly.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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>
|
||||
|
||||
@ -32,6 +32,7 @@ DSTATUS disk_initialize (
|
||||
<div class="para">
|
||||
<h4>Return Values</h4>
|
||||
<p>This function returns a disk status as the result. For details of the disk status, refer to the <a href="dstat.html">disk_status</a> function.</p>
|
||||
<p>This function is called from volume mount process in the FatFs module to manage the media change. Application module should not use this function during FatFs module is active.</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
|
||||
@ -53,11 +53,12 @@ DRESULT disk_ioctl (
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The FatFs module uses only device independent commands described below. Any device dependent function is not used.</p>
|
||||
<p>In read-only configuration, the disk_ioctl function is not needed.</p>
|
||||
<table class="lst">
|
||||
<tr><th>Command</th><th>Description</th></tr>
|
||||
<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately.</td></tr>
|
||||
<tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by Buffer. This command is used in only f_mkfs function.</td></tr>
|
||||
<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. This function is not required in read-only configuration.</p>
|
||||
</td></tr>
|
||||
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by Buffer. This functions is not required in single sector size configuration, _MAX_SS is 512.</td></tr>
|
||||
<tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by Buffer. This function is used in only f_mkfs function.</td></tr>
|
||||
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the memory array in unit of sector into the DWORD variable pointed by Buffer. When the erase block size is unknown or magnetic disk device, return 1. This command is used in only f_mkfs function.</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -29,7 +29,7 @@ DRESULT disk_read (
|
||||
<dt>Drive</dt>
|
||||
<dd>Specifies the physical drive number.</dd>
|
||||
<dt>Buffer</dt>
|
||||
<dd>Pointer to the read buffer to store the read data. The buffer size of number of bytes to be read is required.</dd>
|
||||
<dd>Pointer to the byte array to store the read data. The buffer size of number of bytes to be read is required. The start address specified by upper layer may be aligned or non-aligned.</dd>
|
||||
<dt>SectorNumber</dt>
|
||||
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
||||
<dt>SectorCount</dt>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<pre>
|
||||
DRESULT disk_write (
|
||||
BYTE <em>Drive</em>, /* Physical drive number */
|
||||
const BYTE* <em>Buffer</em>, /* Pointer to the write data */
|
||||
const BYTE* <em>Buffer</em>, /* Pointer to the write data (may be non aligned) */
|
||||
DWORD <em>SectorNumber</em>, /* Sector number to write */
|
||||
BYTE <em>SectorCount</em> /* Number of sectors to write */
|
||||
);
|
||||
@ -29,7 +29,7 @@ DRESULT disk_write (
|
||||
<dt>Drive</dt>
|
||||
<dd>Specifies the physical drive number.</dd>
|
||||
<dt>Buffer</dt>
|
||||
<dd>Pointer to the data to be written.</dd>
|
||||
<dd>Pointer to the byte array to be written. The start address specified by upper layer may be aligned or non-aligned.</dd>
|
||||
<dt>SectorNumber</dt>
|
||||
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
||||
<dt>SectorCount</dt>
|
||||
@ -46,7 +46,7 @@ DRESULT disk_write (
|
||||
<dt>RES_ERROR</dt>
|
||||
<dd>Any hard error occured during the write operation and could not recover it.</dd>
|
||||
<dt>RES_WRPRT</dt>
|
||||
<dd>The disk is write protected.</dd>
|
||||
<dd>The medium is write protected.</dd>
|
||||
<dt>RES_PARERR</dt>
|
||||
<dd>Invalid parameter.</dd>
|
||||
<dt>RES_NOTRDY</dt>
|
||||
|
||||
@ -12,23 +12,23 @@
|
||||
|
||||
<div class="para">
|
||||
<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 like OS oriented file system. All objects on the drive are specified in full path name from the root directory.</p>
|
||||
<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 like OS oriented file system. All objects on the drive are always specified in full path name from the root directory.</p>
|
||||
<pre>
|
||||
|
||||
"[<em>drive#</em>:][/]<em>directory</em>/<em>file</em>"
|
||||
|
||||
"file1.txt" a file on drive 0
|
||||
"file1.txt" A file on the drive 0
|
||||
"/file1.txt" (same as above)
|
||||
"dir1/dir2/file1.txt" a file on drive 0
|
||||
"2:dir3/file2.txt" a file on drive 2
|
||||
"2:/dir5" a directory on drive 2
|
||||
"" the root directory on drive 0
|
||||
"dir1/dir2/file1.txt" A file on the drive 0
|
||||
"2:dir3/file2.txt" A file on the drive 2
|
||||
"2:/dir5" A directory on the drive 2
|
||||
"" The root directory on the drive 0
|
||||
"/" (same as above)
|
||||
"2:" the root directory on drive 2
|
||||
"2:" The root directory on the 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 '\'. Heading '/' is ignored and can be omitted.</p>
|
||||
<p>The logical drive number is specified in a numeral with a colon. When the drive number is omitted, it is assumed 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>
|
||||
<p>The FatFs module supports long file name and 8.3 format file name. The long file name can be handled when _USE_LFN option is selected. The sub directories are separated with a / or \. Heading separator is ignored and it may be exist or omitted.</p>
|
||||
<p>The logical drive number is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0:).</p>
|
||||
</div>
|
||||
|
||||
<p><br></p>
|
||||
@ -51,7 +51,7 @@ const PARTITION Drives[] = {
|
||||
<li>Only pri-partition (0-3) can be mounted.</li>
|
||||
<li>When the physical drive have no partition table (super floppy format), the partition number is ignored.</li>
|
||||
<li>The physical drive that has two or more logical drives must be fixed drive.</li>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
@ -45,8 +45,10 @@ FRESULT f_forward (
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>The function denied due to the file has been opened in non-read mode.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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>
|
||||
@ -57,8 +59,8 @@ FRESULT f_forward (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_forward() is for only Tiny-FatFs and not supported on FatFs. It reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt>*ByteFwd < ByteToFwd</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during transfering process.</p>
|
||||
<p>This function is available when <tt>_USE_FORWARD == 1</tt>.</p>
|
||||
<p>The f_forward function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt>*ByteFwd < ByteToFwd</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p>
|
||||
<p>This function is available on <tt>_USE_FORWARD == 1</tt> and <tt>_FS_TINY == 1</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -80,7 +82,7 @@ UINT out_stream ( /* Returns number of bytes sent or stream status */
|
||||
if (btf == 0) { /* Sense call */
|
||||
/* Return stream status (0: Busy, 1: Ready) */
|
||||
/* When once it returned ready to sense call, it must accept a byte at least */
|
||||
/* at subsequent transfer call, or f_forward will result FR_RW_ERROR. */
|
||||
/* at subsequent transfer call, or f_forward will fail with FR_INT_ERROR. */
|
||||
if (FIFO_READY) cnt = 1;
|
||||
}
|
||||
else { /* Transfer call */
|
||||
|
||||
@ -44,8 +44,10 @@ FRESULT f_getfree (
|
||||
<dd>The drive number is invalid.</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_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
@ -56,7 +58,7 @@ FRESULT f_getfree (
|
||||
|
||||
<div class="para">
|
||||
<h4>Descriptions</h4>
|
||||
<p>The f_getfree function gets number of free clusters on the drive. The member <tt>csize</tt> in the file system object is refreting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When <tt>_USE_FSINFO</tt> option is enabled, this function might return an inaccurate free cluster count on FAT32 volume. When it is disabled, this function will take a time on FAT32 volume.</p>
|
||||
<p>The f_getfree function gets number of free clusters on the drive. The member <tt>csize</tt> in the file system object is refreting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When FSInfo structure on FAT32 volume is not in sync, this function can return an incorrect free cluster count.</p>
|
||||
<p>This function is not supported in read-only configuration and minimization level of >= 1.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
<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 - fgets</title>
|
||||
<title>FatFs - f_gets</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>fgets</h2>
|
||||
<p>The fgets reads a string from the file.</p>
|
||||
<h2>f_gets</h2>
|
||||
<p>The f_gets reads a string from the file.</p>
|
||||
<pre>
|
||||
char* fgets (
|
||||
char* f_gets (
|
||||
char* <em>Str</em>, /* Read buffer */
|
||||
int <em>Size</em>, /* Size of the read buffer */
|
||||
FIL* <em>FileObject</em> /* File object */
|
||||
@ -43,14 +43,14 @@ char* fgets (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The fgets() is a wrapper function of <a href="read.html">f_read()</a>. The read operation continues until a <tt>'\n'</tt> is stored, reached end of file or buffer is filled with Size - 1 characters. The read string is terminated with a <tt>'\0'</tt>. When the file is already reached end of file or any error occured during read operation, fgets() returns a <tt>NULL</tt>. The EOF status can be examined with <tt>feof()</tt> macro.</p>
|
||||
<p>The f_gets() is a wrapper function of <a href="read.html">f_read()</a>. The read operation continues until a <tt>'\n'</tt> is stored, reached end of file or buffer is filled with Size - 1 characters. The read string is terminated with a <tt>'\0'</tt>. When the file has reached end of the file or any error occured during read operation, f_gets() returns a <tt>NULL</tt>. The EOF and error status can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macro.</p>
|
||||
<p>This function is available when <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\r'</tt> contained in the file is stripped.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>References</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">fputc</a>, <a href="puts.html">fputs</a>, <a href="printf.html">fprintf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
|
||||
<pre>
|
||||
FRESULT f_lseek (
|
||||
FIL* <em>FileObject</em>, /* Pointer to the file object structure *
|
||||
DWORD <em>Offset</em> /* File offset in unit of byte *
|
||||
FIL* <em>FileObject</em>, /* Pointer to the file object structure */
|
||||
DWORD <em>Offset</em> /* File offset in unit of byte */
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@ -38,8 +38,10 @@ FRESULT f_lseek (
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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>
|
||||
@ -50,11 +52,10 @@ FRESULT f_lseek (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<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 size is extended to the offset and the data in the extended area is undefined. This is suitable to create a large file quickly, for fast write operation without cluster allocation delay. After the f_lseek 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 expected value, any of the followings has been occured.</p>
|
||||
<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 size is extended to the offset and the data in the extended area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek 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 expected value, 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>
|
||||
|
||||
@ -74,6 +75,23 @@ FRESULT f_lseek (
|
||||
// Move to end of the file to append data
|
||||
res = f_lseek(&file, file.fsize);
|
||||
</pre>
|
||||
<pre>
|
||||
// Cluster pre-allocation (to prevent data overrun on streaming write)
|
||||
|
||||
res = f_open(&file, recfile, FA_CREATE_NEW | FA_WRITE); // Create a file
|
||||
|
||||
res = f_lseek(&file, PRE_SIZE); // Pre-allocate clusters
|
||||
if (res || file.fptr != PRE_SIZE) .... // Check if the file is extended corrctly
|
||||
|
||||
res = f_lseek(&file, DATA_START); // Record data stream without cluster allocation delay
|
||||
...
|
||||
|
||||
res = f_truncate(&file); // Truncate unused area
|
||||
res = f_lseek(&file, 0); // Put file header
|
||||
...
|
||||
|
||||
res = f_close(&file);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -48,8 +48,10 @@ FRESULT f_mkdir (
|
||||
<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>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
|
||||
@ -30,7 +30,7 @@ FRESULT f_mkfs (
|
||||
<dt>PartitioningRule</dt>
|
||||
<dd>When 0 is given, a partition table is created into first sector on the drive and then the file system is created on the partition. This is called FDISK format. When 1 is given, the file system starts from the first sector without partition table. This is often called super floppy (SFD) format.</dd>
|
||||
<dt>AllocSize</dt>
|
||||
<dd>Specifies allocation unit size in number of bytes per cluster. The value must be power of 2 in range of from 512 to 32768. FAT64 (64KB/cluster on FAT16) is not supported.</dd>
|
||||
<dd>Specifies allocation unit size in number of bytes per cluster. The value must be 0 or power of 2 in range of from 512 to 32768. When 0 is specified, the cluster size is determined by the drive size. FAT64 (64KB/cluster on FAT16) cannot be created by this function.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -47,8 +47,8 @@ FRESULT f_mkfs (
|
||||
<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 disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_MKFS_ABORTED</dt>
|
||||
<dd>The function aborted before start in format due to a reason as follows.
|
||||
<ul>
|
||||
@ -62,9 +62,9 @@ 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 an argument. The FDISK format is recommended for most case. This function currently <em>does not support multiple partition</em>, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.</p>
|
||||
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the drive and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the drive size and the specified cluster size. The cluster size affects performance of file system and large cluster increases the performance, so that 32768 bytes per cluster is recommended for most case except for small drive.</p>
|
||||
<p>This function is supported on only FatFs with _USE_MKFS option.</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 an argument. The FDISK format is recommended for the most case. This function currently <em>does not support multiple partition</em>, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.</p>
|
||||
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the drive and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the partition size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p>
|
||||
<p>This function is supported on only _USE_MKFS option is selected.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ FRESULT f_mount (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>Drive</dt>
|
||||
<dd>Logical drive number (0-9) to register/unregister the work area. Always 0 for Tiny-FatFs.</dd>
|
||||
<dd>Logical drive number (0-9) to register/unregister the work area.</dd>
|
||||
<dt>FileSystemObject</dt>
|
||||
<dd>Pointer to the work area (file system object) to be registered.</dd>
|
||||
</dl>
|
||||
|
||||
@ -69,8 +69,10 @@ FRESULT f_open (
|
||||
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>Write mode open or creation under the medium is write protected.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
@ -81,9 +83,9 @@ FRESULT f_open (
|
||||
|
||||
<div class="para">
|
||||
<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. If modified file is not closed correctly, the file may be collapsed.</p>
|
||||
<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. If modified file is not closed, the file may be collapsed.</p>
|
||||
<p>Before using any file function, a work area (file system object) must be given to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</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>
|
||||
<p>The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not available in read-only configuration.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -45,8 +45,10 @@ FRESULT f_opendir (
|
||||
<dd>The drive number is invalid.</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_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
<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 - fprintf</title>
|
||||
<title>FatFs - f_printf</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>fprintf</h2>
|
||||
<p>The fprintf function writes formatted string to the file.</p>
|
||||
<h2>f_printf</h2>
|
||||
<p>The f_printf function writes formatted string to the file.</p>
|
||||
<pre>
|
||||
int fprintf (
|
||||
int f_printf (
|
||||
FIL* <em>FileObject</em>, /* File object */
|
||||
const char* <em>Foramt</em>, /* Format stirng */
|
||||
...
|
||||
@ -44,7 +44,7 @@ int fprintf (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The fprintf() is a wrapper function of <a href="putc.html">fputc()</a> and <a href="puts.html">fputs()</a>. The format control directive is a sub-set of standard library. It supports <tt>c s d u X</tt> for the data type, <tt>l</tt> for the precision and <tt>0</tt> for the flags.</p>
|
||||
<p>The f_printf() is a wrapper function of <a href="putc.html">f_putc()</a> and <a href="puts.html">f_puts()</a>. The format control directive is a sub-set of standard library. It supports <tt>c s d u X</tt> for the data type, <tt>l</tt> for the precision and <tt>0</tt> for the flags.</p>
|
||||
<p>This function is available when read-write configuration and <tt>_USE_STRFUNC</tt> is 1 or 2.</p>
|
||||
</div>
|
||||
|
||||
@ -52,19 +52,19 @@ int fprintf (
|
||||
<div class="para">
|
||||
<h4>Example</h4>
|
||||
<pre>
|
||||
fprintf(&fil, "%6d", -200); // " -200"
|
||||
fprintf(&fil, "%02u", 5); // "05"
|
||||
fprintf(&fil, "%ld", 12345678L); // "12345678"
|
||||
fprintf(&fil, "%08lX", 1194684UL); // "00123ABC"
|
||||
fprintf(&fil, "%s", "String"); // "String"
|
||||
fprintf(&fil, "%c", 'a'); // "a"
|
||||
f_printf(&fil, "%6d", -200); // " -200"
|
||||
f_printf(&fil, "%02u", 5); // "05"
|
||||
f_printf(&fil, "%ld", 12345678L); // "12345678"
|
||||
f_printf(&fil, "%08lX", 1194684UL); // "00123ABC"
|
||||
f_printf(&fil, "%s", "String"); // "String"
|
||||
f_printf(&fil, "%c", 'a'); // "a"
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>References</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">fputc</a>, <a href="puts.html">fputs</a>, <a href="gets.html">fgets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
<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 - fputc</title>
|
||||
<title>FatFs - f_putc</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>fputc</h2>
|
||||
<p>The fputc funciton puts a character to the file.</p>
|
||||
<h2>f_putc</h2>
|
||||
<p>The f_putc funciton puts a character to the file.</p>
|
||||
<pre>
|
||||
int fputc (
|
||||
int f_putc (
|
||||
int <em>Chr</em>, /* A character to put */
|
||||
FIL* <em>FileObject</em> /* File object */
|
||||
);
|
||||
@ -40,13 +40,13 @@ int fputc (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The fputc() is a wrapper function of <a href="write.html">f_write()</a>. This function is available when read-write configuration and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set 2, a <tt>'\n'</tt> is extended to <tt>"\r\n"</tt>.</p>
|
||||
<p>The f_putc() is a wrapper function of <a href="write.html">f_write()</a>. This function is available when read-write configuration and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set 2, a <tt>'\n'</tt> is extended to <tt>"\r\n"</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Reference</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="puts.html">fputs</a>, <a href="printf.html">fprintf</a>, <a href="gets.html">fgets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
<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 - fputs</title>
|
||||
<title>FatFs - f_puts</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>fputs</h2>
|
||||
<p>The fputs function writes a string to the file.</p>
|
||||
<h2>f_puts</h2>
|
||||
<p>The f_puts function writes a string to the file.</p>
|
||||
<pre>
|
||||
int fputs (
|
||||
int f_puts (
|
||||
const char* <em>Str</em>, /* String */
|
||||
FIL* <em>FileObject</em> /* File object */
|
||||
);
|
||||
@ -40,13 +40,13 @@ int fputs (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The fputs() is a wrapper function of <a href="putc.html">fputc()</a>. This function is available when read-write configuration and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set 2, a <tt>'\n'</tt> is extended to <tt>"\r\n"</tt>.</p>
|
||||
<p>The f_puts() is a wrapper function of <a href="putc.html">f_putc()</a>. This function is available when read-write configuration and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set 2, a <tt>'\n'</tt> is extended to <tt>"\r\n"</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Reference</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">fputc</a>, <a href="printf.html">fprintf</a>, <a href="gets.html">fgets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
@ -45,8 +45,10 @@ FRESULT f_read (
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>The function denied due to the file has been opened in non-read mode.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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,7 +15,7 @@
|
||||
<p>The f_readdir function reads directory entries.</p>
|
||||
<pre>
|
||||
FRESULT f_readdir (
|
||||
DIR* <em>DirObject</em>, /* Pointer to the directory object structure */
|
||||
DIR* <em>DirObject</em>, /* Pointer to the open directory object */
|
||||
FILINFO* <em>FileInfo</em> /* Pointer to the file information structure */
|
||||
);
|
||||
</pre>
|
||||
@ -25,7 +25,7 @@ FRESULT f_readdir (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>DirObject</dt>
|
||||
<dd>Pointer to the open directory strcture.</dd>
|
||||
<dd>Pointer to the open directory object.</dd>
|
||||
<dt>FileInfo</dt>
|
||||
<dd>Pointer to the file information structure to store the read item.</dd>
|
||||
</dl>
|
||||
@ -39,8 +39,10 @@ FRESULT f_readdir (
|
||||
<dd>The function succeeded.</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_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
<dd>The directory object is invalid.</dd>
|
||||
</dl>
|
||||
@ -49,31 +51,52 @@ 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. When a null pointer is given to the <tt>FileInfo</tt>, the read index of the directory object will be rewinded.</p>
|
||||
<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to calling the f_readdir function. The <tt>lfname</tt> is a pointer to the string buffer to return the long file name. The <tt>lfsize</tt> is the size of the string buffer. When either the size of specified buffer or LFN working buffer is insufficient to store the LFN or LFN is not exist, a null string will be returned. When <tt>lfname</tt> is a NULL, nothing is returned.</p>
|
||||
<p>For details on the file informations, refer to the <tt>FILINFO</tt>. This function is not supported in minimization level of >=2.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Sample Code</h4>
|
||||
<pre>
|
||||
void scan_files (char* path)
|
||||
FRESULT scan_files (char* path)
|
||||
{
|
||||
FILINFO finfo;
|
||||
DIR dirs;
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
int i;
|
||||
char *fn;
|
||||
#if _USE_LFN
|
||||
static char lfn[_MAX_LFN * (_DF1S ? 2 : 1) + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof(lfn);
|
||||
#endif
|
||||
|
||||
if (f_opendir(&dirs, path) == FR_OK) {
|
||||
|
||||
res = f_opendir(&dir, path);
|
||||
if (res == FR_OK) {
|
||||
i = strlen(path);
|
||||
while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) {
|
||||
if (finfo.fattrib & AM_DIR) {
|
||||
sprintf(&path[i], "/%s", &finfo.fname[0]);
|
||||
scan_files(path);
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &fno);
|
||||
if (res != FR_OK || fno.fname[0] == 0) break;
|
||||
#if _USE_LFN
|
||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||
#else
|
||||
fn = fno.fname;
|
||||
#endif
|
||||
if (fno.fattrib & AM_DIR) {
|
||||
sprintf(&path[i], "/%s", fn);
|
||||
res = scan_files(path);
|
||||
if (res != FR_OK) break;
|
||||
path[i] = 0;
|
||||
} else {
|
||||
printf("%s/%s\n", path, &finfo.fname[0]);
|
||||
printf("%s/%s\n", path, fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -38,7 +38,7 @@ FRESULT f_rename (
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_NO_FILE</dt>
|
||||
<dd>Could not find the file nor directory.</dd>
|
||||
<dd>Could not find the old name.</dd>
|
||||
<dt>FR_NO_PATH</dt>
|
||||
<dd>Could not find the path.</dd>
|
||||
<dt>FR_INVALID_NAME</dt>
|
||||
@ -47,12 +47,16 @@ FRESULT f_rename (
|
||||
<dd>The drive number is invalid.</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_EXIST</dt>
|
||||
<dd>There is an object that have a name equal to new name.</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>The new name could not be created due to any reason.</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>The medium is write protected.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
@ -64,17 +68,16 @@ FRESULT f_rename (
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>Rename a file or directory and can move it to other directory. Logical drive number is determined by old name, new name must not contain logical drive number. This function is not supported in read-only configuration or minimization level of >= 1.</p>
|
||||
<p>Note: In this revision, moving any directory to other directory collapses the FAT structure on the disk.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Example</h4>
|
||||
<pre>
|
||||
// Rename file or directory
|
||||
// Rename a file or directory
|
||||
f_rename("oldname.txt", "newname.txt");
|
||||
|
||||
// Rename and move file to other directory simultaneously
|
||||
// Rename and move a file or directory to other directory simultaneously
|
||||
f_rename("oldname.txt", "dir1/newname.txt");
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -12,27 +12,21 @@
|
||||
|
||||
<div class="para">
|
||||
<h2>DIR</h2>
|
||||
<p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir and f_readdir functions.</p>
|
||||
<h4>FatFs</h4>
|
||||
<p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir, f_readdir function.</p>
|
||||
<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 */
|
||||
} 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 id; /* Owner file system mount ID */
|
||||
WORD index; /* Current index number */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
DWORD sclust; /* Table start cluster (0:Static table) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index (0xFFFF:No LFN) */
|
||||
#endif
|
||||
} DIR;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -13,47 +13,36 @@
|
||||
<div class="para">
|
||||
<h2>FATFS</h2>
|
||||
<p>The <tt>FATFS</tt> structure holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Following members are in standard configuration. There is no member that can be changed from the application program.</p>
|
||||
<h4>FatFs</h4>
|
||||
<pre>
|
||||
typedef struct _FATFS {
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
DWORD sects_fat; /* Sectors per fat */
|
||||
DWORD max_clust; /* Maximum cluster# + 1 */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (cluster# for FAT32) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
BYTE fs_type; /* FAT type (0:Not mounted) */
|
||||
BYTE csize; /* 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 fs_type; /* FAT sub type */
|
||||
BYTE drive; /* Physical drive number */
|
||||
BYTE csize; /* Number of sectors per cluster */
|
||||
BYTE n_fats; /* Number of FAT copies */
|
||||
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
||||
BYTE pad1;
|
||||
BYTE win[512]; /* Disk access window for Directory/FAT */
|
||||
} FATFS;
|
||||
</pre>
|
||||
|
||||
<h4>Tiny-FatFs</h4>
|
||||
<pre>
|
||||
typedef struct _FATFS {
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector */
|
||||
DWORD database; /* Data start sector */
|
||||
CLUST sects_fat; /* Sectors per fat */
|
||||
CLUST max_clust; /* Maximum cluster# + 1 */
|
||||
CLUST last_clust; /* Last allocated cluster */
|
||||
CLUST free_clust; /* Number of free clusters */
|
||||
BYTE fs_type; /* FAT type (0:Not mounted) */
|
||||
BYTE csize; /* 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 */
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
||||
#if _FS_REENTRANT
|
||||
HANDLE h_mutex; /* Handle to the mutex (Platform dependent) */
|
||||
#endif
|
||||
#if _MAX_SS != 512
|
||||
WORD s_size; /* Sector size */
|
||||
#endif
|
||||
#if !_FS_READONLY
|
||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||
BYTE pad2;
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
DWORD fsi_sector; /* fsinfo sector */
|
||||
#endif
|
||||
DWORD sects_fat; /* Sectors per fat */
|
||||
DWORD max_clust; /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[MAX_SS]; /* Disk access window for Directory/FAT */
|
||||
} FATFS;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -12,42 +12,29 @@
|
||||
|
||||
<div class="para">
|
||||
<h2>FIL</h2>
|
||||
<p>The FIL structure (file object) holds state of a file. It is created by f_open function and discarded by f_close function. There is no member that can be changed by the application program.</p>
|
||||
<p>The FIL structure (file object) holds state of an open file. It is initialzed by f_open function and discarded by f_close function. There is no member that can be changed by the application program.</p>
|
||||
|
||||
<h4>FatFs</h4>
|
||||
<pre>
|
||||
typedef struct _FIL {
|
||||
WORD id; /* Owner file system mount ID (inverted) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD org_clust; /* File start cluster */
|
||||
DWORD curr_clust; /* Current cluster */
|
||||
DWORD curr_sect; /* Current sector */
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
BYTE buffer[512]; /* File R/W buffer */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
WORD id; /* Owner file system mount ID */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD org_clust; /* File start cluster */
|
||||
DWORD curr_clust; /* Current cluster */
|
||||
DWORD dsect; /* Current data sector */
|
||||
#if _FS_READONLY == 0
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[SS_MAX]; /* File R/W buffer */
|
||||
#endif
|
||||
} FIL;
|
||||
</pre>
|
||||
|
||||
<h4>Tiny-FatFs</h4>
|
||||
<pre>
|
||||
typedef struct _FIL {
|
||||
WORD id; /* Owner file system mount ID (inverted) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
FATFS* fs; /* Pointer to owner file system */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
CLUST org_clust; /* File start cluster */
|
||||
CLUST curr_clust; /* Current cluster */
|
||||
DWORD curr_sect; /* Current sector */
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
} FIL;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
@ -12,14 +12,18 @@
|
||||
|
||||
<div class="para">
|
||||
<h2>FILINFO</h2>
|
||||
<p>The <tt>FILINFO</tt> structure holds a file information returned by <tt>f_stat()</tt> and <tt>f_readdir()</tt>.</p>
|
||||
<p>The <tt>FILINFO</tt> structure holds a file information returned by f_stat and f_readdir function.</p>
|
||||
<pre>
|
||||
typedef struct _FILINFO {
|
||||
DWORD fsize; /* Size */
|
||||
WORD fdate; /* Date */
|
||||
WORD ftime; /* Time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
char fname[8+1+3+1]; /* Name */
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
char fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
char* lfname; /* Pointer to the LFN buffer */
|
||||
int lfsize; /* Size of LFN buffer [bytes] */
|
||||
#endif
|
||||
} FILINFO;
|
||||
</pre>
|
||||
</div>
|
||||
@ -32,7 +36,7 @@ typedef struct _FILINFO {
|
||||
<dd>Indicates the date that the file was modified or the directory was created.<br>
|
||||
<dl>
|
||||
<dt>bit15:9</dt>
|
||||
<dd>Year from 1980 (0..127)</dd>
|
||||
<dd>Year origin from 1980 (0..127)</dd>
|
||||
<dt>bit8:5</dt>
|
||||
<dd>Month (1..12)</dd>
|
||||
<dt>bit4:0</dt>
|
||||
@ -54,6 +58,10 @@ typedef struct _FILINFO {
|
||||
<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd>
|
||||
<dt>fname[]</dt>
|
||||
<dd>Indicates the file/directory name in 8.3 format null-terminated string.</dd>
|
||||
<dt>lfname</dt>
|
||||
<dd>Pointer to the buffer to store the long file name. This member must be initialized by application.</dd>
|
||||
<dt>lfsize</dt>
|
||||
<dd>Size of long file name buffer. This member must be initialized by application.</dd>
|
||||
</dl>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
@ -47,8 +47,10 @@ FRESULT f_stat (
|
||||
<dd>The drive number is invalid.</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_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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 +61,7 @@ FRESULT f_stat (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_stat gets the information of a file or directory. For details of the infomation, refer to the <tt>FILINFO</tt> structure. This function is not supported in minimization level of >= 1.</p>
|
||||
<p>The f_stat gets the information of a file or directory. For details of the infomation, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html">f_readdir</a> function. This function is not supported in minimization level of >= 1.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -34,8 +34,10 @@ FRESULT f_sync (
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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>
|
||||
@ -46,7 +48,7 @@ FRESULT f_sync (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for applications that open files for a long time in writing mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize risk of data loss due to a sudden blackout or an unintentional disk removal. This function is not supported in read-only configuration.</p>
|
||||
<p>The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for applications that open files for a long time in writing mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize risk of data loss due to a sudden blackout or an unintentional disk removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. This function is not available in read-only configuration.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -36,8 +36,10 @@ FRESULT f_truncate (
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>The file has been opened in read-only mode.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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>
|
||||
@ -48,7 +50,7 @@ FRESULT f_truncate (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_truncate function truncates the file size to the current file R/W point. When the file R/W pointer is already pointing end of the file, there is no effect. This function is not supported in read-only configuration and minimization level of >=1.</p>
|
||||
<p>The f_truncate function truncates the file size to the current file R/W point. When the file R/W pointer is already pointing end of the file, this function has no effect. This function is not available in read-only configuration or minimization level of >=1.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -49,8 +49,10 @@ FRESULT f_unlink (
|
||||
<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>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
@ -61,7 +63,7 @@ FRESULT f_unlink (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_unlink function removes a file or directory. In read-only configuration or minimization level is >= 1, this function is not supported.</p>
|
||||
<p>The f_unlink function removes a file or directory. In read-only configuration or minimization level is >= 1, this function is not available.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -49,8 +49,10 @@ FRESULT f_utime (
|
||||
<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>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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_write (
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>The function denied due to the file has been opened in non-write mode.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure 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>
|
||||
@ -58,7 +60,7 @@ FRESULT f_write (
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The read/write pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect disk full. In case of <tt>*ByteWritten < ByteToWrite</tt>, it means the disk got full during write operation.</p>
|
||||
<p>This function is not supported in read-only configuration.</p>
|
||||
<p>This function is not available in read-only configuration.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.3 KiB |
@ -13,71 +13,121 @@
|
||||
<hr>
|
||||
|
||||
<div class="para">
|
||||
<h3>移植の際に配慮すべきこと</h3>
|
||||
<h3>ポーティングの際に配慮すべきこと</h3>
|
||||
<p>FatFsモジュールは移植性に関して次の点を前提としています。</p>
|
||||
<ul>
|
||||
<li>処理系はANSI C準拠であること。<br>
|
||||
FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠のコンパイラなら特に処理系依存な点はありません。ただし、FATというシステム間でポータブルな構造体を操作するため、プロセッサのエンディアンの違いは意識する必要があります。これは ff.h(tff.h) で定義されているので、最初にこれを適切に設定します。</li>
|
||||
FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠のコンパイラなら特に処理系依存な点はありません。</li>
|
||||
<li>char/short/longのサイズは、それぞれ8/16/32ビットで、intは16または32ビットであること。<br>
|
||||
使用される整数の型は integer.h 内で typedef されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合は矛盾がないように注意しなければなりません。</li>
|
||||
使用される整数の型は integer.h 内で typedef されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合はユーザによって解決されなければなりません。</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>メモリ使用量 (R0.06)</h3>
|
||||
<p>各種環境でのモジュールのメモリ使用量の例を示します。数値の単位はバイトで、<em>D</em>は論理ドライブ数、<em>F</em>は同時オープン・ファイル数を示します。最適化オプションはコード・サイズとしています。</p>
|
||||
<h3>メモリ使用量 (R0.07)</h3>
|
||||
<table class="lst2">
|
||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>MSP430</th><th>TLCS870C</th><th>V850ES</th><th>SH2</th></tr>
|
||||
<tr><td>コンパイラ</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</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>2</td><td>1</td><td>1</td><td>2</td></tr>
|
||||
<tr class="lst3"><td>FatFs Code<br>(Full, R/W)</td><td>9280</td><td>9348</td><td>9387</td><td></td><td></td><td>6728</td><td>7538</td></tr>
|
||||
<tr><td>FatFs Code<br>(Minimum, R/W)</td><td>5814</td><td>5798</td><td>5913</td><td></td><td></td><td>4094</td><td>4742</td></tr>
|
||||
<tr><td>FatFs Code<br>(Full, R/O)</td><td>4402</td><td>4236</td><td>4371</td><td></td><td></td><td>3054</td><td>3474</td></tr>
|
||||
<tr><td>FatFs Code<br>(Minimum, R/O)</td><td>3066</td><td>3158</td><td>3213</td><td></td><td></td><td>2172</td><td>2630</td></tr>
|
||||
<tr><td>FatFs Work (Static)</td><td>D*2+2</td><td>D*4+2</td><td>D*2+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*554+F*544</td><td>D*554+F*550</td><td>D*554+F*544</td><td></td><td></td><td>D*554+F*550</td><td>D*554+F*550</td></tr>
|
||||
<tr class="lst3"><td>Tiny-FatFs Code<br>(Full, R/W)</td><td>7628</td><td>7668</td><td>7560</td><td>7108</td><td>9501</td><td>5978</td><td>6640</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Minimum, R/W)</td><td>4684</td><td>4820</td><td>4698</td><td>4390</td><td>6322</td><td>3678</td><td>4236</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Full, R/O)</td><td>3634</td><td>3600</td><td>3618</td><td>3382</td><td>4554</td><td>2722</td><td>3072</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Minimum, R/O)</td><td>2524</td><td>2700</td><td>2601</td><td>2398</td><td>3390</td><td>1862</td><td>2300</td></tr>
|
||||
<tr><td>Tiny-FatFs Wrok (Static)</td><td>4</td><td>6</td><td>4</td><td>4</td><td>4</td><td>6</td><td>6</td></tr>
|
||||
<tr><td>Tiny-FatFs Work (Dynamic)</td><td>544+F*28</td><td>544+F*32</td><td>544+F*28</td><td>544+F*28</td><td>544+F*28</td><td>544+F*32</td><td>544+F*32</td></tr>
|
||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th><th>ARM7TDMI</th><th>IA-32</th></tr>
|
||||
<tr><td>Compiler</td><td>gcc(WinAVR)</td><td>CH38</td><td>gcc(C30)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>gcc(WinARM)</td><td>MSC</td></tr>
|
||||
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>1</td></tr>
|
||||
<tr class="lst3"><td>ROM (Full, R/W)</td><td>11136</td><td>10356</td><td>10838</td><td>15167</td><td>7682</td><td>8654</td><td>10628</td><td>7232</td></tr>
|
||||
<tr><td>ROM (Min, R/W)</td><td>7072</td><td>6696</td><td>7007</td><td>9800</td><td>4634</td><td>5570</td><td>6564</td><td>4647</td></tr>
|
||||
<tr><td>ROM (Full, R/O)</td><td>5218</td><td>4626</td><td>4949</td><td>6786</td><td>3528</td><td>3826</td><td>4676</td><td>3267</td></tr>
|
||||
<tr><td>ROM (Min, R/O)</td><td>3626</td><td>3418</td><td>3536</td><td>4941</td><td>2558</td><td>2874</td><td>3272</td><td>2397</td></tr>
|
||||
<tr><td>RAM (Static)</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
|
||||
<tr><td>RAM (Dynamic)<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
|
||||
<tr><td>RAM (Dynamic)<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td></tr>
|
||||
</table>
|
||||
<p>上の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションは次の通りです。数値の単位はバイトで、<em>D</em>は論理ドライブ数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p>
|
||||
<pre>
|
||||
_FS_READONLY 0 (R/W), 1 (R/O)
|
||||
_FS_MINIMIZE 0 (Full function), 3 (Minimized function)
|
||||
_USE_STRFUNC 0 (Disable string functions)
|
||||
_USE_MKFS 0 (Disable f_mkfs function)
|
||||
_USE_FORWARD 0 (Disable f_forward function)
|
||||
_CODE_PAGE 932 (Japanese Shift-JIS)
|
||||
_USE_LFN 0 (Disable LFN)
|
||||
_MULTI_PARTITION 0 (Single partition per drive)
|
||||
_FS_REENTRANT 0 (Disable reentrancy)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>モジュール・サイズの縮小</h3>
|
||||
<p>次の表は構成オプションの設定値によりどの機能が削除されるかを示します。</p>
|
||||
<table class="lst2">
|
||||
<tr><td rowspan="2">Function</td><td colspan="3">_FS_MINIMIZE</td><td>_FS_READONLY</td><td>_USE_STRFUNC</td><td>_USE_MKFS</td><td>_USE_FORWARD</td></tr>
|
||||
<tr><td>1</td><td>2</td><td>3</td><td>1</td><td>0</td><td>0</td><td>0</td></tr>
|
||||
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_write</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_sync</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_lseek</td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_opendir</td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_readdir</td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_stat</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getfree</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_truncate</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_unlink</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_mkdir</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_chmod</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_utime</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_rename</td><td>x</td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_mkfs</td><td></td><td></td><td></td><td>x</td><td></td><td>x</td><td></td></tr>
|
||||
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td></tr>
|
||||
<tr><td>f_putc</td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td></tr>
|
||||
<tr><td>f_puts</td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td></tr>
|
||||
<tr><td>f_printf</td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td></tr>
|
||||
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>FatFs vs. Tiny-FatFs</h3>
|
||||
<p>ポータブル・オーディオやデータ・ロガーなど、よくある用途ではTiny-FatFsで十分です。しかし、Tiny-FatFsは標準構成ではFAT32に対応していないので、使用できるディスクは2GBまでという制約があります。<tt>_FAT32</tt>オプションでFAT32対応を追加できますが、その分コード・サイズが膨らみます。FatFsは、複数ファイルを高速アクセスする場合や、複数ドライブの対応が必要な用途に適しています。</p>
|
||||
<div class="rset">
|
||||
<table class="lst2">
|
||||
<tr><th>メモリ容量</th><th>FATタイプ</th></tr>
|
||||
<tr><td>64MB以下</td><td>FAT12</td></tr>
|
||||
<tr><td>128MB~2GB</td><td>FAT16</td></tr>
|
||||
<tr><td>4GB以上</td><td>FAT32</td></tr>
|
||||
<h3>長いファイル名</h3>
|
||||
<p>FatFsモジュールはR0.07から長いファイル名(LFN)をサポートしました。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、f_readdir関数を除くファイル操作関数において透過です。LFN機能を有効にするには、<tt>_USE_LFN</tt>を1または2に設定し、OEM-Unicode相互変換関数 ff_convert をプロジェクトに追加します。これらの関数は、<tt>cc*.c</tt>に含まれています。LFN機能は、加えてある程度のワーク・エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt>_MAX_LFN</tt>オプションで構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには<tt>_MAX_LFN</tt>は255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数は<tt>FR_INVALID_NAME</tt>で失敗します。</p>
|
||||
<p>LFN機能をリエントラント構成で使用する場合は、<tt>_USE_LFN</tt>は2に設定されなければなりません。この場合、ファイル関数はバッファをスタックに確保します。バッファ・サイズは、<tt>_MAX_LFN</tt> * 2 + 1 バイトになるので、呼び出し側スタックのサイズはそれを考慮した十分なサイズでなければなりません。</p>
|
||||
<table class="lst2 rset">
|
||||
<caption>LFN cfg on ARM7DMI</caption>
|
||||
<tr><th>コードページ</th><th>ROMサイズ[bytes]</th></tr>
|
||||
<tr><td>SBCS</td><td>+4719</td></tr>
|
||||
<tr><td>932(Shift-JIS)</td><td>+63755</td></tr>
|
||||
<tr><td>936(GBK)</td><td>+178943</td></tr>
|
||||
<tr><td>949(Korean)</td><td>+141003</td></tr>
|
||||
<tr><td>950(Big5)</td><td>+112631</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<p>2GBまでのカードに限るなら、FAT32への対応は不要です。右の表にメモリ・カードの容量と規定のFATタイプ(SDメモリの場合)を示します。メモリ・カードの出荷時は、最大のパフォーマンスが出るようにデータ領域の境界が調整されたフォーマットになっています。したがって、PCでフォーマットするなどして規定と違うフォーマットになると、書き込み性能が大幅に低下する場合があるので注意が必要です。</p>
|
||||
<p>LFNを有効にすると、選択されたコード・ページに応じてモジュール・サイズが増大されます。右の表に各コード・ページにおけるLFNを有効にしたときのモジュール・サイズの違いを示します。私たち日本人、中国人および韓国人は数万の文字を持ちます。不幸なことに、それは巨大なOEM-Unicode相互変換テーブルを要求し、モジュール・サイズは劇的に増大されます。その結果、LFNを有効にしたFatFsモジュールは、AVRを含む殆どの8ビット・マイコンにインプリメントされることができません。<small>これは長い間私がLFNをインプリメントすることに興味を持ってこなかった理由です。</small></p>
|
||||
<p>注: FATファイル・システム上のLFN機能はマイクロソフト社の特許です。商用製品でそれを有効にするときは、最終仕向地によってはライセンスが必要かも知れません。</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>効率の良いファイル・アクセスの方法</h3>
|
||||
<p>資源の限られた組み込みシステムで効率よくアクセスするためには、ファイル・アクセスの仕組みをある程度意識した使用が求められます。FatFsモジュールでは、ディスク上のファイル・データは f_read()内で次のような手順で読み出されます。</p>
|
||||
<div class="lset">図1. セクタ・ミスアライメント・リード<br>
|
||||
<h3>リエントランシー</h3>
|
||||
<p>異なるボリューム(論理ドライブ)に対するファイル操作は、リエントラント設定によらず常に同時平行に動作できます。同じボリュームに対するリエントランシーは<tt>_FS_REENTRANT</tt>オプションで有効にされることができます。この場合、OS依存の同期オブジェクト操作関数 ff_cre_syncobj, ff_del_syncobj, ff_req_grant と ff_rel_grant もまたプロジェクトに追加されなければなりません。サンプル・コードと解説は<tt>syncobj.c</tt>にあります。</p>
|
||||
<p>他のタスクがそのボリュームを使用中にファイル関数が呼び出されると、そのアクセスはそのタスクがファイル関数を抜けるまでブロックされます。もし、待ち時間が<tt>_TIMEOUT</tt>で指定された期間を越すと、その関数は<tt>FR_TIMEOUT</tt>でアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません。</p>
|
||||
<p>ひとつの例外がf_mountとf_mkfs関数にあります。これらの関数は同じボリュームに対してリエントラントではありません。これらの関数を使用するときは、他のスレッドは関連するファイルを閉じ、そのボリュームへのアクセスを避けなければなりません。</p>
|
||||
<p>注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。ディスクI/Oモジュールのリエントランシーに関しては何の前提もありません。</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>多重ファイル・アクセス</h3>
|
||||
<p>FatFsモジュールでは多重アクセス機能はサポートされません。ファイルに対する多重アクセスは、そのアクセス・モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード・モードのとき許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや消去を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>効率的なファイル・アクセス</h3>
|
||||
<p>小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション・プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ディスク上のデータはf_read関数により次のシーケンスで転送されます。</p>
|
||||
<p>図1. セクタ・ミスアラインド・リード (ショート)<br>
|
||||
<img src="../img/f1.png" width="490" height="73" alt="fig.1">
|
||||
</div>
|
||||
<br class="clr">
|
||||
<div class="lset">図2. セクタ・ミスアライメント・リード<br>
|
||||
</p>
|
||||
<p>図2. セクタ・ミスアラインド・リード (ロング)<br>
|
||||
<img src="../img/f2.png" width="490" height="140" alt="fig.2">
|
||||
</div>
|
||||
<br class="clr">
|
||||
<div class="lset">図3. セクタ・アライメント・リード<br>
|
||||
</p>
|
||||
<p>図3. セクタ・アラインド・リード<br>
|
||||
<img src="../img/f3.png" width="490" height="119" alt="fig.3">
|
||||
</div>
|
||||
<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>
|
||||
<p>ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタ・バッファを意味します。セクタ・バッファは、それぞれのファイル・オブジェクト内のプライベート・セクタ・バッファまたはファイル・システム・オブジェクト内の共有セクタ・バッファのどちらかです。バッファ構成オプションの<tt>_FS_TINY</tt>は、データ転送にどちらを使うかを決定します。タイニー・バッファ(1)が選択されるとデータ・メモリの消費はそれぞれのファイル・オブジェクトで512バイト減少されます。この場合、FatFsモジュールはファイル・データの転送とFAT/ディレクトリ・アクセスにファイル・システム・オブジェクト内のセクタ・バッファだけを使用します。タイニー・バッファの欠点は、セクタ・バッファにキャッシュされたFATデータがファイル・データの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。</p>
|
||||
<p>図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーション・バッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタがdisk_read関数で一度に読み込まれますが、クラスタ境界を越えるマルチ・セクタ転送はそれが隣接であっても行われません。</p>
|
||||
<p>このように、セクタにアライメントしたファイルの読み書きへの配慮はバッファ経由のデータ転送を避け、読み書き性能は改善されるでしょう。その効果に加え、タイニー構成でキャッシュされたFATデータがファイル・データの転送によりフラッシュされず、非タイニー構成と同じ性能を小さなメモリ・フットプリントで達成できます。</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
@ -103,23 +153,6 @@ FatFs
|
||||
<p>いずれも書き込み中や操作対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のようにリスクを最小化することができます。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h3>現リビジョンの問題点とその改善案</h3>
|
||||
<ul>
|
||||
<li>ファイル・オブジェクトの抽象化<br>
|
||||
現在はファイル・オブジェクトの実体をアプリケーション側で管理しているので、アプリケーション・モジュールでのスタック消費量が多くなります(Tiny-FatFsでは問題にならない)。これをハンドルで管理するなどより抽象化すればアプリケーション・モジュールでのスタック消費量を減らせるし、他のファイル・システムへの対応も容易になります。この場合、FatFs内でファイル・オブジェクトの領域を静的に確保しておくか、malloc()することになります。ただし、このようにするとファイル・オブジェクトを直接参照できなくなり、feofやftellなどムダな関数が新たに必要になります。</li>
|
||||
<li>セクタ・バッファ管理の改善<br>
|
||||
現在はセクタ・バッファを固定して使用しているため、無駄なディスクアクセスが多く効率が悪い。メモリの潤沢なシステムでは、複数のセクタ・バッファを使用してディスク・キャッシュを構成すれば性能を向上させることができます。</li>
|
||||
<li>長いファイル名への対応<br>
|
||||
FATの拡張仕様ではMS-DOSの8.3形式ファイル名に加え、255文字までの長いファイル名(LFN)を扱えるようになっていますが、現リビジョンでは未対応で8.3形式しか使用できません。これに対応するには、ファイル名1個で500バイト以上のバッファが必要になったり、Unicodeとローカル・コードの相互変換(256Kバイトの変換テーブルを使う)が必要になるなど、メモリの消費が爆発的に増えてしまいます。なお、LFNの機能はMicrosoft社の特許になっているため、これを製品に使うにはライセンス契約が必要です。</li>
|
||||
<li>RTOSへの対応<br>
|
||||
FatFsモジュールを使用するタスクを一つに限るなら特に意識する必要はありませんが、同じ論理ドライブに対して複数のタスクから再入するには、何らかの排他制御が必要になってきます。FatFsモジュールのRTOSへの対応作業は、<a href="http://www.toppers.jp/">TOPPERSプロジェクト</a>で行われています。</li>
|
||||
</ul>
|
||||
<br>
|
||||
<p>そして、これらの機能拡張を行うとそれだけ多くのリソースが要求されるようになり、このプロジェクトの対象とする8/16ビット・マイコンのシステムに載せられなくなってしまうという問題もあります(これが一番の問題かも知れません)。</p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -60,8 +60,10 @@ FRESULT f_chmod (
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>メディアが書き込み禁止状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
|
||||
@ -34,8 +34,10 @@ FRESULT f_close (
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
|
||||
@ -32,6 +32,7 @@ DSTATUS disk_initialize (
|
||||
<div class="para">
|
||||
<h4>戻り値</h4>
|
||||
<p>この関数は戻り値としてディスク・ステータスを返します。ディスク・ステータスの詳細に関しては<tt><a href="dstat.html">disk_status()</a></tt>を参照してください。</p>
|
||||
<p>FatFsモジュールは、自動マウント動作で必要に応じてこの関数を呼び出します。FatFsモジュール使用中は、アプリケーションからこの関数を呼び出すことは禁止です。</p>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
|
||||
@ -55,6 +55,7 @@ DRESULT disk_ioctl (
|
||||
<table class="lst">
|
||||
<tr><th>コマンド</th><th>解説</th></tr>
|
||||
<tr><td>CTRL_SYNC</td><td>ドライブがデータの書き込みを完了するのを待ちます。ライト・バック・キャッシュがある場合は、書き込まれていないデータを即時書き戻します。</td></tr>
|
||||
<tr><td>GET_SECTOR_SIZE</td><td>Bufferの指すWORD変数にドライブのセクタ・サイズを返します。_MAX_SSが1024以上のとき必要とされます。</td></tr>
|
||||
<tr><td>GET_SECTOR_COUNT</td><td>Bufferの指すDWORD変数にドライブ上の総セクタ数を返します。f_mkfs内でのみ使用。</td></tr>
|
||||
<tr><td>GET_BLOCK_SIZE</td><td>Bufferの指すDWORD変数にメモリ・アレーの消去ブロックサイズをセクタ単位で返します。不明な場合またはHDDでは1を返します。f_mkfs内でのみ使用。</td></tr>
|
||||
</table>
|
||||
|
||||
@ -29,7 +29,7 @@ DRESULT disk_read (
|
||||
<dt>Drive</dt>
|
||||
<dd>物理ドライブ番号(0-9)を指定します。</dd>
|
||||
<dt>Buffer</dt>
|
||||
<dd>ディスクから読み出したデータを格納するバッファ。読み出されるバイト数分のサイズが必要です。</dd>
|
||||
<dd>ディスクから読み出したデータを格納するバイト配列で、読み出されるバイト数分のサイズが必要です。アドレスはアライメントされているとは限りません。</dd>
|
||||
<dt>SectorNumber</dt>
|
||||
<dd>読み出しを開始するセクタ番号。LBAで指定します。</dd>
|
||||
<dt>SectorCount</dt>
|
||||
|
||||
@ -29,7 +29,7 @@ DRESULT disk_write (
|
||||
<dt>Drive</dt>
|
||||
<dd>物理ドライブ番号(0-9)を指定します。</dd>
|
||||
<dt>Buffer</dt>
|
||||
<dd>ディスクに書き込むデータを指定します。</dd>
|
||||
<dd>ディスクに書き込むバイト配列を指定します。アドレスはアライメントされているとは限りません。</dd>
|
||||
<dt>SectorNumber</dt>
|
||||
<dd>書き込みを開始するセクタ番号。LBAで指定します。</dd>
|
||||
<dt>SectorCount</dt>
|
||||
@ -46,7 +46,7 @@ DRESULT disk_write (
|
||||
<dt>RES_ERROR</dt>
|
||||
<dd>書き込み中にエラーが発生し、その回復にも失敗した。</dd>
|
||||
<dt>RES_WRPRT</dt>
|
||||
<dd>ディスクが書き込み禁止状態。</dd>
|
||||
<dd>メディアが書き込み禁止状態。</dd>
|
||||
<dt>RES_PARERR</dt>
|
||||
<dd>パラメータが不正。</dd>
|
||||
<dt>RES_NOTRDY</dt>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
"2:" ルート・ディレクトリ(ドライブ2)
|
||||
|
||||
</pre>
|
||||
<p>FatFsモジュールは8.3形式ファイル名にのみ対応しています。長いファイル名には対応していないので、ファイル名やディレクトリ名は8.3形式の範囲内で指定します。ディレクトリ・セパレータには'/'を使用します。パス名先頭の'/'は、あってもなくても同じです。論理ドライブ番号は、'0'~'9'の一文字の数字とコロンで指定します。省略した場合は"0:"を指定したことになります。Tiny-FatFsでは一つのファイル・システム・オブジェクトしか持てず、常に論理ドライブ0として動作します。また、パス名中に論理ドライブ番号を使用できません。</p>
|
||||
<p>FatFsモジュールは長いファイル名および8.3形式ファイル名に対応しています。長いファイル名は、_USE_LFNオプションが選択されたとき使用可能になります。ディレクトリ・セパレータには / または \ を使用します。パス名先頭のセパレータは、あってもなくても同じです。論理ドライブ番号は、'0'~'9'の一文字の数字とコロンで指定します。省略した場合は"0:"を指定したことになります。</p>
|
||||
</div>
|
||||
<p><br></p>
|
||||
<div class="para">
|
||||
@ -48,7 +48,7 @@ const PARTITION Drives[] = {
|
||||
<li>指定可能な区画は基本区画(0~3)のみ。</li>
|
||||
<li>物理ドライブがSFD形式(区画テーブル無し)の場合、区画指定は無視される。</li>
|
||||
<li>複数の論理ドライブを持つ物理ドライブは、固定ディスクでなければならない。</li>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@ -45,8 +45,10 @@ FRESULT f_forward (
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>非読み込みモードで開いたファイルから読み込もうとした。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
@ -57,8 +59,8 @@ FRESULT f_forward (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>Tiny-FatFs専用関数です。ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータ・バッファを必要としないので、メモリの限られた環境で有効です。転送開始位置は、現在のファイルR/Wポインタからになります。ファイルR/Wポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt>*ByteFwd</tt>は<tt>ByteToFwd</tt>よりも小さくなります。</p>
|
||||
<p>この関数は、<tt>_USE_FORWARD == 0</tt>および、FatFsではサポートされません。</p>
|
||||
<p>ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータ・バッファを必要としないので、メモリの限られた環境で有効です。転送開始位置は、現在のファイルR/Wポインタからになります。ファイルR/Wポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt>*ByteFwd</tt>は<tt>ByteToFwd</tt>よりも小さくなります。</p>
|
||||
<p>この関数は、<tt>_USE_FORWARD == 1</tt>で、且つ<tt>_FS_TINY == 1</tt>のときにサポートされます。</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -44,8 +44,10 @@ FRESULT f_getfree (
|
||||
<dd>ドライブ番号が不正。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
@ -56,7 +58,7 @@ FRESULT f_getfree (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいて、_USE_FSINFOが指定されているときは不正確な値を返す可能性があり、指定されていないときは処理に時間がかかります。</p>
|
||||
<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOの状態によっては不正確な値を返したり、処理に時間がかかったりする可能性があります。</p>
|
||||
<p>リードオンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
<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 - fgets</title>
|
||||
<title>FatFs - f_gets</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>fgets</h2>
|
||||
<h2>f_gets</h2>
|
||||
<p>ファイルから文字列を読み出します。</p>
|
||||
<pre>
|
||||
char* fgets (
|
||||
char* f_gets (
|
||||
char* <em>Str</em>, /* バッファ */
|
||||
int <em>Size</em>, /* バッファのサイズ */
|
||||
FIL* <em>FileObject</em> /* ファイル・オブジェクト */
|
||||
@ -43,14 +43,14 @@ char* fgets (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>この関数は<a href="read.html">f_read()</a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt>Size - 1</tt>文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは<tt>NULL</tt>を返します。ファイル終端に達しているかどうかは<tt>feof()</tt>マクロで調べられます。</p>
|
||||
<p>この関数は<a href="read.html">f_read()</a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt>Size - 1</tt>文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは<tt>NULL</tt>を返します。ファイル終端かエラーかは<tt>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p>
|
||||
<p><tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。2のときは、ファイルに含まれる<tt>'\r'</tt>が取り除かれてバッファに読み込まれます。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">fputc</a>, <a href="puts.html">fputs</a>, <a href="printf.html">fprintf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
|
||||
@ -37,8 +37,10 @@ FRESULT f_lseek (
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
@ -49,11 +51,10 @@ FRESULT f_lseek (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>ファイルR/Wポインタ(ファイル・オブジェクト内のfptrメンバで、次に読み出し・書き込みされるバイトのオフセットを示す)を移動します。オフセットの原点はファイル先頭からです。書き込みモードでファイル・サイズより大きな値を指定すると、そこまでファイルが拡張され、拡張された部分のデータは未定義となります。大容量データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル・サイズを拡張しておくと良いでしょう。f_lseek関数が正常終了したあとは、ファイルR/Wポインタが正しく移動したかfptrをチェックするべきです。ファイル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>
|
||||
@ -68,12 +69,29 @@ FRESULT f_lseek (
|
||||
// 3000バイト進める
|
||||
res = f_lseek(&file, file.fptr + 3000);
|
||||
|
||||
// 2000バイト戻す(オーバーフローに注意)
|
||||
// 2000バイト戻す (オーバーフローに注意)
|
||||
res = f_lseek(&file, file.fptr - 2000);
|
||||
|
||||
// ファイル追記の準備(ファイル終端へ移動)
|
||||
// ファイル追記の準備 (ファイル終端へ移動)
|
||||
res = f_lseek(&file, file.fsize);
|
||||
</pre>
|
||||
<pre>
|
||||
// クラスタ先行割り当て (データ・オーバーランの防止)
|
||||
|
||||
res = f_open(&file, "record.wav", FA_CREATE_NEW | FA_WRITE); // ファイル作成
|
||||
|
||||
res = f_lseek(&file, MAX_SIZE); // 十分なクラスタの先行割り当て
|
||||
if (res || file.fptr != PRE_SIZE) .... // 正しくファイルが拡張されたかチェック
|
||||
|
||||
res = f_lseek(&file, DATA_START); // データ・ストリームの記録(アロケーションディレイ無し)
|
||||
...
|
||||
|
||||
res = f_truncate(&file); // 不要領域の切り捨て
|
||||
res = f_lseek(&file, 0); // ヘッダの記録
|
||||
...
|
||||
|
||||
res = f_close(&file);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -48,8 +48,10 @@ FRESULT f_mkdir (
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>メディアが書き込み禁止状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</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 */
|
||||
WORD <em>AllocSize</em> /* Allocation unit size */
|
||||
BYTE <em>Drive</em>, /* 論理ドライブ番号 */
|
||||
BYTE <em>PartitioningRule</em>, /* 区画作成方法 */
|
||||
WORD <em>AllocSize</em> /* クラス・タサイズ */
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@ -30,7 +30,7 @@ FRESULT f_mkfs (
|
||||
<dt>PartitioningRule</dt>
|
||||
<dd>0を指定すると、ドライブの全領域を占める基本DOS区画を作成したあとその区画にファイル・システムを作成します(FDISKフォーマット)。1を指定すると、区画テーブルを作成せずドライブの先頭セクタから直接ファイル・システムを作成します(super floppy (SFD) フォーマット)。</dd>
|
||||
<dt>AllocSize</dt>
|
||||
<dd>クラスタ・サイズをバイト単位で指定します。512~32768の範囲でかつ2の累乗でなければなりません。FAT64(64KB/クラスタ)は選択できません。</dd>
|
||||
<dd>クラスタ・サイズをバイト単位で指定します。0または512~32768の範囲でかつ2の累乗でなければなりません。0を指定するとドライブ・サイズに応じたデフォルトのクラスタ・サイズを選択します。FAT64(64KB/クラスタ)は選択できません。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -47,8 +47,8 @@ FRESULT f_mkfs (
|
||||
<dd>メディアが書き込み禁止状態。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>その論理ドライブにワーク・エリアが割り当てられていない。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_MKFS_ABORTED</dt>
|
||||
<dd>次の理由で開始前に処理が中断された。
|
||||
<ul>
|
||||
@ -62,9 +62,9 @@ FRESULT f_mkfs (
|
||||
|
||||
<div class="para">
|
||||
<h4>説明</h4>
|
||||
<p>f_mkfs関数はFATファイル・システムをドライブ上に作成します。リムーバブル・メディアのパーテーショニング・ルールとしてはFDISK形式とSFD形式があり、メモリ・カードではFDISK形式が一般的です。この関数は<em>複数区画には対応していない</em>ので、その物理ドライブの既存の区画は全て削除され、全体が一つの区画になります。</p>
|
||||
<p>FATタイプ(FAT12/FAT16/FAT32)は、ディスク上の<em>クラスタ数によってのみ決定</em>される[FAT仕様書より]決まりになっていて、それ以外の要因はありません。したがって、どのFATタイプになるかは、ディスク・サイズとクラスタ・サイズに依存します。クラスタ・サイズは大きいほど性能が上がるので、特に小容量のドライブでなければ32768バイトを選択しておけばよいです。</p>
|
||||
<p>この関数は、FatFsで構成オプション<tt>_USE_MKFS</tt>を選択したときにサポートされます。また、Tiny-FatFsではサポートされません。</p>
|
||||
<p>f_mkfs関数はFATファイル・システムをドライブ上に作成します。リムーバブル・メディアのパーテーショニング・ルールとしてはFDISK形式とSFD形式があり、メモリ・カードではFDISK形式が普通です。この関数は<em>複数区画には対応していない</em>ので、その物理ドライブの既存の区画は全て削除され、全体が一つの区画になります。</p>
|
||||
<p>FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上の<em>クラスタ数によってのみ決定</em>される[FAT仕様書より]決まりになっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズと指定されたクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、逆にディスク利用効率は落ちます。</p>
|
||||
<p>この関数は、構成オプション<tt>_USE_MKFS</tt>を選択したときにサポートされます。</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
<div class="para">
|
||||
<h2>f_mount</h2>
|
||||
<p>論理ドライブのワーク・エリアを登録・抹消します。</p>
|
||||
<p>論理ドライブ(ボリューム)のワーク・エリアを登録・抹消します。</p>
|
||||
<pre>
|
||||
FRESULT f_mount (
|
||||
BYTE <em>Drive</em>, /* 論理ドライブ番号 */
|
||||
@ -25,7 +25,7 @@ FRESULT f_mount (
|
||||
<h4>引数</h4>
|
||||
<dl class="par">
|
||||
<dt>Drive</dt>
|
||||
<dd>論理ドライブ番号(0-9)。Tiny-FatFsでは常に0。</dd>
|
||||
<dd>論理ドライブ番号(0-9)。</dd>
|
||||
<dt>FileSystemObject</dt>
|
||||
<dd>登録するワーク・エリア(ファイル・システム・オブジェクト)へのポインタ。</dd>
|
||||
</dl>
|
||||
|
||||
@ -66,8 +66,10 @@ FRESULT f_open (
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>メディアが書き込み禁止状態で書き込み系オープンをした。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>その論理ドライブにワーク・エリアが割り当てられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
|
||||
@ -45,8 +45,10 @@ FRESULT f_opendir (
|
||||
<dd>ドライブ番号が不正。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
<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 - fprintf</title>
|
||||
<title>FatFs - f_printf</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>fprintf</h2>
|
||||
<h2>f_printf</h2>
|
||||
<p>ファイルに書式化文字列を書き込みます。</p>
|
||||
<pre>
|
||||
int fprintf (
|
||||
int f_printf (
|
||||
FIL* <em>FileObject</em>, /* ファイル・オブジェクト */
|
||||
const char* <em>Foramt</em>, /* 書式制御文字列 */
|
||||
...
|
||||
@ -44,26 +44,26 @@ int fprintf (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>この関数は<a href="putc.html">fputc()</a>および<a href="puts.html">fputs()</a>のラッパー関数です。書式制御機能はサブセットとなっていて、使用可能はタイプは<tt>c s d u X</tt>、精度指定は<tt>l</tt>、フラグは<tt>0</tt>となっています。リード・ライト構成で<tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。</p>
|
||||
<p>この関数は<a href="putc.html">f_putc()</a>および<a href="puts.html">f_puts()</a>のラッパー関数です。書式制御機能はサブセットとなっていて、使用可能はタイプは<tt>c s d u X</tt>、精度指定は<tt>l</tt>、フラグは<tt>0</tt>となっています。リード・ライト構成で<tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>使用例</h4>
|
||||
<pre>
|
||||
fprintf(&fil, "%6d", -200); // " -200"
|
||||
fprintf(&fil, "%02u", 5); // "05"
|
||||
fprintf(&fil, "%ld", 12345678L); // "12345678"
|
||||
fprintf(&fil, "%08lX", 1194684UL); // "00123ABC"
|
||||
fprintf(&fil, "%s", "String"); // "String"
|
||||
fprintf(&fil, "%c", 'a'); // "a"
|
||||
f_printf(&fil, "%6d", -200); // " -200"
|
||||
f_printf(&fil, "%02u", 5); // "05"
|
||||
f_printf(&fil, "%ld", 12345678L); // "12345678"
|
||||
f_printf(&fil, "%08lX", 1194684UL); // "00123ABC"
|
||||
f_printf(&fil, "%s", "String"); // "String"
|
||||
f_printf(&fil, "%c", 'a'); // "a"
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">fputc</a>, <a href="puts.html">fputs</a>, <a href="gets.html">fgets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
<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 - fputc</title>
|
||||
<title>FatFs - f_putc</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>fputc</h2>
|
||||
<h2>f_putc</h2>
|
||||
<p>ファイルに文字を書き込みます。</p>
|
||||
<pre>
|
||||
int fputc (
|
||||
int f_putc (
|
||||
int <em>Chr</em>, /* 書き込む文字 */
|
||||
FIL* <em>FileObject</em> /* ファイル・オブジェクト */
|
||||
);
|
||||
@ -46,7 +46,7 @@ int fputc (
|
||||
|
||||
<div class="para">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="puts.html">fputs</a>, <a href="printf.html">fprintf</a>, <a href="gets.html">fgets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
<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 - fputs</title>
|
||||
<title>FatFs - f_puts</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>fputs</h2>
|
||||
<h2>f_puts</h2>
|
||||
<p>ファイルに文字列を書き込みます。</p>
|
||||
<pre>
|
||||
int fputs (
|
||||
int f_puts (
|
||||
const char* <em>Str</em>, /* 文字列 */
|
||||
FIL* <em>FileObject</em> /* ファイル・オブジェクト */
|
||||
);
|
||||
@ -40,13 +40,13 @@ int fputs (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>この関数は<a href="putc.html">fputc()</a>のラッパー関数です。リード・ライト構成で、<tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。2を指定すると、文字列中の<tt>'\n'</tt>が<tt>"\r\n"</tt>に変換されて書き込まれます。</p>
|
||||
<p>この関数は<a href="putc.html">f_putc()</a>のラッパー関数です。リード・ライト構成で、<tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。2を指定すると、文字列中の<tt>'\n'</tt>が<tt>"\r\n"</tt>に変換されて書き込まれます。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">fputc</a>, <a href="printf.html">fprintf</a>, <a href="gets.html">fgets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
|
||||
@ -45,8 +45,10 @@ FRESULT f_read (
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>非読み込みモードで開いたファイルから読み込もうとした。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
|
||||
@ -39,8 +39,10 @@ FRESULT f_readdir (
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
<dd>無効なディレクトリ・オブジェクト。</dd>
|
||||
</dl>
|
||||
@ -49,31 +51,52 @@ 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>構造体を参照してください。FileInfoにヌル・ポインタを指定すると、そのディレクトリのリード・インデックスを巻き戻します。</p>
|
||||
<p>LFN機能が有効な時は、f_readdir関数の呼び出しに先立ってFILINFO構造体の<tt>lfname</tt>と<tt>lfsize</tt>が有効な値で初期化されていなければなりません。<tt>lfname</tt>はLFNを格納するバッファで、<tt>lfsize</tt>はそのバッファ・サイズです。LFN格納バッファまたはLFN操作バッファどちらかのサイズがそのLFNのサイズに対して不十分だった場合、またはLFNが存在しない場合はLFN格納バッファにヌル文字列が返されます。<tt>lfname</tt>にヌル・ポインタを指定した場合は、LFNに関して何も返されません。</p>
|
||||
<p><tt>_FS_MINIMIZE >= 2</tt>ではこの関数はサポートされません。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>使用例</h4>
|
||||
<pre>
|
||||
void scan_files (char* path)
|
||||
FRESULT scan_files (char* path)
|
||||
{
|
||||
FILINFO finfo;
|
||||
DIR dirs;
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
int i;
|
||||
char *fn;
|
||||
#if _USE_LFN
|
||||
static char lfn[_MAX_LFN * (_DF1S ? 2 : 1) + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof(lfn);
|
||||
#endif
|
||||
|
||||
if (f_opendir(&dirs, path) == FR_OK) {
|
||||
|
||||
res = f_opendir(&dir, path);
|
||||
if (res == FR_OK) {
|
||||
i = strlen(path);
|
||||
while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) {
|
||||
if (finfo._attrib & AM_DIR) {
|
||||
sprintf(&path[i], "/%s", &finfo.fname[0]);
|
||||
scan_files(path);
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &fno);
|
||||
if (res != FR_OK || fno.fname[0] == 0) break;
|
||||
#if _USE_LFN
|
||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||
#else
|
||||
fn = fno.fname;
|
||||
#endif
|
||||
if (fno.fattrib & AM_DIR) {
|
||||
sprintf(&path[i], "/%s", fn);
|
||||
res = scan_files(path);
|
||||
if (res != FR_OK) break;
|
||||
path[i] = 0;
|
||||
} else {
|
||||
printf("%s/%s\n", path, &finfo.fname[0]);
|
||||
printf("%s/%s\n", path, fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -25,7 +25,7 @@ FRESULT f_rename (
|
||||
<h4>引数</h4>
|
||||
<dl class="par">
|
||||
<dt>OldName</dt>
|
||||
<dd>変更対象のファイルまたはディレクトリの<a href="filename.html">フルパス名</a>の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
|
||||
<dd>変更対象のオブジェクト(ファイルまたはディレクトリ)の<a href="filename.html">フルパス名</a>の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
|
||||
<dt>NewName</dt>
|
||||
<dd>新しいファイルまたはディレクトリのフルパス名の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。既に存在するものと同じ名前は使えません。また、ドライブ番号は指定できず、<tt>OldName</tt>で指定されたドライブ上のオブジェクトとして扱われます。<br>
|
||||
</dl>
|
||||
@ -38,7 +38,7 @@ FRESULT f_rename (
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_NO_FILE</dt>
|
||||
<dd>ファイルが見つからない。</dd>
|
||||
<dd>OldNameのオブジェクトが見つからない。</dd>
|
||||
<dt>FR_NO_PATH</dt>
|
||||
<dd>パスが見つからない。</dd>
|
||||
<dt>FR_INVALID_NAME</dt>
|
||||
@ -46,15 +46,17 @@ 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>
|
||||
<dd>NewNameと同じオブジェクトが既に存在する。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>メディアが書き込み禁止状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>論理ドライブにワークエリアが割り当てられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
@ -65,18 +67,17 @@ FRESULT f_rename (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>ファイルまたはディレクトリの名前を変更します。別のディレクトリへの移動(同じドライブ内のみ)も可能です。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
||||
<p>※現リビジョンでは、ディレクトリを別のディレクトリに移動するとファイル・システムが壊れます。</p>
|
||||
<p>ファイルまたはディレクトリの名前を変更します。また、別のディレクトリへの移動(同じドライブ内のみ)も可能です。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>使用例</h4>
|
||||
<pre>
|
||||
// 名前を変更する
|
||||
// ファイルまたはサブディレクトリの名前を変更する
|
||||
f_rename("oldname.txt", "newname.txt");
|
||||
|
||||
// 名前の変更と同時に別のディレクトリへ移動する
|
||||
// ファイルまたはサブディレクトリの名前を変更すると同時に別のディレクトリへ移動する
|
||||
f_rename("oldname.txt", "dir1/newname.txt");
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -13,26 +13,20 @@
|
||||
<div class="para">
|
||||
<h2>DIR</h2>
|
||||
<p><tt>DIR</tt>構造体は、f_opendir(), f_readdir()のワーク・エリアとして使用されます。</p>
|
||||
<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 */
|
||||
} 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 id; /* Owner file system mount ID */
|
||||
WORD index; /* Current index number */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
DWORD sclust; /* Table start cluster (0:Static table) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index (0xFFFF:No LFN) */
|
||||
#endif
|
||||
} DIR;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -13,47 +13,37 @@
|
||||
<div class="para">
|
||||
<h2>FATFS</h2>
|
||||
<p><tt>FATFS</tt>構造体は、個々の論理ドライブのダイナミック・ワーク・エリアを保持し、f_mount()でFatFsモジュールに登録されます。標準状態では次のようなメンバになっています。アプリケーションから書き換え可能なメンバはありません。</p>
|
||||
<h4>FatFs</h4>
|
||||
<pre>
|
||||
typedef struct _FATFS {
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
DWORD sects_fat; /* Sectors per fat */
|
||||
DWORD max_clust; /* Maximum cluster# + 1 */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (cluster# for FAT32) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
BYTE fs_type; /* FAT type (0:Not mounted) */
|
||||
BYTE csize; /* 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>
|
||||
|
||||
<h4>Tiny-FatFs</h4>
|
||||
<pre>
|
||||
typedef struct _FATFS {
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector */
|
||||
DWORD database; /* Data start sector */
|
||||
CLUST sects_fat; /* Sectors per fat */
|
||||
CLUST max_clust; /* Maximum cluster# + 1 */
|
||||
CLUST last_clust; /* Last allocated cluster */
|
||||
CLUST free_clust; /* Number of free clusters */
|
||||
BYTE fs_type; /* FAT type (0:Not mounted) */
|
||||
BYTE csize; /* 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 */
|
||||
BYTE fs_type; /* FAT sub type */
|
||||
BYTE drive; /* Physical drive number */
|
||||
BYTE csize; /* Number of sectors per cluster */
|
||||
BYTE n_fats; /* Number of FAT copies */
|
||||
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
||||
BYTE pad1;
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
||||
#if _FS_REENTRANT
|
||||
HANDLE h_mutex; /* Handle to the mutex (Platform dependent) */
|
||||
#endif
|
||||
#if _MAX_SS != 512
|
||||
WORD s_size; /* Sector size */
|
||||
#endif
|
||||
#if !_FS_READONLY
|
||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||
BYTE pad2;
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
DWORD fsi_sector; /* fsinfo sector */
|
||||
#endif
|
||||
DWORD sects_fat; /* Sectors per fat */
|
||||
DWORD max_clust; /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory/FAT */
|
||||
} FATFS;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -13,38 +13,25 @@
|
||||
<div class="para">
|
||||
<h2>FIL</h2>
|
||||
<p><tt>FIL</tt>構造体は、f_open()で作成され、そのファイルの状態を保持します。アプリケーションから書き換え可能なメンバはありません。</p>
|
||||
<h4>FatFs</h4>
|
||||
<pre>
|
||||
typedef struct _FIL {
|
||||
WORD id; /* Owner file system mount ID (inverted) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD org_clust; /* File start cluster */
|
||||
DWORD curr_clust; /* Current cluster */
|
||||
DWORD curr_sect; /* Current sector */
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
BYTE buffer[512]; /* File R/W buffer */
|
||||
} FIL;
|
||||
</pre>
|
||||
|
||||
<h4>Tiny-FatFs</h4>
|
||||
<pre>
|
||||
typedef struct _FIL {
|
||||
WORD id; /* Owner file system mount ID (inverted) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
FATFS* fs; /* Pointer to owner file system */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
CLUST org_clust; /* File start cluster */
|
||||
CLUST curr_clust; /* Current cluster */
|
||||
DWORD curr_sect; /* Current sector */
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
WORD id; /* Owner file system mount ID */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD org_clust; /* File start cluster */
|
||||
DWORD curr_clust; /* Current cluster */
|
||||
DWORD dsect; /* Current data sector */
|
||||
#if _FS_READONLY == 0
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; /* File R/W buffer */
|
||||
#endif
|
||||
} FIL;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -15,11 +15,15 @@
|
||||
<p><tt>FILINFO</tt>構造体は、<tt>f_stat(), f_readdir()</tt>で返されるファイル情報を保持します。</p>
|
||||
<pre>
|
||||
typedef struct _FILINFO {
|
||||
DWORD fsize; /* Size [bytes] */
|
||||
WORD fdate; /* Date [15-9]:Year-1980, [8-5]:Month, [4-0]:Mday */
|
||||
WORD ftime; /* Time [15-11]:Hour, [10-5]:Minute, [4-0]:Sec/2 */
|
||||
BYTE fattrib; /* Attribute */
|
||||
char fname[8+1+3+1]; /* Name */
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
char fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
char* lfname; /* Pointer to the LFN buffer */
|
||||
int lfsize; /* Size of LFN buffer [bytes] */
|
||||
#endif
|
||||
} FILINFO;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -46,8 +46,10 @@ FRESULT f_stat (
|
||||
<dd>ドライブ番号が不正。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>論理ドライブにワークエリアが割り当てられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
|
||||
@ -34,8 +34,10 @@ FRESULT f_sync (
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
@ -46,7 +48,7 @@ FRESULT f_sync (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>この関数は<tt>f_close()</tt>と同じ処理を実行しますが、ファイルは引き続き開かれたままになり、読み書きを続行できます。ロギングなど、書き込みモードで長時間ファイルが開かれているアプリケーションにおいて、定期的または区切りの良いところでsyncすることにより、不意の電源断やメディアの取り外しにより失われるデータを最小にすることができます。</p>
|
||||
<p>この関数は<tt>f_close()</tt>と同じ処理を実行しますが、ファイルは引き続き開かれたままになり、読み書きを続行できます。ロギングなど、書き込みモードで長時間ファイルが開かれているアプリケーションにおいて、定期的または区切りの良いところでsyncすることにより、不意の電源断やメディアの取り外しにより失われるデータを最小にすることができます。実際のところ、f_closeではsyncしたあとファイル・オブジェクトを破棄しているだけなので、f_close直前のsyncは意味がありません。</p>
|
||||
<p>リード・オンリー構成ではこの関数はサポートされません。</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -36,8 +36,10 @@ FRESULT f_truncate (
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>ファイルが非書き込みモードで開かれている。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
|
||||
@ -48,8 +48,10 @@ FRESULT f_unlink (
|
||||
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>メディアが書き込み禁止状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>論理ドライブにワーク・エリアが割り当てられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
|
||||
@ -49,8 +49,10 @@ FRESULT f_utime (
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>メディアが書き込み禁止状態。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
|
||||
@ -45,8 +45,10 @@ FRESULT f_write (
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>非書き込みモードで開かれたファイルに書き込もうとした。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_DISK_ERR</dt>
|
||||
<dd>ディスク・エラーによる失敗。</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
|
||||
@ -1,3 +1,17 @@
|
||||
R0.07a, Apr 14, 2009
|
||||
Separated out OS dependent code on re-entrant configuration.
|
||||
Added multiple sector size support.
|
||||
|
||||
R0.07, Apr 01, 2009
|
||||
Merged Tiny-FatFs as a buffer configuration option.
|
||||
Added long file name support.
|
||||
Added multiple code page support.
|
||||
Added re-entrancy for multitask operation.
|
||||
Added auto cluster size selection to f_mkfs().
|
||||
Added rewind option to f_readdir().
|
||||
Changed result code of critical errors.
|
||||
Renamed string functions to avoid name collision.
|
||||
|
||||
R0.06, Apr 01, 2008
|
||||
Added f_forward. (Tiny-FatFs)
|
||||
Added string functions: fgets, fputc, fputs and fprintf.
|
||||
@ -40,6 +54,10 @@ R0.03a, Dec 11, 2006
|
||||
Improved cluster scan algolithm to write files fast.
|
||||
Fixed f_mkdir creates incorrect directory on FAT32.
|
||||
|
||||
R0.03, Sep 22, 2006
|
||||
Added f_rename.
|
||||
Changed option _FS_MINIMUM to _FS_MINIMIZE.
|
||||
|
||||
R0.02a, Jun 10, 2006
|
||||
Added a configuration option _FS_MINIMUM.
|
||||
|
||||
@ -48,10 +66,6 @@ R0.02, Jun 01, 2006
|
||||
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
|
||||
|
||||
|
||||
63
patches.txt
63
patches.txt
@ -1,63 +0,0 @@
|
||||
Patches for FatFs and Tiny-FatFs R0.06
|
||||
|
||||
April 16, 2008 - FatFs and Tiny-FatFs
|
||||
------------------------------------------------------------------------------
|
||||
The va_arg(arp,char) used in fprintf() will cause an incorrect behavior on
|
||||
the big-endian processor due to type promotion rules. Thus the corresponding
|
||||
code should be changed to va_arg(arp,int).
|
||||
|
||||
|
||||
|
||||
October 11, 2008 - FatFs and Tiny-FatFs
|
||||
------------------------------------------------------------------------------
|
||||
Warnings due to wrong cast may occure in the get_fileinfo function. To
|
||||
eliminate it, remove const attribute of the argument, "const BYTE *dir".
|
||||
|
||||
|
||||
|
||||
October 22, 2008 - FatFs and Tiny-FatFs
|
||||
------------------------------------------------------------------------------
|
||||
Improving write performance. On sector misaligned long writes, FatFs issues
|
||||
sector write requests out of the sector order. It will decrease the write
|
||||
performance of flash memory storages. This is not the case on short writes
|
||||
without direct transfer. To solve this problem, apply following patches.
|
||||
|
||||
--- ff.c Tue Apr 1 21:49:26 2008
|
||||
+++ ff_new.c Tue Oct 21 23:27:44 2008
|
||||
@@ -1018,6 +1018,11 @@
|
||||
fp->curr_clust = clust; /* Update current cluster */
|
||||
fp->csect = 0; /* Reset sector address in the cluster */
|
||||
}
|
||||
+ if (fp->flag & FA__DIRTY) { /* Write back file I/O buffer prior to following direct transfer */
|
||||
+ if (disk_write(fp->fs->drive, fp->buffer, fp->curr_sect, 1) != RES_OK)
|
||||
+ goto fw_error;
|
||||
+ fp->flag &= (BYTE)~FA__DIRTY;
|
||||
+ }
|
||||
sect = clust2sect(fp->fs, fp->curr_clust) + fp->csect; /* Get current sector */
|
||||
cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */
|
||||
if (cc) { /* Write maximum contiguous sectors directly */
|
||||
@@ -1030,11 +1035,6 @@
|
||||
continue;
|
||||
}
|
||||
if (sect != fp->curr_sect) { /* Is window offset changed? */
|
||||
- if (fp->flag & FA__DIRTY) { /* Write back file I/O buffer if needed */
|
||||
- if (disk_write(fp->fs->drive, fp->buffer, fp->curr_sect, 1) != RES_OK)
|
||||
- goto fw_error;
|
||||
- fp->flag &= (BYTE)~FA__DIRTY;
|
||||
- }
|
||||
if (fp->fptr < fp->fsize && /* Fill file I/O buffer with file data */
|
||||
disk_read(fp->fs->drive, fp->buffer, sect, 1) != RES_OK)
|
||||
goto fw_error;
|
||||
|
||||
|
||||
--- tff.c Tue Apr 1 21:49:28 2008
|
||||
+++ tff_new.c Wed Oct 22 02:13:05 2008
|
||||
@@ -1037,6 +1037,8 @@
|
||||
if (wcnt > btw) wcnt = btw;
|
||||
memcpy(&fp->fs->win[fp->fptr % 512U], wbuff, wcnt);
|
||||
fp->fs->winflag = 1;
|
||||
+ if (((UINT)fp->fptr + wcnt) % 512U == 0 /* Flush sector window when last byte is written */
|
||||
+ && !move_window(0)) goto fw_error;
|
||||
}
|
||||
|
||||
if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */
|
||||
151
src/00readme.txt
151
src/00readme.txt
@ -1,139 +1,34 @@
|
||||
FatFs/Tiny-FatFs Module Source Files R0.06 (C)ChaN, 2008
|
||||
FatFs/Tiny-FatFs Module Source Files R0.07a (C)ChaN, 2009
|
||||
|
||||
|
||||
FILES
|
||||
|
||||
ff.h Common include file for FatFs and application module.
|
||||
ff.c FatFs module.
|
||||
tff.h Common include file for Tiny-FatFs and application module.
|
||||
tff.c Tiny-FatFs module.
|
||||
diskio.h Common include file for (Tiny-)FatFs and disk I/O module.
|
||||
diskio.h Common include file for FatFs and disk I/O module.
|
||||
diskio.c Skeleton of low level disk I/O module.
|
||||
integer.h Alternative type definitions for integer variables.
|
||||
option Optional external functions.
|
||||
|
||||
Low level disk I/O module is not included in this archive because the
|
||||
FatFs/Tiny-FatFs module is only a generic file system layer and not depend
|
||||
on any specific storage device. You have to provide a low level disk I/O
|
||||
module that written to control your storage device.
|
||||
|
||||
|
||||
|
||||
CONFIGURATION OPTIONS
|
||||
|
||||
There are several configuration options for various envilonment and
|
||||
requirement. The configuration options are defined in header files, ff.h
|
||||
and tff.h.
|
||||
|
||||
_MCU_ENDIAN
|
||||
|
||||
This is the most impotant option that depends on the processor architecture.
|
||||
The value 2 is compatible with all MCUs. It forces FatFs to access FAT
|
||||
structures in byte-by-byte. When the target device corresponds to either or
|
||||
both of following cases, it must always be set 2.
|
||||
|
||||
- Muti-byte integers (short, long) are stored in Big-Endian.
|
||||
- Address miss-aligned memory access results in an incorrect behavior.
|
||||
|
||||
If not the case, setting 1 is recommended rather than 2 for good code
|
||||
efficiency. The initial value is 0. (Must set 1 or 2 properly)
|
||||
|
||||
|
||||
_FS_READONLY
|
||||
|
||||
When application program does not require write functions, _FS_READONLY 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. (Read and Write)
|
||||
|
||||
|
||||
_FS_MINIMIZE
|
||||
|
||||
When application program requires only file read/write function and nothing
|
||||
else, _FS_MINIMIZE can be changed to eliminate some functions to reduce the
|
||||
module size. The initial value is 0. (Full function)
|
||||
|
||||
|
||||
_USE_STRFUNC
|
||||
|
||||
When _USE_STRFUNC is set to 1, the string functions, fputc, fputs, fprintf
|
||||
and fgets are enabled. The initial value is 0. (String functions are not
|
||||
available)
|
||||
|
||||
|
||||
_DRIVES
|
||||
|
||||
Number of drives to be used. This option is not available on Tiny-FatFs.
|
||||
The initial value is 2.
|
||||
|
||||
_FAT32
|
||||
|
||||
When _FAT32 is set to 1, the FAT32 support is added with an additional
|
||||
code size. This option is for only Tiny-FatFs. FatFs always supports all
|
||||
FAT sub-types. The initial value is 0. (No FAT32 support)
|
||||
|
||||
|
||||
_USE_FSINFO
|
||||
|
||||
When _USE_FSINFO is set to 1, FSInfo is used for FAT32 volume. The initial
|
||||
value is 0. (FSInfo is not used)
|
||||
|
||||
_USE_SJIS
|
||||
|
||||
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_NTFLAG
|
||||
|
||||
When _USE_NTFLAG is set to 1, upper/lower case of the file/dir name is
|
||||
preserved. Note that the files are always accessed in case insensitive.
|
||||
The initial value is 1.
|
||||
|
||||
|
||||
_USE_MKFS
|
||||
|
||||
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.
|
||||
The initial value is 0. (f_mkfs is not available)
|
||||
|
||||
|
||||
Following table shows which function is removed by configuration options.
|
||||
|
||||
_FS_MINIMIZE _FS_READONLY _USE_STRFUNC _USE_MKFS _USE_FORWARD
|
||||
(1) (2) (3) (1) (0) (0) (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_truncate x x x x
|
||||
f_unlink x x x x
|
||||
f_mkdir x x x x
|
||||
f_chmod x x x x
|
||||
f_utime x x x x
|
||||
f_rename x x x x
|
||||
f_mkfs x x
|
||||
f_forward x
|
||||
fputc x x
|
||||
fputs x x
|
||||
fprintf x x
|
||||
fgets x
|
||||
Low level disk I/O module is not included in this archive because the FatFs
|
||||
module is only a generic file system layer and not depend on any specific
|
||||
storage device. You have to provide a low level disk I/O module that written
|
||||
to control your storage device.
|
||||
|
||||
|
||||
|
||||
AGREEMENTS
|
||||
|
||||
The FatFs/Tiny-FatFs module is a free software and there is no warranty.
|
||||
The FatFs/Tiny-FatFs module is opened for education, reserch and development.
|
||||
There is no restriction on use. You can use it for personal, non-profit or
|
||||
commercial use under your responsibility.
|
||||
FatFs module is an open source software to implement FAT file system to
|
||||
small embedded systems. This is a free software and is opened for education,
|
||||
research and commercial developments under license policy of following trems.
|
||||
|
||||
Copyright (C) 2009, ChaN, all right reserved.
|
||||
|
||||
* The FatFs module is a free software and there is NO WARRANTY.
|
||||
* No restriction on use. You can use, modify and redistribute it for
|
||||
personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.
|
||||
* Redistributions of source code must retain the above copyright notice.
|
||||
|
||||
|
||||
|
||||
@ -187,3 +82,15 @@ REVISION HISTORY
|
||||
Apr 01, 2008 R0.06 Added f_forward(). (Tiny-FatFs)
|
||||
Added string functions: fputc(), fputs(), fprintf() and fgets().
|
||||
Improved performance of f_lseek() on move to the same or following cluster.
|
||||
|
||||
Apr 01, 2009, R0.07 Merged Tiny-FatFs as a buffer configuration option.
|
||||
Added long file name support.
|
||||
Added multiple code page support.
|
||||
Added re-entrancy for multitask operation.
|
||||
Added auto cluster size selection to f_mkfs().
|
||||
Added rewind option to f_readdir().
|
||||
Changed result code of critical errors.
|
||||
Renamed string functions to avoid name collision.
|
||||
|
||||
Apr 14, 2009, R0.07a Separated out OS dependent code on reentrant cfg.
|
||||
Added multiple sector size support.
|
||||
|
||||
@ -9,8 +9,6 @@
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Correspondence between physical drive number and physical drive. */
|
||||
/* Note that Tiny-FatFs supports only single drive and always */
|
||||
/* accesses drive number 0. */
|
||||
|
||||
#define ATA 0
|
||||
#define MMC 1
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------------------------------------
|
||||
/ Low level disk interface modlue include file R0.06 (C)ChaN, 2007
|
||||
/ Low level disk interface modlue include file R0.07 (C)ChaN, 2009
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO
|
||||
@ -26,6 +26,7 @@ typedef enum {
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
BOOL assign_drives (int argc, char *argv[]);
|
||||
DSTATUS disk_initialize (BYTE);
|
||||
DSTATUS disk_status (BYTE);
|
||||
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
|
||||
@ -33,8 +34,6 @@ DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
|
||||
DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
|
||||
#endif
|
||||
DRESULT disk_ioctl (BYTE, BYTE, void*);
|
||||
void disk_timerproc (void);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -48,7 +47,7 @@ void disk_timerproc (void);
|
||||
/* Command code for disk_ioctrl() */
|
||||
|
||||
/* Generic command */
|
||||
#define CTRL_SYNC 0 /* Mandatory for read/write configuration */
|
||||
#define CTRL_SYNC 0 /* Mandatory for write functions */
|
||||
#define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
|
||||
#define GET_SECTOR_SIZE 2
|
||||
#define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
|
||||
|
||||
472
src/ff.h
472
src/ff.h
@ -1,198 +1,373 @@
|
||||
/*--------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include file R0.06 (C)ChaN, 2008
|
||||
/---------------------------------------------------------------------------/
|
||||
/ FatFs module is an experimenal project to implement FAT file system to
|
||||
/ cheap microcontrollers. This is a free software and is opened for education,
|
||||
/ research and development under license policy of following trems.
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include file R0.07a (C)ChaN, 2009
|
||||
/----------------------------------------------------------------------------/
|
||||
/ FatFs module is an open source software to implement FAT file system to
|
||||
/ small embedded systems. This is a free software and is opened for education,
|
||||
/ research and commercial developments under license policy of following trems.
|
||||
/
|
||||
/ Copyright (C) 2008, ChaN, all right reserved.
|
||||
/ Copyright (C) 2009, ChaN, all right reserved.
|
||||
/
|
||||
/ * The FatFs module is a free software and there is no warranty.
|
||||
/ * You can use, modify and/or redistribute it for personal, non-profit or
|
||||
/ commercial use without any restriction under your responsibility.
|
||||
/ * The FatFs module is a free software and there is NO WARRANTY.
|
||||
/ * No restriction on use. You can use, modify and redistribute it for
|
||||
/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.
|
||||
/ * Redistributions of source code must retain the above copyright notice.
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs Configuration Options
|
||||
/
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
/ CAUTION! Do not forget to make clean the project after any changes to
|
||||
/ the configuration options.
|
||||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
#ifndef _FATFS
|
||||
#define _FATFS
|
||||
|
||||
#define _WORD_ACCESS 0
|
||||
/* The _WORD_ACCESS option defines which access method is used to the word
|
||||
/ data in the FAT structure.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless following condition is met.
|
||||
/
|
||||
/ When the byte order on the memory is big-endian or address miss-aligned
|
||||
/ word access results incorrect behavior, the _WORD_ACCESS must be set to 0.
|
||||
/ If it is not the case, the value can also be set to 1 to improve the
|
||||
/ performance and code efficiency. */
|
||||
|
||||
#define _MCU_ENDIAN 0
|
||||
/* The _MCU_ENDIAN defines which access method is used to the FAT structure.
|
||||
/ 1: Enable word access.
|
||||
/ 2: Disable word access and use byte-by-byte access instead.
|
||||
/ When the architectural byte order of the MCU is big-endian and/or address
|
||||
/ miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
|
||||
/ If it is not the case, it can also be set to 1 for good code efficiency. */
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
||||
/ f_truncate and useless f_getfree. */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* 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, f_truncate and f_rename are removed.
|
||||
/ 2: f_opendir and f_readdir are removed in addition to level 1.
|
||||
/ 3: f_lseek is removed in addition to level 2. */
|
||||
/
|
||||
/ 0: Full function.
|
||||
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename
|
||||
/ are removed.
|
||||
/ 2: f_opendir and f_readdir are removed in addition to level 1.
|
||||
/ 3: f_lseek is removed in addition to level 2. */
|
||||
|
||||
|
||||
#define _FS_TINY 0
|
||||
/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
|
||||
/ object instead of the sector buffer in the individual file object for file
|
||||
/ data transfer. This reduces memory consumption 512 bytes each file object. */
|
||||
|
||||
|
||||
#define _USE_STRFUNC 0
|
||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
||||
|
||||
#define _USE_MKFS 0
|
||||
/* When _USE_MKFS is set to 1 and _FS_READONLY is set to 0, f_mkfs function is
|
||||
/ enabled. */
|
||||
|
||||
#define _DRIVES 2
|
||||
/* Number of logical drives to be used. This affects the size of internal table. */
|
||||
#define _USE_MKFS 0
|
||||
/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
|
||||
|
||||
|
||||
#define _DRIVES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _MAX_SS 512
|
||||
/* Maximum sector size to be handled. (512/1024/2048/4096) */
|
||||
/* 512 for memroy card and hard disk, 1024 for floppy disk, 2048 for MO disk */
|
||||
|
||||
|
||||
#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[]. */
|
||||
|
||||
#define _USE_FSINFO 0
|
||||
/* To enable FSInfo support on FAT32 volume, set _USE_FSINFO to 1. */
|
||||
|
||||
#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_NTFLAG 1
|
||||
/* When _USE_NTFLAG is set to 1, upper/lower case of the file name is preserved.
|
||||
/ Note that the files are always accessed in case insensitive. */
|
||||
/* When _MULTI_PARTITION is set to 0, each volume is bound to the same physical
|
||||
/ drive number and can mount only first primaly partition. When it is set to 1,
|
||||
/ each volume is tied to the partitions listed in Drives[]. */
|
||||
|
||||
|
||||
#include "integer.h"
|
||||
#define _CODE_PAGE 932
|
||||
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
|
||||
/ When it is non LFN configuration, there is no difference between SBCS code
|
||||
/ pages. When LFN is enabled, the code page must always be set correctly.
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 775 - Baltic
|
||||
/ 850 - Multilingual Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 858 - Multilingual Latin 1 + Euro
|
||||
/ 862 - Hebrew
|
||||
/ 866 - Russian
|
||||
/ 874 - Thai
|
||||
/ 932 - Japanese Shift-JIS (DBCS)
|
||||
/ 936 - Simplified Chinese GBK (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS)
|
||||
/ 1258 - Vietnam
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_LFN 0
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (max:255) */
|
||||
/* The _USE_LFN option switches the LFN support.
|
||||
/
|
||||
/ 0: Disable LFN.
|
||||
/ 1: Enable LFN with static working buffer on the bss. NOT REENTRANT.
|
||||
/ 2: Enable LFN with dynamic working buffer on the caller's STACK.
|
||||
/
|
||||
/ The working buffer occupies (_MAX_LFN + 1) * 2 bytes. When enable LFN,
|
||||
/ a Unicode - OEM code conversion function ff_convert() must be added to
|
||||
/ the project. */
|
||||
|
||||
|
||||
#define _FS_REENTRANT 0
|
||||
#define _TIMEOUT 1000 /* Timeout period in unit of time ticks */
|
||||
#define _SYNC_t HANDLE /* Type of sync object used on the OS. */
|
||||
/* e.g. HANDLE, OS_EVENT*, ID and etc.. */
|
||||
/* To make the FatFs module re-entrant, set _FS_REENTRANT to 1 and add user
|
||||
/ provided synchronization handlers, ff_req_grant, ff_rel_grant,
|
||||
/ ff_del_syncobj and ff_cre_syncobj function to the project. */
|
||||
|
||||
|
||||
|
||||
/* Definitions corresponds to multiple sector size (not tested) */
|
||||
#define S_MAX_SIZ 512U /* Do not change */
|
||||
#if S_MAX_SIZ > 512U
|
||||
/* End of configuration options. Do not change followings without care. */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* Definitions corresponds to multiple sector size */
|
||||
|
||||
#if _MAX_SS == 512
|
||||
#define SS(fs) 512
|
||||
#else
|
||||
#if _MAX_SS == 1024 || _MAX_SS == 2048 || _MAX_SS == 4096
|
||||
#define SS(fs) ((fs)->s_size)
|
||||
#else
|
||||
#define SS(fs) 512U
|
||||
#error Sector size must be 512, 1024, 2048 or 4096.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* File system object structure */
|
||||
|
||||
typedef struct _FATFS {
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
DWORD sects_fat; /* Sectors per fat */
|
||||
DWORD max_clust; /* Maximum cluster# + 1 */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (cluster# for FAT32) */
|
||||
DWORD database; /* Data start sector */
|
||||
#if !_FS_READONLY
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
#if _USE_FSINFO
|
||||
DWORD fsi_sector; /* fsinfo sector */
|
||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||
BYTE pad2;
|
||||
#endif
|
||||
#endif
|
||||
BYTE fs_type; /* FAT sub type */
|
||||
BYTE csize; /* Number of sectors per cluster */
|
||||
#if S_MAX_SIZ > 512U
|
||||
WORD s_size; /* Sector size */
|
||||
#endif
|
||||
BYTE n_fats; /* Number of FAT copies */
|
||||
BYTE drive; /* Physical drive number */
|
||||
BYTE winflag; /* win[] dirty flag (1:must be written back) */
|
||||
BYTE fs_type; /* FAT sub type */
|
||||
BYTE drive; /* Physical drive number */
|
||||
BYTE csize; /* Number of sectors per cluster */
|
||||
BYTE n_fats; /* Number of FAT copies */
|
||||
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
||||
BYTE pad1;
|
||||
BYTE win[S_MAX_SIZ]; /* Disk access window for Directory/FAT */
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
||||
#if _FS_REENTRANT
|
||||
_SYNC_t sobj; /* Identifier of sync object */
|
||||
#endif
|
||||
#if _MAX_SS != 512U
|
||||
WORD s_size; /* Sector size */
|
||||
#endif
|
||||
#if !_FS_READONLY
|
||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||
BYTE pad2;
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
DWORD fsi_sector; /* fsinfo sector */
|
||||
#endif
|
||||
DWORD sects_fat; /* Sectors per fat */
|
||||
DWORD max_clust; /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS];/* Disk access window for Directory/FAT */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure */
|
||||
|
||||
typedef struct _DIR {
|
||||
WORD id; /* Owner file system mount ID */
|
||||
WORD index; /* Current index */
|
||||
WORD index; /* Current index number */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
DWORD sclust; /* Start cluster */
|
||||
DWORD sclust; /* Table start cluster (0:Static table) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index (0xFFFF:No LFN) */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File object structure */
|
||||
|
||||
typedef struct _FIL {
|
||||
WORD id; /* Owner file system mount ID */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD org_clust; /* File start cluster */
|
||||
DWORD curr_clust; /* Current cluster */
|
||||
DWORD curr_sect; /* Current sector */
|
||||
#if _FS_READONLY == 0
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
WORD id; /* Owner file system mount ID */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD org_clust; /* File start cluster */
|
||||
DWORD curr_clust; /* Current cluster */
|
||||
DWORD dsect; /* Current data sector */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS];/* File R/W buffer */
|
||||
#endif
|
||||
BYTE buffer[S_MAX_SIZ]; /* File R/W buffer */
|
||||
} FIL;
|
||||
|
||||
|
||||
|
||||
/* File status structure */
|
||||
|
||||
typedef struct _FILINFO {
|
||||
DWORD fsize; /* Size */
|
||||
WORD fdate; /* Date */
|
||||
WORD ftime; /* Time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
char fname[8+1+3+1]; /* Name (8.3 format) */
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
char fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
char *lfname; /* Pointer to the LFN buffer */
|
||||
int lfsize; /* Size of LFN buffer [bytes] */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
|
||||
|
||||
/* DBCS code ranges */
|
||||
|
||||
#if _CODE_PAGE == 932 /* CP932 (Japanese Shift-JIS) */
|
||||
#define _DF1S 0x81 /* DBC 1st byte range 1 start */
|
||||
#define _DF1E 0x9F /* DBC 1st byte range 1 end */
|
||||
#define _DF2S 0xE0 /* DBC 1st byte range 2 start */
|
||||
#define _DF2E 0xFC /* DBC 1st byte range 2 end */
|
||||
#define _DS1S 0x40 /* DBC 2nd byte range 1 start */
|
||||
#define _DS1E 0x7E /* DBC 2nd byte range 1 end */
|
||||
#define _DS2S 0x80 /* DBC 2nd byte range 2 start */
|
||||
#define _DS2E 0xFC /* DBC 2nd byte range 2 end */
|
||||
|
||||
#elif _CODE_PAGE == 936 /* CP936 (Simplified Chinese GBK) */
|
||||
#define _DF1S 0x81
|
||||
#define _DF1E 0xFE
|
||||
#define _DS1S 0x40
|
||||
#define _DS1E 0x7E
|
||||
#define _DS2S 0x80
|
||||
#define _DS2E 0xFE
|
||||
|
||||
#elif _CODE_PAGE == 949 /* CP949 (Korean) */
|
||||
#define _DF1S 0x81
|
||||
#define _DF1E 0xFE
|
||||
#define _DS1S 0x41
|
||||
#define _DS1E 0x5A
|
||||
#define _DS2S 0x61
|
||||
#define _DS2E 0x7A
|
||||
#define _DS3S 0x81
|
||||
#define _DS3E 0xFE
|
||||
|
||||
#elif _CODE_PAGE == 950 /* CP950 (Traditional Chinese Big5) */
|
||||
#define _DF1S 0x81
|
||||
#define _DF1E 0xFE
|
||||
#define _DS1S 0x40
|
||||
#define _DS1E 0x7E
|
||||
#define _DS2S 0xA1
|
||||
#define _DS2E 0xFE
|
||||
|
||||
#else /* SBCS code pages */
|
||||
#define _DF1S 0
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Character code support macros */
|
||||
|
||||
#define IsUpper(c) (((c)>='A')&&((c)<='Z'))
|
||||
#define IsLower(c) (((c)>='a')&&((c)<='z'))
|
||||
#define IsDigit(c) (((c)>='0')&&((c)<='9'))
|
||||
|
||||
#if _DF1S /* DBCS configuration */
|
||||
|
||||
#if _DF2S /* Two 1st byte areas */
|
||||
#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
|
||||
#else /* One 1st byte area */
|
||||
#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
|
||||
#endif
|
||||
|
||||
#if _DS3S /* Three 2nd byte areas */
|
||||
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E))
|
||||
#else /* Two 2nd byte areas */
|
||||
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
|
||||
#endif
|
||||
|
||||
#else /* SBCS configuration */
|
||||
|
||||
#define IsDBCS1(c) 0
|
||||
#define IsDBCS2(c) 0
|
||||
|
||||
#endif /* _DF1S */
|
||||
|
||||
|
||||
|
||||
/* Definitions corresponds to multi partition */
|
||||
|
||||
#if _MULTI_PARTITION != 0 /* Multiple partition cfg */
|
||||
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||
|
||||
typedef struct _PARTITION {
|
||||
BYTE pd; /* Physical drive # (0-255) */
|
||||
BYTE pd; /* Physical drive# */
|
||||
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 */
|
||||
#else /* Single partition configuration */
|
||||
|
||||
#define LD2PD(drv) (drv) /* Physical drive# is equal to logical drive# */
|
||||
#define LD2PT(drv) 0 /* Always mounts the 1st partition */
|
||||
#define LD2PD(drv) (drv) /* Physical drive# is equal to the 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 */
|
||||
FR_DISK_ERR, /* 1 */
|
||||
FR_INT_ERR, /* 2 */
|
||||
FR_NOT_READY, /* 3 */
|
||||
FR_NO_FILE, /* 4 */
|
||||
FR_NO_PATH, /* 5 */
|
||||
FR_INVALID_NAME, /* 6 */
|
||||
FR_DENIED, /* 7 */
|
||||
FR_EXIST, /* 8 */
|
||||
FR_INVALID_OBJECT, /* 9 */
|
||||
FR_WRITE_PROTECTED, /* 10 */
|
||||
FR_INVALID_DRIVE, /* 11 */
|
||||
FR_NOT_ENABLED, /* 12 */
|
||||
FR_NO_FILESYSTEM, /* 13 */
|
||||
FR_MKFS_ABORTED, /* 14 */
|
||||
FR_TIMEOUT /* 15 */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
|
||||
FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_open (FIL*, const char*, BYTE); /* Open or create a file */
|
||||
@ -208,24 +383,52 @@ FRESULT f_truncate (FIL*); /* Truncate file */
|
||||
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
|
||||
FRESULT f_unlink (const char*); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir (const char*); /* Create a new directory */
|
||||
FRESULT f_chmod (const char*, BYTE, BYTE); /* Change file/dir attriburte */
|
||||
FRESULT f_utime (const char*, const FILINFO*); /* Change file/dir timestamp */
|
||||
FRESULT f_chmod (const char*, BYTE, BYTE); /* Change attriburte of the file/dir */
|
||||
FRESULT f_utime (const char*, const FILINFO*); /* Change timestamp of the file/dir */
|
||||
FRESULT f_rename (const char*, const char*); /* Rename/Move a file or directory */
|
||||
FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */
|
||||
FRESULT f_mkfs (BYTE, BYTE, WORD); /* Create a file system on the drive */
|
||||
|
||||
#if _USE_STRFUNC
|
||||
#define feof(fp) ((fp)->fptr == (fp)->fsize)
|
||||
int f_putc (int, FIL*); /* Put a character to the file */
|
||||
int f_puts (const char*, FIL*); /* Put a string to the file */
|
||||
int f_printf (FIL*, const char*, ...); /* Put a formatted string to the file */
|
||||
char* f_gets (char*, int, FIL*); /* Get a string from the file */
|
||||
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
|
||||
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
|
||||
#ifndef EOF
|
||||
#define EOF -1
|
||||
int fputc (int, FIL*); /* Put a character to the file */
|
||||
int fputs (const char*, FIL*); /* Put a string to the file */
|
||||
int fprintf (FIL*, const char*, ...); /* Put a formatted string to the file */
|
||||
char* fgets (char*, int, FIL*); /* Get a string from the file */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* User defined function to give a current time to fatfs module */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* User defined functions */
|
||||
|
||||
/* Real time clock */
|
||||
#if !_FS_READONLY
|
||||
DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
|
||||
/* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
|
||||
#endif
|
||||
|
||||
/* Unicode - OEM code conversion */
|
||||
#if _USE_LFN
|
||||
WCHAR ff_convert (WCHAR, UINT);
|
||||
#endif
|
||||
|
||||
/* Sync functions */
|
||||
#if _FS_REENTRANT
|
||||
BOOL ff_cre_syncobj(BYTE, _SYNC_t*);
|
||||
BOOL ff_del_syncobj(_SYNC_t);
|
||||
BOOL ff_req_grant(_SYNC_t);
|
||||
void ff_rel_grant(_SYNC_t);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and offset address */
|
||||
|
||||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
@ -259,10 +462,12 @@ DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
|
||||
|
||||
|
||||
/* Offset of FAT structure members */
|
||||
/* FatFs refers the members in the FAT structures with byte offset instead
|
||||
/ of structure member because there are incompatibility of the packing option
|
||||
/ between various compilers. */
|
||||
|
||||
#define BS_jmpBoot 0
|
||||
#define BS_OEMName 3
|
||||
@ -315,25 +520,28 @@ DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20
|
||||
#define DIR_WrtDate 24
|
||||
#define DIR_FstClusLO 26
|
||||
#define DIR_FileSize 28
|
||||
#define LDIR_Ord 0
|
||||
#define LDIR_Attr 11
|
||||
#define LDIR_Type 12
|
||||
#define LDIR_Chksum 13
|
||||
#define LDIR_FstClusLO 26
|
||||
|
||||
|
||||
|
||||
/*--------------------------------*/
|
||||
/* Multi-byte word access macros */
|
||||
|
||||
#if _MCU_ENDIAN == 1 /* Use word access */
|
||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#elif _MCU_ENDIAN == 2 /* Use byte-by-byte access */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*(volatile BYTE*)((ptr)+1)<<8)|(WORD)*(volatile BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*(volatile BYTE*)((ptr)+3)<<24)|((DWORD)*(volatile BYTE*)((ptr)+2)<<16)|((WORD)*(volatile BYTE*)((ptr)+1)<<8)|*(volatile BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
#define ST_DWORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(volatile BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(volatile BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
||||
#else
|
||||
#error Do not forget to set _MCU_ENDIAN properly!
|
||||
#else /* Use byte-by-byte access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*(BYTE*)((ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*(BYTE*)((ptr)+3)<<24)|((DWORD)*(BYTE*)((ptr)+2)<<16)|((WORD)*(BYTE*)((ptr)+1)<<8)|*(BYTE*)(ptr))
|
||||
#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)
|
||||
#endif
|
||||
|
||||
|
||||
#define _FATFS
|
||||
#endif /* _FATFS */
|
||||
|
||||
@ -4,6 +4,10 @@
|
||||
|
||||
#ifndef _INTEGER
|
||||
|
||||
#if 0
|
||||
#include <windows.h>
|
||||
#else
|
||||
|
||||
/* These types must be 16-bit, 32-bit or larger integer */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
@ -17,6 +21,7 @@ typedef unsigned char BYTE;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
|
||||
/* These types must be 32-bit integer */
|
||||
typedef long LONG;
|
||||
@ -26,5 +31,7 @@ typedef unsigned long DWORD;
|
||||
/* Boolean type */
|
||||
typedef enum { FALSE = 0, TRUE } BOOL;
|
||||
|
||||
#endif
|
||||
|
||||
#define _INTEGER
|
||||
#endif
|
||||
|
||||
3784
src/option/cc932.c
Normal file
3784
src/option/cc932.c
Normal file
File diff suppressed because it is too large
Load Diff
10960
src/option/cc936.c
Normal file
10960
src/option/cc936.c
Normal file
File diff suppressed because it is too large
Load Diff
8588
src/option/cc949.c
Normal file
8588
src/option/cc949.c
Normal file
File diff suppressed because it is too large
Load Diff
6814
src/option/cc950.c
Normal file
6814
src/option/cc950.c
Normal file
File diff suppressed because it is too large
Load Diff
332
src/option/ccsbcs.c
Normal file
332
src/option/ccsbcs.c
Normal file
@ -0,0 +1,332 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Unicode - OEM code bidirectional converter (C)ChaN, 2009 */
|
||||
/* */
|
||||
/* SBCS code */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include "../ff.h"
|
||||
|
||||
|
||||
#if _USE_LFN && _CODE_PAGE == 437
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
|
||||
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 720
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */
|
||||
0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9,
|
||||
0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627,
|
||||
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
|
||||
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642,
|
||||
0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A,
|
||||
0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0xO650, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 737
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */
|
||||
0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
|
||||
0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
|
||||
0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
|
||||
0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8,
|
||||
0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0,
|
||||
0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD,
|
||||
0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E,
|
||||
0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 775
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */
|
||||
0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107,
|
||||
0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A,
|
||||
0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4,
|
||||
0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6,
|
||||
0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118,
|
||||
0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D,
|
||||
0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B,
|
||||
0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144,
|
||||
0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019,
|
||||
0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E,
|
||||
0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 850
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
|
||||
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
|
||||
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
|
||||
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
|
||||
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
|
||||
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 852
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7,
|
||||
0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,
|
||||
0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A,
|
||||
0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E,
|
||||
0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A,
|
||||
0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE,
|
||||
0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161,
|
||||
0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4,
|
||||
0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8,
|
||||
0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 855
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */
|
||||
0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
|
||||
0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
|
||||
0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C,
|
||||
0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A,
|
||||
0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414,
|
||||
0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438,
|
||||
0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E,
|
||||
0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580,
|
||||
0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443,
|
||||
0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116,
|
||||
0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D,
|
||||
0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 857
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F,
|
||||
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
|
||||
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE,
|
||||
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000,
|
||||
0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4,
|
||||
0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
|
||||
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 858
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP858(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
|
||||
0x00A9, 0x2563, 0x2551, 0x2557, 0x2550, 0x00A2, 0x00A5, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x20AC, 0x00CD, 0x00CE,
|
||||
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00C6, 0x00CC, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
|
||||
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
|
||||
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
|
||||
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 862
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */
|
||||
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
|
||||
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
|
||||
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
|
||||
0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
|
||||
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 866
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */
|
||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
|
||||
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
|
||||
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
|
||||
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
|
||||
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
|
||||
0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 874
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP874(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
|
||||
0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
|
||||
0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
|
||||
0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
|
||||
0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
|
||||
0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
|
||||
0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
|
||||
0x0E38, 0x0E39, 0x0E3A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0E3F,
|
||||
0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
|
||||
0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
|
||||
0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
|
||||
0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0000, 0x0000, 0x0000, 0x0000
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1258
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1258(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0000, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x02DC, 0x2122, 0x0000, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||
0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF,
|
||||
0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7,
|
||||
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF,
|
||||
0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF,
|
||||
0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7,
|
||||
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if _TBLDEF
|
||||
|
||||
WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
WCHAR src, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
{
|
||||
const WCHAR *p;
|
||||
WCHAR c;
|
||||
|
||||
|
||||
if (src < 0x80) { /* ASCII */
|
||||
c = src;
|
||||
|
||||
} else {
|
||||
if (dir) { /* OEMCP to Unicode */
|
||||
c = (src >= 0x100) ? 0 : Tbl[src - 0x80];
|
||||
|
||||
} else { /* Unicode to OEMCP */
|
||||
for (c = 0; c < 0x80; c++) {
|
||||
if (src == Tbl[c]) break;
|
||||
}
|
||||
c = (c + 0x80) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#else
|
||||
#error This file is not needed in current configuration
|
||||
|
||||
#endif
|
||||
|
||||
115
src/option/syncobj.c
Normal file
115
src/option/syncobj.c
Normal file
@ -0,0 +1,115 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Sample code of OS dependent synchronization object controls */
|
||||
/* for FatFs R0.07a (C)ChaN, 2009 */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include <windows.h> // Win32
|
||||
//#include <ucos_ii.h> // uC/OS-II
|
||||
|
||||
#include "../ff.h"
|
||||
|
||||
#if _FS_REENTRANT
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Create a Synchronization Object for a Volume
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount function to create a new
|
||||
/ synchronization object, such as semaphore and mutex. When a FALSE is
|
||||
/ returned, the f_mount function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
BOOL ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to any error */
|
||||
BYTE vol, /* Corresponding logical drive being processed */
|
||||
_SYNC_t *sobj /* Pointer to return the created sync object */
|
||||
)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
*sobj = CreateMutex(NULL, FALSE, NULL); // Win32
|
||||
ret = (*sobj != INVALID_HANDLE_VALUE) ? TRUE : FALSE; //
|
||||
|
||||
// *sobj = VolumeSemId[vol]; // uITRON (give a static created sync object)
|
||||
// ret = TRUE; // The initial value of the semaphore must be 1.
|
||||
|
||||
// *sobj = OSMutexCreate(0, &err); // uC/OS-II
|
||||
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Delete a Synchronization Object */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount function to delete a synchronization
|
||||
/ object that created with ff_cre_syncobj function. When a FALSE is
|
||||
/ returned, the f_mount function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
BOOL ff_del_syncobj ( /* TRUE:Function succeeded, FALSE:Could not delete due to any error */
|
||||
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
||||
)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
ret = CloseHandle(sobj); // Win32
|
||||
|
||||
// ret = TRUE; // uITRON (nothing to do)
|
||||
|
||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); // uC/OS-II
|
||||
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Request Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on entering file functions to lock the volume.
|
||||
/ When a FALSE is returned, the file function fails with FR_TIMEOUT.
|
||||
*/
|
||||
|
||||
BOOL ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
|
||||
_SYNC_t sobj /* Sync object to wait */
|
||||
)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
ret = (WaitForSingleObject(sobj, _TIMEOUT) == WAIT_OBJECT_0) ? TRUE : FALSE; // Win32
|
||||
|
||||
// ret = (wai_sem(sobj) == E_OK) ? TRUE : FALSE; // uITRON
|
||||
|
||||
// OSMutexPend(sobj, _TIMEOUT, &err)); // uC/OS-II
|
||||
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Release Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on leaving file functions to unlock the volume.
|
||||
*/
|
||||
|
||||
void ff_rel_grant (
|
||||
_SYNC_t sobj /* Sync object to be signaled */
|
||||
)
|
||||
{
|
||||
ReleaseMutex(sobj); // Win32
|
||||
|
||||
// sig_sem(sobj); // uITRON
|
||||
|
||||
// OSMutexPost(sobj); // uC/OS-II
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#error This file is not needed in this configuration.
|
||||
|
||||
#endif
|
||||
306
src/tff.h
306
src/tff.h
@ -1,306 +0,0 @@
|
||||
/*--------------------------------------------------------------------------/
|
||||
/ Tiny-FatFs - FAT file system module include file R0.06 (C)ChaN, 2008
|
||||
/---------------------------------------------------------------------------/
|
||||
/ FatFs module is an experimenal project to implement FAT file system to
|
||||
/ cheap microcontrollers. This is a free software and is opened for education,
|
||||
/ research and development under license policy of following trems.
|
||||
/
|
||||
/ Copyright (C) 2008, ChaN, all right reserved.
|
||||
/
|
||||
/ * The FatFs module is a free software and there is no warranty.
|
||||
/ * You can use, modify and/or redistribute it for personal, non-profit or
|
||||
/ commercial use without any restriction under your responsibility.
|
||||
/ * Redistributions of source code must retain the above copyright notice.
|
||||
/
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _FATFS
|
||||
|
||||
#define _MCU_ENDIAN 0
|
||||
/* The _MCU_ENDIAN defines which access method is used to the FAT structure.
|
||||
/ 1: Enable word access.
|
||||
/ 2: Disable word access and use byte-by-byte access instead.
|
||||
/ When the architectural byte order of the MCU is big-endian and/or address
|
||||
/ miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
|
||||
/ If it is not the case, it can also be set to 1 for good code efficiency. */
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
||||
/ f_truncate, f_getfree and internal writing codes. */
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* 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, f_truncate and f_rename are removed.
|
||||
/ 2: f_opendir and f_readdir are removed in addition to level 1.
|
||||
/ 3: f_lseek is removed in addition to level 2. */
|
||||
|
||||
#define _USE_STRFUNC 0
|
||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* To enable f_forward function, set _USE_FORWARD to 1. */
|
||||
|
||||
#define _FAT32 0
|
||||
/* To enable FAT32 support in addition of FAT12/16, set _FAT32 to 1. */
|
||||
|
||||
#define _USE_FSINFO 0
|
||||
/* To enable FSInfo support on FAT32 volume, set _USE_FSINFO to 1. */
|
||||
|
||||
#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_NTFLAG 1
|
||||
/* When _USE_NTFLAG is set to 1, upper/lower case of the file name is preserved.
|
||||
/ Note that the files are always accessed in case insensitive. */
|
||||
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
|
||||
/* Type definition for cluster number */
|
||||
#if _FAT32
|
||||
typedef DWORD CLUST;
|
||||
#else
|
||||
typedef WORD CLUST;
|
||||
#undef _USE_FSINFO
|
||||
#define _USE_FSINFO 0
|
||||
#endif
|
||||
|
||||
|
||||
/* File system object structure */
|
||||
typedef struct _FATFS {
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector */
|
||||
DWORD database; /* Data start sector */
|
||||
CLUST sects_fat; /* Sectors per fat */
|
||||
CLUST max_clust; /* Maximum cluster# + 1 */
|
||||
#if !_FS_READONLY
|
||||
CLUST last_clust; /* Last allocated cluster */
|
||||
CLUST free_clust; /* Number of free clusters */
|
||||
#if _USE_FSINFO
|
||||
DWORD fsi_sector; /* fsinfo sector */
|
||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||
BYTE pad1;
|
||||
#endif
|
||||
#endif
|
||||
BYTE fs_type; /* FAT sub type */
|
||||
BYTE csize; /* Number of 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 */
|
||||
} DIR;
|
||||
|
||||
|
||||
/* File object structure */
|
||||
typedef struct _FIL {
|
||||
WORD id; /* Owner file system mount ID */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE csect; /* Sector address in the cluster */
|
||||
FATFS* fs; /* Pointer to owner file system */
|
||||
DWORD fptr; /* File R/W pointer */
|
||||
DWORD fsize; /* File size */
|
||||
CLUST org_clust; /* File start cluster */
|
||||
CLUST curr_clust; /* Current cluster */
|
||||
DWORD curr_sect; /* Current sector */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
||||
/* File status structure */
|
||||
typedef struct _FILINFO {
|
||||
DWORD fsize; /* Size */
|
||||
WORD fdate; /* Date */
|
||||
WORD ftime; /* Time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
char fname[8+1+3+1]; /* Name (8.3 format) */
|
||||
} 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 */
|
||||
FR_MKFS_ABORTED /* 13 (not used) */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------*/
|
||||
/* Tiny-FatFs module application interface */
|
||||
|
||||
FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_open (FIL*, const char*, BYTE); /* Open or create a file */
|
||||
FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */
|
||||
FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
|
||||
FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */
|
||||
FRESULT f_close (FIL*); /* Close an open file object */
|
||||
FRESULT f_opendir (DIR*, const char*); /* Open an existing directory */
|
||||
FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */
|
||||
FRESULT f_stat (const char*, FILINFO*); /* Get file status */
|
||||
FRESULT f_getfree (const char*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
|
||||
FRESULT f_truncate (FIL*); /* Truncate file */
|
||||
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
|
||||
FRESULT f_unlink (const char*); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir (const char*); /* Create a new directory */
|
||||
FRESULT f_chmod (const char*, BYTE, BYTE); /* Change file/dir attriburte */
|
||||
FRESULT f_utime (const char*, const FILINFO*); /* Change file/dir timestamp */
|
||||
FRESULT f_rename (const char*, const char*); /* Rename/Move a file or directory */
|
||||
FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */
|
||||
#if _USE_STRFUNC
|
||||
#define feof(fp) ((fp)->fptr == (fp)->fsize)
|
||||
#define EOF -1
|
||||
int fputc (int, FIL*); /* Put a character to the file */
|
||||
int fputs (const char*, FIL*); /* Put a string to the file */
|
||||
int fprintf (FIL*, const char*, ...); /* Put a formatted string to the file */
|
||||
char* fgets (char*, int, FIL*); /* Get a string from the file */
|
||||
#endif
|
||||
|
||||
|
||||
/* User defined function to give a current time to fatfs module */
|
||||
|
||||
DWORD get_fattime (void); /* 31-25: Year(0-127 +1980), 24-21: Month(1-12), 20-16: Day(1-31) */
|
||||
/* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
|
||||
|
||||
|
||||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
|
||||
#define FA_READ 0x01
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
#if !_FS_READONLY
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA__WRITTEN 0x20
|
||||
#endif
|
||||
#define FA__ERROR 0x80
|
||||
|
||||
|
||||
/* FAT sub type (FATFS.fs_type) */
|
||||
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
|
||||
|
||||
/* File attribute bits for directory entry */
|
||||
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_VOL 0x08 /* Volume label */
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
|
||||
|
||||
|
||||
/* 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 FSI_LeadSig 0
|
||||
#define FSI_StrucSig 484
|
||||
#define FSI_Free_Count 488
|
||||
#define FSI_Nxt_Free 492
|
||||
|
||||
#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 */
|
||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#elif _MCU_ENDIAN == 2 /* Use byte-by-byte access */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*(volatile BYTE*)((ptr)+1)<<8)|(WORD)*(volatile BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*(volatile BYTE*)((ptr)+3)<<24)|((DWORD)*(volatile BYTE*)((ptr)+2)<<16)|((WORD)*(volatile BYTE*)((ptr)+1)<<8)|*(volatile BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
#define ST_DWORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(volatile BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(volatile BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
||||
#else
|
||||
#error Do not forget to set _MCU_ENDIAN properly!
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define _FATFS
|
||||
#endif /* _FATFS */
|
||||
Loading…
Reference in New Issue
Block a user