fatfs v0.01 Apr 29, 2006:

- First stable version
This commit is contained in:
savelij13 2025-09-11 08:52:19 +03:00
commit 4f7376e6aa
62 changed files with 6136 additions and 0 deletions

99
doc/00index_e.html Normal file
View File

@ -0,0 +1,99 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html">
<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FAT Files System Module</title>
</head>
<body>
<h1>FAT File System Module</h1>
<hr>
<div class="abst">
<img src="layers.png" class="rset" width="245" height="255">
<p>FatFs module is an experimental project to implement a FAT file system to small embdded system. Because the module is written in compliance with ANSI C, it can be used for most 8/16 bit microcontrollers, such as PIC, AVR, H8, Z80 and etc..., without any modification. To use the FatFs module, low level disk I/O functions for each recording media must be provided by user. I created two modules in different configurations in consideration of various use. For read only applications, wriiting codes can also be eliminated to reduce the code size.</p>
<h4>Features of FatFs Module</h4>
<ul>
<li>Separated buffer for FAT and each file. Suitable for fast multiple file accsess.</li>
<li>Low memory consumption (ex. avr-gcc)
<ul>
<li>Program Code: 7752 bytes (R/W cfg.), 4154 bytes (R/O cfg.)</li>
<li>Static Work Area: 2 bytes</li>
<li>Dynamic Work Area: 544 + 542 * &lt;files&gt; bytes</li>
</ul>
</li>
<li>Supports FAT16(+FAT64) and FAT32 <small>(FAT64: FAT16 in 64KB/cluster)</small></li>
<li>Supports 8.3 format file name and NT lower capital flags</li>
<li>Supports two partitioning formats: FDISK (only primariy partition) and SFD (only 512B/sector)</li>
</ul>
<h4>Features of Tiny-FatFs Module</h4>
<ul>
<li>Only a common buffer for FAT and each file to reduce memory consumption.</li>
<li>Low memory consumption (ex. avr-gcc), suitable for small memory system (1KB)
<ul>
<li>Program Code: 6470 bytes (R/W cfg.), 3556 bytes (R/O cfg.)</li>
<li>Static Work Area: 2 bytes</li>
<li>Dynamic Work Area: 538 + 24 * &lt;files&gt; bytes</li>
</ul>
</li>
<li>Supports FAT16(+FAT64)</li>
<li>Supports 8.3 format file name and NT lower capital flags</li>
<li>Supports two partitioning formats: FDISK (only primariy partition) and SFD (only 512B/sector)</li>
</ul>
</div>
<div class="para">
<h3>Application Interface</h3>
<p>FatFs module and Tiny-FatFs module provide following functions.</p>
<ul>
<li><a href="en/open.html">f_open</a> - Open/Create a File</li>
<li><a href="en/close.html">f_close</a> - Close a File</li>
<li><a href="en/read.html">f_read</a> - Read File</li>
<li><a href="en/write.html">f_write</a> - Write File</li>
<li><a href="en/lseek.html">f_lseek</a> - Move R/W Pointer</li>
<li><a href="en/sync.html">f_sync</a> - Flush Cached Data</li>
<li><a href="en/opendir.html">f_opendir</a> - Open a Directory</li>
<li><a href="en/readdir.html">f_readdir</a> - Read a Directory Item</li>
<li><a href="en/getfree.html">f_getfree</a> - Get Free Clusters</li>
<li><a href="en/stat.html">f_stat</a> - Get File Status</li>
<li><a href="en/mkdir.html">f_mkdir</a> - Create a Directory</li>
<li><a href="en/unlink.html">f_unlink</a> - Remove a File or Directory</li>
<li><a href="en/chmod.html">f_chmod</a> - Change Attribute</li>
<li><a href="en/mountdrv.html">f_mountdrv</a> - Force Initialized FatFs Module</li>
</ul>
</div>
<div class="para">
<h3>Disk I/O Interface</h3>
<p>FatFs module and Tiny-FatFs module require following functions to lower layer to read/write to physical disk and to get current time.</p>
<ul>
<li><a href="en/dinit.html">disk_initialize</a> - Initialize disk drive</li>
<li><a href="en/dstat.html">disk_status</a> - Get disk status</li>
<li><a href="en/dread.html">disk_read</a> - Read sector(s)</li>
<li><a href="en/dwrite.html">disk_write</a> - Write sector(s)</li>
<li><a href="en/fattime.html">get_fattime</a> - Get current time</li>
</ul>
</div>
<div class="para">
<h3>Resources</h3>
<p>The FatFs module is opened for education, reserch and development. You can use, modify and republish it for personal, non-profit or profit use without any limitation under your responsibility.</p>
<br>
<ul>
<li><a href="rwtest.png">Bench Mark</a> (Test Board: ATmega64/9.2MHz with <a href="rw_mmc.jpeg">MMC</a>/<a href="rw_ata.jpeg">HDD</a>/<a href="rw_cfc.jpeg">CFC</a>)</li>
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification</a> (Microsoft)</li>
<li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to Use an MMC</a></li>
</ul>
</div>
<hr>
</body>
</html>

98
doc/00index_j.html Normal file
View File

@ -0,0 +1,98 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="alternate" hreflang="en" title="English version" href="00index_e.html">
<link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FAT Files System Module</title>
</head>
<body>
<h1>FATファイルシステム・モジュール</h1>
<hr>
<div class="abst">
<img src="layers.png" class="rset" width="245" height="255">
<p>小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・プラットフォームには依存しないので、必要なワークエリアが確保できれば、PIC, AVR, H8, Z80などほとんどのマイコンでそのまま使用可能です。実際に使用するには、各記録メディアCFC, MMC, SDC, ATA, USB, SCSI等に対応したディスクI/Oモジュールを用意する必要があります。いろいろな使用形態を考慮して、高速版FatFsと省メモリ版Tiny-FatFsの2通りを作成してみました。読み出し専用アプリケーションではさらに書き込み関係のコードを削減した構成もできます。</p>
<h4>FatFsモジュールの特徴</h4>
<ul>
<li>システム用と各ファイル用バッファを分離し、複数ファイルの高速アクセスに適する</li>
<li>メモリの消費が少ない(avrgccでの例)
<ul>
<li>プログラム・エリア: 7736 bytes (R/W構成), 4154 bytes (R/O構成)</li>
<li>静的ワーク・エリア: 2 bytes</li>
<li>動的ワーク・エリア: 544 + 542 * &lt;files&gt; bytes</li>
</ul>
</li>
<li>FAT16(+FAT64), FAT32に対応 <small>(FAT64: FAT16 in 64KB/cluster)</small></li>
<li>8.3形式ファイル名とNT小文字フラグに対応</li>
<li>FDISKフォーマット(基本区画)およびSFDフォーマット(512B/sectorのみ)に対応</li>
</ul>
<h4>Tiny-FatFsモジュールの特徴</h4>
<ul>
<li>システム用と各ファイル用バッファを共通化し、RAMの使用量を削減</li>
<li>メモリの消費が少なく(avrgccでの例)、小メモリ・システム(1KB)に対応</li>
<ul>
<li>プログラム・エリア: 6470 bytes (R/W構成), 3556 bytes (R/O構成)</li>
<li>静的ワーク・エリア: 2 bytes</li>
<li>動的ワーク・エリア: 538 + 24 * &lt;files&gt; bytes</li>
</ul>
</li>
<li>FAT16(+FAT64)に対応</li>
<li>8.3形式ファイル名とNT小文字フラグに対応</li>
<li>FDISKフォーマット(基本区画)およびSFDフォーマット(512B/sectorのみ)に対応</li>
</ul>
</div>
<div class="para">
<h3>上位レイヤI/F</h3>
<p>FatFsモジュールとTiny-FatFsモジュールは、次のファイル操作関数を提供しています。</p>
<ul>
<li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li>
<li><a href="ja/close.html">f_close</a> - ファイルのクローズ</li>
<li><a href="ja/read.html">f_read</a> - ファイルの読み込み</li>
<li><a href="ja/write.html">f_write</a> - ファイルの書き込み</li>
<li><a href="ja/lseek.html">f_lseek</a> - ファイルR/Wポインタの移動</li>
<li><a href="ja/sync.html">f_sync</a> - キャッシュされたデータのフラッシュ</li>
<li><a href="ja/opendir.html">f_opendir</a> - ディレクトリのオープン</li>
<li><a href="ja/readdir.html">f_readdir</a> - ディレクトリの読み出し</li>
<li><a href="ja/getfree.html">f_getfree</a> - ディスク空き領域の取得</li>
<li><a href="ja/stat.html">f_stat</a> - ファイル・ステータスの取得</li>
<li><a href="ja/mkdir.html">f_mkdir</a> - ディレクトリの作成</li>
<li><a href="ja/unlink.html">f_unlink</a> - ファイルまたはディレクトリの削除</li>
<li><a href="ja/chmod.html">f_chmod</a> - ファイルまたはディレクトリ属性の変更</li>
<li><a href="ja/mountdrv.html">f_mountdrv</a> - ファイル・システムの明示的初期化</li>
</ul>
</div>
<div class="para">
<h3>下位レイヤI/F</h3>
<p>FatFsモジュールとTiny-FatFsモジュールは、物理ドライブへのアクセスや現在時刻を得るため、下位レイヤに次のインターフェースを要求します。</p>
<ul>
<li><a href="ja/dinit.html">disk_initialize</a> - ディスク・ドライブの初期化</li>
<li><a href="ja/dstat.html">disk_status</a> - ディスク・ドライブの状態取得</li>
<li><a href="ja/dread.html">disk_read</a> - ディスクからの読み込み</li>
<li><a href="ja/dwrite.html">disk_write</a> - ディスクへの書き込み</li>
<li><a href="ja/fattime.html">get_fattime</a> - 日付・時刻の取得</li>
</ul>
</div>
<div class="para">
<h3>資料</h3>
<p>FatFsモジュールとTiny-FatFsモジュールは教育・研究・開発用に公開しています。どのような目的個人・非商用・商用の利用でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。</p>
<br>
<ul>
<li><a href="rwtest.png">パフォーマンス・テスト</a>テストボードATmega64/9.2MHz with <a href="rw_mmc.jpeg">MMC</a>/<a href="rw_ata.jpeg">HDD</a>/<a href="rw_cfc.jpeg">CFC</a></li>
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32仕様書</a> (Microsoft)</li>
<li><a href="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li>
</ul>
</div>
<hr>
</body>
</html>

51
doc/css_e.css Normal file
View File

@ -0,0 +1,51 @@
* {margin: 0; padding: 0; border-width: 0;}
body {margin: 8px; background-color: #e0ffff; font-color: black; line-height: 133%; max-width: 1024px;}
a:link {color: blue;}
a:visited {color: darkmagenta;}
a:hover {background-color: #a0ffff;}
a:active {color: darkmagenta; position: relative; top: 1px; left: 1px;}
abbr {border-width: 1px;}
p {margin: 0 0 0.3em 1em;}
em {}
strong {}
pre {margin: 1em; line-height: 1.2em; background-color: white;}
tt {margin: 0 0.2em;}
ol {margin: 0 2em;}
ul {margin: 0 2em;}
dl {margin: 0 1em;}
dt {font-family: monospace;}
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
dl.ret dt {margin: 0.5em 0 0 0 ; font-weight: bold;}
dd {margin: 0 2em;}
hr {border-width: 1px; margin: 1em;}
div.abst {font-family: sans-serif;}
div.para {clear: both; font-family: serif;}
.equ {text-indent: 0; margin: 1em 2em 1em;}
.indent {margin-left: 2em;}
.rset {float: right; margin: 0 0 0.5em 0.5em;}
.lset {float: left; margin: 0 0.5em 0.5em 0;}
ul.flat li {list-style-type: none; margin: 0;}
a.imglnk img {border: 1px solid;}
.iequ {white-space: nowrap; font-weight: bold;}
.clr {clear: both;}
.it {font-style: italic;}
h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
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: 2em 0 0.5em;}
h4 {font-size: 1.2em; font-family: sans-serif; margin: 1.5em 0 0.2em;}
h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}
small {font-size: 80%;}
.indent {margin-left: 2em;}
/* Tables */
table.lst {margin: 4px; border-collapse: collapse; border-style: solid; border-width: 2px; border-color: black; }
table.lst th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;}
table.lst 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;}
p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}

54
doc/css_j.css Normal file
View File

@ -0,0 +1,54 @@
@charset "Shift_JIS";
/* Common style sheet for Tech Notes */
* {margin: 0; padding: 0; border-width: 0;}
body {margin: 8px; background-color: #e0ffff; font-color: black; line-height: 133%; letter-spacing: 1px; max-width: 1024px;}
a:link {color: blue;}
a:visited {color: darkmagenta;}
a:hover {background-color: #a0ffff;}
a:active {color: darkmagenta; position: relative; top: 1px; left: 1px;}
abbr {border-width: 1px;}
p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
em {}
strong {}
pre {margin: 1em; 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;}
dl {margin: 0 1em;}
dt {font-family: monospace;}
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; letter-spacing: 0;}
dl.ret dt {margin: 0.5em 0 0 0 ; font-family: monospace; letter-spacing: 0; font-weight: bold;}
dd {margin: 0 2em;}
hr {border-width: 1px; margin: 1em;}
div.abst {font-family: " Pゴシック",sans-serif;}
div.para {clear: both; font-family: " P明朝",serif;}
.equ {text-indent: 0; margin: 1em 2em 1em;}
.indent {margin-left: 2em;}
.rset {float: right; margin: 0 0 0.5em 0.5em;}
.lset {float: left; margin: 0 0.5em 0.5em 0;}
ul.flat li {list-style-type: none; margin: 0;}
a.imglnk img {border: 1px solid;}
.iequ {white-space: nowrap; font-weight: bold;}
.clr {clear: both;}
.it {font-style: italic;}
h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
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: 2em 0 0.5em;}
h4 {font-size: 1.2em; font-family: sans-serif; margin: 1.5em 0 0.2em;}
h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}
small {font-size: 80%;}
.indent {margin-left: 2em;}
/* Tables */
table.lst {margin: 4px; border-collapse: collapse; border-style: solid; border-width: 2px; border-color: black; letter-spacing: 0;}
table.lst th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top;}
table.lst 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;}
p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}

88
doc/en/chmod.html Normal file
View File

@ -0,0 +1,88 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chmod</title>
</head>
<body>
<div class="para">
<h2>f_chmod</h2>
<p>The f_chmod changes the attribute of a file or directory.</p>
<pre>
FRESULT f_chmod (
const char* <em>FileName</em>, // Pointer to the file or directory
BYTE <em>Attribute</em>, // Attribute flags
BYTE <em>AttributeMask</em> // Attribute masks
);
</pre>
</div>
<div class="para">
<h4>Parameter</h4>
<dl class="par">
<dt>FileName</dt>
<dd>Pointer to the null-terminated string that specifies a file or directory to be changed</dd>
<dt>Attribute</dt>
<dd>Attribute flags to be set in one or more combination of the following flags. The specified flags are set and others are cleard.<br>
<table class="lst">
<tr><th>Attribute</th><th>Description</th></td>
<tr><td>AR_RDO</td><td>Read only</td></td>
<tr><td>AR_ARC</td><td>Archive</td></td>
<tr><td>AR_SYS</td><td>System</td></td>
<tr><td>AR_HID</td><td>Hidden</td></td>
</table>
</dd>
<dt>AttributeMask</dt>
<dd>Attribute mask that specifies which attribute is changed. The specified aattributes are set or cleard.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded.</dd>
<dt>FR_NOFILE</dt>
<dd>Could not find the file.</dd>
<dt>FR_NOPATH</dt>
<dd>Could not find the path.</dd>
<dt>FR_INVALID_NAME</dt>
<dd>The file name 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_WRITE_PROTECTED</dt>
<dd>The medium is in write protected.</dd>
<dt>FR_RW_ERROR</dt>
<dd>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The f_chmod changes the attribute of a file or directory. This function is not supported in read-only configuration.</p>
</div>
<div class="para">
<h4>Sample Code</h4>
<pre>
// Set read-only flag, clear archive flag and others are not changed.
f_chmod("/file.txt", AR_RDO, AR_RDO | AR_ARC);
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

59
doc/en/close.html Normal file
View File

@ -0,0 +1,59 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_close</title>
</head>
<body>
<div class="para">
<h2>f_close</h2>
<p>Function f_close closes a file.</p>
<pre>
FRESULT f_close (
FIL* <em>FileObject</em> // Pointer to the file object structure
);
</pre>
</div>
<div class="para">
<h4>Parameter</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>Pointer to the file object structure to be closed.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The file has been closed successfuly.</dd>
<dt>FR_RW_ERROR</dt>
<dd>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module is not enabled.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>Function f_close closes a file. When the function succeeded, the file object structure can be discarded.</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="write.html">f_write</a>, <a href="sync.html">f_sync</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

32
doc/en/dinit.html Normal file
View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_initialize</title>
</head>
<body>
<div class="para">
<h2>disk_initialize</h2>
<p>The disk_initialize initializes the disk drive.</p>
<pre>
DSTATUS disk_initialize ();
</pre>
</div>
<div class="para">
<h4>Return Values</h4>
<p>This function returns a disk status. For details of the disk status, refer to the <tt><a href="dstat.html">disk_status()</a></tt>.</p>
</div>
<div class="para">
<h4>Description</h4>
<p>The disk_initialize initializes the disk drive. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value will be cleard.</p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

54
doc/en/dread.html Normal file
View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_read</title>
</head>
<body>
<div class="para">
<h2>disk_read</h2>
<p>The disk_read reads sector(s) from the disk drive.</p>
<pre>
DRESULT disk_read (
BYTE* <em>Buffer</em>, // Pointer to the read buffer.
DWORD <em>SectorNumber</em>, // Sector number to read from.
BYTE <em>SectorCount</em> // Number of sectros to read.
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>Buffer</dt>
<dd>Pointer to the read buffer to store the read data. <tt>SectorCount * 512</tt> bytes is required for the size of the read buffer.</dd>
<dt>SectorNumber</dt>
<dd>Specifies the sector number in logical block address to read from.</dd>
<dt>SectorCount</dt>
<dd>Specifies number of sectors to read. The value can be 1 to 255.</dd>
</dl>
</div>
<div class="para">
<h4>Return Value</h4>
<dl class="ret">
<dt>RES_OK</dt>
<dd>The function succeeded.</dd>
<dt>RES_ERROR</dt>
<dd>Any error occured during read operation.</dd>
<dt>RES_PARERR</dt>
<dd>Invalid parameter.</dd>
<dt>RES_NOTRDY</dt>
<dd>The disk dirve has not been initialized.</dd>
</dl>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

35
doc/en/dstat.html Normal file
View File

@ -0,0 +1,35 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_status</title>
</head>
<body>
<div class="para">
<h2>disk_status</h2>
<p>The disk_status gets the disk status.</p>
<pre>
DSTATUS disk_status ();
</pre>
</div>
<div class="para">
<h4>Return Values</h4>
<p>The disk status is returned in combinatin of following flags.</p>
<dl class="ret">
<dt>STA_NOINIT</dt>
<dd>Indicates that the disk drive has not been initialiezed. This flag is set when power-on, occurrence of disk removal or <tt>disk_initialize()</tt> failed and cleared when <tt>disk_initialize()</tt> succeeded.</dd>
<dt>STA_NODISK</dt>
<dd>Indicates that no disk in the drive. It is always cleared on non-removable drive.</dd>
<dt>STA_PROTECTED</dt>
<dd>Indicates that the disk is write protected. It is always cleared on the disk that has not write protect notch.</dd>
</dl>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

62
doc/en/dwrite.html Normal file
View File

@ -0,0 +1,62 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_write</title>
</head>
<body>
<div class="para">
<h2>disk_write</h2>
<p>The disk_write writes sector(s) to the disk.</p>
<pre>
DRESULT disk_write (
const BYTE* <em>Buffer</em>, // Pointer to the data to be written.
DWORD <em>SectorNumber</em>, // Sector number to write.
BYTE <em>SectorCount</em> // Number of sectors to write.
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>Buffer</dt>
<dd>Pointer to the data to be written.</dd>
<dt>SectorNumber</dd>
<dd>Specifies the sector number in logical block address to write from.</dd>
<dt>SectorCount</dt>
<dd>Specifies number of sectors to write. The value can be 1 to 255.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>RES_OK</dt>
<dd>The function succeeded.</dd>
<dt>RES_ERROR</dt>
<dd>Any error occured during read operation.</dd>
<dt>RES_WRPRT</dt>
<dd>The disk is write protected.</dd>
<dt>RES_PARERR</dt>
<dd>Invalid parameter.</dd>
<dt>RES_NOTRDY</dt>
<dd>The disk dirve has not been initialized.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>This function is not required in read only configuration.</p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

49
doc/en/fattime.html Normal file
View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - get_fattime</title>
</head>
<body>
<div class="para">
<h2>get_fattime</h2>
<p>The get_fattime gets current time.</p>
<pre>
DWORD get_fattime ();
</pre>
</div>
<div class="para">
<h4>Return Value</h4>
<p>Currnet time is returned with packed into a DWORD value. The bit field is as follows:</p>
<dl class="ret">
<dt>bit31:25</dt>
<dd>Year from 1980 (0..127)</dd>
<dt>bit24:21</dt>
<dd>Month (1..12)</dd>
<dt>bit20:16</dt>
<dd>Date (1..31)</dd>
<dt>bit15:11</dt>
<dd>Hour (0..23)</dd>
<dt>bit10:5</dt>
<dd>Minute (0..59)</dd>
<dt>bit4:0</dt>
<dd>Second/2 (0..29)</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The function must be return any valid time even if the system does not support a real time clock. The get_fattime is not required in read only configuration.</p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

78
doc/en/getfree.html Normal file
View File

@ -0,0 +1,78 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getfree</title>
</head>
<body>
<div class="para">
<h2>f_getfree</h2>
<p>The f_getfree gets number of the free clusters.</p>
<pre>
FRESULT f_getfree (
DWORD* <em>Clusters</em> // Pointer to the variable to store number of free clusters.
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>Clusters</dt>
<dd>Pointer to the DWORD variable to store number of free clusters.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded. The <tt><em>*Clusters</em></tt> havs number of free clusters.</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>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
</dl>
</div>
<div class="para">
<h4>Descriptions</h4>
<p>The f_getfree gets number of free clusters on the drive. The <tt>FatFs.sects_clust</tt> is indicating number of sectors per cluster, so that the free space in unit of byte can be calcurated with this.</p>
</div>
<div class="para">
<h4>Samples Code</h4>
<pre>
DWORD clust;
// Get free clusters
res = f_getfree(&clust);
if (res) die(res);
// Get free bytes
printf("%lu bytes available on the disk.\n", clust * FatFs->sects_clust * 512);
</pre>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

82
doc/en/lseek.html Normal file
View File

@ -0,0 +1,82 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_lseek</title>
</head>
<body>
<div class="para">
<h2>f_lseek</h2>
<p>The f_lseek moves the file read/write pointer.</p>
<pre>
FRESULT f_lseek (
FIL* <em>FileObject</em>, // Pointer to the file object structure
DWORD <em>Offset</em> // File offset in unit of byte
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>Pointer to the file object structure.</dd>
<dt>Offset</dt>
<dd>Number of bytes where from start of file</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded.</dd>
<dt>FR_ALIGN_ERROR</dt>
<dd>Out of alignment. In unbuffered mode, specified offset must be aligned on 512 byte boundary.</dd>
<dt>FR_RW_ERROR</dt>
<dd>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The f_lseek moves the file read/write pointer. The offset can be specified in only origin from top of the file and cannot moved to above end of the file. When an offset above the file size was specified, the read/write pointer moves to end of the file.</p>
</div>
<div class="para">
<h4>Sample Code</h4>
<pre>
// Move to offset of 5000 from top of file.
res = f_lseek(&file, 5000);
if (res) die(res);
// Move to 3000 bytes front of current offset.
res = f_lseek(&file, file.fptr + 3000);
if (res) die(res);
// Move to 2000 bytes back of current offset.
res = f_lseek(&file, file.fptr - 2000);
if (res) die(res);
</pre>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

80
doc/en/mkdir.html Normal file
View File

@ -0,0 +1,80 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mkdir</title>
</head>
<body>
<div class="para">
<h2>f_mkdir</h2>
<p>The f_mkdir creates a directory.</p>
<pre>
FRESULT f_mkdir (
const char* <em>DirName</em> // Pointer to the directory name
);
</pre>
</div>
<div class="para">
<h4>Parameter</h4>
<dl class="par">
<dt>DirName</dt>
<dd>Pointer to the null-terminated string that specifies the full-path directory name to create. The directory separator is <tt>'/'</tt>. Because the FatFs module does not have a concept of current directory, a full-path name that followed from the root directory must be used. Leading space charactors are skipped if exist and heading <tt>'/'</tt> can be exist or omitted.</dd>
</dl>
</div>
<div class="para">
<h4>Return Value</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded.</dd>
<dt>FR_NOPATH</dt>
<dd>Could not find the path.</dd>
<dt>FR_INVALID_NAME</dt>
<dd>The path name is invalid.</dd>
<dt>FR_DENIED</dt>
<dd>The function was denied due to any of following reasons: any file or directory that has same name is existing, cannot be created due to the directory table or disk full.</dd>
<dt>FR_NOT_READY</dt>
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
<dt>FR_WRITE_PROTECTED</dt>
<dd>The medium is write protected.</dd>
<dt>FR_RW_ERROR</dt>
<dd>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The f_mkdir creates an empty directory. This function is not supported in read only configuration.</p>
<p>
</p>
</div>
<div class="para">
<h4>Sample Code</h4>
<pre>
res = f_mkdir("/sub1");
if (res) die(res);
res = f_mkdir("/sub1/sub2");
if (res) die(res);
res = f_mkdir("/sub1/sub2/sub3");
if (res) die(res);
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

56
doc/en/mountdrv.html Normal file
View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mountdrv</title>
</head>
<body>
<div class="para">
<h2>f_mountdrv</h2>
<p>The f_mountdrv forces mounted the partition.</p>
<pre>
FRESULT f_mountdrv ();
</pre>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<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>Any error occured in low level disk I/O.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The f_mountdrv mounts a partition (initializes <tt>FATFS</tt> structure) and put all file functions can be used. The file system is mounted (initialized) automatically in accordance with the necessity when any file function is called, so that any initialization is not needed before using file functions. To terminate use of the FatFs module, close all files and clear the global variable <em>FatFs</em>, then the <tt>FATFS</tt> structure can be discarded. In this function, following process is executed.</p>
<br>
<ul>
<li>Initializes lower level layer (disk I/O module).</li>
<li>Searches a FAT boot record in order of sector 0 (as SFD format) and first primary partition (as FDISK format).</li>
<li>Initializes file system object (<tt>FATFS</tt> structure).</li>
</ul>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

138
doc/en/open.html Normal file
View File

@ -0,0 +1,138 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_open</title>
</head>
<body>
<div class="para">
<h2>f_open</h2>
<p>The f_open function creates or opens the file and initialize a file object structure to be used to access the file.</p>
<pre>
FRESULT f_open (
FIL* <em>FileObject</em>, // Pointer to the file object structure
const char* <em>FileName</em>, // Pointer to the file neme
BYTE <em>ModeFlags</em> // Mode flags
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>Pointer to the blank file object structure to be initialized. After the f_open function succeeded, the file can be accessed with the file object structure until it is closed. The member <tt>buffer</tt> in the structure must be initialized with the address of a 512 bytes file read/write buffer before or immediataly after the f_open function. The initialization is not needed when <tt>FA_UNBUFFERED</tt> flag has been specified.</dd>
<dt>FileName</dt>
<dd>Pointer to a null-terminated string specifies the full-path file name to create or open. The directory separator is <tt>'/'</tt>. Because the FatFs module does not have a concept of current directory, a full-path name that followed from the root directory must be used. Leading space charactors are skipped if exist and heading <tt>'/'</tt> can be exist or omitted.</dd>
<dt>ModeFlags</dt>
<dd>Specifies the type of access and open method for the file. It is specified by a combination of following flags.<br>
<table class="lst">
<tr><th>Value</th><th>Description</th></td>
<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with FA_WRITE for read-write access.</td></td>
<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file.<br>Combine with FA_READ for read-write access.</td></td>
<tr><td>FA_UNBUFFERED</td><td>This is for only FatFs module. When not specified, the file can be read/written in<br>stream I/O via the file read/write buffer pointed by member 'buffer' in the file<br>object. When specified, file read/write buffer is not used and number of bytes<br>to read/write must be integer multiple of 512. </td></td>
<tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file does not exist.</td></td>
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file exists, it is truncated and overwritten.</td></td>
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file, if it exists. If the file does not exist, the function creates the file.</td></td>
</table>
</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded. The <tt><em>FileObject</em></tt> structure is used for subsequent calls to refer to the file. When close the file, use function <tt><a href="close.html">f_close()</a></tt>.</dd>
<dt>FR_NOFILE</dt>
<dd>Could not find the file.</dd>
<dt>FR_NOPATH</dt>
<dd>Could not find the path.</dd>
<dt>FR_INVALID_NAME</dt>
<dd>The file name is invalid.</dd>
<dt>FR_DENIED</dt>
<dd>The required access was denied due to any of following reasons: write mode open of a file that has read-only attribute, file creation under existing a same name directory or read-only file, cannot be created due to the directory table or disk full.</dd>
<dt>FR_NOT_READY</dt>
<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>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>To start to use the FatFs module, prepare a work area (<tt>FATFS</tt> structure), clear the structure and store the address to the global variable 'FatFs' to allocate the work area to the FatFs module. Then the FatFs module can work.</p>
<p>Flags <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_OPEN_ALWAYS</tt> are not supported in read-only configuration. Flag <tt>FA_UNBUFFERED</tt> is not supported in Tiny-FatFs.</p>
</div>
<div class="para">
<h4>Sample Code</h4>
<pre>
void main ()
{
FATFS fs; // FatFs work area
FIL fsrc, fdst; // file structures
BYTE fbuff[512*2]; // file r/w buffers (not required for Tiny-FatFs)
BYTE buffer[4096]; // file copy buffer
FRESULT res; // FatFs function common result code
WORD br, bw; // File R/W count
// Activate FatFs module
memset(&fs, 0, sizeof(FATFS));
FatFs = &fs;
// Open source file
fsrc.buffer = fbuff+0; // (not required for Tiny-FatFs)
res = f_open(&fsrc, "/srcfile.dat", FA_OPEN_EXISTING | FA_READ);
if (res) die(res);
// Create destination file
fdst.buffer = fbuff+512; // (not required for Tiny-FatFs)
res = f_open(&fdst, "/dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
if (res) die(res);
// Copy source to destination
for (;;) {
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
if (res) die(res);
if (br == 0) break;
res = f_write(&fdst, buffer, br, &bw);
if (res) die(res);
if (bw &lt; br) break;
}
// Close all files
f_close(&fsrc);
f_close(&fdst);
// Deactivate FatFs module
FatFs = NULL;
}
</pre>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

70
doc/en/opendir.html Normal file
View File

@ -0,0 +1,70 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_opendir</title>
</head>
<body>
<div class="para">
<h2>f_opendir</h2>
<p>The f_opendir opens a directory.</p>
<pre>
FRESULT f_opendir (
DIR* <em>DirObject</em>, // Pointer to blank directory object structure
const char* <em>DirName</em> // Pointer to the directory name
);
</pre>
</div>
<div class="para">
<h4>Parameter</h4>
<dl class="par">
<dt>DirObject</dt>
<dd>Pointer to the blank directory object to be initialized</dd>
<dt>DirName</dt>
<dd>Pinter to the null-terminated string that specifies the full-path directory name to be opened. The directory separator is <tt>'/'</tt>. Because the FatFs module does not have a concept of current directory, a full-path name that followed from the root directory must be used. Leading space charactors are skipped if exist and heading <tt>'/'</tt> can be exist or omitted. The target directory name cannot be followed by a <tt>'/'</tt>. When open the root directory, specify <tt>&quot;&quot;</tt> or <tt>&quot;/&quot;</tt>.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded. The <tt><em>DirObject</em></tt> structure is used for subsequent calls to read the directory items.</dd>
<dt>FR_NOPATH</dt>
<dd>Could not find the path.</dd>
<dt>FR_INVALID_NAME</dt>
<dd>The path name 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>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The f_opendir opens a directory and initializes the <tt><em>DirObject</em></tt> structure for subsequent calls. The directory object structure can be discarded at any time.</p>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

72
doc/en/read.html Normal file
View File

@ -0,0 +1,72 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_read</title>
</head>
<body>
<div class="para">
<h2>f_read</h2>
<p>The f_read reads data from a file.</p>
<pre>
FRESULT f_read (
FIL* <em>FileObject</em>, // Pointer to the file object structure
BYTE* <em>Buffer</em>, // Pointer to the buffer to store read data
WORD <em>ByteToRead</em>, // Number of bytes to read
WORD* <em>ByteRead</em> // Pointer to the variable to return number of bytes read
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>Pointer to the valid file object structure.</dd>
<dt>Buffer</dt>
<dd>Pointer to the buffer to store read data</dd>
<dt>ByteToRead</dt>
<dd>Number of bytes to read</dd>
<dt>ByteRead</dt>
<dd>Pointer to the WORD variable to return number of bytes read.</dd>
</dt>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded.</dd>
<dt>FR_DENIED</dt>
<dd>The function denied due to the file has been opened in write only mode.</dd>
<dt>FR_ALIGN_ERROR</dt>
<dd>The file has been opened in unbufferred mode but unaligned access was detected.</dd>
<dt>FR_RW_ERROR</dt>
<dd>Any error occured in low level disk I/O.</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_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The read/write pointer increases in number of bytes read. The <tt>ByteRead</tt> will be smaller than <tt>ByteToRead</tt> when the read pointer reached to end of the file or alignment error occured during the read operation. In unbufferred mode, last fractional bytes cannot be read due to <tt>FR_ALIGN_ERROR</tt>.</p>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="open.html">f_open</a>, <a href="write.html">f_write</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>
</body>
</html>

88
doc/en/readdir.html Normal file
View File

@ -0,0 +1,88 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_readdir</title>
</head>
<body>
<div class="para">
<h2>f_readdir</h2>
<p>The f_readdir reads directory items.</p>
<pre>
FRESULT f_readdir (
DIR* <em>DirObject</em>, // Pointer to the directory object strcture
FILINFO* <em>FileInfo</em> // Pointer to the blank file information structure
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>DirObject</dt>
<dd>Pointer to the valid directory object strcture.</dd>
<dt>FileInfo</dt>
<dd>Pointer to the file information structure to store the read item.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<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>Any error occured in low level disk I/O.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The f_readdir reads directory items in sequence. All items in the directory can be read by calling f_readdir repeatedly. When all items have been read and no item to read, the member <tt>f_name[]</tt> in the file information structure gets a null string. For details of the file informations, refer to the <tt>FILINFO</tt>.</p>
</div>
<div class="para">
<h4>Sample Code</h4>
<pre>
void scan_files (char* path)
{
FILINFO finfo;
DIR dirs;
int i;
if (f_opendir(&dirs, path) == FR_OK) {
i = strlen(path);
while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.f_name[0]) {
if (finfo.f_attrib & AM_DIR) {
sprintf(path+i, "/%s", &finfo.f_name[0]);
scan_files(path);
*(path+i) = '\0';
} else {
printf("%s/%s\n", path, &finfo.f_name[0]);
}
}
}
}
</pre>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="opendir.html">f_opendir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

37
doc/en/sdir.html Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - DIR</title>
</head>
<body>
<div class="para">
<h2>DIR</h2>
<p>The <tt>DIR</tt> structure is used for the work area to read a directory.</p>
<h4>FatFs</h4>
<pre>
typedef struct _DIR {
DWORD sclust; // Directory start cluster
DWORD clust; // Current reading cluster
DWORD sect; // Current reading sector
WORD index; // Current index
} DIR;
</pre>
<h4>Tiny-FatFs</h4>
<pre>
typedef struct _DIR {
WORD sclust; // Directory start cluster
WORD clust; // Current reading cluster
DWORD sect; // Current reading sector
WORD index; // Current index
} DIR;
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

58
doc/en/sfatfs.html Normal file
View File

@ -0,0 +1,58 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FATFS</title>
</head>
<body>
<div class="para">
<h2>FATFS</h2>
<p>The <tt>FATFS</tt> structure holds dynamic work area of the FatFs modlue and it is allocated by an application program. There is no members that can be changed from the application program.</p>
<h4>FatFs</h4>
<pre>
typedef struct _FATFS {
BYTE fs_type; // FAT type
BYTE files; // Number of files currently opend
BYTE sects_clust; // Sectors per cluster
BYTE n_fats; // Number of FAT copies
WORD n_rootdir; // Number of root directory entry (always 0 in FAT32)
BYTE winflag; // win[] dirty flag (1:must be written back)
BYTE pad1;
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 winsect; // Current sector# appearing in the win[]
BYTE win[512]; // Disk access window for directory and FAT
} FATFS;
</pre>
<h4>Tiny-FatFs</h4>
<pre>
typedef struct _FATFS {
BYTE fs_type; // FAT type
BYTE files; // Number of files currently opend
BYTE sects_clust; // Sectors per cluster
BYTE n_fats; // Number of FAT copies
WORD n_rootdir; // Number of root directory entry
BYTE winflag; // win[] dirty flag (1:must be written back)
BYTE pad1;
WORD sects_fat; // Sectors per fat
WORD max_clust; // Maximum cluster# + 1
DWORD fatbase; // FAT start sector
DWORD dirbase; // Root directory start sector
DWORD database; // Data start sector
DWORD winsect; // Current sector# appearing in the win[]
BYTE win[512]; // Disk access window for directory, FAT and file
} FATFS;
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

50
doc/en/sfile.html Normal file
View File

@ -0,0 +1,50 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FIL</title>
</head>
<body>
<div class="para">
<h2>FIL</h2>
<p>The FIL structure holds state of a file and it is allocated by an application program. Only <tt>buffer</tt> member can be initialized by the application program.</p>
<h4>FatFs</h4>
<pre>
typedef struct _FIL {
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; // Pointer to 512 byte file R/W buffer
BYTE flag; // File status flags
BYTE sect_clust; // Left sectors in current cluster
} FIL;
</pre>
<h4>Tiny-FatFs</h4>
<pre>
typedef struct _FIL {
DWORD fptr; // File R/W pointer
DWORD fsize; // File size
WORD org_clust; // File start cluster
WORD 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 flag; // File status flags
BYTE sect_clust; // Left sectors in current cluster
} FIL;
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

42
doc/en/sfileinfo.html Normal file
View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FILINFO</title>
</head>
<body>
<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>
<pre>
typedef struct _FILINFO {
DWORD fsize; // Size
WORD fdate; // Date
WORD ftime; // Time
BYTE fattrib; // Attribute
char fname[8+1+3+1]; // Name
} FILINFO;
</pre>
</div>
<h4>Members</h4>
<dl>
<dt>fsize</dt>
<dd>Indicates size of the file in unit of byte. This is always zero when it is a directory.</dd>
<dt>fdate</dt>
<dd>Indicates the date that the file was modified or the directory was created.</dd>
<dt>ftime</dt>
<dd>Indicates the time that the file was modified or the directory was created.</dd>
<dt>fattrib</dt>
<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</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>
</dl>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

70
doc/en/stat.html Normal file
View File

@ -0,0 +1,70 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_stat</title>
</head>
<body>
<div class="para">
<h2>f_stat</h2>
<p>The f_stat gets the file status.</p>
<pre>
FRESULT f_stat (
const char* <em>FileName</em>, // Pointer to the file or directory name
FILINFO* <em>FileInfo</em> // Pointer to the FILINFO structure
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>FileName</dt>
<dd>Pointer to the null-terminated string that specifies the file or directory name to get the information .</dd>
<dt>FileInfo</dt>
<dd>Pointer to the <tt>FILINFO</tt> structure to store the information.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded.</dd>
<dt>FR_NOPATH</dt>
<dd>Could not find the path.</dd>
<dt>FR_INVALID_NAME</dt>
<dd>The file name 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>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
</dl>
</div>
<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.</p>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

59
doc/en/sync.html Normal file
View File

@ -0,0 +1,59 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_sync</title>
</head>
<body>
<div class="para">
<h2>f_sync</h2>
<p>The f_sync flushes the cached information of the wriiting file.</p>
<pre>
FRESULT f_sync (
FIL* <em>FileObject</em> // Pointer to the file object structure
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>Pointer to the file object to be flushed.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded.</dd>
<dt>FR_RW_ERROR</dt>
<dd>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The f_sync writes back the cached information of a file being written into the disk. This is the same function as f_close but the file is left opened and can continue the file access. This is suitable for an application of data logger that opens a file for long time in writing mode. The f_sync of periodic or immediataly after f_wriete can minimize the lost data due to an unintentional black out or disk removal. This function is not supported in read-only configuration.</p>
</div>
<div class="para">
<h4>References</h4>
<p><tt><a href="close.html">f_close</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

62
doc/en/unlink.html Normal file
View File

@ -0,0 +1,62 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_unlink</title>
</head>
<body>
<div class="para">
<h2>f_unlink</h2>
<p>The f_unlink removes file or directory.</p>
<pre>
FRESULT f_unlink (
const char* <em>FileName</em> // Pointer to the file or directory name
);
</pre>
</div>
<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>FileName</dt>
<dd>Pointer to the null-terminated string that specifies the full path name of a file or directory to be removed. In read only configuration, this function is not supported.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded.</dd>
<dt>FR_NOFILE</dt>
<dd>Could not find the file or directory.</dd>
<dt>FR_NOPATH</dt>
<dd>Could not find the path.</dd>
<dt>FR_INVALID_NAME</dt>
<dd>The path name is invalid.</dd>
<dt>FR_DENIED</dt>
<dd>The function was denied due to any of following reasons: the file or directory has read-only attribute, the directory is not empty.</dd>
<dt>FR_NOT_READY</dt>
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
<dt>FR_WRITE_PROTECTED</dt>
<dd>Write mode open or creation under the medium is write protected.</dd>
<dt>FR_RW_ERROR</dt>
<dd>Any error occured in low level disk I/O.</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>Incorrect disk removal, such as a medium change during any file opend, has been occured.</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
</dl>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

72
doc/en/write.html Normal file
View File

@ -0,0 +1,72 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_write</title>
</head>
<body>
<div class="para">
<h2>f_write</h2>
<p>The f_write writes data to a file.</p>
<pre>
FRESULT f_write (
FIL* <em>FileObject</em>, // Pointer to the file object structure
const BYTE* <em>Buffer</em>, // Pointer to the data to be written
WORD <em>ByteToWrite</em>, // Number of bytes to write
WORD* <em>ByteWritten</em> // Pointer to the variable to return number of bytes written
);
</pre>
</div>
<div class="para">
<h4>Parameter</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>Pointer to the valid file object structure.</dd>
<dt>Buffer</dt>
<dd>Pointer to the data to be written.</dd>
<dt>ByteToWrite</dt>
<dd>Specifies number of bytes to write.</dd>
<dt>ByteWritten</dt>
<dd>Pointer to the WORD variable to return number of bytes written.</dd>
</dl>
</div>
<div class="para">
<h4>Return Values</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>The function succeeded.</dd>
<dt>FR_DENIED</dt>
<dd>The function denied due to the file has been opened in read only mode.</dd>
<dt>FR_ALIGN_ERROR</dt>
<dd>The file has been opened in unbufferred mode but unaligned access was detected.</dd>
<dt>FR_RW_ERROR</dt>
<dd>Any error occured in low level disk I/O.</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_NOT_ENABLED</dt>
<dd>FatFs module has not been enabled.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The read/write pointer increases in number of bytes written. The <tt>ByteWritten</tt> will be smaller than <tt>ByteToWrite</tt> when disk full or alignment error occured during write function. This function is not supported in read only configuration.</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="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>
</body>
</html>

88
doc/ja/chmod.html Normal file
View File

@ -0,0 +1,88 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chmod</title>
</head>
<body>
<div class="para">
<h2>f_chmod</h2>
<p>ファイルまたはディレクトリの属性を変更します。</p>
<pre>
FRESULT f_chmod (
const char* <em>FileName</em>, // ファイルまたはディレクトリの文字列へのポインタ
BYTE <em>Attribute</em>, // 設定値
BYTE <em>AttributeMask</em> // 変更マスク
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileName</dt>
<dd>属性変更対象のファイルまたはディレクトリのフルパス名の入った<tt>'\0'</tt>で終わる文字列を指定します。</dd>
<dt>Attribute</dt>
<dd>設定する属性。指定可能な属性は次の通りで、これらの組み合わせで指定します。指定されなかった属性は解除されます。<br>
<table class="lst">
<tr><th></th><th>意味</th></td>
<tr><td>AR_RDO</td><td>リードオンリー</td></td>
<tr><td>AR_ARC</td><td>アーカイブ</td></td>
<tr><td>AR_SYS</td><td>システム</td></td>
<tr><td>AR_HID</td><td>ヒドゥン</td></td>
</table>
</dd>
<dt>AttributeMask</dt>
<dd>変更する属性のマスク。指定した属性が設定または解除されます。<tt>Attribute</tt>と同じ値を使います。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_NOFILE</dt>
<dd>ファイルが見つからない。</dd>
<dt>FR_NOPATH</dt>
<dd>パスが見つからない。</dd>
<dt>FR_INVALID_NAME</dt>
<dd>パス名が不正。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_WRITE_PROTECTED</dt>
<dd>メディアが書き込み禁止状態。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ファイルまたはディレクトリの属性を変更します。リードオンリー構成ではこの関数はサポートされません。</p>
</div>
<div class="para">
<h4>使用例</h4>
<pre>
// Set read-only flag , clear archive flag and others are not changed.
f_chmod("/file.txt", AR_RDO, AR_RDO | AR_ARC);
</pre>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

59
doc/ja/close.html Normal file
View File

@ -0,0 +1,59 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_close</title>
</head>
<body>
<div class="para">
<h2>f_close</h2>
<p>ファイルを閉じます。</p>
<pre>
FRESULT f_close (
FIL* <em>FileObject</em> // ファイルオブジェクト構造体へのポインタ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>閉じるファイルオブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ファイルを閉じます。関数が正常終了したら、そのファイルオブジェクト構造体を破棄できます。</p>
</div>
<div class="para">
<h4>参照</h4>
<tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="sync.html">f_sync</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

32
doc/ja/dinit.html Normal file
View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_initialize</title>
</head>
<body>
<div class="para">
<h2>disk_initialize</h2>
<p>ディスクドライブを初期化します。</p>
<pre>
DSTATUS disk_initialize ();
</pre>
</div>
<div class="para">
<h4>戻り値</h4>
<p>この関数は戻り値としてディスクステータスを返します。ディスクステータスの詳細に関しては<tt><a href="dstat.html">disk_status()</a></tt>を参照してください。</p>
</div>
<div class="para">
<h4>解説</h4>
<p>ディスクドライブを初期化します。関数が成功すると、戻り値の<tt>STA_NOINIT</tt>フラグがクリアされます。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

54
doc/ja/dread.html Normal file
View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_read</title>
</head>
<body>
<div class="para">
<h2>disk_read</h2>
<p>ディスクからセクタを読み出します。</p>
<pre>
DRESULT disk_read (
BYTE* <em>Buffer</em>, // 読み出しバッファへのポインタ
DWORD <em>SectorNumber</em>, // 読み出し開始セクタ番号
BYTE <em>SectorCount</em> // 読み出しセクタ数
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>Buffer</dt>
<dd>ディスクから読み出したセクタデータを格納するバッファ。<tt>SectorCount * 512</tt>バイトのサイズが必要です。</dd>
<dt>SectorNumber</dt>
<dd>読み出しを開始するセクタ番号。LBAで指定します。</dd>
<dt>SectorCount</dt>
<dd>読み出すセクタ数。 1255で設定します</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>RES_OK</dt>
<dd>正常終了。</dd>
<dt>RES_ERROR</dt>
<dd>読み込み中にエラーが発生した。</dd>
<dt>RES_PARERR</dt>
<dd>パラメータが不正。</dd>
<dt>RES_NOTRDY</dt>
<dd>ドライブが動作可能状態ではない(初期化されていない)。</dd>
</dl>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

35
doc/ja/dstat.html Normal file
View File

@ -0,0 +1,35 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_status</title>
</head>
<body>
<div class="para">
<h2>disk_status</h2>
<p>ディスクの状態を取得します。</p>
<pre>
DSTATUS disk_status ();
</pre>
</div>
<div class="para">
<h4>戻り値</h4>
<p>ディスクの状態が次のフラグの組み合わせの値で返されます。</p>
<dl class="ret">
<dt>STA_NOINIT</dt>
<dd>ドライブが初期化されていないことを示すフラグ。電源ONまたはメディアの取り外しでセットされ、<tt>disk_initialize()</tt>の正常終了でクリア、失敗でセットされます。</dd>
<dt>STA_NODISK</dt>
<dd>メディアがセットされていないことを示すフラグ。メディアが取り外されているときセットされ、メディアがセットされているときクリアされます。ハードディスクでは常にクリアされています。</dd>
<dt>STA_PROTECTED</dt>
<dd>メディアがライトプロテクトされていることを示すフラグ。ライトプロテクトノッチのないメディアでは常にクリアされています。</dd>
</dl>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

62
doc/ja/dwrite.html Normal file
View File

@ -0,0 +1,62 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_write</title>
</head>
<body>
<div class="para">
<h2>disk_write</h2>
<p>ディスクにセクタデータを書き込みます。</p>
<pre>
DRESULT disk_write (
const BYTE* <em>Buffer</em>, // 書き込むデータへのポインタ
DWORD <em>SectorNumber</em>, // 書き込み開始セクタ番号
BYTE <em>SectorCount</em> // 書き込みセクタ数
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>Buffer</dt>
<dd>ディスクに書き込むセクタデータを指定します。</dd>
<dt>SectorNumber</dt>
<dd>書き込みを開始するセクタ番号。LBAで指定します。</dd>
<dt>SectorCount</dt>
<dd>書き込むセクタ数。 1255で設定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="par">
<dt>RES_OK</dt>
<dd>正常終了。</dd>
<dt>RES_ERROR</dt>
<dd>書き込み中にエラーが発生した。</dd>
<dt>RES_WRPRT</dt>
<dd>ディスクが書き込み禁止状態。</dd>
<dt>RES_PARERR</dt>
<dd>パラメータが不正。</dd>
<dt>RES_NOTRDY</dt>
<dd>ドライブが動作可能状態ではない(初期化されていない)。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>リードオンリー構成ではこの関数は必要とされません。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

49
doc/ja/fattime.html Normal file
View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - get_fattime</title>
</head>
<body>
<div class="para">
<h2>get_fattime</h2>
<p>現在時刻を取得します。</p>
<pre>
DWORD get_fattime ();
</pre>
</div>
<div class="para">
<h4>戻り値</h4>
<p>現在のローカルタイムが<tt>DWORD</tt>値にパックされて返されます。ビットフィールドは次に示すようになります。</p>
<dl>
<dt>bit31:25</dt>
<dd>1980年を起点とした年が 0..127 で入ります。</dd>
<dt>bit24:21</dt>
<dd>月が 1..12 の値で入ります。</dd>
<dt>bit20:16</dt>
<dd>日が 1..31 の値で入ります。</dd>
<dt>bit15:11</dt>
<dd>時が 0..23 の値で入ります。</dd>
<dt>bit10:5</dt>
<dd>分が 0..59 の値で入ります。</dd>
<dt>bit4:0</dt>
<dd>秒/2が 0..29 の値で入ります。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>RTCをサポートしないシステムでも、何らかの有効な値を返さなければなりません。リードオンリー構成ではこの関数は必要とされません。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

78
doc/ja/getfree.html Normal file
View File

@ -0,0 +1,78 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getfree</title>
</head>
<body>
<div class="para">
<h2>f_getfree</h2>
<p>ディスクの未使用領域を得ます。</p>
<pre>
FRESULT f_getfree (
DWORD* <em>Clusters</em> // 空きクラスタ数を格納する変数へのポインタ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>Clusters</dt>
<dd>空きクラスタ数を格納するDWORD変数へのポインタを指定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。<tt><em>*Clusters</em></tt>に空きクラスタ数が返されます。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ファイルシステム上の空きクラスタ数を取得します。<tt>FatFs.sects_clust</tt> がクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。</p>
</div>
<div class="para">
<h4>使用例</h4>
<pre>
DWORD clust;
// Get free clusters
res = f_getfree(&clust);
if (res) die(res);
// Get free bytes
printf("%lu bytes available on the disk.\n", clust * FatFs->sects_clust * 512);
</pre>
</div>
<div class="para">
<h4>参照</h4>
<tt><a href="sfatfs.html">FATFS</a></tt>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

82
doc/ja/lseek.html Normal file
View File

@ -0,0 +1,82 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_lseek</title>
</head>
<body>
<div class="para">
<h2>f_lseek</h2>
<p>ファイルのR/Wポインタを移動します。</p>
<pre>
FRESULT f_lseek (
FIL* <em>FileObject</em>, // ファイルオブジェクト構造体へのポインタ
DWORD <em>Offset</em> // 移動先オフセット
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>対象となるファイルオブジェクト構造体へのポインタを指定します。</dd>
<dt>Offset</dt>
<dd>移動先のオフセットR/Wポインタ値。ファイル先頭からのオフセットをバイト単位で指定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_ALIGN_ERROR</dt>
<dd>アンバッファモードで開いたファイルで、512の整数倍でないオフセットを指定した。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ファイルR/Wポインタを移動します。オフセットの指定はファイル先頭からのみです。ファイル末尾以降への移動はできません。ファイルサイズ以上のオフセットを指定した場合、R/Wポインタはファイル末尾に移動します。</p>
</div>
<div class="para">
<h4>使用例</h4>
<pre>
// Move to offset of 5000 from top of file.
res = f_lseek(&file, 5000);
if (res) die(res);
// Move to 3000 bytes front of current offset.
res = f_lseek(&file, file.fptr + 3000);
if (res) die(res);
// Move to 2000 bytes back of current offset.
res = f_lseek(&file, file.fptr - 2000);
if (res) die(res);
</pre>
</div>
<div class="para">
<h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

80
doc/ja/mkdir.html Normal file
View File

@ -0,0 +1,80 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mkdir</title>
</head>
<body>
<div class="para">
<h2>f_mkdir</h2>
<p>ディレクトリを作成します。</p>
<pre>
FRESULT f_mkdir (
const char* <em>DirName</em> // 作成するディレクトリ名へのポインタ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>DirName</dt>
<dd>作成するディレクトリのフルパス名が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。ディレクトリセパレータには<tt>'/'</tt>を使用します。FatFsモジュールにはカレントディレクトリの概念がないので、パスはルートディレクトリから辿る絶対パスとなります。文字列先頭のスペースはスキップされます。パス先頭の<tt>'/'</tt>はあってもなくてもかまいません。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_NOPATH</dt>
<dd>パスが見つからない。</dd>
<dt>FR_INVALID_NAME</dt>
<dd>パス名が不正。</dd>
<dt>FR_DENIED</dt>
<dd>同名のディレクトリやファイルの存在、ディスクやディレクトリエントリが満杯の場合など。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_WRITE_PROTECTED</dt>
<dd>メディアが書き込み禁止状態。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>空のディレクトリを作成します。リードオンリー構成ではこの関数はサポートされません。</p>
<p>
</p>
</div>
<div class="para">
<h4>使用例</h4>
<pre>
res = f_mkdir("/sub1");
if (res) die(res);
res = f_mkdir("/sub1/sub2");
if (res) die(res);
res = f_mkdir("/sub1/sub2/sub3");
if (res) die(res);
</pre>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

57
doc/ja/mountdrv.html Normal file
View File

@ -0,0 +1,57 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mountdrv</title>
</head>
<body>
<div class="para">
<h2>f_mountdrv</h2>
<p>ファイルシステムを明示的に初期化します。</p>
<pre>
FRESULT f_mountdrv ();
</pre>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>ディスク上に有効なFATファイルシステムが見つからない。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ファイルシステムを初期化マウントして他の全てのファイル関数が使える状態にします。FatFsモジュールではマウント動作はファイル関数呼び出し時に必要に応じて行われるため、通常はこの関数を使用する必要はありません。自動マウント動作中に回復不能エラーたとえば<tt>FR_INCORRECT_DISK_CHANGE</tt>)が発生した場合、全てのファイル関数が使えなくなるので、そのときはこの関数で強制マウントして回復します。</p>
<p>FatFsモジュールの使用を終了するには、全てのファイルを閉じたあとグローバル変数<tt>FatFs</tt>をクリアします。その後、ワークエリアは解放できます。f_mountdrv関数内では次の処理が行われます。</p>
<br>
<ul>
<li>下位レイヤディスクI/Oモジュールの初期化。</li>
<li>FATブートレコードの検索。先頭セクタ(SFD)→第一基本区画(FDISK)の順に検索します。</li>
<li>ファイルシステムオブジェクト構造体の初期化。</li>
</ul>
</div>
<div class="para">
<h4>参照</h4>
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

141
doc/ja/open.html Normal file
View File

@ -0,0 +1,141 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_open</title>
</head>
<body>
<div class="para">
<h2>f_open</h2>
<p>ファイルをオープンまたは作成します。</p>
<pre>
FRESULT f_open (
FIL* <em>FileObject</em>, // 作成するファイルオブジェクト構造体へのポインタ
const char* <em>FileName</em>, // ファイルのフルパス名へのポインタ
BYTE <em>ModeFlags</em> // モードフラグ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>新しく作成するファイルオブジェクト構造体へのポインタを指定します。以降、このファイルを閉じるまでそのファイルオブジェクトを使用してファイル操作をします。構造体メンバの<tt>buffer</tt>は、オープン前または直後にそのファイルで使用するR/Wバッファへのアドレスで初期化しておく必要があります<tt>FA_UNBUFFERED</tt>を指定した場合はバッファは不要)。</dd>
<dt>FileName</dt>
<dd>作成する (またはオープンする) ファイルのフルパス名が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。ディレクトリセパレータには<tt>'/'</tt>を使用します。FatFsモジュールにはカレントディレクトリの概念がないので、パスはルートディレクトリから辿る絶対パスとなります。文字列先頭のスペースはスキップされます。パス先頭の<tt>'/'</tt>はあってもなくてもかまいません。</dd>
<dt>ModeFlags</dt>
<dd>ファイルのアクセス方法やオープン方法を決めるフラグです。このパラメータには次の組み合わせを指定します。<br>
<table class="lst">
<tr><th></th><th>意味</th></td>
<tr><td>FA_READ</td><td>読み出しモードでオープンします。読み書きする場合は<tt>FA_WRITE</tt>と共に指定します。</td></td>
<tr><td>FA_WRITE</td><td>書き込みモードでオープンします。読み書きする場合は<tt>FA_READ</tt>と共に指定します。</td></td>
<tr><td>FA_UNBUFFERED</td><td>
FatFsでのみ指定可。指定するとファイルR/Wバッファを使用せず、メモリを節約できます。<br>
read/write/seekは512の整数倍単位でなければなりません。指定しない場合は、ファイル<br>
R/Wバッファファイルオブジェクト構造体メンバの<tt>buffer</tt>で指定)を使用。</td></td>
<tr><td>FA_OPEN_EXISTING</td><td>既存のファイルを開きます。ファイルが無いときはエラーになります。</td></td>
<tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。既存のファイルがある場合は、サイズを0にしてから開きます。</td></td>
<tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。</td></td>
</table>
</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。以降、<tt><em>FileObject</em></tt>構造体を使ってこのファイルを操作できます。ファイルを閉じるときは、<tt><a href="close.html">f_close()</a></tt>を使用します。</dd>
<dt>FR_NOFILE</dt>
<dd>ファイルが見つからない。</dd>
<dt>FR_NOPATH</dt>
<dd>パスが見つからない。</dd>
<dt>FR_INVALID_NAME</dt>
<dd>ファイル名が不正。</dd>
<dt>FR_DENIED</dt>
<dd>アクセスが拒否された。リードオンリーファイルの書き込みモードオープン、同名のディレクトリまたはリードオンリファイルがある状態でのファイル作成、ディスクまたはディレクトリテーブルが満杯でファイルを作成できないなど。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_WRITE_PROTECTED</dt>
<dd>メディアが書き込み禁止状態で書き込みオープンまたはファイル作成をした。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>FatFsモジュールの使用を開始するにはまず、FatFsモジュールにワークエリア構造体<tt>FATFS</tt>を割り当てます。確保したワークエリアを0で初期化したあと、FatFsモジュールのグローバル変数<em>FatFs</em>にそのアドレスを代入するだけでモジュールは動作可能状態になり、ファイル関数が使えるようになります。</p>
<p>リードオンリー構成では、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p>
</div>
<div class="para">
<h4>使用例</h4>
<pre>
void main ()
{
FATFS fs; // FatFs work area
FIL fsrc, fdst; // file structures
BYTE fbuff[512*2]; // file r/w buffers (not required for Tiny-FatFs)
BYTE buffer[4096]; // file copy buffer
FRESULT res; // FatFs function common result code
WORD br, bw; // File R/W count
// Activate FatFs module
memset(&fs, 0, sizeof(FATFS));
FatFs = &fs;
// Open source file
fsrc.buffer = fbuff+0; // (not required for Tiny-FatFs)
res = f_open(&fsrc, "/srcfile.dat", FA_OPEN_EXISTING | FA_READ);
if (res) die(res);
// Create destination file
fdst.buffer = fbuff+512; // (not required for Tiny-FatFs)
res = f_open(&fdst, "/dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
if (res) die(res);
// Copy source to destination
for (;;) {
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
if (res) die(res);
if (br == 0) break;
res = f_write(&fdst, buffer, br, &bw);
if (res) die(res);
if (bw &lt; br) break;
}
// Close all files
f_close(&fsrc);
f_close(&fdst);
// Deactivate FatFs module
FatFs = NULL;
}
</pre>
</div>
<div class="para">
<h4>参照</h4>
<p><tt><a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

70
doc/ja/opendir.html Normal file
View File

@ -0,0 +1,70 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_opendir</title>
</head>
<body>
<div class="para">
<h2>f_opendir</h2>
<p>ディレクトリをオープンします。</p>
<pre>
FRESULT f_opendir (
DIR* <em>DirObject</em>, // ディレクトリブジェクト構造体へのポインタ
const char* <em>DirName</em> // ディレクトリ名へのポインタ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>DirObject</dt>
<dd>初期化するディレクトリオブジェクト構造体へのポインタを指定します。</dd>
<dt>DirName</dt>
<dd>オープンするディレクトリのフルパス名が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。ディレクトリセパレータには<tt>'/'</tt>を使用します。FatFsモジュールにはカレントディレクトリの概念がないので、パスはルートディレクトリから辿る絶対パスとなります。先頭のスペースはスキップされます。パス先頭の<tt>'/'</tt>はあってもなくてもかまいませんが、最後のディレクトリ名の後ろに<tt>'/'</tt>を付けることはできません。ルートディレクトリを開くときは、<tt>&quot;&quot;</tt>または<tt>&quot;/&quot;</tt>を指定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_NOPATH</dt>
<dd>パスが見つからない。</dd>
<dt>FR_INVALID_NAME</dt>
<dd>パス名が不正。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ディレクトリをオープンします。正常終了したら、<tt><em>DirObject</em></tt>構造体を使ってこのディレクトリの項目を順次読み出せます。使用後の処理は必要ありません。<tt><em>DirObject</em></tt>構造体は任意の時点で破棄できます。</p>
</div>
<div class="para">
<h4>参照</h4>
<p><tt><a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

72
doc/ja/read.html Normal file
View File

@ -0,0 +1,72 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_read</title>
</head>
<body>
<div class="para">
<h2>f_read</h2>
<p>ファイルからデータを読み出します。</p>
<pre>
FRESULT f_read (
FIL* <em>FileObject</em>, // ファイルオブジェクト構造体
BYTE* <em>Buffer</em>, // 読み出したデータを格納するバッファ
WORD <em>ByteToRead</em>, // 読み出すバイト数
WORD* <em>ByteRead</em> // 読み出されたバイト数
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>ファイルオブジェクト構造体へのポインタを指定します。</dd>
<dt>Buffer</dt>
<dd>読み出したデータを格納するバッファを指すポインタを指定します。</dd>
<dt>ByteToRead</dt>
<dd>読み出すバイト数を指定します。</dd>
<dt>ByteRead</dt>
<dd>実際に読み出されたバイト数を格納する変数を指すポインタを指定します。</dd>
</dt>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_DENIED</dt>
<dd>書き込み専用モードで開いたファイルから読み込もうとした。</dd>
<dt>FR_ALIGN_ERROR</dt>
<dd>アンバッファモードで開かれたファイルで、512の整数倍でないアクセスを検出した。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>読み込み開始位置は、現在のファイルR/Wポインタからになります。ファイルR/Wポインタは読み込まれたバイト数だけ進みます。読み込み中にファイルの終端に達すると、<tt>*ByteRead</tt><tt>ByteToRead</tt>よりも小さくなります。アンバッファモードでは最後の端数バイトを残して<tt>FR_ALIGN_ERROR</tt>になります。</p>
</div>
<div class="para">
<h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="write.html">f_write</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>
</body>
</html>

88
doc/ja/readdir.html Normal file
View File

@ -0,0 +1,88 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_readdir</title>
</head>
<body>
<div class="para">
<h2>f_readdir</h2>
<p>ディレクトリ項目を読み出します</p>
<pre>
FRESULT f_readdir (
DIR* <em>DirObject</em>, // ディレクトリブジェクト構造体へのポインタ
FILINFO* <em>FileInfo</em> // ファイル情報構造体へのポインタ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>DirObject</dt>
<dd>初期化済みのディレクトリオブジェクト構造体へのポインタを指定します。</dd>
<dt>FileInfo</dt>
<dd>読み出したディレクトリ項目を格納するファイル情報構造体へのポインタを指定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ディレクトリ項目を順次読み出します。この関数を繰り返し実行することによりディレクトリの全ての項目を読み出すことができます。全ての項目を読み出し、読み出す項目がもう無いときは、<tt>f_name[]</tt>メンバにヌル文字列が返されます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。</p>
</div>
<div class="para">
<h4>使用例</h4>
<pre>
void scan_files (char* path)
{
FILINFO finfo;
DIR dirs;
int i;
if (f_opendir(&dirs, path) == FR_OK) {
i = strlen(path);
while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.f_name[0]) {
if (finfo.f_attrib & AM_DIR) {
sprintf(path+i, "/%s", &finfo.f_name[0]);
scan_files(path);
*(path+i) = '\0';
} else {
printf("%s/%s\n", path, &finfo.f_name[0]);
}
}
}
}
</pre>
</div>
<div class="para">
<h4>参照</h4>
<p><tt><a href="opendir.html">f_opendir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

37
doc/ja/sdir.html Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - DIR</title>
</head>
<body>
<div class="para">
<h2>DIR</h2>
<p><tt>DIR</tt>構造体は、ディレクトリ情報読み出しのワークエリアとして使用されます。</p>
<h4>FatFs</h4>
<pre>
typedef struct _DIR {
DWORD sclust; // Directory start cluster
DWORD clust; // Current reading cluster
DWORD sect; // Current reading sector
WORD index; // Current index
} DIR;
</pre>
<h4>Tiny-FatFs</h4>
<pre>
typedef struct _DIR {
WORD sclust; // Directory start cluster
WORD clust; // Current reading cluster
DWORD sect; // Current reading sector
WORD index; // Current index
} DIR;
</pre>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

58
doc/ja/sfatfs.html Normal file
View File

@ -0,0 +1,58 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FATFS</title>
</head>
<body>
<div class="para">
<h2>FATFS</h2>
<p><tt>FATFS</tt>構造体は、FatFsモジュールのダイナミックワークエリアを保持し、アプリケーション側で確保・管理されます。アプリケーションから変更可能なメンバはありません。</p>
<h4>FatFs</h4>
<pre>
typedef struct _FATFS {
BYTE fs_type; // FAT type
BYTE files; // Number of files currently opend
BYTE sects_clust; // Sectors per cluster
BYTE n_fats; // Number of FAT copies
WORD n_rootdir; // Number of root directory entry
BYTE winflag; // win[] dirty flag (1:must be written back)
BYTE pad1;
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 winsect; // Current sector# appearing in the win[]
BYTE win[512]; // Disk access window for Directory/FAT area
} FATFS;
</pre>
<h4>Tiny-FatFs</h4>
<pre>
typedef struct _FATFS {
BYTE fs_type; // FAT type
BYTE files; // Number of files currently opend
BYTE sects_clust; // Sectors per cluster
BYTE n_fats; // Number of FAT copies
WORD n_rootdir; // Number of root directory entry
BYTE winflag; // win[] dirty flag (1:must be written back)
BYTE pad1;
WORD sects_fat; // Sectors per fat
WORD 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 winsect; // Current sector# appearing in the win[]
BYTE win[512]; // Disk access window
} FATFS;
</pre>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

49
doc/ja/sfile.html Normal file
View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FIL</title>
</head>
<body>
<div class="para">
<h2>FIL</h2>
<p><tt>FIL</tt>構造体は、1個で1ファイルの状態を保持し、アプリケーション側で確保・管理されます。アプリケーションから変更可能なメンバは<tt>buffer</tt>のみです。</p>
<h4>FatFs</h4>
<pre>
typedef struct _FIL {
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; // Pointer to 512 byte file R/W buffer
BYTE flag; // File status flags
BYTE sect_clust; // Left sectors in current cluster
} FIL;
</pre>
<h4>Tiny-FatFs</h4>
<pre>
typedef struct _FIL {
DWORD fptr; // File R/W pointer
DWORD fsize; // File size
WORD org_clust; // File start cluster
WORD 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 flag; // File status flags
BYTE sect_clust; // Left sectors in current cluster
} FIL;
</pre>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

42
doc/ja/sfileinfo.html Normal file
View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FILINFO</title>
</head>
<body>
<div class="para">
<h2>FILINFO</h2>
<p><tt>FILINFO</tt>構造体は、<tt>f_stat(), f_readdir()</tt>で返されるファイル情報を保持します。</p>
<pre>
typedef struct _FILINFO {
DWORD fsize; // Size
WORD fdate; // Date
WORD ftime; // Time
BYTE fattrib; // Attribute
char fname[8+1+3+1]; // Name
} FILINFO;
</pre>
</div>
<h4>メンバ</h4>
<dl>
<dt>fsize</dt>
<dd>ファイルのバイト単位のサイズが格納されます。ディレクトリの場合は常に0です。</dd>
<dt>fdate</dt>
<dd>ファイルの変更された日付、またはディレクトリの作成された日付が格納されます。</dd>
<dt>ftime</dt>
<dd>ファイルの変更された時刻、またはディレクトリの作成された時刻が格納されます。</dd>
<dt>fattrib</dt>
<dd>属性フラグが格納されます。フラグは<tt>AM_DIR, AM_RDO, AM_HID, AM_SYS, AM_ARC</tt>の組み合わせとなります。</dd>
<dt>fname[]</dt>
<dd>8.3形式の名前が<tt>'\0'</tt>で終わる文字列として格納されます。</dd>
</dl>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

70
doc/ja/stat.html Normal file
View File

@ -0,0 +1,70 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_stat</title>
</head>
<body>
<div class="para">
<h2>f_stat</h2>
<p></p>
<pre>
FRESULT f_stat (
const char* <em>FileName</em>, // ファイルまたはディレクトリ名へのポインタ
FILINFO* <em>FileInfo</em> // ファイル情報構造体へのポインタ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileName</dt>
<dd>情報を得るファイルまたはディレクトリ名の<tt>'\0'</tt>で終わる文字列を指すポインタを指定します。</dd>
<dt>FileInfo</dt>
<dd>読み出し結果を格納するファイル情報構造体へのポインタを指定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_NOPATH</dt>
<dd>パスが見つからない。</dd>
<dt>FR_INVALID_NAME</dt>
<dd>パス名が不正。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ファイルまたはディレクトリに関する情報を得ます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。</p>
</div>
<div class="para">
<h4>参照</h4>
<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

60
doc/ja/sync.html Normal file
View File

@ -0,0 +1,60 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_sync</title>
</head>
<body>
<div class="para">
<h2>f_sync</h2>
<p>書き込み中のファイルのキャッシュされた情報をフラッシュします。</p>
<pre>
FRESULT f_sync (
FIL* <em>FileObject</em> // ファイルオブジェクト構造体へのポインタ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>syncするファイルオブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>書き込み中のファイルのそこまでの状態R/Wバッファ上のデータ、変更されたFATやディレクトリ項目をディスクに書き込みます。この関数はファイルクローズのプロセスを実行しますが、ファイルは引き続き開かれたままになり、読み書きを続行できます。ロギングなど、書き込みモードで長時間ファイルが開かれているアプリケーションにおいて、定期的または区切りの良いところでsyncすることにより、不意の電源断やメディアの取り外しにより失われるデータを最小限にします。</p>
<p>リードオンリー構成ではこの関数はサポートされません。</p>
</div>
<div class="para">
<h4>参照</h4>
<p><tt><a href="close.html">f_close</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

67
doc/ja/unlink.html Normal file
View File

@ -0,0 +1,67 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_unlink</title>
</head>
<body>
<div class="para">
<h2>f_unlink</h2>
<p>ファイルまたはディレクトリを削除します。</p>
<pre>
FRESULT f_unlink (
const char* <em>FileName</em> // ファイルまたはディレクトリ名へのポインタ
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileName</dt>
<dd>削除対象のファイルまたはディレクトリ名の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。リードオンリー構成ではこの関数はサポートされません。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_NOFILE</dt>
<dd>ファイルが見つからない。</dd>
<dt>FR_NOPATH</dt>
<dd>パスが見つからない。</dd>
<dt>FR_INVALID_NAME</dt>
<dd>パス名が不正。</dd>
<dt>FR_DENIED</dt>
<dd>対象ファイル・ディレクトリがリードオンリー状態、対象ディレクトリが空でない場合など。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_WRITE_PROTECTED</dt>
<dd>メディアが書き込み禁止状態。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_INCORRECT_DISK_CHANGE</dt>
<dd>不正なメディアの取り外しがあった。ファイルを開いたままのメディア交換など。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>ファイルまたはディレクトリを削除します。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

72
doc/ja/write.html Normal file
View File

@ -0,0 +1,72 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_write</title>
</head>
<body>
<div class="para">
<h2>f_write</h2>
<p>ファイルにデータを書き込みます。</p>
<pre>
FRESULT f_write (
FIL* <em>FileObject</em>, // ファイルオブジェクト構造体
const BYTE* <em>Buffer</em>, // 書き込みデータ
WORD <em>ByteToWrite</em>, // 書き込むバイト数
WORD* <em>ByteWritten</em> // 書き込まれたバイト数
);
</pre>
</div>
<div class="para">
<h4>パラメータ</h4>
<dl class="par">
<dt>FileObject</dt>
<dd>ファイルオブジェクト構造体へのポインタを指定します。</dd>
<dt>Buffer</dt>
<dd>書き込むデータを格納したバッファを指すポインタを指定します。</dd>
<dt>ByteToWrite</dt>
<dd>書き込むバイト数を指定します。</dd>
<dt>ByteWritten</dt>
<dd>実際に書き込まれたバイト数を格納する変数を指すポインタを指定します。</dd>
</dl>
</div>
<div class="para">
<h4>戻り値</h4>
<dl class="ret">
<dt>FR_OK</dt>
<dd>正常終了。</dd>
<dt>FR_DENIED</dt>
<dd>読み込み専用モードで開いたファイルに書き込もうとした。</dd>
<dt>FR_ALIGN_ERROR</dt>
<dd>アンバッファモードで開かれたファイルで、512の整数倍でないアクセスを検出した。</dd>
<dt>FR_RW_ERROR</dt>
<dd>ディスクアクセスでエラーが発生した。</dd>
<dt>FR_NOT_READY</dt>
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
<dt>FR_NOT_ENABLED</dt>
<dd>FatFsモジュールが停止状態。</dd>
</dl>
</div>
<div class="para">
<h4>解説</h4>
<p>書き込み開始位置は、ファイルR/Wポインタの現在位置からになります。ファイルR/Wポインタは実際に書き込まれたバイト数だけ進みます。書き込み中にディスクが一杯になった、または<tt>FR_ALIGN_ERROR</tt>が帰ったときは、<tt>*ByteWritten</tt><tt>ByteToWrite</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="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

BIN
doc/layers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
doc/rw_ata.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
doc/rw_cfc.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
doc/rw_mmc.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
doc/rwtest.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

60
src/00readme.txt Normal file
View File

@ -0,0 +1,60 @@
FatFs/Tiny-FatFs Module Source Files R0.01 (C)ChaN, 2006
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.
integer.h Alternative type definitions for unsigned integers.
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 in include files ff.h and tff.h.
#define _BYTE_ACC
This is the most impotant option that depends on the processor architecture.
When your microcontroller corresponds to either or both of following terms, the
_BYTE_ACC must be defined.
- Muti-byte integers (short, long) are stored in Big-Endian.
- Address unaligned word access causes an address error or incorrect behavior.
#define _FS_READONLY
When application program does not require any write access, _FS_READONLY can be
defined to eliminate writing code to reduce module size.
#define _USE_SJIS
When _USE_SJIS is defined, Shift-JIS code set can be used as a file name,
otherwire second byte of double-byte characters will be collapted.
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.
You can use, modify and republish it for personal, non-profit or profit use
without any limitation under your responsibility.
Revision History
Feb 26, 2006 R0.00 Prototype
Apr 29, 2006 R0.01 First stable version

57
src/diskio.h Normal file
View File

@ -0,0 +1,57 @@
/*-----------------------------------------------------------------------
/ Low level disk interface modlue include file R0.01 (C)ChaN, 2006
/-----------------------------------------------------------------------*/
#ifndef _DISKIF
//#define _READONLY /* Define this for read-only use */
#include "integer.h"
typedef unsigned char DSTATUS;
typedef unsigned char DRESULT;
/*---------------------------------------*/
/* Prototypes for disk control functions */
DSTATUS disk_initialize ();
DSTATUS disk_shutdown ();
DSTATUS disk_status ();
DRESULT disk_read (BYTE*, DWORD, BYTE);
#ifndef _READONLY
DRESULT disk_write (const BYTE*, DWORD, BYTE);
#endif
DRESULT disk_ioctl (BYTE, void*);
void disk_timerproc ();
/* Results of Disk Functions (DRESULT) */
#define RES_OK 0 /* Successful */
#define RES_ERROR 1 /* R/W Error */
#define RES_WRPRT 2 /* Write Protected */
#define RES_NOTRDY 3 /* Not Ready */
#define RES_PARERR 4 /* Invalid Parameter */
/* Disk Status Bits (DSTATUS) */
#define STA_NOINIT 0x01 /* Drive not initialized */
#define STA_NODISK 0x02 /* No medium in the drive */
#define STA_PROTECT 0x04 /* Write protected */
/* Command code for disk_ioctrl() */
#define GET_SECTORS 1
#define PUT_IDLE_STATE 2
#define MMC_GET_CSD 10
#define MMC_GET_CID 11
#define MMC_GET_OCR 12
#define ATA_GET_REV 20
#define ATA_GET_MODEL 21
#define _DISKIF
#endif

1202
src/ff.c Normal file

File diff suppressed because it is too large Load Diff

186
src/ff.h Normal file
View File

@ -0,0 +1,186 @@
/*--------------------------------------------------------------------------/
/ FatFs - FAT file system module include file R0.01 (C)ChaN, 2006
/---------------------------------------------------------------------------/
/ FatFs module is an experimenal project to implement FAT file system to
/ cheap microcontrollers. This is opened for education, reserch and
/ development. You can use it for non-profit or profit use without any
/ limitation under your responsibility.
/---------------------------------------------------------------------------/
/ Feb 26, 2006 R0.00 Prototype
/ Apr 29, 2006 R0.01 First stable version
/---------------------------------------------------------------------------*/
#ifndef _FATFS
//#define _BYTE_ACC
/* This enables byte-by-byte access for multi-byte variables */
/* It must be defined on the big-endian processor, or to prevent address error */
//#define _FS_READONLY
/* This removes writing code for read-only applications */
#define _USE_SJIS
/* This enables Shift-JIS code transparency, or only US-ASCII file name can be accepted */
#include "integer.h"
/* Result type for fatfs application interface */
typedef unsigned char FRESULT;
/* File system object structure */
typedef struct _FATFS {
BYTE fs_type; // FAT type
BYTE files; // Number of files currently opend
BYTE sects_clust; // Sectors per cluster
BYTE n_fats; // Number of FAT copies
WORD n_rootdir; // Number of root directory entry
BYTE winflag; // win[] dirty flag (1:must be written back)
BYTE pad1;
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 winsect; // Current sector appearing in the win[]
BYTE win[512]; // Disk access window for Directory/FAT area
} FATFS;
/* Directory object structure */
typedef struct _DIR {
DWORD sclust; // Start cluster
DWORD clust; // Current cluster
DWORD sect; // Current sector
WORD index; // Current index
} DIR;
/* File object structure */
typedef struct _FIL {
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
#ifndef _FS_READONLY
DWORD dir_sect; // Sector containing the directory entry
BYTE* dir_ptr; // Ponter to the directory entry in the window
#endif
BYTE* buffer; // Pointer to 512 byte file R/W buffer
BYTE flag; // File status flags
BYTE sect_clust; // Left sectors in cluster
} 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;
/*-----------------------------------------------------*/
/* FatFs module application interface */
extern FATFS *FatFs; // Pointer to active file system object
FRESULT f_open (FIL*, const char*, BYTE); // Open or create a file
FRESULT f_read (FIL*, BYTE*, WORD, WORD*); // Read file
FRESULT f_close (FIL*); // Close file
FRESULT f_lseek (FIL*, DWORD); // Seek file pointer
FRESULT f_opendir (DIR*, const char*); // Initialize to read a directory
FRESULT f_readdir (DIR*, FILINFO*); // Read a directory item
FRESULT f_stat (const char*, FILINFO*); // Get file status
FRESULT f_getfree (DWORD*); // Get number of free clusters
FRESULT f_mountdrv (); // Force initialized the file system
#ifndef _FS_READONLY
FRESULT f_write (FIL*, const BYTE*, WORD, WORD*); // Write file
FRESULT f_sync (FIL*); // Flush cached information of a writing file
FRESULT f_unlink (const char*); // Delete a file or directory
FRESULT f_mkdir (const char*); // Create a directory
FRESULT f_chmod (const char*, BYTE, BYTE); // Change file attriburte
#endif
/* User defined function to give a current time to fatfs module */
#ifndef _FS_READONLY
DWORD get_fattime(); // 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)
#endif
/* File function return code */
#define FR_OK 0
#define FR_NOT_READY 1
#define FR_NO_FILE 2
#define FR_NO_PATH 3
#define FR_INVALID_NAME 4
#define FR_DENIED 5
#define FR_DISK_FULL 6
#define FR_RW_ERROR 7
#define FR_ALIGN_ERROR 8
#define FR_INCORRECT_DISK_CHANGE 9
#define FR_WRITE_PROTECTED 10
#define FR_NOT_ENABLED 11
#define FR_NO_FILESYSTEM 12
/* File access control and file status flags */
#define FA_READ 0x01
#define FA_UNBUFFERED 0x04
#define FA_OPEN_EXISTING 0x00
#ifndef _FS_READONLY
#define FA_WRITE 0x02
#define FA_CREATE_ALWAYS 0x08
#define FA_OPEN_ALWAYS 0x10
#define FA__WRITTEN 0x20
#define FA__DIRTY 0x40
#endif
#define FA__ERROR 0x80
/* FAT type signature (fs_type) */
#define FS_FAT16 1
#define FS_FAT32 2
/* File attribute mask 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_DIR 0x10 // Directory
#define AM_ARC 0x20 // Archive
/* Multi-byte word access macros */
#ifdef _BYTE_ACC
#define LD_WORD(ptr) (((WORD)*(BYTE*)(ptr+1)<<8)|*(ptr))
#define LD_DWORD(ptr) (((DWORD)*(BYTE*)(ptr+3)<<24)|((DWORD)*(BYTE*)(ptr+2)<<16)|((WORD)*(BYTE*)(ptr+1)<<8)|*(BYTE*)(ptr))
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=val; *(BYTE*)(ptr+1)=val>>8
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=val; *(BYTE*)(ptr+1)=val>>8; *(BYTE*)(ptr+2)=val>>16; *(BYTE*)(ptr+3)=val>>24
#else
#define LD_WORD(ptr) (*(WORD*)(BYTE*)(ptr))
#define LD_DWORD(ptr) (*(DWORD*)(BYTE*)(ptr))
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(val)
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(val)
#endif
#define _FATFS
#endif

12
src/integer.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef _INTEGER
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned char BOOL;
#define FALSE 0
#define TRUE 1
#define _INTEGER
#endif

1141
src/tff.c Normal file

File diff suppressed because it is too large Load Diff

181
src/tff.h Normal file
View File

@ -0,0 +1,181 @@
/*--------------------------------------------------------------------------/
/ FatFs - FAT file system module include file R0.01 (C)ChaN, 2006
/---------------------------------------------------------------------------/
/ FatFs module is an experimenal project to implement FAT file system to
/ cheap microcontrollers. This is opened for education, reserch and
/ development. You can use it for non-profit or profit use without any
/ limitation under your responsibility.
/---------------------------------------------------------------------------/
/ Feb 26, 2006 R0.00 Prototype
/ Apr 29, 2006 R0.01 First stable version
/---------------------------------------------------------------------------*/
#ifndef _FATFS
//#define _BYTE_ACC
/* This enables byte-by-byte access for multi-byte variables */
/* It must be defined on the big-endian processor, or to prevent address error */
//#define _FS_READONLY
/* This removes writing code for read-only applications */
#define _USE_SJIS
/* This enables Shift-JIS code transparency, or only US-ASCII file name can be accepted */
#include "integer.h"
/* Result type for fatfs application interface */
typedef unsigned char FRESULT;
/* File system object */
typedef struct _FATFS {
BYTE fs_type; // FAT type
BYTE files; // Number of files currently opend
BYTE sects_clust; // Sectors per cluster
BYTE n_fats; // Number of FAT copies
WORD n_rootdir; // Number of root directory entry
BYTE winflag; // win[] dirty flag (1:must be written back)
BYTE pad1;
WORD sects_fat; // Sectors per fat
WORD 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 winsect; // Current sector appearing in the win[]
BYTE win[512]; // Disk access window
} FATFS;
/* Directory scan object */
typedef struct _DIR {
WORD sclust; // Start cluster
WORD clust; // Current cluster
DWORD sect; // Current sector
WORD index; // Current index
} DIR;
/* File object */
typedef struct _FIL {
DWORD fptr; // File Pointer
DWORD fsize; // File Size
WORD org_clust; // File start cluster
WORD curr_clust; // Current cluster
DWORD curr_sect; // Current sector
#ifndef _FS_READONLY
DWORD dir_sect; // Sector containing the directory entry
BYTE* dir_ptr; // Ponter to the directory entry in the window
#endif
BYTE flag; // File status flags
BYTE sect_clust; // Left sectors in cluster
} 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]; // File/Directory name (8.3 format)
} FILINFO;
/* fatfs module application interface */
extern FATFS *FatFs; // Pointer to active file system object
FRESULT f_open (FIL*, const char*, BYTE); // Open or create a file
FRESULT f_read (FIL*, BYTE*, WORD, WORD*); // Read file
FRESULT f_close (FIL*); // Close file
FRESULT f_lseek (FIL*, DWORD); // Seek file pointer
FRESULT f_opendir (DIR*, const char*); // Initialize to read a directory
FRESULT f_readdir (DIR*, FILINFO*); // Read a directory item
FRESULT f_stat (const char*, FILINFO*); // Get file status
FRESULT f_getfree (DWORD*); // Get number of free clusters
FRESULT f_mountdrv (); // Force initialized the file system
#ifndef _FS_READONLY
FRESULT f_write (FIL*, const BYTE*, WORD, WORD*); // Write file
FRESULT f_sync (FIL*); // Flush cached information of a writing file
FRESULT f_unlink (const char*); // Delete a file or directory
FRESULT f_mkdir (const char*); // Create a directory
FRESULT f_chmod (const char*, BYTE, BYTE); // Change file attriburte
#endif
/* User defined function to give a current time to fatfs module */
#ifndef _FS_READONLY
DWORD get_fattime(); // 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)
#endif
/* File function return code */
#define FR_OK 0
#define FR_NOT_READY 1
#define FR_NO_FILE 2
#define FR_NO_PATH 3
#define FR_INVALID_NAME 4
#define FR_DENIED 5
#define FR_DISK_FULL 6
#define FR_RW_ERROR 7
#define FR_ALIGN_ERROR 8
#define FR_INCORRECT_DISK_CHANGE 9
#define FR_WRITE_PROTECTED 10
#define FR_NOT_ENABLED 11
#define FR_NO_FILESYSTEM 12
/* File access control and file status flags */
#define FA_READ 0x01
#define FA_OPEN_EXISTING 0x00
#ifndef _FS_READONLY
#define FA_WRITE 0x02
#define FA_CREATE_ALWAYS 0x08
#define FA_OPEN_ALWAYS 0x10
#define FA__WRITTEN 0x20
#endif
#define FA__ERROR 0x80
/* FAT type signature (fs_type) */
#define FS_FAT16 1
/* File attribute mask 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_DIR 0x10 // Directory
#define AM_ARC 0x20 // Archive
/* Multi-byte word access macros */
#ifdef _BYTE_ACC
#define LD_WORD(ptr) (((WORD)*(BYTE*)(ptr+1)<<8)|*(ptr))
#define LD_DWORD(ptr) (((DWORD)*(BYTE*)(ptr+3)<<24)|((DWORD)*(BYTE*)(ptr+2)<<16)|((WORD)*(BYTE*)(ptr+1)<<8)|*(BYTE*)(ptr))
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=val; *(BYTE*)(ptr+1)=val>>8
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=val; *(BYTE*)(ptr+1)=val>>8; *(BYTE*)(ptr+2)=val>>16; *(BYTE*)(ptr+3)=val>>24
#else
#define LD_WORD(ptr) (*(WORD*)(BYTE*)(ptr))
#define LD_DWORD(ptr) (*(DWORD*)(BYTE*)(ptr))
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(val)
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(val)
#endif
#define _FATFS
#endif