fatfs v0.05a Feb 03, 2008:
- Added f_truncate(). - Added f_utime(). - Fixed off by one error at FAT sub-type determination. - Fixed btr in f_read() can be mistruncated. - Fixed cached sector is not flushed when create and close without write.
This commit is contained in:
parent
36c173e705
commit
e400c8c902
@ -3,9 +3,11 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="start" title="Site Top" href="../../">
|
||||
<link rel="up" title="Freewares" href="../../fsw_e.html">
|
||||
<link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html">
|
||||
<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>ELM - Generic FAT File System Module</title>
|
||||
<title>ELM - FAT File System Module</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -14,18 +16,18 @@
|
||||
|
||||
<div class="abst">
|
||||
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||
<p>FatFs module is an experimental project to implement the FAT file system to small embedded systems. The FatFs module is written in compliance with ANSI C, therefore it is independent of hardware architecture. It can be incorporated into cheap microcontrollers, such as 8051, PIC, AVR, SH, Z80, H8, ARM and etc..., without any change.</p>
|
||||
<p>FatFs is a generic file system module to implement the FAT file system to small embedded systems. The FatFs is written in compliance with ANSI C, therefore it is independent of hardware architecture. It can be incorporated into cheap microcontrollers, such as 8051, PIC, AVR, SH, Z80, H8, ARM and etc..., without any change.</p>
|
||||
|
||||
<h4>Features of FatFs Module</h4>
|
||||
<h4>Features of FatFs</h4>
|
||||
<ol>
|
||||
<li>Separated buffer for FAT structure and each file, suitable for fast multiple file accsess.</li>
|
||||
<li>Supports multiple drives/partitions.</li>
|
||||
<li>Separated buffer for FAT structure and each file, suitable for fast multiple file access.</li>
|
||||
<li>Supports multiple drives and partitions.</li>
|
||||
<li>Supports FAT12, FAT16 and FAT32.</li>
|
||||
<li>Supports 8.3 format file name. (LFN is not supported)</li>
|
||||
<li>Supports two partitioning rules: FDISK and Super-floppy.</li>
|
||||
<li>Optimized for 8/16-bit microcontrollers.</li>
|
||||
</ol>
|
||||
<h4>Features of Tiny-FatFs Module (different to FatFs)</h4>
|
||||
<h4>Features of Tiny-FatFs (different to FatFs)</h4>
|
||||
<ol>
|
||||
<li>Very low memory consumption, suitable for small memory system. (1KB RAM)</li>
|
||||
<li>Supports only single drive.</li>
|
||||
@ -37,12 +39,13 @@
|
||||
<h3>Application Interface</h3>
|
||||
<p>FatFs/Tiny-FatFs module provides following functions.</p>
|
||||
<ul>
|
||||
<li><a href="en/mount.html">f_mount</a> - Register/Unregister a Work Area</li>
|
||||
<li><a href="en/open.html">f_open</a> - Open/Create a File</li>
|
||||
<li><a href="en/mount.html">f_mount</a> - Register or Unregister a Work Area</li>
|
||||
<li><a href="en/open.html">f_open</a> - Open or 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/lseek.html">f_lseek</a> - Move File R/W Pointer</li>
|
||||
<li><a href="en/truncate.html">f_truncate</a> - Truncate File</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>
|
||||
@ -51,6 +54,7 @@
|
||||
<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/utime.html">f_utime</a> - Change Timestamp</li>
|
||||
<li><a href="en/rename.html">f_rename</a> - Rename/Move a File or Directory</li>
|
||||
<li><a href="en/mkfs.html">f_mkfs</a> - Create a File System on the Drive</li>
|
||||
</ul>
|
||||
@ -73,8 +77,9 @@
|
||||
|
||||
<div class="para">
|
||||
<h3>Resources</h3>
|
||||
<p>The FatFs/Tiny-FatFs module is a free software and is opened for education, research and development. You can use, modify and/or republish it for personal, non-profit or profit use without any restriction under your responsibility.</p>
|
||||
<p>The FatFs/Tiny-FatFs module is a free software and is opened for education, research and development. You can use, modify and/or republish it for personal, non-profit or commercial use without any restriction under your responsibility.</p>
|
||||
<ul>
|
||||
<li><a href="ff005a.zip">FatFs/Tiny-FatFs R0.05a</a> | <a href="updates.txt">Updates</a> <span class="mfd">Feb 3, 2008</span></li>
|
||||
<li><a href="en/appnote.html">FatFs module application note</a></li>
|
||||
<li><a href="img/rwtest.png">Benchmark</a> (Test Board: ATmega64/9.2MHz with <a href="img/rw_mmc.jpeg">MMC</a>/<a href="img/rw_ata.jpeg">HDD</a>/<a href="img/rw_cfc.jpeg">CFC</a>)</li>
|
||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification</a> (Microsoft)</li>
|
||||
@ -82,5 +87,8 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_e.html">FatFs Home Page</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
<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="start" title="Site Top" href="../../index_j.html">
|
||||
<link rel="up" title="Freewares" href="../../fsw.html">
|
||||
<link rel="alternate" hreflang="en" title="英文" href="00index_e.html">
|
||||
<link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>ELM - 汎用FATファイルシステム・モジュール</title>
|
||||
</head>
|
||||
@ -42,15 +44,17 @@
|
||||
<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/truncate.html">f_truncate</a> - ファイル・サイズの切り詰め</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/rename.html">f_rename</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/utime.html">f_utime</a> - ファイル/ディレクトリのタイムスタンプの変更</li>
|
||||
<li><a href="ja/rename.html">f_rename</a> - ファイル/ディレクトリの名前変更・移動</li>
|
||||
<li><a href="ja/mkfs.html">f_mkfs</a> - ディスクのフォーマット</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -74,6 +78,7 @@
|
||||
<h3>資料</h3>
|
||||
<p>FatFs/Tiny-FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人・非商用・商用)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。</p>
|
||||
<ul>
|
||||
<li><a href="ff005a.zip">FatFs/Tiny-FatFs R0.05a</a> | <a href="updates.txt">変更点</a> <span class="mfd">2008. 2. 3</span></li>
|
||||
<li><a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a></li>
|
||||
<li><a href="img/rwtest.png">パフォーマンス・テスト</a>(テスト・ボード:ATmega64/9.2MHz with <a href="img/rw_mmc.jpeg">MMC</a>/<a href="img/rw_ata.jpeg">HDD</a>/<a href="img/rw_cfc.jpeg">CFC</a>)</li>
|
||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32仕様書</a> (Microsoft)</li>
|
||||
@ -82,5 +87,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_j.html">FatFs Home Page</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -51,5 +51,6 @@ td {background-color: white; border-style: solid; border-width: 1px; border-colo
|
||||
table.lst td:first-child {font-family: monospace;}
|
||||
table.lst2 td {font-family: monospace;}
|
||||
table caption {font-family: sans-serif; font-weight: bold;}
|
||||
tr.lst3 td { border-width: 2px 1px 1px; }
|
||||
|
||||
p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}
|
||||
|
||||
@ -54,5 +54,6 @@ td {background-color: white; border-style: solid; border-width: 1px; border-colo
|
||||
table.lst td:first-child {font-family: monospace; white-space: nowrap;}
|
||||
table.lst2 td {font-family: monospace; white-space: nowrap;}
|
||||
table caption {font-family: sans-serif; font-weight: bold;}
|
||||
tr.lst3 td { border-width: 2px 1px 1px; }
|
||||
|
||||
p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}
|
||||
|
||||
@ -18,30 +18,30 @@
|
||||
<ul>
|
||||
<li>ANSI C<br>
|
||||
The FatFs module is a middleware that written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C. However it handles the system portable FAT structures. You must take the <strong>endian</strong> into consideration. This setting is defined in ff.h (tff.h). It must be changed for your platform first or the compiler will abort with an error.</li>
|
||||
<li>Size of char/short/long are 8/16/32 bit and int is 16 bit or greater.<br>
|
||||
<li>Size of char/short/long are 8/16/32-bit and int is 16 or 32 bit.<br>
|
||||
These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict of the definitions between the integer.h and existing definitions is occured, you must resolve the confrict with care.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>Memory Usage (R0.05)</h3>
|
||||
<h3>Memory Usage (R0.05a)</h3>
|
||||
<p>These are the memory usage on some target systems. The memory sizes are in unit of byte, D means number of logical drives and F means number of open files. All samples are optimezed in code size.</p>
|
||||
<table class="lst2">
|
||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>MSP430</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th></tr>
|
||||
<tr><td>Compiler</td><td>gcc</td><td>CH38</td><td>CL430</td><td>CC870C</td><td>CA850</td><td>SHC</td></tr>
|
||||
<tr><td>_MCU_ENDIAN</td><td>1</td><td>2</td><td>2</td><td>1</td><td>1</td><td>2</td></tr>
|
||||
<tr><td>FatFs Code<br>(Standard, R/W cfg.)</td><td>8810</td><td>8880</td><td></td><td></td><td>6418</td><td>7830</td></tr>
|
||||
<tr><td>FatFs Code<br>(Minimum, R/W cfg.)</td><td>5832</td><td>5748</td><td></td><td></td><td>4072</td><td>5366</td></tr>
|
||||
<tr><td>FatFs Code<br>(Standard, R/O cfg.)</td><td>4264</td><td>4110</td><td></td><td></td><td>2990</td><td>3420</td></tr>
|
||||
<tr><td>FatFs Code<br>(Minimum, R/O cfg.)</td><td>3052</td><td>3124</td><td></td><td></td><td>2194</td><td>2634</td></tr>
|
||||
<tr><td>FatFs Work (Static)</td><td>D*2 + 2</td><td>D*4 + 2</td><td></td><td></td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
|
||||
<tr><td>FatFs Work (Dynamic)</td><td>D*554 + F*544</td><td>D*554 + F*550</td><td></td><td></td><td>D*554 + F*550</td><td>D*554 + F*550</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Standard, R/W cfg.)</td><td>7376</td><td>7274</td><td>6622</td><td>8854</td><td>5670</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Minimum, R/W cfg.)</td><td>4866</td><td>4326</td><td>4354</td><td>6176</td><td>3726</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Standard, R/O cfg.)</td><td>3654</td><td>3554</td><td>3220</td><td>4358</td><td>2710</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Minimum, R/O cfg.)</td><td>2620</td><td>2708</td><td>2402</td><td>3329</td><td>1910</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Wrok (Static)</td><td>4</td><td>6</td><td>4</td><td>4</td><td>6</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs Work (Dynamic)</td><td>544 + F*28</td><td>544 + F*32</td><td>544 + F*28</td><td>544 + F*28</td><td>544 + F*32</td><td></td></tr>
|
||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>MSP430</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th></tr>
|
||||
<tr><td>Compiler</td><td>gcc</td><td>CH38</td><td>C30(gcc)</td><td>CL430</td><td>CC870C</td><td>CA850</td><td>SHC</td></tr>
|
||||
<tr><td>_MCU_ENDIAN</td><td>1</td><td>2</td><td>2</td><td>2</td><td>1</td><td>1</td><td>2</td></tr>
|
||||
<tr class="lst3"><td>FatFs Code<br>(Full, R/W)</td><td>9146</td><td>9218</td><td>9155</td><td></td><td></td><td>6662</td><td>7430</td></tr>
|
||||
<tr><td>FatFs Code<br>(Minimum, R/W)</td><td>5824</td><td>5756</td><td>5861</td><td></td><td></td><td>4096</td><td>4710</td></tr>
|
||||
<tr><td>FatFs Code<br>(Full, R/O)</td><td>4268</td><td>4116</td><td>4187</td><td></td><td></td><td>2986</td><td>3382</td></tr>
|
||||
<tr><td>FatFs Code<br>(Minimum, R/O)</td><td>3076</td><td>3134</td><td>3143</td><td></td><td></td><td>2200</td><td>2610</td></tr>
|
||||
<tr><td>FatFs Work (Static)</td><td>D*2+2</td><td>D*4+2</td><td>D*2+2</td><td></td><td></td><td>D*4+2</td><td>D*4+2</td></tr>
|
||||
<tr><td>FatFs Work (Dynamic)</td><td>D*554+F*544</td><td>D*554+F*550</td><td>D*554+F*544</td><td></td><td></td><td>D*554+F*550</td><td>D*554+F*550</td></tr>
|
||||
<tr class="lst3"><td>Tiny-FatFs Code<br>(Full, R/W)</td><td>7566</td><td>7626</td><td>7371</td><td>6894</td><td>9314</td><td>5926</td><td>6580</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Minimum, R/W)</td><td>4730</td><td>4814</td><td>4683</td><td>4306</td><td>6285</td><td>3670</td><td>4236</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Full, R/O)</td><td>3564</td><td>3532</td><td>3522</td><td>3226</td><td>4389</td><td>2678</td><td>3022</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Minimum, R/O)</td><td>2554</td><td>2674</td><td>2595</td><td>2372</td><td>3376</td><td>1856</td><td>2300</td></tr>
|
||||
<tr><td>Tiny-FatFs Wrok (Static)</td><td>4</td><td>6</td><td>4</td><td>4</td><td>4</td><td>6</td><td>6</td></tr>
|
||||
<tr><td>Tiny-FatFs Work (Dynamic)</td><td>544+F*28</td><td>544+F*32</td><td>544+F*28</td><td>544+F*28</td><td>544+F*28</td><td>544+F*32</td><td>544+F*32</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -62,7 +62,7 @@ These correspondence are defined in integer.h. This will not be a problem on mos
|
||||
|
||||
<div class="para">
|
||||
<h3>Performance effective file access</h3>
|
||||
<p>For good performance on reading/writing files on the small embedded system, application program should consider what process is done in the FatFs module. The file data on the disk is transferred by f_read function in following process.</p>
|
||||
<p>For good performance on reading/writing files on the small embedded system, application program should consider what process is done in the FatFs module. The file data on the disk is transferred by f_read function in these sequence.</p>
|
||||
<p>Figure 1. Sector miss-aligned read (short)<br>
|
||||
<img src="../img/f1.png" width="490" height="73">
|
||||
</p>
|
||||
@ -73,7 +73,7 @@ These correspondence are defined in integer.h. This will not be a problem on mos
|
||||
<img src="../img/f3.png" width="490" height="119">
|
||||
</p>
|
||||
<p>The file I/O buffer means a sector buffer to read/write a partial data on the sector. On the FatFs, member buffer[] in the file object is used. On the Tiny-FatFs, member win[] in the file system object is used.</p>
|
||||
<p>Tiny-FatFs processes all data transfer and access to the FAT/directory with only one sector buffer, so that FAT sector cached into the buffer is lost and it must reloaded at every cluster boundary. FatFs has a FAT/directory buffer separated from file I/O buffer, the frequency of FAT accesses is only 1/341, 1/256 or 1/128 (when cluster is contiguous) compared to Tiny-FatFs. Thus the Tiny-FatFs is sacrificing its performance in compensation for very small memory footprint.</p>
|
||||
<p>Tiny-FatFs processes all file data transfer and access to the FAT/directory with only one sector buffer, so that FAT sector cached into the buffer is lost and it must reloaded at every cluster boundary. FatFs has a FAT/directory buffer separated from file I/O buffer, the frequency of FAT accesses is only 1/341, 1/256 or 1/128 (when cluster is contiguous) compared to Tiny-FatFs. Thus the Tiny-FatFs is sacrificing its performance in compensation for very small memory footprint.</p>
|
||||
<p>Figure 1 shows that partial sector data is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that aligned to sector boundary is transferred into memory directly. Figure 3 shows that entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. At the unbuffered transfer, maximum extent of sectors are read with disk_read function at a time but it never across cluster boundary even if it is contiguous.</p>
|
||||
<p>Therefore taking effort to sector aligned read/write accesss eliminates memcpy and the read/write performance will be improved. Besides the effect, cached FAT sector is not flushed during read/write access on the Tiny-FatFs, so that it can achieve same performance as FatFs and its small memory footprint simultanesously.</p>
|
||||
</div>
|
||||
@ -96,7 +96,7 @@ Figure 5. Minimized critical section<br>
|
||||
<li>File data being rewrited is collapted.</li>
|
||||
<li>A file being appended returns initial state.</li>
|
||||
<li>A file created as new is gone.</li>
|
||||
<li>A file created as new or in overwrite remains with length of zero.</li>
|
||||
<li>A file created as new or in overwritten remains with length of zero.</li>
|
||||
<li>Efficiency of disk use gets worse due to lost chain.</li>
|
||||
</ul>
|
||||
<p>Each case does not affect the files that not in write operation. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode and using f_sync function properly.</p>
|
||||
|
||||
@ -55,7 +55,7 @@ DRESULT disk_ioctl (
|
||||
<p>The FatFs module uses only device independent commands described below. Any device dependent function is not used.</p>
|
||||
<table class="lst">
|
||||
<tr><th>Command</th><th>Description</td></tr>
|
||||
<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the module has a write back cache, flush the dirty sector immediately. In read-only configuration, this command is not needed.</td></tr>
|
||||
<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. In read-only configuration, this command is not needed.</td></tr>
|
||||
<tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by Buffer. This command is used in only f_mkfs function.</td></tr>
|
||||
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the memory array in unit of sector into the DWORD variable pointed by Buffer. When the erase block size is unknown or magnetic disk device, return 1. This command is used in only f_mkfs function.</td></tr>
|
||||
</table>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<pre>
|
||||
DRESULT disk_read (
|
||||
BYTE <em>Drive</em>, /* Physical drive number */
|
||||
BYTE* <em>Buffer</em>, /* Pointer to the read buffer */
|
||||
BYTE* <em>Buffer</em>, /* Pointer to the read data buffer */
|
||||
DWORD <em>SectorNumber</em>, /* Sector number to read from */
|
||||
BYTE <em>SectorCount</em> /* Number of sectros to read */
|
||||
);
|
||||
@ -31,7 +31,7 @@ DRESULT disk_read (
|
||||
<dt>Buffer</dt>
|
||||
<dd>Pointer to the read buffer to store the read data. The buffer size of number of bytes to be read is required.</dd>
|
||||
<dt>SectorNumber</dt>
|
||||
<dd>Specifies the start sector number in logical block address.</dd>
|
||||
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
||||
<dt>SectorCount</dt>
|
||||
<dd>Specifies number of sectors to read. The value can be 1 to 255.</dd>
|
||||
</dl>
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
<div class="para">
|
||||
<h2>disk_status</h2>
|
||||
<p>The disk_status function return the current disk status.</p>
|
||||
<p>The disk_status function returns the current disk status.</p>
|
||||
<pre>
|
||||
DSTATUS disk_status (
|
||||
BYTE <em>Drive</em> /* Physical drive number */
|
||||
@ -24,7 +24,7 @@ DSTATUS disk_status (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>Drive</dt>
|
||||
<dd>Specifies the physical drive number to be tested.</dd>
|
||||
<dd>Specifies the physical drive number to be confirmed.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -38,7 +38,7 @@ DSTATUS disk_status (
|
||||
<dt>STA_NODISK</dt>
|
||||
<dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive.</dd>
|
||||
<dt>STA_PROTECTED</dt>
|
||||
<dd>Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch.</dd>
|
||||
<dd>Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid when <tt>STA_NODISK</tt> is set.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<pre>
|
||||
DRESULT disk_write (
|
||||
BYTE <em>Drive</em>, /* Physical drive number */
|
||||
const BYTE* <em>Buffer</em>, /* Pointer to the read buffer */
|
||||
const BYTE* <em>Buffer</em>, /* Pointer to the write data */
|
||||
DWORD <em>SectorNumber</em>, /* Sector number to write */
|
||||
BYTE <em>SectorCount</em> /* Number of sectors to write */
|
||||
);
|
||||
@ -31,7 +31,7 @@ DRESULT disk_write (
|
||||
<dt>Buffer</dt>
|
||||
<dd>Pointer to the data to be written.</dd>
|
||||
<dt>SectorNumber</dd>
|
||||
<dd>Specifies the start sector number in logical block address.</dd>
|
||||
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
||||
<dt>SectorCount</dt>
|
||||
<dd>Specifies the number of sectors to write. The value can be 1 to 255.</dd>
|
||||
</dl>
|
||||
|
||||
@ -28,7 +28,7 @@ DWORD get_fattime (void);
|
||||
<dt>bit24:21</dt>
|
||||
<dd>Month (1..12)</dd>
|
||||
<dt>bit20:16</dt>
|
||||
<dd>Date (1..31)</dd>
|
||||
<dd>Day in month(1..31)</dd>
|
||||
<dt>bit15:11</dt>
|
||||
<dd>Hour (0..23)</dd>
|
||||
<dt>bit10:5</dt>
|
||||
|
||||
@ -34,10 +34,10 @@
|
||||
<p><br></p>
|
||||
<div class="para">
|
||||
<h2>Correspondence between logical/physical drive</h2>
|
||||
<p>In default, the FatFs module has work areas that called `file system object' for each logical drive. The logical drive is bound simply to the physical drive that has same drive number, and first partition is mounted. When <tt>_MULTI_PARTITION</tt> is specified in configuration option, each individual logical drive can be bound to any physical drive/partition. In this case, a drive number resolution table must be defined as follows:</p>
|
||||
<p>In default, the FatFs module has work areas that called <em>file system object</em> for each logical drive. The logical drive is bound to the physical drive that has same drive number, and the first partition is mounted. When <tt>_MULTI_PARTITION</tt> is specified in configuration option, each individual logical drive can be bound to any physical drive/partition. In this case, a drive number resolution table must be defined as follows:</p>
|
||||
<pre>
|
||||
Example: Logical drive 0-2 are assigned to three pri-partitions on the physical drive 0 (fixed disk)
|
||||
Logical drive 3 is assigned to physical drive 0 (removable disk)
|
||||
Logical drive 3 is assigned to physical drive 1 (removable disk)
|
||||
|
||||
const PARTITION Drives[] = {
|
||||
{0, 0}, /* Logical drive 0 ==> Physical drive 0, 1st partition */
|
||||
|
||||
@ -30,7 +30,7 @@ FRESULT f_getfree (
|
||||
<dt>Clusters</dt>
|
||||
<dd>Pointer to the DWORD variable to store number of free clusters.</dd>
|
||||
<dt>FileSystemObject</dt>
|
||||
<dd>Pointer to the pointer that to be stored the pointer to corresponding file system object.</dd>
|
||||
<dd>Pointer to pointer that to store a pointer to the corresponding file system object.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -56,7 +56,7 @@ FRESULT f_getfree (
|
||||
|
||||
<div class="para">
|
||||
<h4>Descriptions</h4>
|
||||
<p>The f_getfree function gets number of free clusters on the drive. The <tt>sects_clust</tt> member in the file system object refreting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When _USE_FSINFO option is enabled, this function can return inaccurate free cluster count on FAT32 volume. When _USE_FSINFO option is disabled, this function will take a time on FAT32 volume.</p>
|
||||
<p>The f_getfree function gets number of free clusters on the drive. The <tt>sects_clust</tt> member in the file system object is refreting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When <tt>_USE_FSINFO</tt> option is enabled, this function might return an inaccurate free cluster count on FAT32 volume. When it is disabled, this function will take a time on FAT32 volume.</p>
|
||||
<p>This function is not supported in read-only configuration and minimization level of >= 1.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -12,7 +12,8 @@
|
||||
|
||||
<div class="para">
|
||||
<h2>f_lseek</h2>
|
||||
<p>The f_lseek functione moves the file read/write pointer of an open file object.</p>
|
||||
<p>The f_lseek function moves the file read/write pointer of an open file object. It can also be used to extend the file size (cluster pre-allocation).</p>
|
||||
|
||||
<pre>
|
||||
FRESULT f_lseek (
|
||||
FIL* <em>FileObject</em>, /* Pointer to the file object structure *
|
||||
@ -78,7 +79,7 @@ FRESULT f_lseek (
|
||||
|
||||
<div class="para">
|
||||
<h4>References</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
@ -63,7 +63,7 @@ FRESULT f_mkfs (
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_mkfs function creates a FAT file system on the drive. There are two partitioning rules, FDISK and SFD, for removable media. It can be selected with an argument. The FDISK format is recommended for most case. This function currently does not support multiple partition, so that existing partitions on the physical dirve will be deleted and re-created a partition occupies entire disk space.</p>
|
||||
<p>The FAT type, FAT12/FAT16/FAT32, is determined by only how many clusters on the drive and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT type is selected, is depends on the drive size and specified cluster size. The cluster size affects performance of file system and large cluster increases the performance, so that 32768 bytes per cluster is recommended for most case except for small drive.</p>
|
||||
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by only how many clusters on the drive and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the drive size and specified cluster size. The cluster size affects performance of file system and large cluster increases the performance, so that 32768 bytes per cluster is recommended for most case except for small drive.</p>
|
||||
<p>This function is supported on only FatFs with _USE_MKFS option.<p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -44,8 +44,8 @@ FRESULT f_mount (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_mount function registers/unregisters a work area to the FatFs module. The work area must be given to the logical drive with this function before using any file function. To unregister a work area, specify a NULL to the <em>FileSystemObject</em>, and then the work area can be discarded.</p>
|
||||
<p>This function only initializes the work area and registers its address to the internal table, any access to the disk I/O layer does not occure. Actual mounting process is performed in any other file funcitons with path name when it is needed.<p>
|
||||
<p>The f_mount function registers/unregisters a work area to the FatFs module. The work area must be given to the logical drive with this function before any other file function. To unregister a work area, specify a NULL to the <em>FileSystemObject</em>, and then the work area can be discarded.</p>
|
||||
<p>This function only initializes the work area and registers its address to the internal table, any access to the disk I/O layer does not occure. The actual mounting process is performed depends on requirement in any other file funcitons with path name.<p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -61,7 +61,10 @@ FRESULT f_open (
|
||||
<dt>FR_EXIST</dt>
|
||||
<dd>The file is already existing.</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>The required access was denied due to any of following reasons: write mode open of a file that has read-only attribute, file creation under existing a same name directory or read-only file, cannot be created due to the directory table or disk full.</dd>
|
||||
<dd>The required access was denied due to one of the following reasons:
|
||||
<ul><li>Write mode open of a read-only file.</li>
|
||||
<li>File cannot be created due to a read-only file or same name directory is existing.</li>
|
||||
<li>File cannot be created due to the directory table or disk is full.</li></ul></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>
|
||||
@ -78,8 +81,8 @@ FRESULT f_open (
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The created file object is used for subsequent calls to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function.</p>
|
||||
<p>Before using any file function, work area (file system object) must be given to each logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p>
|
||||
<p>The created file object is used for subsequent calls to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If modified file is not closed correctly, the file will be collapsed.</p>
|
||||
<p>Before using any file function, a work area (file system object) must be given to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p>
|
||||
<p>The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not supported in read-only configuration.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ FRESULT f_read (
|
||||
<dt>FR_OK (0)</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>
|
||||
<dd>The function denied due to the file has been opened in non-read mode.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
|
||||
@ -15,11 +15,11 @@
|
||||
<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
|
||||
DWORD fsize; /* Size */
|
||||
WORD fdate; /* Date */
|
||||
WORD ftime; /* Time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
char fname[8+1+3+1]; /* Name */
|
||||
} FILINFO;
|
||||
</pre>
|
||||
</div>
|
||||
@ -29,11 +29,29 @@ typedef struct _FILINFO {
|
||||
<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>
|
||||
<dd>Indicates the date that the file was modified or the directory was created.<br>
|
||||
<dl>
|
||||
<dt>bit15:9</dt>
|
||||
<dd>Year from 1980 (0..127)</dd>
|
||||
<dt>bit8:5</dt>
|
||||
<dd>Month (1..12)</dd>
|
||||
<dt>bit4:0</dt>
|
||||
<dd>Day (1..31)</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>ftime</dt>
|
||||
<dd>Indicates the time that the file was modified or the directory was created.</dd>
|
||||
<dd>Indicates the time that the file was modified or the directory was created.<br>
|
||||
<dl>
|
||||
<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>
|
||||
</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>
|
||||
<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd>
|
||||
<dt>fname[]</dt>
|
||||
<dd>Indicates the file/directory name in 8.3 format null-terminated string.</dd>
|
||||
</dl>
|
||||
|
||||
63
doc/en/truncate.html
Normal file
63
doc/en/truncate.html
Normal file
@ -0,0 +1,63 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="up" title="FatFs" href="../00index_e.html">
|
||||
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_truncate</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>f_truncate</h2>
|
||||
<p>The f_truncate function truncates the file size.</p>
|
||||
<pre>
|
||||
FRESULT f_truncate (
|
||||
FIL* <em>FileObject</em> /* Pointer to the file object */
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>FileObject</dt>
|
||||
<dd>Pointer to the open file object to be truncated.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Return Values</h4>
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>The file has been opened in read-only mode.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
<dd>The file object is invalid.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_truncate function truncates the file size to the current file R/W point. When the file R/W pointer is pointing end of the file, there is no effect. This function is not supported in read-only configuration and minimization level of >=1.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>References</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
</body>
|
||||
</html>
|
||||
@ -43,7 +43,8 @@ FRESULT f_unlink (
|
||||
<dt>FR_INVALID_DRIVE</dt>
|
||||
<dd>The drive number is invalid.</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>The function was denied due to either of following reasons: the file or directory has read-only attribute, the directory is not empty.</dd>
|
||||
<dd>The function was denied due to either of following reasons:
|
||||
<ul><li>The file or directory has read-only attribute</li><li>The directory is not empty.</li></ul></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>
|
||||
|
||||
75
doc/en/utime.html
Normal file
75
doc/en/utime.html
Normal file
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="up" title="FatFs" href="../00index_e.html">
|
||||
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_utime</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>f_utime</h2>
|
||||
<p>The f_utime function changes the timestamp of a file or directory.</p>
|
||||
<pre>
|
||||
FRESULT f_utime (
|
||||
const char* <em>FileName</em>, /* Pointer to the file or directory path */
|
||||
const FILINFO* <em>TimeDate</em> /* Time and data to be set */
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h4>Parameter</h4>
|
||||
<dl class="par">
|
||||
<dt>FileName</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">file or directory</a> to be changed.</dd>
|
||||
<dt>TimeDate</dt>
|
||||
<dd>Pointer to the file information structure that has a timestamp to be set in member fdate and ftime. Do not care any other members.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Return Values</h4>
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>The function succeeded.</dd>
|
||||
<dt>FR_NO_FILE</dt>
|
||||
<dd>Could not find the file.</dd>
|
||||
<dt>FR_NO_PATH</dt>
|
||||
<dd>Could not find the path.</dd>
|
||||
<dt>FR_INVALID_NAME</dt>
|
||||
<dd>The file name is invalid.</dd>
|
||||
<dt>FR_INVALID_DRIVE</dt>
|
||||
<dd>The drive number is invalid.</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
||||
<dt>FR_WRITE_PROTECTED</dt>
|
||||
<dd>The medium is write protected.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</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_utime function changes the timestamp of a file or directory. This function is not supported in read-only configuration and minimization level of >=1.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>References</h4>
|
||||
<p><tt><a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
</body>
|
||||
</html>
|
||||
@ -44,7 +44,7 @@ FRESULT f_write (
|
||||
<dt>FR_OK (0)</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>
|
||||
<dd>The function denied due to the file has been opened in non-write mode.</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>The function failed due to a disk error or an internal error.</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
|
||||
BIN
doc/img/f4.png
BIN
doc/img/f4.png
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.3 KiB |
BIN
doc/img/f5.png
BIN
doc/img/f5.png
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 20 KiB |
@ -18,30 +18,30 @@
|
||||
<ul>
|
||||
<li>処理系はANSI C準拠であること。<br>
|
||||
FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠のコンパイラなら特に処理系依存な点はありません。ただし、FATというシステム間でポータブルな構造体を操作するため、プロセッサのエンディアンの違いは意識する必要があります。これは ff.h(tff.h) で定義されているので、最初にこれを適切に設定します(忘れている場合はエラーを出す)。</li>
|
||||
<li>char/short/long のサイズは、それぞれ 8/16/32ビット で、intは 16ビット以上 であること。<br>
|
||||
これは integer.h 内で typedef されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合は矛盾がないように注意しなければなりません。</li>
|
||||
<li>char/short/long のサイズは、それぞれ 8/16/32ビット で、intは 16または32ビット であること。<br>
|
||||
使用される整数の型は integer.h 内で typedef されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合は矛盾がないように注意しなければなりません。</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h3>メモリ使用量 (R0.05)</h3>
|
||||
<p>各種環境でのモジュールのメモリ使用量の例を示します。数値の単位はバイトで、Dは論理ドライブ数、Fは同時オープン・ファイル数を示します。最適化オプションは、全てコード・サイズとしています。</p>
|
||||
<h3>メモリ使用量 (R0.05a)</h3>
|
||||
<p>各種環境でのモジュールのメモリ使用量の例を示します。数値の単位はバイトで、<em>D</em>は論理ドライブ数、<em>F</em>は同時オープン・ファイル数を示します。最適化オプションはコード・サイズとしています。</p>
|
||||
<table class="lst2">
|
||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>MSP430</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th></tr>
|
||||
<tr><td>コンパイラ</td><td>gcc</td><td>CH38</td><td>CL430</td><td>CC870C</td><td>CA850</td><td>SHC</td></tr>
|
||||
<tr><td>_MCU_ENDIAN</td><td>1</td><td>2</td><td>2</td><td>1</td><td>1</td><td>2</td></tr>
|
||||
<tr><td>FatFs コード<br>(標準, R/W構成)</td><td>8810</td><td>8880</td><td></td><td></td><td>6418</td><td>7830</td></tr>
|
||||
<tr><td>FatFs コード<br>(最小, R/W構成)</td><td>5832</td><td>5748</td><td></td><td></td><td>4072</td><td>5366</td></tr>
|
||||
<tr><td>FatFs コード<br>(標準, R/O構成)</td><td>4264</td><td>4110</td><td></td><td></td><td>2990</td><td>3420</td></tr>
|
||||
<tr><td>FatFs コード<br>(最小, R/O構成)</td><td>3052</td><td>3124</td><td></td><td></td><td>2194</td><td>2634</td></tr>
|
||||
<tr><td>FatFs 静的ワーク</td><td>D*2 + 2</td><td>D*4 + 2</td><td></td><td></td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
|
||||
<tr><td>FatFs 動的ワーク</td><td>D*554 + F*544</td><td>D*554 + F*550</td><td></td><td></td><td>D*554 + F*550</td><td>D*554 + F*550</td></tr>
|
||||
<tr><td>Tiny-FatFs コード<br>(標準, R/W構成)</td><td>7376</td><td>7274</td><td>6622</td><td>8854</td><td>5670</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs コード<br>(最小, R/W構成)</td><td>4866</td><td>4826</td><td>4354</td><td>6176</td><td>3726</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs コード<br>(標準, R/O構成)</td><td>3654</td><td>3554</td><td>3220</td><td>4358</td><td>2710</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs コード<br>(最小, R/O構成)</td><td>2620</td><td>2708</td><td>2402</td><td>3329</td><td>1910</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs 静的ワーク</td><td>4</td><td>6</td><td>4</td><td>4</td><td>6</td><td></td></tr>
|
||||
<tr><td>Tiny-FatFs 動的ワーク</td><td>544 + F*28</td><td>544 + F*32</td><td>544 + F*28</td><td>544 + F*28</td><td>544 + F*32</td><td></td></tr>
|
||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>MSP430</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th></tr>
|
||||
<tr><td>コンパイラ</td><td>gcc</td><td>CH38</td><td>C30(gcc)</td><td>CL430</td><td>CC870C</td><td>CA850</td><td>SHC</td></tr>
|
||||
<tr><td>_MCU_ENDIAN</td><td>1</td><td>2</td><td>2</td><td>2</td><td>1</td><td>1</td><td>2</td></tr>
|
||||
<tr class="lst3"><td>FatFs Code<br>(Full, R/W)</td><td>9146</td><td>9218</td><td>9155</td><td></td><td></td><td>6662</td><td>7430</td></tr>
|
||||
<tr><td>FatFs Code<br>(Minimum, R/W)</td><td>5824</td><td>5756</td><td>5861</td><td></td><td></td><td>4096</td><td>4710</td></tr>
|
||||
<tr><td>FatFs Code<br>(Full, R/O)</td><td>4268</td><td>4116</td><td>4187</td><td></td><td></td><td>2986</td><td>3382</td></tr>
|
||||
<tr><td>FatFs Code<br>(Minimum, R/O)</td><td>3076</td><td>3134</td><td>3143</td><td></td><td></td><td>2200</td><td>2610</td></tr>
|
||||
<tr><td>FatFs Work (Static)</td><td>D*2+2</td><td>D*4+2</td><td>D*2+2</td><td></td><td></td><td>D*4+2</td><td>D*4+2</td></tr>
|
||||
<tr><td>FatFs Work (Dynamic)</td><td>D*554+F*544</td><td>D*554+F*550</td><td>D*554+F*544</td><td></td><td></td><td>D*554+F*550</td><td>D*554+F*550</td></tr>
|
||||
<tr class="lst3"><td>Tiny-FatFs Code<br>(Full, R/W)</td><td>7566</td><td>7626</td><td>7371</td><td>6894</td><td>9314</td><td>5926</td><td>6580</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Minimum, R/W)</td><td>4730</td><td>4814</td><td>4683</td><td>4306</td><td>6285</td><td>3670</td><td>4236</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Full, R/O)</td><td>3564</td><td>3532</td><td>3522</td><td>3226</td><td>4389</td><td>2678</td><td>3022</td></tr>
|
||||
<tr><td>Tiny-FatFs Code<br>(Minimum, R/O)</td><td>2554</td><td>2674</td><td>2595</td><td>2372</td><td>3376</td><td>1856</td><td>2300</td></tr>
|
||||
<tr><td>Tiny-FatFs Wrok (Static)</td><td>4</td><td>6</td><td>4</td><td>4</td><td>4</td><td>6</td><td>6</td></tr>
|
||||
<tr><td>Tiny-FatFs Work (Dynamic)</td><td>544+F*28</td><td>544+F*32</td><td>544+F*28</td><td>544+F*28</td><td>544+F*28</td><td>544+F*32</td><td>544+F*32</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -51,9 +51,9 @@ FatFs
|
||||
<div class="rset">
|
||||
<table class="lst2">
|
||||
<tr><th>メモリ容量</th><th>FATタイプ</th></tr>
|
||||
<tr><td><= 64MB</td><td>FAT12</td></tr>
|
||||
<tr><td>64MB以下</td><td>FAT12</td></tr>
|
||||
<tr><td>128MB~2GB</td><td>FAT16</td></tr>
|
||||
<tr><td>>= 4GB</td><td>FAT32</td></tr>
|
||||
<tr><td>4GB以上</td><td>FAT32</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<p>2GBまでのカードに限るなら、FAT32への対応は不要です。右の表にメモリ・カードの容量と規定のFATタイプ(SDメモリの場合)を示します。メモリ・カードの出荷時は、最大のパフォーマンスが出るようにデータ領域の境界が調整されたフォーマットになっています。したがって、PCでフォーマットするなどして規定と違うフォーマットになると、書き込み性能が大幅に低下する場合があるので注意が必要です。</p>
|
||||
@ -88,7 +88,7 @@ FatFs
|
||||
<img src="../img/f4.png" width="320" height="436" alt="fig.4">
|
||||
</div>
|
||||
<div class="lset">
|
||||
図5. 短くしたクリチカル・セクション<br>
|
||||
図5. 最小化したクリチカル・セクション<br>
|
||||
<img src="../img/f5.png" width="320" height="436" alt="fig.5">
|
||||
</div>
|
||||
<br class="clr">
|
||||
|
||||
@ -56,7 +56,7 @@ FRESULT f_getfree (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>sects_clust</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいて、_USE_FSINFOが指定されている場合、不正確な値を返す場合があります。指定されていない場合、処理に時間がかかります。</p>
|
||||
<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>sects_clust</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいて、_USE_FSINFOが指定されているときは不正確な値を返す可能性があり、指定されていないときは処理に時間がかかります。</p>
|
||||
<p>リードオンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ FRESULT f_open (
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>作成されたファイル・オブジェクトは、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html">f_close()</a>を使用します。</p>
|
||||
<p>作成されたファイル・オブジェクトは、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html">f_close()</a>を使用します。書き込みが行われたファイルが閉じられなかった場合、そのファイルは破損します。</p>
|
||||
<p>ファイル操作関数を使用する前にまず、<a href="mount.html">f_mount()</a>を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与えなければなりません。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p>
|
||||
<p>リードオンリー構成では、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p>
|
||||
</div>
|
||||
|
||||
@ -29,9 +29,27 @@ typedef struct _FILINFO {
|
||||
<dt>fsize</dt>
|
||||
<dd>ファイルのバイト単位のサイズが格納されます。ディレクトリの場合は常に0です。</dd>
|
||||
<dt>fdate</dt>
|
||||
<dd>ファイルの変更された日付、またはディレクトリの作成された日付が格納されます。</dd>
|
||||
<dd>ファイルの変更された日付、またはディレクトリの作成された日付が格納されます。<br>
|
||||
<dl>
|
||||
<dt>bit15:9</dt>
|
||||
<dd>1980年を起点とした年が 0..127 で入ります。</dd>
|
||||
<dt>bit8:5</dt>
|
||||
<dd>月が 1..12 の値で入ります。</dd>
|
||||
<dt>bit4:0</dt>
|
||||
<dd>日が 1..31 の値で入ります。</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>ftime</dt>
|
||||
<dd>ファイルの変更された時刻、またはディレクトリの作成された時刻が格納されます。</dd>
|
||||
<dd>ファイルの変更された時刻、またはディレクトリの作成された時刻が格納されます。<br>
|
||||
<dl>
|
||||
<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>
|
||||
</dd>
|
||||
<dt>fattrib</dt>
|
||||
<dd>属性フラグが格納されます。フラグは<tt>AM_DIR, AM_RDO, AM_HID, AM_SYS, AM_ARC</tt>の組み合わせとなります。</dd>
|
||||
<dt>fname[]</dt>
|
||||
|
||||
63
doc/ja/truncate.html
Normal file
63
doc/ja/truncate.html
Normal file
@ -0,0 +1,63 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="up" title="FatFs" href="../00index_j.html">
|
||||
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_truncate</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>f_truncate</h2>
|
||||
<p>ファイル長を切り詰めます。</p>
|
||||
<pre>
|
||||
FRESULT f_truncate (
|
||||
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 (0)</dt>
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_DENIED</dt>
|
||||
<dd>ファイルが非書き込みモードで開かれている。</dd>
|
||||
<dt>FR_RW_ERROR</dt>
|
||||
<dd>ディスク・エラーまたは内部エラーによる失敗。</dd>
|
||||
<dt>FR_NOT_READY</dt>
|
||||
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
<dd>無効なファイル・オブジェクト。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>ファイルの長さが現在のファイルR/Wポインタに切り詰められます。ファイルR/Wポインタがファイルの終端を指しているときは、この関数は何の効果も持ちません。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">Return</a></p>
|
||||
</body>
|
||||
</html>
|
||||
75
doc/ja/utime.html
Normal file
75
doc/ja/utime.html
Normal file
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="up" title="FatFs" href="../00index_j.html">
|
||||
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_utime</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para">
|
||||
<h2>f_utime</h2>
|
||||
<p>ファイルまたはディレクトリのタイムスタンプを変更します。</p>
|
||||
<pre>
|
||||
FRESULT f_utime (
|
||||
const char* <em>FileName</em>, /* ファイルまたはディレクトリ名へのポインタ */
|
||||
const FILINFO* <em>TimeDate</em> /* 設定する日付 */
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para">
|
||||
<h4>引数</h4>
|
||||
<dl class="par">
|
||||
<dt>FileName</dt>
|
||||
<dd>変更対象のファイルまたはディレクトリの<a href="filename.html">フルパス名</a>の入った<tt>'\0'</tt>で終わる文字列を指定します。</dd>
|
||||
<dt>TimeDate</dt>
|
||||
<dd>設定する日付と時間をfdateとftimeメンバに設定されたFILINFO構造体へのポインタ。他のメンバはDon't careです。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>戻り値</h4>
|
||||
<dl class="ret">
|
||||
<dt>FR_OK (0)</dt>
|
||||
<dd>正常終了。</dd>
|
||||
<dt>FR_NO_FILE</dt>
|
||||
<dd>ファイルが見つからない。</dd>
|
||||
<dt>FR_NO_PATH</dt>
|
||||
<dd>パスが見つからない。</dd>
|
||||
<dt>FR_INVALID_NAME</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_NOT_ENABLED</dt>
|
||||
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>解説</h4>
|
||||
<p>ファイルまたはディレクトリのタイムスタンプを変更します。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,3 +1,10 @@
|
||||
R0.05a, Feb 03, 2008
|
||||
Added f_truncate.
|
||||
Added f_utime.
|
||||
Fixed off by one error at FAT sub-type determination.
|
||||
Fixed btr in f_read can be mistruncated.
|
||||
Fixed cached sector is left not flushed when create and close without write.
|
||||
|
||||
R0.05, Aug 26, 2007
|
||||
Changed arguments of f_read, f_write.
|
||||
Changed arguments of f_mkfs. (FatFs)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FatFs/Tiny-FatFs Module Source Files R0.05 (C)ChaN, 2007
|
||||
FatFs/Tiny-FatFs Module Source Files R0.05a (C)ChaN, 2008
|
||||
|
||||
|
||||
FILES
|
||||
@ -67,20 +67,21 @@ CONFIGURATION OPTIONS
|
||||
|
||||
_USE_FSINFO
|
||||
|
||||
When _USE_FSINFO is set to 1, FSInfo is used for FAT32 volume.
|
||||
|
||||
When _USE_FSINFO is set to 1, FSInfo is used for FAT32 volume. The initial
|
||||
value is 0. (FSInfo is not used)
|
||||
|
||||
_USE_SJIS
|
||||
|
||||
When _USE_SJIS is set to 1, Shift_JIS code set can be used as a file name,
|
||||
otherwire second byte of double-byte characters will be collapted.
|
||||
The initial value is 1.
|
||||
otherwire second byte of double-byte characters will be collapted. The
|
||||
initial value is 1.
|
||||
|
||||
|
||||
_USE_NTFLAG
|
||||
|
||||
When _USE_NTFLAG is set to 1, upper/lower case of the file/dir name is
|
||||
preserved. Note that the files are always accessed in case insensitive.
|
||||
The initial value is 1.
|
||||
|
||||
|
||||
_USE_MKFS
|
||||
@ -90,7 +91,7 @@ CONFIGURATION OPTIONS
|
||||
The initial value is 0. (f_mkfs is not available)
|
||||
|
||||
|
||||
Following table shows which function is removed by configuratin options.
|
||||
Following table shows which function is removed by configuration options.
|
||||
|
||||
_FS_MINIMIZE _FS_READONLY _USE_MKFS
|
||||
(1) (2) (3) (1) (0)
|
||||
@ -105,9 +106,11 @@ CONFIGURATION OPTIONS
|
||||
f_readdir x x
|
||||
f_stat x x x
|
||||
f_getfree x x x x
|
||||
f_truncate x x x x
|
||||
f_unlink x x x x
|
||||
f_mkdir x x x x
|
||||
f_chmod x x x x
|
||||
f_utime x x x x
|
||||
f_rename x x x x
|
||||
f_mkfs x x x x x
|
||||
|
||||
@ -117,8 +120,8 @@ 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 and/or modify it for personal, non-profit or profit use without
|
||||
any restriction under your responsibility.
|
||||
You can use and/or modify it for personal, non-profit or commercial use
|
||||
without any restriction under your responsibility.
|
||||
|
||||
|
||||
|
||||
@ -162,3 +165,9 @@ REVISION HISTORY
|
||||
Changed arguments of f_mkfs. (FatFs)
|
||||
Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs)
|
||||
Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
|
||||
|
||||
Feb 03, 2008 R0.05a Added f_truncate().
|
||||
Added f_utime().
|
||||
Fixed off by one error at FAT sub-type determination.
|
||||
Fixed btr in f_read() can be mistruncated.
|
||||
Fixed cached sector is not flushed when create and close without write.
|
||||
|
||||
10
src/diskio.c
10
src/diskio.c
@ -8,7 +8,7 @@
|
||||
#include "diskio.h"
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Correspondence between drive number and physical drive */
|
||||
/* Correspondence between physical drive number and physical drive. */
|
||||
/* Note that Tiny-FatFs supports only single drive and always */
|
||||
/* accesses drive number 0. */
|
||||
|
||||
@ -92,8 +92,8 @@ DSTATUS disk_status (
|
||||
DRESULT disk_read (
|
||||
BYTE drv, /* Physical drive nmuber (0..) */
|
||||
BYTE *buff, /* Data buffer to store read data */
|
||||
DWORD sector, /* Sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
DWORD sector, /* Sector address (LBA) */
|
||||
BYTE count /* Number of sectors to read (1..255) */
|
||||
)
|
||||
{
|
||||
DRESULT res;
|
||||
@ -130,8 +130,8 @@ DRESULT disk_read (
|
||||
DRESULT disk_write (
|
||||
BYTE drv, /* Physical drive nmuber (0..) */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
DWORD sector, /* Sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
DWORD sector, /* Sector address (LBA) */
|
||||
BYTE count /* Number of sectors to write (1..255) */
|
||||
)
|
||||
{
|
||||
DRESULT res;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------------------------------------
|
||||
/ Low level disk interface modlue include file R0.05 (C)ChaN, 2007
|
||||
/ Low level disk interface modlue include file R0.05x (C)ChaN, 2007
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO
|
||||
|
||||
24
src/ff.h
24
src/ff.h
@ -1,11 +1,11 @@
|
||||
/*--------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include file R0.05 (C)ChaN, 2007
|
||||
/ FatFs - FAT file system module include file R0.05a (C)ChaN, 2008
|
||||
/---------------------------------------------------------------------------/
|
||||
/ FatFs module is an experimenal project to implement FAT file system to
|
||||
/ cheap microcontrollers. This is a free software and is opened for education,
|
||||
/ research and development under license policy of following trems.
|
||||
/
|
||||
/ Copyright (C) 2007, ChaN, all right reserved.
|
||||
/ Copyright (C) 2008, ChaN, all right reserved.
|
||||
/
|
||||
/ * The FatFs module is a free software and there is no warranty.
|
||||
/ * You can use, modify and/or redistribute it for personal, non-profit or
|
||||
@ -21,18 +21,18 @@
|
||||
/ 1: Enable word access.
|
||||
/ 2: Disable word access and use byte-by-byte access instead.
|
||||
/ When the architectural byte order of the MCU is big-endian and/or address
|
||||
/ miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set
|
||||
/ to 2. If it is not the case, it can be set to 1 for good code efficiency. */
|
||||
/ miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
|
||||
/ If it is not the case, it can also be set to 1 for good code efficiency. */
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename
|
||||
/ and useless f_getfree. */
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
||||
/ f_truncate and useless f_getfree. */
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
|
||||
/ 0: Full function.
|
||||
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod and f_rename are removed.
|
||||
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename are removed.
|
||||
/ 2: f_opendir and f_readdir are removed in addition to level 1.
|
||||
/ 3: f_lseek is removed in addition to level 2. */
|
||||
|
||||
@ -67,9 +67,9 @@
|
||||
/* Definitions corresponds to multiple sector size (not tested) */
|
||||
#define S_MAX_SIZ 512 /* Do not change */
|
||||
#if S_MAX_SIZ > 512
|
||||
#define S_SIZ (fs->s_size)
|
||||
#define SS(fs) ((fs)->s_size)
|
||||
#else
|
||||
#define S_SIZ 512
|
||||
#define SS(fs) 512
|
||||
#endif
|
||||
|
||||
|
||||
@ -201,10 +201,12 @@ FRESULT f_opendir (DIR*, const char*); /* Open an existing directory */
|
||||
FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */
|
||||
FRESULT f_stat (const char*, FILINFO*); /* Get file status */
|
||||
FRESULT f_getfree (const char*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
|
||||
FRESULT f_truncate (FIL*); /* Truncate file */
|
||||
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
|
||||
FRESULT f_unlink (const char*); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir (const char*); /* Create a new directory */
|
||||
FRESULT f_chmod (const char*, BYTE, BYTE); /* Change file/dir attriburte */
|
||||
FRESULT f_utime (const char*, const FILINFO*); /* Change file/dir timestamp */
|
||||
FRESULT f_rename (const char*, const char*); /* Rename/Move a file or directory */
|
||||
FRESULT f_mkfs (BYTE, BYTE, WORD); /* Create a file system on the drive */
|
||||
|
||||
@ -313,8 +315,7 @@ DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#else
|
||||
#if _MCU_ENDIAN == 2 /* Use byte-by-byte access */
|
||||
#elif _MCU_ENDIAN == 2 /* Use byte-by-byte access */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*(volatile BYTE*)((ptr)+1)<<8)|(WORD)*(volatile BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*(volatile BYTE*)((ptr)+3)<<24)|((DWORD)*(volatile BYTE*)((ptr)+2)<<16)|((WORD)*(volatile BYTE*)((ptr)+1)<<8)|*(volatile BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
@ -322,7 +323,6 @@ DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20
|
||||
#else
|
||||
#error Do not forget to set _MCU_ENDIAN properly!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define _FATFS
|
||||
|
||||
@ -1,20 +1,24 @@
|
||||
/*-------------------------------------------*/
|
||||
/* Integer type definitions for FatFs module */
|
||||
/*-------------------------------------------*/
|
||||
|
||||
#ifndef _INTEGER
|
||||
|
||||
/* These types are assumed as 16-bit or larger integer */
|
||||
/* These types must be 16-bit, 32-bit or larger integer */
|
||||
typedef signed int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* These types are assumed as 8-bit integer */
|
||||
/* These types must be 8-bit integer */
|
||||
typedef signed char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* These types are assumed as 16-bit integer */
|
||||
/* These types must be 16-bit integer */
|
||||
typedef signed short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned short WORD;
|
||||
|
||||
/* These types are assumed as 32-bit integer */
|
||||
/* These types must be 32-bit integer */
|
||||
typedef signed long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
20
src/tff.h
20
src/tff.h
@ -1,11 +1,11 @@
|
||||
/*--------------------------------------------------------------------------/
|
||||
/ Tiny-FatFs - FAT file system module include file R0.05 (C)ChaN, 2007
|
||||
/ Tiny-FatFs - FAT file system module include file R0.05a (C)ChaN, 2008
|
||||
/---------------------------------------------------------------------------/
|
||||
/ FatFs module is an experimenal project to implement FAT file system to
|
||||
/ cheap microcontrollers. This is a free software and is opened for education,
|
||||
/ research and development under license policy of following trems.
|
||||
/
|
||||
/ Copyright (C) 2007, ChaN, all right reserved.
|
||||
/ Copyright (C) 2008, ChaN, all right reserved.
|
||||
/
|
||||
/ * The FatFs module is a free software and there is no warranty.
|
||||
/ * You can use, modify and/or redistribute it for personal, non-profit or
|
||||
@ -21,18 +21,18 @@
|
||||
/ 1: Enable word access.
|
||||
/ 2: Disable word access and use byte-by-byte access instead.
|
||||
/ When the architectural byte order of the MCU is big-endian and/or address
|
||||
/ miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set
|
||||
/ to 2. If it is not the case, it can be set to 1 for good code efficiency. */
|
||||
/ miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
|
||||
/ If it is not the case, it can also be set to 1 for good code efficiency. */
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename
|
||||
/ and useless f_getfree. */
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
||||
/ f_truncate, f_getfree and internal writing codes. */
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
|
||||
/ 0: Full function.
|
||||
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod and f_rename are removed.
|
||||
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename are removed.
|
||||
/ 2: f_opendir and f_readdir are removed in addition to level 1.
|
||||
/ 3: f_lseek is removed in addition to level 2. */
|
||||
|
||||
@ -163,10 +163,12 @@ FRESULT f_opendir (DIR*, const char*); /* Open an existing directory */
|
||||
FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */
|
||||
FRESULT f_stat (const char*, FILINFO*); /* Get file status */
|
||||
FRESULT f_getfree (const char*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
|
||||
FRESULT f_truncate (FIL*); /* Truncate file */
|
||||
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
|
||||
FRESULT f_unlink (const char*); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir (const char*); /* Create a new directory */
|
||||
FRESULT f_chmod (const char*, BYTE, BYTE); /* Change file/dir attriburte */
|
||||
FRESULT f_utime (const char*, const FILINFO*); /* Change file/dir timestamp */
|
||||
FRESULT f_rename (const char*, const char*); /* Rename/Move a file or directory */
|
||||
|
||||
|
||||
@ -273,8 +275,7 @@ DWORD get_fattime (void); /* 31-25: Year(0-127 +1980), 24-21: Month(1-12), 20-16
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#else
|
||||
#if _MCU_ENDIAN == 2 /* Use byte-by-byte access */
|
||||
#elif _MCU_ENDIAN == 2 /* Use byte-by-byte access */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*(volatile BYTE*)((ptr)+1)<<8)|(WORD)*(volatile BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*(volatile BYTE*)((ptr)+3)<<24)|((DWORD)*(volatile BYTE*)((ptr)+2)<<16)|((WORD)*(volatile BYTE*)((ptr)+1)<<8)|*(volatile BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
@ -282,7 +283,6 @@ DWORD get_fattime (void); /* 31-25: Year(0-127 +1980), 24-21: Month(1-12), 20-16
|
||||
#else
|
||||
#error Do not forget to set _MCU_ENDIAN properly!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user