1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00
elua/doc/en/fatfs.html
Dado Sutter 17487f9ebe - doc folder replaced by some work done on Led Lab for the new doc and site
- This should actually be a merge but we made a mistake on the initial repo creation
  and a merge was not possible.
- Below there is a resumed log of the commit messages for the few steps, just for
  the record.

- The merged commit messages for this work are:

 - Removing Portuguese doc content
 - Ignore folder names fixed on .gitignore
 - Removed doc files which content migrated to the CMS
 - docdata.lua updated accordingly
 - Doc build checked ok
 - Overall doc structure and contents still being refined
 - Removing folder cache from git versioning
 - Removing folder dist from git versioning. The folders above are generated by the buildall.lua script and are not part of the sources
 - Adding .gitignore file with objects info to inform git what to ignore
 - Removed file
 - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git
 - Moving all files and folders to a working doc folder
 - Css updated
 - Index page added and CSS adjusts
 - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git
 - Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com>
 - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git
 - files deleted
 - Changed function that creates functions submenus.
 - Menu inserted with árvore, CSS adjusts, google search
 - Changed past design to new design
 - CSS updated
 - initial import

- The commit ids were also preserved but they are related to this "other"
  work done on Led Lab. We'll keep the repo just in case.

4dce3f77c47b0c3001a2075a946e80ee52759b49 - Removing Portuguese doc content
78d8847525cacf045fe7e672cff6bd1e058a6a4b Ignore folder names fixed on .gitignore
48dee6b7962168ab1098bf709ead6f3cfe6b7964 - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined
2aa2fe0c554db03dbc7029c34d0f4500fe625b37 - Removing folder cache from git versioning - Removing folder dist from git versioning   The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore
af6cc2890edf1855af319dc999a03feee5f9bee0 Removed file
6a180e72eb4f4860620cafc0685000e9f2174cfe Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git
eb430112e78ae537459ab315e228ebca84bdf2d4 Moving all files and folders to a working doc folder
d28a7c99489915630bd2625f3756fecf0d08ce37 Css updated
32836ffe382f04ab07c3e6f018c7b449a20d7a8d Index page added and CSS adjusts
1461d9957d9d25a1467cb57ab8717aa213a37e8d Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git
ae1934c04f35a29e25bb4495ae8a31cd9c000b5b Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com>
b5f31d70f1fac8d3fba325c9867a03f976775698 Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git
ec9ad8446b7ea38b252c6a416e70774349835e45 files deleted
bd7a80151b2030720ba8d8a303467d8c25a4b4b2 Changed function that creates functions submenus.
6a7494acaec694fadbb13520bcbccc51a6b95dfe Inserido menu com árvore, ajustes no CSS, busca do google
e979f1c259d425c9a3be83f9cda20eddffe073bb Changed past design to new design.
381459e95286886b052103a0253e60b29e064d7a CSS updated
4f81d2f1195efe733fe5f97517be325d75937bc3 initial import
2011-05-06 06:49:21 -03:00

54 lines
2.8 KiB
HTML

$$HEADER$$
<h3>The FAT file system</h3>
<p>The FAT file system implementation in <b>eLua</b> uses Elm Chan's excellent FatFS package, available <a href="http://elm-chan.org/fsw/ff/00index_e.html">here</a>. It can handle FAT12, FAT16
and FAT32 file systems in read/write mode, and it packs a lot of functionality in a low footprint. Like the ROM filesystem it is integrated with the C library, so similar POSIX file manipulation will work in addition to accessing the filesystem via the Lua <b>io</b> module. <b>eLua</b> adds a platform abstraction layer on top of FatFS which makes it very easy to
port the FAT file system implementation between different <b>eLua</b> targets. Since most SD/MMC cards can be accessed using the very common SPI interface, and since <b>eLua</b> already provides
a <a href="arch_platform_spi.html">SPI platform interface</a>, porting the FAT file system to an <b>eLua</b> board is a fairly simple process.</p>
<p>To use the FAT file system on your <b>elua</b> board (that has the proper hardware to access SD/MMC cards), first make sure that there is a working implementation of the
<a href="arch_platform_spi.html">eLua SPI platform interface</a> on your platform (as currently <b>eLua</b> can access SD/MMC cards only via SPI). Then you need to enable the FAT file system module (MMCFS)
in your <b>eLua</b> binary image, as described on the <a href="building.html">building page</a>.</p>
<h2>Using the FAT file system</h2>
<p>To use the FAT filesystem with an SD or MMC card, first ensure that the card has been properly formatted as a FAT filesystem (many come preformatted with this file system).</p>
<p>Next, ensure that you have connected the SD or MMC card using the pin configuration described in the table below. For more more information, see Elm Chan's page on <a href="http://elm-chan.org/docs/mmc/mmc_e.html">SD/MMC with SPI</a>.</p>
<table class="table_center">
<tbody>
<tr>
<th>eLua PIN</th>
<th>Static Config</th>
<th>SD Card Pin</th>
<th>MMC Card Pin</th>
</tr>
<tr>
<td>CS</td>
<td>MMCFS_CS_PORT,<br> MMCFS_CS_PIN</td>
<td>DAT3/CS</td>
<td>RES/CS</td>
</tr>
<tr>
<td>SPI DO</td>
<td>MMCFS_SPI_NUM</td>
<td>CMD/DI</td>
<td>CMD/DI</td>
</tr>
<tr>
<td>SPI DI</td>
<td>MMCFS_SPI_NUM</td>
<td>DAT0/DO</td>
<td>DAT0/DO</td>
</tr>
<tr>
<td>SPI SCLK</td>
<td>MMCFS_SPI_NUM</td>
<td>CLK</td>
<td>CLK</td>
</tr>
</tbody>
</table>
<p>Once configured, connected, and <b>eLua</b> has started up, you are ready to work with the files on your card. To open a file on the SD/MMC card, all you need to do is to prefix its name with <i>/mmc/</i>, like this:</p>
<p><pre><code># lua /mmc/info.lua </code></pre></p>
<p>Similarly, if you wanted to access a text file <b>a.txt</b> from your card, you could use fopen like this:</p>
<p><pre><code>f = fopen( "/mmc/a.txt", "rb" )</code></pre></p>
$$FOOTER$$