Browse Source

Add GFILE support for PetitFS (a very tiny FAT implementation)

inmarket 5 years ago
parent
commit
75e1e7a5e2
36 changed files with 3094 additions and 3 deletions
  1. 77 0
      3rdparty/petitfs-0.03/doc/00index_p.html
  2. 65 0
      3rdparty/petitfs-0.03/doc/css_e.css
  3. 1 0
      3rdparty/petitfs-0.03/doc/css_p.css
  4. BIN
      3rdparty/petitfs-0.03/doc/img/layers3.png
  5. BIN
      3rdparty/petitfs-0.03/doc/img/rwtest3.png
  6. 91 0
      3rdparty/petitfs-0.03/doc/pf/appnote.html
  7. 40 0
      3rdparty/petitfs-0.03/doc/pf/dinit.html
  8. 59 0
      3rdparty/petitfs-0.03/doc/pf/dreadp.html
  9. 73 0
      3rdparty/petitfs-0.03/doc/pf/dwritep.html
  10. 22 0
      3rdparty/petitfs-0.03/doc/pf/filename.html
  11. 79 0
      3rdparty/petitfs-0.03/doc/pf/lseek.html
  12. 65 0
      3rdparty/petitfs-0.03/doc/pf/mount.html
  13. 103 0
      3rdparty/petitfs-0.03/doc/pf/open.html
  14. 72 0
      3rdparty/petitfs-0.03/doc/pf/opendir.html
  15. 73 0
      3rdparty/petitfs-0.03/doc/pf/read.html
  16. 100 0
      3rdparty/petitfs-0.03/doc/pf/readdir.html
  17. 30 0
      3rdparty/petitfs-0.03/doc/pf/sdir.html
  18. 39 0
      3rdparty/petitfs-0.03/doc/pf/sfatfs.html
  19. 62 0
      3rdparty/petitfs-0.03/doc/pf/sfileinfo.html
  20. 86 0
      3rdparty/petitfs-0.03/doc/pf/write.html
  21. 46 0
      3rdparty/petitfs-0.03/src/00readme.txt
  22. 73 0
      3rdparty/petitfs-0.03/src/diskio.c
  23. 42 0
      3rdparty/petitfs-0.03/src/diskio.h
  24. 33 0
      3rdparty/petitfs-0.03/src/integer.h
  25. 1108 0
      3rdparty/petitfs-0.03/src/pff.c
  26. 159 0
      3rdparty/petitfs-0.03/src/pff.h
  27. 89 0
      3rdparty/petitfs-0.03/src/pffconf.h
  28. 1 0
      docs/releases.txt
  29. 89 0
      pffconf.h
  30. 157 0
      src/gfile/inc_petitfs.c
  31. 82 0
      src/gfile/petitfs_chibios_diskio.c
  32. 23 0
      src/gfile/petitfs_wrapper.c
  33. 26 0
      src/gfile/petitfs_wrapper.h
  34. 6 1
      src/gfile/sys_make.mk
  35. 20 2
      src/gfile/sys_options.h
  36. 3 0
      src/gfile/sys_rules.h

+ 77 - 0
3rdparty/petitfs-0.03/doc/00index_p.html

@@ -0,0 +1,77 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<meta http-equiv="cache-control" content="no-cache">
7
+<meta name="description" content="A tiny FAT file system for embedded projects">
8
+<link rel="start" title="Site Top" href="../../">
9
+<link rel="up" title="Freewares" href="../../fsw_e.html">
10
+<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
11
+<link rel="stylesheet" href="css_p.css" type="text/css" media="screen" title="ELM Default">
12
+<title>Petit FAT File System Module</title>
13
+</head>
14
+
15
+<body>
16
+<h1>Petit FAT File System Module</h1>
17
+<hr>
18
+
19
+<div class="abst">
20
+<img src="img/layers3.png" class="rset" width="245" height="255" alt="layer">
21
+<p>Petit FatFs is a sub-set of FatFs module for tiny 8-bit microcontrollers. It is written in compliance with ANSI C and completely separated from the disk I/O layer. It can be incorporated into the tiny microcontrollers with limited memory even if the RAM size is less than sector size. Also full featured FAT file system module is available <a href="http://elm-chan.org/fsw/ff/00index_e.html">here</a>↗.</p>
22
+
23
+<h4>Features</h4>
24
+<ul>
25
+ <li>Very small RAM consumption (44 bytes work area + certain stack).</li>
26
+ <li>Very small code size (2K-4K bytes).</li>
27
+ <li>FAT12, FAT16 and FAT32.</li>
28
+ <li>Single volume and Single file.</li>
29
+ <li>File write function with some restrictions.</li>
30
+</ul>
31
+</div>
32
+
33
+
34
+<div class="para">
35
+<h3>Application Interface</h3>
36
+<p>Petit FatFs module provides following functions.</p>
37
+<ul>
38
+<li><a href="pf/mount.html">pf_mount</a> - Mount a Volume</li>
39
+<li><a href="pf/open.html">pf_open</a> - Open a File</li>
40
+<li><a href="pf/read.html">pf_read</a> - Read File</li>
41
+<li><a href="pf/write.html">pf_write</a> - Write File</li>
42
+<li><a href="pf/lseek.html">pf_lseek</a> - Move read/write Pointer</li>
43
+<li><a href="pf/opendir.html">pf_opendir</a> - Open a Directory</li>
44
+<li><a href="pf/readdir.html">pf_readdir</a> - Read a Directory Item</li>
45
+</ul>
46
+</div>
47
+
48
+
49
+<div class="para">
50
+<h3>Disk I/O Interface</h3>
51
+<p>Since the Petit FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read data from storage device. The low level disk I/O module is not a part of Petit FatFs module and it must be provided by user. The sample drivers are also available in the resources.</p>
52
+<ul>
53
+<li><a href="pf/dinit.html">disk_initialize</a> - Initialize storage device</li>
54
+<li><a href="pf/dreadp.html">disk_readp</a> - Read a partial sector</li>
55
+<li><a href="pf/dwritep.html">disk_writep</a> - Divided write to a sector</li>
56
+</ul>
57
+</div>
58
+
59
+
60
+<div class="para">
61
+<h3>Resources</h3>
62
+<p>The Petit FatFs module is a free software and is opened for education, research and development. You can use, modify and/or redistribute it for personal, non-profit or commercial use without any restriction under your responsibility. For further information, refer to the application note.</p>
63
+<ul>
64
+<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a>↗</li>
65
+<li>Read first: <a href="pf/appnote.html">Petit FatFs module application note</a> <span class="mfd">June 10, 2014</span></li>
66
+ <li>Latest Information: <a href="http://elm-chan.org/fsw/ff/00index_p.html">http://elm-chan.org/fsw/ff/00index_p.html</a>↗</li>
67
+<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a>↗ (The reference document on FAT file system)</li>
68
+<li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to Use MMC/SDC</a>↗</li>
69
+<li><a href="img/rwtest3.png">Benchmark 3</a> (ATtiny85/8MHz with MMC via USI)</li>
70
+</ul>
71
+</div>
72
+
73
+
74
+<hr>
75
+<p class="foot"><a href="../../fsw_e.html">Return</a></p>
76
+</body>
77
+</html>

+ 65 - 0
3rdparty/petitfs-0.03/doc/css_e.css

@@ -0,0 +1,65 @@
1
+* {margin: 0; padding: 0; border-width: 0;}
2
+body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}
3
+a:link {color: blue;}
4
+a:visited {color: darkmagenta;}
5
+a:hover {background-color: #a0ffff;}
6
+a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
7
+abbr {border-width: 1px;}
8
+
9
+p {margin: 0 0 0.3em 1em;}
10
+i {margin: 0 0.3em 0 0;}
11
+b {margin: 0 0.1em;}
12
+em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
13
+strong {}
14
+pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;}
15
+pre span.c {color: green;}
16
+pre span.k {color: blue;}
17
+pre span.arg {font-style: italic;}
18
+tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
19
+tt.arg {font-style: italic;}
20
+ol {margin: 0.5em 2.5em;}
21
+ul {margin: 0.5em 2em;}
22
+dl {margin: 0.5em 1em;}
23
+dd {margin: 0 2em;}
24
+dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
25
+dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
26
+dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
27
+hr {border-width: 1px; margin: 1em;}
28
+div.abst {font-family: sans-serif;}
29
+div.para {clear: both; font-family: serif;}
30
+div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
31
+.equ {text-indent: 0; margin: 1em 2em 1em;}
32
+.indent {margin-left: 2em;}
33
+.rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
34
+.lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;}
35
+ul.flat li {list-style-type: none; margin: 0;}
36
+a.imglnk img {border: 1px solid;}
37
+.iequ {white-space: nowrap; font-weight: bold;}
38
+.clr {clear: both;}
39
+.it {font-style: italic;}
40
+.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap}
41
+.ral {text-align: right; }
42
+.lal {text-align: left; }
43
+.cal {text-align: center; }
44
+
45
+h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
46
+p.hdd {float: right; text-align: right; margin-top: 0.5em;}
47
+hr.hds {clear: both; margin-bottom: 1em;}
48
+
49
+h2 {font-size: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;}
50
+h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;}
51
+h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;}
52
+h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}
53
+small {font-size: 80%;}
54
+.indent {margin-left: 2em;}
55
+
56
+/* Tables */
57
+table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; }
58
+th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;}
59
+td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
60
+table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
61
+table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
62
+table caption {font-family: sans-serif; font-weight: bold;}
63
+tr.lst3 td { border-width: 2px 1px 1px; }
64
+
65
+p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}

+ 1 - 0
3rdparty/petitfs-0.03/doc/css_p.css

@@ -0,0 +1 @@
1
+body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}

BIN
3rdparty/petitfs-0.03/doc/img/layers3.png


BIN
3rdparty/petitfs-0.03/doc/img/rwtest3.png


File diff suppressed because it is too large
+ 91 - 0
3rdparty/petitfs-0.03/doc/pf/appnote.html


+ 40 - 0
3rdparty/petitfs-0.03/doc/pf/dinit.html

@@ -0,0 +1,40 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - disk_initialize</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>disk_initialize</h2>
16
+<p>The disk_initialize function initializes the disk drive.</p>
17
+<pre>
18
+DSTATUS disk_initialize (void)
19
+</pre>
20
+</div>
21
+
22
+<div class="para">
23
+<h4>Return Values</h4>
24
+<p>The disk status is returned in combination of following flags.</p>
25
+<dl class="ret">
26
+<dt>STA_NOINIT</dt>
27
+<dd>Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.</dd>
28
+<dt>STA_NODISK</dt>
29
+<dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive. This flag is not referred by Petit FatFs.</dd>
30
+</dl>
31
+</div>
32
+
33
+<div class="para">
34
+<h4>Description</h4>
35
+<p>The disk_initialize function initializes the storage device. If the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleared.</p>
36
+</div>
37
+
38
+<p class="foot"><a href="../00index_p.html">Return</a></p>
39
+</body>
40
+</html>

+ 59 - 0
3rdparty/petitfs-0.03/doc/pf/dreadp.html

@@ -0,0 +1,59 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - disk_readp</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>disk_readp</h2>
16
+<p>The disk_readp function reads a partial sector of the device.</p>
17
+<pre>
18
+DRESULT disk_readp (
19
+  BYTE* <span class="arg">buff</span>,    <span class="c">/* [OUT] Pointer to the read buffer */</span>
20
+  DWORD <span class="arg">sector</span>,  <span class="c">/* [IN]  Sector number */</span>
21
+  UINT <span class="arg">offset</span>,   <span class="c">/* [IN]  Byte offset in the sector to start to read */</span>
22
+  UINT <span class="arg">count</span>     <span class="c">/* [IN]  Number of bytes to read */</span>
23
+);
24
+</pre>
25
+</div>
26
+
27
+<div class="para">
28
+<h4>Parameters</h4>
29
+<dl class="par">
30
+<dt>buff</dt>
31
+<dd>Pointer to the read buffer to store the read data. If a NULL is given, read bytes will be forwarded to the outgoing stream instead of the memory.</dd>
32
+<dt>sector</dt>
33
+<dd>Specifies the sector number to be read in logical block address (LBA).</dd>
34
+<dt>offset</dt>
35
+<dd>Specifies the byte offset in the sector to start to read. The value can be 0 to 511.</dd>
36
+<dt>count</dt>
37
+<dd>Specifies number of bytes to read. The value can be 0 to 512 and <tt class="arg">offset</tt> + <tt class="arg">count</tt> must not exceed 512.</dd>
38
+</dl>
39
+</div>
40
+
41
+
42
+<div class="para">
43
+<h4>Return Value</h4>
44
+<dl class="ret">
45
+<dt>RES_OK (0)</dt>
46
+<dd>The function succeeded.</dd>
47
+<dt>RES_ERROR</dt>
48
+<dd>Any hard error occured during the disk read operation and could not recover it.</dd>
49
+<dt>RES_PARERR</dt>
50
+<dd>Invalid parameter.</dd>
51
+<dt>RES_NOTRDY</dt>
52
+<dd>The device has not been initialized.</dd>
53
+</dl>
54
+</div>
55
+
56
+
57
+<p class="foot"><a href="../00index_p.html">Return</a></p>
58
+</body>
59
+</html>

+ 73 - 0
3rdparty/petitfs-0.03/doc/pf/dwritep.html

@@ -0,0 +1,73 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - disk_writep</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>disk_writep</h2>
16
+<p>The disk_writep function writes data to the sector.</p>
17
+<pre>
18
+DRESULT disk_writep (
19
+  BYTE* <span class="arg">buff</span>,  <span class="c">/* [IN] Pointer to the data to be written */</span>
20
+  DWORD <span class="arg">sc</span>,    <span class="c">/* [IN] Sector number or Number of bytes to wtite */</span>
21
+);
22
+</pre>
23
+</div>
24
+
25
+<div class="para">
26
+<h4>Parameters</h4>
27
+<dl class="par">
28
+<dt>buff</dt>
29
+<dd>Pointer to the data to be written to the sector. If a NULL is given, the function initiate/finalize a write transaction to the sector.</dd>
30
+<dt>sc</dt>
31
+<dd>Specifies nubmer of bytes to write if <tt class="arg">buff</tt> is not a NULL. If <tt class="arg">buff</tt> is a NULL and <tt class="arg">sc</tt> is not a zero, the function initiates a write transactin to the sector. If  <tt class="arg">buff</tt> and <tt class="arg">sc</tt> are zero, the function finalize the current sector write transactin.</dd>
32
+</dl>
33
+</div>
34
+
35
+
36
+<div class="para">
37
+<h4>Return Value</h4>
38
+<dl class="ret">
39
+<dt>RES_OK (0)</dt>
40
+<dd>The function succeeded.</dd>
41
+<dt>RES_ERROR</dt>
42
+<dd>Any hard error occured during the write operation and could not recover it or the medium is write protected.</dd>
43
+<dt>RES_PARERR</dt>
44
+<dd>Invalid parameter.</dd>
45
+<dt>RES_NOTRDY</dt>
46
+<dd>The device has not been initialized.</dd>
47
+</dl>
48
+</div>
49
+
50
+
51
+<div class="para">
52
+<h4>Description</h4>
53
+<p>A sector write operation is done in following sequence.</p>
54
+<ol>
55
+<li><tt>disk_writep(0, sector_number);</tt> Initiate a sector write transaction.</li>
56
+<li><tt>disk_writep(data, byte_to_write);</tt> Start to write data to the sector.</li>
57
+<li><tt>disk_writep(data, byte_to_write);</tt> And data can be written upto 512 bytes with one or more calls.</li>
58
+<li><tt>disk_writep(data, byte_to_write);</tt> ...</li>
59
+<li><tt>disk_writep(0, 0);</tt> Finalize the write transaction. If number of bytes sent is less than 512, left bytes in the sector is filled by zero.</li>
60
+</ol>
61
+<p>If a write transaction is in progress, <tt>disk_readp()</tt> function will fail and <tt>disk_initialize()</tt> function finalize the current write transaction.</p>
62
+</div>
63
+
64
+
65
+<div class="para">
66
+<h4>Remarks</h4>
67
+<p>This funciton is needed when <tt>_USE_WRITE == 1</tt>.</p>
68
+</div>
69
+
70
+
71
+<p class="foot"><a href="../00index_p.html">Return</a></p>
72
+</body>
73
+</html>

+ 22 - 0
3rdparty/petitfs-0.03/doc/pf/filename.html

@@ -0,0 +1,22 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - Path Names</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>Format of the path names</h2>
16
+<p>The path name format on the Petit FatFs module is similer to MS-DOS as follows.</p>
17
+<pre>"[/]<em>directory</em>/<em>file</em>"</pre>
18
+<p>The Petit FatFs module supports only 8.3 format file name. The sub-directories are separated with a /. The path name is terminated with a nul character, control character or white space. Heading spaces are ignored and skipped. When <tt>_USE_LCC == 1</tt>, lower case characters are allowed for the path name.</p>
19
+<p>The Petit FatFs module does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name following from the root directory. Heading separator is ignored and it can be exist or omitted.</p>
20
+</div>
21
+</body>
22
+</html>

+ 79 - 0
3rdparty/petitfs-0.03/doc/pf/lseek.html

@@ -0,0 +1,79 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - pf_lseek</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>pf_lseek</h2>
16
+<p>The pf_lseek function moves the file read/write pointer of the open file.</p>
17
+
18
+<pre>
19
+FRESULT pf_lseek (
20
+  DWORD <span class="arg">ofs</span>       <span class="c">/* [IN] File offset in unit of byte */</span>
21
+);
22
+</pre>
23
+</div>
24
+
25
+<div class="para">
26
+<h4>Parameters</h4>
27
+<dl class="par">
28
+<dt>ofs</dt>
29
+<dd>Number of bytes where from start of the file</dd>
30
+</dl>
31
+</div>
32
+
33
+
34
+<div class="para">
35
+<h4>Return Values</h4>
36
+<dl class="ret">
37
+<dt>FR_OK (0)</dt>
38
+<dd>The function succeeded.</dd>
39
+<dt>FR_DISK_ERR</dt>
40
+<dd>The function failed due to an error in the disk function, a wrong FAT structure or an internal error.</dd>
41
+<dt>FR_NOT_OPENED</dt>
42
+<dd>The file has not been opened.</dd>
43
+</dl>
44
+</div>
45
+
46
+
47
+<div class="para">
48
+<h4>Description</h4>
49
+<p>The <tt>pf_lseek()</tt> function moves the file read/write pointer of the open file. The <tt class="arg">offset</tt> can be specified in only origin from top of the file.</p>
50
+</div>
51
+
52
+
53
+<div class="para">
54
+<h4>Example</h4>
55
+<pre>
56
+    <span class="c">/* Move to offset of 5000 from top of the file */</span>
57
+    res = pf_lseek(5000);
58
+
59
+    <span class="c">/* Forward 3000 bytes */</span>
60
+    res = pf_lseek(fs.fptr + 3000);
61
+
62
+    <span class="c">/* Rewind 2000 bytes (take care on wraparound) */</span>
63
+    res = pf_lseek(fs.fptr - 2000);
64
+</pre>
65
+</div>
66
+
67
+<div class="para">
68
+<h4>QuickInfo</h4>
69
+<p>Available when <tt>_USE_LSEEK == 1</tt>.</p>
70
+</div>
71
+
72
+<div class="para">
73
+<h4>References</h4>
74
+<p><tt><a href="open.html">pf_open</a>, <a href="sfatfs.html">FATFS</a></tt></p>
75
+</div>
76
+
77
+<p class="foot"><a href="../00index_p.html">Return</a></p>
78
+</body>
79
+</html>

+ 65 - 0
3rdparty/petitfs-0.03/doc/pf/mount.html

@@ -0,0 +1,65 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - pf_mount</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>pf_mount</h2>
16
+<p>The pf_mount fucntion mounts a volume.</p>
17
+<pre>
18
+FRESULT pf_mount (
19
+  FATFS*  <span class="arg">fs</span>  <span class="c">/* [IN] Pointer to the work area */</span>
20
+);
21
+</pre>
22
+</div>
23
+
24
+<div class="para">
25
+<h4>Parameters</h4>
26
+<dl class="par">
27
+<dt>fs</dt>
28
+<dd>Pointer to the work area (file system object) to be registered.</dd>
29
+</dl>
30
+</div>
31
+
32
+<div class="para">
33
+<h4>Return Values</h4>
34
+<dl class="ret">
35
+<dt>FR_OK (0)</dt>
36
+<dd>The function succeeded.</dd>
37
+<dt>FR_NOT_READY</dt>
38
+<dd>The drive could not be initialized due to a disk error or no medium.</dd>
39
+<dt>FR_DISK_ERR</dt>
40
+<dd>An error occured in the disk function.</dd>
41
+<dt>FR_NO_FILESYSTEM</dt>
42
+<dd>There is no valid FAT partition on the disk.</dd>
43
+</dl>
44
+</div>
45
+
46
+
47
+<div class="para">
48
+<h4>Description</h4>
49
+<p>The <tt>pf_mount()</tt> function registers a work area to the Petit FatFs module. The volume is mounted on registration. The volume must be mounted with this function prior to any other file function and after every media changes.</p>
50
+</div>
51
+
52
+
53
+<div class="para">
54
+<h4>QuickInfo</h4>
55
+<p>Always available.</p>
56
+</div>
57
+
58
+<div class="para">
59
+<h4>References</h4>
60
+<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
61
+</div>
62
+
63
+<p class="foot"><a href="../00index_p.html">Return</a></p>
64
+</body>
65
+</html>

+ 103 - 0
3rdparty/petitfs-0.03/doc/pf/open.html

@@ -0,0 +1,103 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - pf_open</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>pf_open</h2>
16
+<p>The pf_open function opens an existing file.</p>
17
+<pre>
18
+FRESULT pf_open (
19
+  const char* <span class="arg">path</span>  <span class="c">/* [IN] Pointer to the file neme */</span>
20
+);
21
+</pre>
22
+</div>
23
+
24
+<div class="para">
25
+<h4>Parameters</h4>
26
+<dl class="par">
27
+<dt>path</dt>
28
+<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to open.</dd>
29
+</dl>
30
+</div>
31
+
32
+
33
+<div class="para">
34
+<h4>Return Values</h4>
35
+<dl class="ret">
36
+<dt>FR_OK (0)</dt>
37
+<dd>The function succeeded.</dd>
38
+<dt>FR_NO_FILE</dt>
39
+<dd>Could not find the file or path.</dd>
40
+<dt>FR_DISK_ERR</dt>
41
+<dd>The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.</dd>
42
+<dt>FR_NOT_ENABLED</dt>
43
+<dd>The volume has not been mounted.</dd>
44
+</dl>
45
+</div>
46
+
47
+
48
+<div class="para">
49
+<h4>Description</h4>
50
+<p>The file must be opend prior to use <tt>pf_read()</tt> and <tt>pf_lseek()</tt> function. The open file is valid until next open.</p>
51
+</div>
52
+
53
+
54
+<div class="para">
55
+<h4>Example</h4>
56
+<pre>
57
+int main (void)
58
+{
59
+    FATFS fs;          <span class="c">/* Work area (file system object) for the volume */</span>
60
+    BYTE buff[16];     <span class="c">/* File read buffer */</span>
61
+    UINT br;           <span class="c">/* File read count */</span>
62
+    FRESULT res;       <span class="c">/* Petit FatFs function common result code */</span>
63
+
64
+
65
+    <span class="c">/* Mount the volume */</span>
66
+    pf_mount(&amp;fs);
67
+    if (res) die(res);
68
+
69
+    <span class="c">/* Open a file */</span>
70
+    res = pf_open("srcfile.dat");
71
+    if (res) die(res);
72
+
73
+    <span class="c">/* Read data to the memory */</span>
74
+    res = pf_read(buff, 16, &amp;br);    <span class="c">/* Read data to the buff[] */</span>
75
+    if (res) die(res);               <span class="c">/* Check error */</span>
76
+    if (br != 16) die(255);          <span class="c">/* Check EOF */</span>
77
+
78
+    ....
79
+
80
+    <span class="c">/* Forward data to the outgoing stream */</span>
81
+    do
82
+        res = pf_read(0, 512, &amp;br);  <span class="c">/* Send data to the stream */</span>
83
+    while (res || br != 512);        <span class="c">/* Break on error or eof */</span>
84
+
85
+    ....
86
+
87
+}
88
+</pre>
89
+</div>
90
+
91
+<div class="para">
92
+<h4>QuickInfo</h4>
93
+<p>Always available.</p>
94
+</div>
95
+
96
+<div class="para">
97
+<h4>References</h4>
98
+<p><tt><a href="read.html">pf_read</a>, <a href="sfatfs.html">FATFS</a></tt></p>
99
+</div>
100
+
101
+<p class="foot"><a href="../00index_p.html">Return</a></p>
102
+</body>
103
+</html>

+ 72 - 0
3rdparty/petitfs-0.03/doc/pf/opendir.html

@@ -0,0 +1,72 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - pf_opendir</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>pf_opendir</h2>
16
+<p>The pf_opendir function opens a directory.</p>
17
+<pre>
18
+FRESULT pf_opendir (
19
+  DIR* <span class="arg">dp</span>,          <span class="c">/* [OUT] Pointer to the blank directory object structure */</span>
20
+  const char* <span class="arg">path</span>  <span class="c">/* [IN]  Pointer to the directory name */</span>
21
+);
22
+</pre>
23
+</div>
24
+
25
+<div class="para">
26
+<h4>Parameters</h4>
27
+<dl class="par">
28
+<dt>dp</dt>
29
+<dd>Pointer to the blank directory object to be created.</dd>
30
+<dt>path</dt>
31
+<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>
32
+</dl>
33
+</div>
34
+
35
+
36
+<div class="para">
37
+<h4>Return Values</h4>
38
+<dl class="ret">
39
+<dt>FR_OK (0)</dt>
40
+<dd>The function succeeded and the directory object is created. It is used for subsequent calls to read the directory entries.</dd>
41
+<dt>FR_NO_FILE</dt>
42
+<dd>Could not find the path.</dd>
43
+<dt>FR_NOT_READY</dt>
44
+<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
45
+<dt>FR_DISK_ERR</dt>
46
+<dd>The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.</dd>
47
+<dt>FR_NOT_ENABLED</dt>
48
+<dd>The volume has no work area.</dd>
49
+</dl>
50
+</div>
51
+
52
+
53
+<div class="para">
54
+<h4>Description</h4>
55
+<p>The <tt>pf_opendir()</tt> function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure.</p>
56
+</div>
57
+
58
+
59
+<div class="para">
60
+<h4>QuickInfo</h4>
61
+<p>Available when <tt>_USE_DIR == 1</tt>.</p>
62
+</div>
63
+
64
+
65
+<div class="para">
66
+<h4>References</h4>
67
+<p><tt><a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
68
+</div>
69
+
70
+<p class="foot"><a href="../00index_p.html">Return</a></p>
71
+</body>
72
+</html>

+ 73 - 0
3rdparty/petitfs-0.03/doc/pf/read.html

@@ -0,0 +1,73 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - pf_read</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>pf_read</h2>
16
+<p>The pf_read function reads data from the file.</p>
17
+<pre>
18
+FRESULT pf_read (
19
+  void* <span class="arg">buff</span>,  <span class="c">/* [OUT] Pointer to the read buffer */</span>
20
+  UINT <span class="arg">btr</span>,    <span class="c">/* [IN]  Number of bytes to read */</span>
21
+  UINT* <span class="arg">br</span>     <span class="c">/* [OUT] Number of bytes read */</span>
22
+);
23
+</pre>
24
+</div>
25
+
26
+<div class="para">
27
+<h4>Parameters</h4>
28
+<dl class="par">
29
+<dt>buff</dt>
30
+<dd>Pointer to the buffer to store the read data. A NULL specifies the destination is an outgoing stream.</dd>
31
+<dt>btr</dt>
32
+<dd>Number of bytes to read.</dd>
33
+<dt>br</dt>
34
+<dd>Pointer to the variable to return number of bytes read.</dd>
35
+</dl>
36
+</div>
37
+
38
+
39
+<div class="para">
40
+<h4>Return Values</h4>
41
+<dl class="ret">
42
+<dt>FR_OK (0)</dt>
43
+<dd>The function succeeded.</dd>
44
+<dt>FR_DISK_ERR</dt>
45
+<dd>The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.</dd>
46
+<dt>FR_NOT_OPENED</dt>
47
+<dd>The file has not been opened.</dd>
48
+<dt>FR_NOT_ENABLED</dt>
49
+<dd>The volume has not been mounted.</dd>
50
+</dl>
51
+</div>
52
+
53
+
54
+<div class="para">
55
+<h4>Description</h4>
56
+<p>The file read/write pointer in the file system object advances in number of bytes read. After the function succeeded, <tt>*br</tt> should be checked to detect end of file. In case of <tt>*br &lt; btr</tt>, it means the read pointer reached end of file during read operation.</p>
57
+<p>If a NULL is given to the <tt class="arg">buff</tt>, the read bytes will be forwarded to the outgoing stream instead of the memory. The streaming function will be typically built-in the <tt>disk_readp()</tt> function.</p>
58
+</div>
59
+
60
+<div class="para">
61
+<h4>QuickInfo</h4>
62
+<p>Available when <tt>_USE_READ == 1</tt>.</p>
63
+</div>
64
+
65
+
66
+<div class="para">
67
+<h4>References</h4>
68
+<p><tt><a href="open.html">pf_open</a>, <a href="write.html">pf_write</a>, <a href="sfatfs.html">FATFS</a></tt></p>
69
+</div>
70
+
71
+<p class="foot"><a href="../00index_p.html">Return</a></p>
72
+</body>
73
+</html>

+ 100 - 0
3rdparty/petitfs-0.03/doc/pf/readdir.html

@@ -0,0 +1,100 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - pf_readdir</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>pf_readdir</h2>
16
+<p>The pf_readdir function reads directory entries.</p>
17
+<pre>
18
+FRESULT pf_readdir (
19
+  DIR* <span class="arg">dp</span>,      <span class="c">/* [IN]  Pointer to the open directory object */</span>
20
+  FILINFO* <span class="arg">fno</span>  <span class="c">/* [OUT] Pointer to the file information structure */</span>
21
+);
22
+</pre>
23
+</div>
24
+
25
+<div class="para">
26
+<h4>Parameters</h4>
27
+<dl class="par">
28
+<dt>dp</dt>
29
+<dd>Pointer to the open directory object.</dd>
30
+<dt>fno</dt>
31
+<dd>Pointer to the file information structure to store the read item.</dd>
32
+</dl>
33
+</div>
34
+
35
+
36
+<div class="para">
37
+<h4>Return Values</h4>
38
+<dl class="ret">
39
+<dt>FR_OK (0)</dt>
40
+<dd>The function succeeded.</dd>
41
+<dt>FR_DISK_ERR</dt>
42
+<dd>The function failed due to an error in the disk function, a wrong FAT structure or an internal error.</dd>
43
+<dt>FR_NOT_OPENED</dt>
44
+<dd>The directory object has not been opened.</dd>
45
+</dl>
46
+</div>
47
+
48
+
49
+<div class="para">
50
+<h4>Description</h4>
51
+<p>The <tt>pf_readdir()</tt> function reads directory entries in sequence. All items in the directory can be read by calling this function repeatedly. When all directory entries have been read and no item to read, the function returns a null string into member <tt>f_name[]</tt> in the file information structure without error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object will be rewinded.</p>
52
+</div>
53
+
54
+
55
+<div class="para">
56
+<h4>Sample Code</h4>
57
+<pre>
58
+FRESULT scan_files (char* path)
59
+{
60
+    FRESULT res;
61
+    FILINFO fno;
62
+    DIR dir;
63
+    int i;
64
+
65
+
66
+    res = pf_opendir(&amp;dir, path);
67
+    if (res == FR_OK) {
68
+        i = strlen(path);
69
+        for (;;) {
70
+            res = pf_readdir(&amp;dir, &amp;fno);
71
+            if (res != FR_OK || fno.fname[0] == 0) break;
72
+            if (fno.fattrib &amp; AM_DIR) {
73
+                sprintf(&amp;path[i], "/%s", fno.fname);
74
+                res = scan_files(path);
75
+                if (res != FR_OK) break;
76
+                path[i] = 0;
77
+            } else {
78
+                printf("%s/%s\n", path, fno.fname);
79
+            }
80
+        }
81
+    }
82
+
83
+    return res;
84
+}
85
+</pre>
86
+</div>
87
+
88
+<div class="para">
89
+<h4>QuickInfo</h4>
90
+<p>Available when <tt>_USE_DIR == 1</tt>.</p>
91
+</div>
92
+
93
+<div class="para">
94
+<h4>References</h4>
95
+<p><tt><a href="opendir.html">pf_opendir</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
96
+</div>
97
+
98
+<p class="foot"><a href="../00index_p.html">Return</a></p>
99
+</body>
100
+</html>

+ 30 - 0
3rdparty/petitfs-0.03/doc/pf/sdir.html

@@ -0,0 +1,30 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - DIR</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>DIR</h2>
16
+<p>The <tt>DIR</tt> structure is used for the work area to read a directory by pf_oepndir, pf_readdir function.</p>
17
+<pre>
18
+typedef struct {
19
+    WORD    index;     <span class="c">/* Current read/write index number */</span>
20
+    BYTE*   fn;        <span class="c">/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */</span>
21
+    CLUST   sclust;    <span class="c">/* Table start cluster (0:Static table) */</span>
22
+    CLUST   clust;     <span class="c">/* Current cluster */</span>
23
+    DWORD   sect;      <span class="c">/* Current sector */</span>
24
+} DIR;
25
+</pre>
26
+</div>
27
+
28
+<p class="foot"><a href="../00index_p.html">Return</a></p>
29
+</body>
30
+</html>

+ 39 - 0
3rdparty/petitfs-0.03/doc/pf/sfatfs.html

@@ -0,0 +1,39 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - FATFS</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>FATFS</h2>
16
+<p>The <tt>FATFS</tt> structure holds dynamic work area of the logical drive and a file. It is given by application program and registerd/unregisterd to the Petit FatFs module with pf_mount function. There is no member that can be changed by application programs.</p>
17
+<pre>
18
+typedef struct {
19
+    BYTE    fs_type;     <span class="c">/* FAT sub type */</span>
20
+    BYTE    csize;       <span class="c">/* Number of sectors per cluster */</span>
21
+    BYTE    flag;        <span class="c">/* File status flags */</span>
22
+    BYTE    pad1;
23
+    WORD    n_rootdir;   <span class="c">/* Number of root directory entries (0 on FAT32) */</span>
24
+    CLUST   n_fatent;    <span class="c">/* Number of FAT entries (= number of clusters + 2) */</span>
25
+    DWORD   fatbase;     <span class="c">/* FAT start sector */</span>
26
+    DWORD   dirbase;     <span class="c">/* Root directory start sector (Cluster# on FAT32) */</span>
27
+    DWORD   database;    <span class="c">/* Data start sector */</span>
28
+    DWORD   fptr;        <span class="c">/* File read/write pointer */</span>
29
+    DWORD   fsize;       <span class="c">/* File size */</span>
30
+    CLUST   org_clust;   <span class="c">/* File start cluster */</span>
31
+    CLUST   curr_clust;  <span class="c">/* File current cluster */</span>
32
+    DWORD   dsect;       <span class="c">/* File current data sector */</span>
33
+} FATFS;
34
+</pre>
35
+</div>
36
+
37
+<p class="foot"><a href="../00index_p.html">Return</a></p>
38
+</body>
39
+</html>

+ 62 - 0
3rdparty/petitfs-0.03/doc/pf/sfileinfo.html

@@ -0,0 +1,62 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - FILINFO</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>FILINFO</h2>
16
+<p>The <tt>FILINFO</tt> structure holds a file information returned by pf_readdir function.</p>
17
+<pre>
18
+typedef struct {
19
+    DWORD   fsize;        <span class="c">/* File size */</span>
20
+    WORD    fdate;        <span class="c">/* Last modified date */</span>
21
+    WORD    ftime;        <span class="c">/* Last modified time */</span>
22
+    BYTE    fattrib;      <span class="c">/* Attribute */</span>
23
+    char    fname[13];    <span class="c">/* File name */</span>
24
+} FILINFO;
25
+</pre>
26
+</div>
27
+
28
+<h4>Members</h4>
29
+<dl>
30
+<dt>fsize</dt>
31
+<dd>Indicates size of the file in unit of byte. This is always zero when it is a directory.</dd>
32
+<dt>fdate</dt>
33
+<dd>Indicates the date that the file was modified or the directory was created.<br>
34
+<dl>
35
+<dt>bit15:9</dt>
36
+<dd>Year origin from 1980 (0..127)</dd>
37
+<dt>bit8:5</dt>
38
+<dd>Month (1..12)</dd>
39
+<dt>bit4:0</dt>
40
+<dd>Day (1..31)</dd>
41
+</dl>
42
+</dd>
43
+<dt>ftime</dt>
44
+<dd>Indicates the time that the file was modified or the directory was created.<br>
45
+<dl>
46
+<dt>bit15:11</dt>
47
+<dd>Hour (0..23)</dd>
48
+<dt>bit10:5</dt>
49
+<dd>Minute (0..59)</dd>
50
+<dt>bit4:0</dt>
51
+<dd>Second / 2 (0..29)</dd>
52
+</dl>
53
+</dd>
54
+<dt>fattrib</dt>
55
+<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>
56
+<dt>fname[]</dt>
57
+<dd>Indicates the file/directory name in 8.3 format null-terminated string.</dd>
58
+</dl>
59
+
60
+<p class="foot"><a href="../00index_p.html">Return</a></p>
61
+</body>
62
+</html>

+ 86 - 0
3rdparty/petitfs-0.03/doc/pf/write.html

@@ -0,0 +1,86 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html lang="en">
3
+<head>
4
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+<meta http-equiv="Content-Style-Type" content="text/css">
6
+<link rel="up" title="Petit FatFs" href="../00index_p.html">
7
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
8
+<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
9
+<title>Petit FatFs - pf_write</title>
10
+</head>
11
+
12
+<body>
13
+
14
+<div class="para">
15
+<h2>pf_write</h2>
16
+<p>The pf_write function writes data to the file.</p>
17
+<pre>
18
+FRESULT pf_write (
19
+  const void* <span class="arg">buff</span>, <span class="c">/* [IN]  Pointer to the data to be written */</span>
20
+  UINT <span class="arg">btw</span>,         <span class="c">/* [IN]  Number of bytes to write */</span>
21
+  UINT* <span class="arg">bw</span>          <span class="c">/* [OUT] Pointer to the variable to return number of bytes written */</span>
22
+);
23
+</pre>
24
+</div>
25
+
26
+<div class="para">
27
+<h4>Parameters</h4>
28
+<dl class="par">
29
+<dt>buff</dt>
30
+<dd>Pointer to the data to be wtitten. A NULL specifies to finalize the current write operation.</dd>
31
+<dt>btw</dt>
32
+<dd>Number of bytes to write.</dd>
33
+<dt>bw</dt>
34
+<dd>Pointer to the variable to return number of bytes read.</dd>
35
+</dl>
36
+</div>
37
+
38
+
39
+<div class="para">
40
+<h4>Return Values</h4>
41
+<dl class="ret">
42
+<dt>FR_OK (0)</dt>
43
+<dd>The function succeeded.</dd>
44
+<dt>FR_DISK_ERR</dt>
45
+<dd>The function failed due to a hard error in the disk function, write protected, a wrong FAT structure or an internal error.</dd>
46
+<dt>FR_NOT_OPENED</dt>
47
+<dd>The file has not been opened.</dd>
48
+<dt>FR_NOT_ENABLED</dt>
49
+<dd>The volume has not been mounted.</dd>
50
+</dl>
51
+</div>
52
+
53
+
54
+<div class="para">
55
+<h4>Description</h4>
56
+<p>The write function has some restrictions listed below:</p>
57
+<ul>
58
+<li>Cannot create file. Only existing file can be written.</li>
59
+<li>Cannot expand file size.</li>
60
+<li>Cannot update time stamp of the file.</li>
61
+<li>Write operation can start/stop on the sector boundary.</li>
62
+<li>Read-only attribute of the file cannot block write operation.</li>
63
+</ul>
64
+<p>File write operation must be done in following sequence.</p>
65
+<ol>
66
+<li><tt>pf_lseek(ofs);</tt> read/write pointer must be moved to sector bundary prior to initiate write operation or it will be rounded-down to the sector boundary.</li>
67
+<li><tt>pf_write(buff, btw, &amp;bw);</tt> Initiate write operation. Write first data to the file.</li>
68
+<li><tt>pf_write(buff, btw, &amp;bw);</tt> Write next data. Any other file function cannot be used while a write operation is in progress.</li>
69
+<li><tt>pf_write(0, 0, &amp;bw);</tt> Finalize the write operation. If read/write pointer is not on the sector boundary, left bytes in the sector will be filled with zero.</li>
70
+</ol>
71
+<p>The read/write pointer in the file system object advances in number of bytes written. After the function succeeded, <tt>*bw</tt> should be checked to detect end of file. In case of <tt>*bw &lt; btw</tt>, it means the read/write pointer reached end of file during the write operation. Once a write operation is initiated, it must be finalized or the written data can be lost.</p>
72
+</div>
73
+
74
+<div class="para">
75
+<h4>QuickInfo</h4>
76
+<p>Available when <tt>_USE_WRITE == 1</tt>.</p>
77
+</div>
78
+
79
+<div class="para">
80
+<h4>References</h4>
81
+<p><tt><a href="open.html">pf_open</a>, <a href="sfatfs.html">FATFS</a></tt></p>
82
+</div>
83
+
84
+<p class="foot"><a href="../00index_p.html">Return</a></p>
85
+</body>
86
+</html>

+ 46 - 0
3rdparty/petitfs-0.03/src/00readme.txt

@@ -0,0 +1,46 @@
1
+Petit FatFs Module Source Files R0.03                (C)ChaN, 2014
2
+
3
+
4
+FILES
5
+
6
+  pff.h      Common include file for Petit FatFs and application module.
7
+  pff.c      Petit FatFs module.
8
+  diskio.h   Common include file for Petit FatFs and disk I/O module.
9
+  diskio.c   Skeleton of low level disk I/O module.
10
+  integer.h  Alternative type definitions for integer variables.
11
+
12
+  Low level disk I/O module is not included in this archive because the Petit
13
+  FatFs module is only a generic file system layer and not depend on any
14
+  specific storage device. You have to provide a low level disk I/O module that
15
+  written to control your storage device.
16
+
17
+
18
+
19
+AGREEMENTS
20
+
21
+ Petit FatFs module is an open source software to implement FAT file system to
22
+ small embedded systems. This is a free software and is opened for education,
23
+ research and commercial developments under license policy of following trems.
24
+
25
+  Copyright (C) 2014, ChaN, all right reserved.
26
+
27
+ * The Petit FatFs module is a free software and there is NO WARRANTY.
28
+ * No restriction on use. You can use, modify and redistribute it for
29
+   personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.
30
+ * Redistributions of source code must retain the above copyright notice.
31
+
32
+
33
+
34
+REVISION HISTORY
35
+
36
+  Jun 15, 2009  R0.01a  First release (Branched from FatFs R0.07b)
37
+
38
+  Dec 14, 2009  R0.02   Added multiple code page support.
39
+                        Added write funciton.
40
+                        Changed stream read mode interface.
41
+  Dec 07,'2010  R0.02a  Added some configuration options.
42
+                        Fixed fails to open objects with DBCS character.
43
+
44
+  Jun 10, 2014  R0.03   Separated out configuration options to pffconf.h.
45
+                        Added _USE_LCC option.
46
+                        Added _FS_FAT16 option.

+ 73 - 0
3rdparty/petitfs-0.03/src/diskio.c

@@ -0,0 +1,73 @@
1
+/*-----------------------------------------------------------------------*/
2
+/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2014      */
3
+/*-----------------------------------------------------------------------*/
4
+
5
+#include "diskio.h"
6
+
7
+
8
+/*-----------------------------------------------------------------------*/
9
+/* Initialize Disk Drive                                                 */
10
+/*-----------------------------------------------------------------------*/
11
+
12
+DSTATUS disk_initialize (void)
13
+{
14
+	DSTATUS stat;
15
+
16
+	// Put your code here
17
+
18
+	return stat;
19
+}
20
+
21
+
22
+
23
+/*-----------------------------------------------------------------------*/
24
+/* Read Partial Sector                                                   */
25
+/*-----------------------------------------------------------------------*/
26
+
27
+DRESULT disk_readp (
28
+	BYTE* buff,		/* Pointer to the destination object */
29
+	DWORD sector,	/* Sector number (LBA) */
30
+	UINT offset,	/* Offset in the sector */
31
+	UINT count		/* Byte count (bit15:destination) */
32
+)
33
+{
34
+	DRESULT res;
35
+
36
+	// Put your code here
37
+
38
+	return res;
39
+}
40
+
41
+
42
+
43
+/*-----------------------------------------------------------------------*/
44
+/* Write Partial Sector                                                  */
45
+/*-----------------------------------------------------------------------*/
46
+
47
+DRESULT disk_writep (
48
+	BYTE* buff,		/* Pointer to the data to be written, NULL:Initiate/Finalize write operation */
49
+	DWORD sc		/* Sector number (LBA) or Number of bytes to send */
50
+)
51
+{
52
+	DRESULT res;
53
+
54
+
55
+	if (!buff) {
56
+		if (sc) {
57
+
58
+			// Initiate write process
59
+
60
+		} else {
61
+
62
+			// Finalize write process
63
+
64
+		}
65
+	} else {
66
+
67
+		// Send data to the disk
68
+
69
+	}
70
+
71
+	return res;
72
+}
73
+

+ 42 - 0
3rdparty/petitfs-0.03/src/diskio.h

@@ -0,0 +1,42 @@
1
+/*-----------------------------------------------------------------------
2
+/  PFF - Low level disk interface modlue include file    (C)ChaN, 2014
3
+/-----------------------------------------------------------------------*/
4
+
5
+#ifndef _DISKIO_DEFINED
6
+#define _DISKIO_DEFINED
7
+
8
+#ifdef __cplusplus
9
+extern "C" {
10
+#endif
11
+
12
+#include "integer.h"
13
+
14
+
15
+/* Status of Disk Functions */
16
+typedef BYTE	DSTATUS;
17
+
18
+
19
+/* Results of Disk Functions */
20
+typedef enum {
21
+	RES_OK = 0,		/* 0: Function succeeded */
22
+	RES_ERROR,		/* 1: Disk error */
23
+	RES_NOTRDY,		/* 2: Not ready */
24
+	RES_PARERR		/* 3: Invalid parameter */
25
+} DRESULT;
26
+
27
+
28
+/*---------------------------------------*/
29
+/* Prototypes for disk control functions */
30
+
31
+DSTATUS disk_initialize (void);
32
+DRESULT disk_readp (BYTE* buff, DWORD sector, UINT offser, UINT count);
33
+DRESULT disk_writep (const BYTE* buff, DWORD sc);
34
+
35
+#define STA_NOINIT		0x01	/* Drive not initialized */
36
+#define STA_NODISK		0x02	/* No medium in the drive */
37
+
38
+#ifdef __cplusplus
39
+}
40
+#endif
41
+
42
+#endif	/* _DISKIO_DEFINED */

+ 33 - 0
3rdparty/petitfs-0.03/src/integer.h

@@ -0,0 +1,33 @@
1
+/*-------------------------------------------*/
2
+/* Integer type definitions for FatFs module */
3
+/*-------------------------------------------*/
4
+
5
+#ifndef _FF_INTEGER
6
+#define _FF_INTEGER
7
+
8
+#ifdef _WIN32	/* FatFs development platform */
9
+
10
+#include <windows.h>
11
+#include <tchar.h>
12
+
13
+#else			/* Embedded platform */
14
+
15
+/* This type MUST be 8 bit */
16
+typedef unsigned char	BYTE;
17
+
18
+/* These types MUST be 16 bit */
19
+typedef short			SHORT;
20
+typedef unsigned short	WORD;
21
+typedef unsigned short	WCHAR;
22
+
23
+/* These types MUST be 16 bit or 32 bit */
24
+typedef int				INT;
25
+typedef unsigned int	UINT;
26
+
27
+/* These types MUST be 32 bit */
28
+typedef long			LONG;
29
+typedef unsigned long	DWORD;
30
+
31
+#endif
32
+
33
+#endif

File diff suppressed because it is too large
+ 1108 - 0
3rdparty/petitfs-0.03/src/pff.c


+ 159 - 0
3rdparty/petitfs-0.03/src/pff.h

@@ -0,0 +1,159 @@
1
+/*---------------------------------------------------------------------------/
2
+/  Petit FatFs - FAT file system module include file  R0.03   (C)ChaN, 2014
3
+/----------------------------------------------------------------------------/
4
+/ Petit FatFs module is an open source software to implement FAT file system to
5
+/ small embedded systems. This is a free software and is opened for education,
6
+/ research and commercial developments under license policy of following trems.
7
+/
8
+/  Copyright (C) 2014, ChaN, all right reserved.
9
+/
10
+/ * The Petit FatFs module is a free software and there is NO WARRANTY.
11
+/ * No restriction on use. You can use, modify and redistribute it for
12
+/   personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.
13
+/ * Redistributions of source code must retain the above copyright notice.
14
+/
15
+/----------------------------------------------------------------------------*/
16
+
17
+#ifndef _PFATFS
18
+#define _PFATFS	4004	/* Revision ID */
19
+
20
+#ifdef __cplusplus
21
+extern "C" {
22
+#endif
23
+
24
+#include "integer.h"
25
+#include "pffconf.h"
26
+
27
+#if _PFATFS != _PFFCONF
28
+#error Wrong configuration file (pffconf.h).
29
+#endif
30
+
31
+#if _FS_FAT32
32
+#define	CLUST	DWORD
33
+#else
34
+#define	CLUST	WORD
35
+#endif
36
+
37
+
38
+/* File system object structure */
39
+
40
+typedef struct {
41
+	BYTE	fs_type;	/* FAT sub type */
42
+	BYTE	flag;		/* File status flags */
43
+	BYTE	csize;		/* Number of sectors per cluster */
44
+	BYTE	pad1;
45
+	WORD	n_rootdir;	/* Number of root directory entries (0 on FAT32) */
46
+	CLUST	n_fatent;	/* Number of FAT entries (= number of clusters + 2) */
47
+	DWORD	fatbase;	/* FAT start sector */
48
+	DWORD	dirbase;	/* Root directory start sector (Cluster# on FAT32) */
49
+	DWORD	database;	/* Data start sector */
50
+	DWORD	fptr;		/* File R/W pointer */
51
+	DWORD	fsize;		/* File size */
52
+	CLUST	org_clust;	/* File start cluster */
53
+	CLUST	curr_clust;	/* File current cluster */
54
+	DWORD	dsect;		/* File current data sector */
55
+} FATFS;
56
+
57
+
58
+
59
+/* Directory object structure */
60
+
61
+typedef struct {
62
+	WORD	index;		/* Current read/write index number */
63
+	BYTE*	fn;			/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
64
+	CLUST	sclust;		/* Table start cluster (0:Static table) */
65
+	CLUST	clust;		/* Current cluster */
66
+	DWORD	sect;		/* Current sector */
67
+} DIR;
68
+
69
+
70
+
71
+/* File status structure */
72
+
73
+typedef struct {
74
+	DWORD	fsize;		/* File size */
75
+	WORD	fdate;		/* Last modified date */
76
+	WORD	ftime;		/* Last modified time */
77
+	BYTE	fattrib;	/* Attribute */
78
+	char	fname[13];	/* File name */
79
+} FILINFO;
80
+
81
+
82
+
83
+/* File function return code (FRESULT) */
84
+
85
+typedef enum {
86
+	FR_OK = 0,			/* 0 */
87
+	FR_DISK_ERR,		/* 1 */
88
+	FR_NOT_READY,		/* 2 */
89
+	FR_NO_FILE,			/* 3 */
90
+	FR_NOT_OPENED,		/* 4 */
91
+	FR_NOT_ENABLED,		/* 5 */
92
+	FR_NO_FILESYSTEM	/* 6 */
93
+} FRESULT;
94
+
95
+
96
+
97
+/*--------------------------------------------------------------*/
98
+/* Petit FatFs module application interface                     */
99
+
100
+FRESULT pf_mount (FATFS* fs);								/* Mount/Unmount a logical drive */
101
+FRESULT pf_open (const char* path);							/* Open a file */
102
+FRESULT pf_read (void* buff, UINT btr, UINT* br);			/* Read data from the open file */
103
+FRESULT pf_write (const void* buff, UINT btw, UINT* bw);	/* Write data to the open file */
104
+FRESULT pf_lseek (DWORD ofs);								/* Move file pointer of the open file */
105
+FRESULT pf_opendir (DIR* dj, const char* path);				/* Open a directory */
106
+FRESULT pf_readdir (DIR* dj, FILINFO* fno);					/* Read a directory item from the open directory */
107
+
108
+
109
+
110
+/*--------------------------------------------------------------*/
111
+/* Flags and offset address                                     */
112
+
113
+/* File status flag (FATFS.flag) */
114
+
115
+#define	FA_OPENED	0x01
116
+#define	FA_WPRT		0x02
117
+#define	FA__WIP		0x40
118
+
119
+
120
+/* FAT sub type (FATFS.fs_type) */
121
+
122
+#define FS_FAT12	1
123
+#define FS_FAT16	2
124
+#define FS_FAT32	3
125
+
126
+
127
+/* File attribute bits for directory entry */
128
+
129
+#define	AM_RDO	0x01	/* Read only */
130
+#define	AM_HID	0x02	/* Hidden */
131
+#define	AM_SYS	0x04	/* System */
132
+#define	AM_VOL	0x08	/* Volume label */
133
+#define AM_LFN	0x0F	/* LFN entry */
134
+#define AM_DIR	0x10	/* Directory */
135
+#define AM_ARC	0x20	/* Archive */
136
+#define AM_MASK	0x3F	/* Mask of defined bits */
137
+
138
+
139
+/*--------------------------------*/
140
+/* Multi-byte word access macros  */
141
+
142
+#if _WORD_ACCESS == 1	/* Enable word access to the FAT structure */
143
+#define	LD_WORD(ptr)		(WORD)(*(WORD*)(BYTE*)(ptr))
144
+#define	LD_DWORD(ptr)		(DWORD)(*(DWORD*)(BYTE*)(ptr))
145
+#define	ST_WORD(ptr,val)	*(WORD*)(BYTE*)(ptr)=(WORD)(val)
146
+#define	ST_DWORD(ptr,val)	*(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
147
+#else					/* Use byte-by-byte access to the FAT structure */
148
+#define	LD_WORD(ptr)		(WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
149
+#define	LD_DWORD(ptr)		(DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
150
+#define	ST_WORD(ptr,val)	*(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
151
+#define	ST_DWORD(ptr,val)	*(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
152
+#endif
153
+
154
+
155
+#ifdef __cplusplus
156
+}
157
+#endif
158
+
159
+#endif /* _PFATFS */

+ 89 - 0
3rdparty/petitfs-0.03/src/pffconf.h

@@ -0,0 +1,89 @@
1
+/*---------------------------------------------------------------------------/
2
+/  Petit FatFs - Configuration file  R0.03 (C)ChaN, 2014
3
+/---------------------------------------------------------------------------*/
4
+
5
+#ifndef _PFFCONF
6
+#define _PFFCONF 4004	/* Revision ID */
7
+
8
+/*---------------------------------------------------------------------------/
9
+/ Function Configurations
10
+/---------------------------------------------------------------------------*/
11
+
12
+#define	_USE_READ	1	/* Enable pf_read() function */
13
+#define	_USE_DIR	0	/* Enable pf_opendir() and pf_readdir() function */
14
+#define	_USE_LSEEK	0	/* Enable pf_lseek() function */
15
+#define	_USE_WRITE	0	/* Enable pf_write() function */
16
+
17
+#define _FS_FAT12	0	/* Enable FAT12 */
18
+#define _FS_FAT16	1	/* Enable FAT16 */
19
+#define _FS_FAT32	0	/* Enable FAT32 */
20
+
21
+
22
+/*---------------------------------------------------------------------------/
23
+/ Locale and Namespace Configurations
24
+/---------------------------------------------------------------------------*/
25
+
26
+#define _USE_LCC	0	/* Allow lower case characters for path name */
27
+
28
+#define	_CODE_PAGE	437
29
+/* The _CODE_PAGE specifies the code page to be used on the target system.
30
+/  SBCS code pages with _USE_LCC == 1 requiers a 128 byte of case conversion
31
+/  table. This might occupy RAM on some platforms, e.g. avr-gcc.
32
+/  When _USE_LCC == 0, _CODE_PAGE has no effect.
33
+/
34
+/   932  - Japanese Shift_JIS (DBCS, OEM, Windows)
35
+/   936  - Simplified Chinese GBK (DBCS, OEM, Windows)
36
+/   949  - Korean (DBCS, OEM, Windows)
37
+/   950  - Traditional Chinese Big5 (DBCS, OEM, Windows)
38
+/   1250 - Central Europe (Windows)
39
+/   1251 - Cyrillic (Windows)
40
+/   1252 - Latin 1 (Windows)
41
+/   1253 - Greek (Windows)
42
+/   1254 - Turkish (Windows)
43
+/   1255 - Hebrew (Windows)
44
+/   1256 - Arabic (Windows)
45
+/   1257 - Baltic (Windows)
46
+/   1258 - Vietnam (OEM, Windows)
47
+/   437  - U.S. (OEM)
48
+/   720  - Arabic (OEM)
49
+/   737  - Greek (OEM)
50
+/   775  - Baltic (OEM)
51
+/   850  - Multilingual Latin 1 (OEM)
52
+/   858  - Multilingual Latin 1 + Euro (OEM)
53
+/   852  - Latin 2 (OEM)
54
+/   855  - Cyrillic (OEM)
55
+/   866  - Russian (OEM)
56
+/   857  - Turkish (OEM)
57
+/   862  - Hebrew (OEM)
58
+/   874  - Thai (OEM, Windows)
59
+*/
60
+
61
+
62
+/*---------------------------------------------------------------------------/
63
+/ System Configurations
64
+/---------------------------------------------------------------------------*/
65
+
66
+#define _WORD_ACCESS	0
67
+/* The _WORD_ACCESS option is an only platform dependent option. It defines
68
+/  which access method is used to the word data on the FAT volume.
69
+/
70
+/   0: Byte-by-byte access. Always compatible with all platforms.
71
+/   1: Word access. Do not choose this unless under both the following conditions.
72
+/
73
+/  * Address misaligned memory access is always allowed for ALL instructions.
74
+/  * Byte order on the memory is little-endian.
75
+/
76
+/  If it is the case, _WORD_ACCESS can also be set to 1 to improve performance and
77
+/  reduce code size. Following table shows an example of some processor types.
78
+/
79
+/   ARM7TDMI    0           ColdFire    0           V850E       0
80
+/   Cortex-M3   0           Z80         0/1         V850ES      0/1
81
+/   Cortex-M0   0           RX600(LE)   0/1         TLCS-870    0/1
82
+/   AVR         0/1         RX600(BE)   0           TLCS-900    0/1
83
+/   AVR32       0           RL78        0           R32C        0
84
+/   PIC18       0/1         SH-2        0           M16C        0/1
85
+/   PIC24       0           H8S         0           MSP430      0
86
+/   PIC32       0           H8/300H     0           x86         0/1
87
+*/
88
+
89
+#endif /* _PFFCONF */

+ 1 - 0
docs/releases.txt

@@ -24,6 +24,7 @@ FEATURE:	Added optional transparency to container
24 24
 FEATURE:	Prevent mouse events going to obscured widgets
25 25
 FEATURE:	Add GFILE support for file lists
26 26
 FEATURE:	Add GFILE support for C strings as files
27
+FEATURE:	Add GFILE support for PetitFS
27 28
 
28 29
 
29 30
 *** Release 2.1 ***

+ 89 - 0
pffconf.h

@@ -0,0 +1,89 @@
1
+/*---------------------------------------------------------------------------/
2
+/  Petit FatFs - Configuration file  R0.03 (C)ChaN, 2014
3
+/---------------------------------------------------------------------------*/
4
+
5
+#ifndef _PFFCONF
6
+#define _PFFCONF 4004	/* Revision ID */
7
+
8
+/*---------------------------------------------------------------------------/
9
+/ Function Configurations
10
+/---------------------------------------------------------------------------*/
11
+
12
+#define	_USE_READ	1	/* Enable pf_read() function */
13
+#define	_USE_DIR	GFILE_NEED_FILELISTS	/* Enable pf_opendir() and pf_readdir() function */
14
+#define	_USE_LSEEK	1	/* Enable pf_lseek() function */
15
+#define	_USE_WRITE	0	/* Enable pf_write() function */
16
+
17
+#define _FS_FAT12	0	/* Enable FAT12 */
18
+#define _FS_FAT16	1	/* Enable FAT16 */
19
+#define _FS_FAT32	1	/* Enable FAT32 */
20
+
21
+
22
+/*---------------------------------------------------------------------------/
23
+/ Locale and Namespace Configurations
24
+/---------------------------------------------------------------------------*/
25
+
26
+#define _USE_LCC	0	/* Allow lower case characters for path name */
27
+
28
+#define	_CODE_PAGE	437
29
+/* The _CODE_PAGE specifies the code page to be used on the target system.
30
+/  SBCS code pages with _USE_LCC == 1 requiers a 128 byte of case conversion
31
+/  table. This might occupy RAM on some platforms, e.g. avr-gcc.
32
+/  When _USE_LCC == 0, _CODE_PAGE has no effect.
33
+/
34
+/   932  - Japanese Shift_JIS (DBCS, OEM, Windows)
35
+/   936  - Simplified Chinese GBK (DBCS, OEM, Windows)
36
+/   949  - Korean (DBCS, OEM, Windows)
37
+/   950  - Traditional Chinese Big5 (DBCS, OEM, Windows)
38
+/   1250 - Central Europe (Windows)
39
+/   1251 - Cyrillic (Windows)
40
+/   1252 - Latin 1 (Windows)
41
+/   1253 - Greek (Windows)
42
+/   1254 - Turkish (Windows)
43
+/   1255 - Hebrew (Windows)
44
+/   1256 - Arabic (Windows)
45
+/   1257 - Baltic (Windows)
46
+/   1258 - Vietnam (OEM, Windows)
47
+/   437  - U.S. (OEM)
48
+/   720  - Arabic (OEM)
49
+/   737  - Greek (OEM)
50
+/   775  - Baltic (OEM)
51
+/   850  - Multilingual Latin 1 (OEM)
52
+/   858  - Multilingual Latin 1 + Euro (OEM)
53
+/   852  - Latin 2 (OEM)
54
+/   855  - Cyrillic (OEM)
55
+/   866  - Russian (OEM)
56
+/   857  - Turkish (OEM)
57
+/   862  - Hebrew (OEM)
58
+/   874  - Thai (OEM, Windows)
59
+*/
60
+
61
+
62
+/*---------------------------------------------------------------------------/
63
+/ System Configurations
64
+/---------------------------------------------------------------------------*/
65
+
66
+#define _WORD_ACCESS	0
67
+/* The _WORD_ACCESS option is an only platform dependent option. It defines
68
+/  which access method is used to the word data on the FAT volume.
69
+/
70
+/   0: Byte-by-byte access. Always compatible with all platforms.
71
+/   1: Word access. Do not choose this unless under both the following conditions.
72
+/
73
+/  * Address misaligned memory access is always allowed for ALL instructions.
74
+/  * Byte order on the memory is little-endian.
75
+/
76
+/  If it is the case, _WORD_ACCESS can also be set to 1 to improve performance and
77
+/  reduce code size. Following table shows an example of some processor types.
78
+/
79
+/   ARM7TDMI    0           ColdFire    0           V850E       0
80
+/   Cortex-M3   0           Z80         0/1         V850ES      0/1
81
+/   Cortex-M0   0           RX600(LE)   0/1         TLCS-870    0/1
82
+/   AVR         0/1         RX600(BE)   0           TLCS-900    0/1
83
+/   AVR32       0           RL78        0           R32C        0
84
+/   PIC18       0/1         SH-2        0           M16C        0/1
85
+/   PIC24       0           H8S         0           MSP430      0
86
+/   PIC32       0           H8/300H     0           x86         0/1
87
+*/
88
+
89
+#endif /* _PFFCONF */

+ 157 - 0
src/gfile/inc_petitfs.c

@@ -0,0 +1,157 @@
1
+/*
2
+ * This file is subject to the terms of the GFX License. If a copy of
3
+ * the license was not distributed with this file, you can obtain one at:
4
+ *
5
+ *              http://ugfx.org/license.html
6
+ */
7
+
8
+/********************************************************
9
+ * The PETITFS file-system
10
+ ********************************************************/
11
+
12
+#include "gfx.h"
13
+
14
+#if GFX_USE_GFILE && GFILE_NEED_PETITFS
15
+
16
+#include "gfile_fs.h"
17
+#include "petitfs_wrapper.h"
18
+
19
+static bool_t petitfsExists(const char* fname);
20
+static bool_t petitfsOpen(GFILE* f, const char* fname);
21
+static int petitfsRead(GFILE* f, void* buf, int size);
22
+static bool_t petitfsSetPos(GFILE* f, long int pos);
23
+#if GFILE_NEED_FILELISTS && _FS_MINIMIZE <= 1
24
+	static gfileList *petitfsFlOpen(const char *path, bool_t dirs);
25
+	static const char *petitfsFlRead(gfileList *pfl);
26
+	static void petitfsFlClose(gfileList *pfl);
27
+#endif
28
+
29
+const GFILEVMT FsPetitFSVMT = {
30
+	GFSFLG_WRITEABLE | GFSFLG_SEEKABLE,
31
+	'F',
32
+	0,
33
+	petitfsExists,
34
+	0,					// No Filesize
35
+	0,
36
+	petitfsOpen,
37
+	0,					// No Close
38
+	petitfsRead,
39
+	0,					// No Write
40
+	petitfsSetPos,
41
+	0,					// No Getsize
42
+	0,					// No EOF
43
+	0, 0, 0,			// No Mount, UnMount or Sync
44
+	#if GFILE_NEED_FILELISTS
45
+		#if _USE_DIR
46
+			petitfsFlOpen, petitfsFlRead, petitfsFlClose
47
+		#else
48
+			0, 0, 0
49
+		#endif
50
+	#endif
51
+};
52
+
53
+// Our directory list structure
54
+typedef struct petitfsList {
55
+	gfileList	fl;					// This must be the first element.
56
+	DIR			dir;
57
+	FILINFO		fno;
58
+} petitfsList;
59
+
60
+// optimize these later on. Use an array to have multiple
61
+static bool_t petitfs_mounted = FALSE;
62
+static FATFS petitfs_fs;
63
+
64
+static bool_t petitfsExists(const char* fname)
65
+{
66
+	// Mount first
67
+	if (!petitfs_mounted && pf_mount(&petitfs_fs) != FR_OK)
68
+		return FALSE;
69
+
70
+	// Open
71
+	if (pf_open(fname) != FR_OK)
72
+		return FALSE;
73
+
74
+	return TRUE;
75
+}
76
+
77
+static bool_t petitfsOpen(GFILE* f, const char* fname)
78
+{
79
+	// No writing
80
+	if ((f->flags & GFILEFLG_WRITE))
81
+		return FALSE;
82
+
83
+	// Mount first
84
+	if (!petitfs_mounted && pf_mount(&petitfs_fs) != FR_OK)
85
+		return FALSE;
86
+
87
+	// Open
88
+	if (pf_open(fname) != FR_OK)
89
+		return FALSE;
90
+
91
+	f->obj = &petitfs_fs;
92
+	return TRUE;	
93
+}
94
+
95
+static int petitfsRead(GFILE* f, void* buf, int size)
96
+{
97
+	int		br;
98
+	(void)	f;
99
+
100
+	if (pf_read(buf, size, (UINT*)&br) != FR_OK)
101
+		return 0;
102
+
103
+	return br;
104
+}
105
+
106
+static bool_t petitfsSetPos(GFILE* f, long int pos)
107
+{
108
+	(void)	f;
109
+	return pf_lseek((DWORD)pos) == FR_OK;
110
+}
111
+
112
+#if GFILE_NEED_FILELISTS
113
+	static gfileList *petitfsFlOpen(const char *path, bool_t dirs) {
114
+		petitfsList	*p;
115
+		(void) dirs;
116
+
117
+		if (!(p = gfxAlloc(sizeof(petitfsList))))
118
+			return 0;
119
+
120
+		if (pf_opendir(&p->dir, path) != FR_OK) {
121
+			gfxFree(p);
122
+			return 0;
123
+		}
124
+		return &p->fl;
125
+	}
126
+
127
+	static const char *petitfsFlRead(gfileList *pfl) {
128
+		#define ffl		((petitfsList *)pfl)
129
+
130
+		while(1) {
131
+			// Read the next entry
132
+			if (pf_readdir(&ffl->dir, &ffl->fno) != FR_OK || !ffl->fno.fname[0])
133
+				return 0;
134
+
135
+			/* Ignore dot entries */
136
+			if (ffl->fno.fname[0] == '.') continue;
137
+
138
+			/* Is it a directory */
139
+			if (ffl->fl.dirs) {
140
+				if ((ffl->fno.fattrib & AM_DIR))
141
+					break;
142
+			} else {
143
+				if (!(ffl->fno.fattrib & (AM_DIR|AM_HID|AM_SYS)))
144
+					break;
145
+			}
146
+		}
147
+
148
+		return ffl->fno.fname;
149
+	}
150
+
151
+	static void petitfsFlClose(gfileList *pfl) {
152
+		gfxFree(pfl);
153
+	}
154
+
155
+#endif
156
+
157
+#endif //GFX_USE_GFILE && GFILE_NEED_PETITFS

+ 82 - 0
src/gfile/petitfs_chibios_diskio.c

@@ -0,0 +1,82 @@
1
+/*-----------------------------------------------------------------------*/
2
+/* Low level disk I/O module skeleton for FatFs     (C)ChaN, 2007        */
3
+/*-----------------------------------------------------------------------*/
4
+/* This is a stub disk I/O module that acts as front end of the existing */
5
+/* disk I/O modules and attach it to FatFs module with common interface. */
6
+/*-----------------------------------------------------------------------*/
7
+
8
+#include "gfx.h"
9
+
10
+#if GFX_USE_GFILE && GFILE_NEED_PETITFS && GFX_USE_OS_CHIBIOS
11
+
12
+#include "petitfs_wrapper.h"
13
+
14
+#include <string.h>
15
+
16
+#if HAL_USE_MMC_SPI && HAL_USE_SDC
17
+#error "cannot specify both MMC_SPI and SDC drivers"
18
+#endif
19
+
20
+#if HAL_USE_MMC_SPI
21
+extern MMCDriver MMCD1;
22
+#elif HAL_USE_SDC
23
+extern SDCDriver SDCD1;
24
+#else
25
+#error "MMC_SPI or SDC driver must be specified"
26
+#endif
27
+
28
+/*-----------------------------------------------------------------------*/
29
+/* Initialize a Drive                                                    */
30
+
31
+DSTATUS disk_initialize (void) {
32
+#if HAL_USE_MMC_SPI
33
+    /* It is initialized externally, just reads the status.*/
34
+    if (blkGetDriverState(&MMCD1) != BLK_READY)
35
+    	return STA_NOINIT;
36
+#else
37
+    /* It is initialized externally, just reads the status.*/
38
+    if (blkGetDriverState(&SDCD1) != BLK_READY)
39
+    	return STA_NOINIT;
40
+#endif
41
+    // All good
42
+	return 0;
43
+}
44
+
45
+/*-----------------------------------------------------------------------*/
46
+/* Read Part Sector(s)                                                        */
47
+
48
+static BYTE		sectBuf[512];
49
+static DWORD	sectpos = -1;
50
+
51
+DRESULT disk_readp (
52
+		BYTE* buff,    /* [OUT] Pointer to the read buffer */
53
+		DWORD sector,  /* [IN]  Sector number */
54
+		UINT offset,   /* [IN]  Byte offset in the sector to start to read */
55
+		UINT count     /* [IN]  Number of bytes to read */
56
+		) {
57
+
58
+	if (sector != sectpos) {
59
+		#if HAL_USE_MMC_SPI
60
+			if (blkGetDriverState(&MMCD1) != BLK_READY)
61
+				return RES_NOTRDY;
62
+			if (mmcStartSequentialRead(&MMCD1, sector))
63
+				return RES_ERROR;
64
+			if (mmcSequentialRead(&MMCD1, sectBuf))
65
+				return RES_ERROR;
66
+			if (mmcStopSequentialRead(&MMCD1))
67
+				return RES_ERROR;
68
+		#else
69
+			if (blkGetDriverState(&SDCD1) != BLK_READY)
70
+				return RES_NOTRDY;
71
+			if (sdcRead(&SDCD1, sector, sectBuf, 1))
72
+				return RES_ERROR;
73
+		#endif
74
+			sectpos = sector;
75
+	}
76
+	memcpy(buff, sectBuf + offset, count);
77
+	return RES_OK;
78
+}
79
+
80
+#endif // GFX_USE_GFILE && GFILE_NEED_PETITFS && GFX_USE_OS_CHIBIOS
81
+
82
+

+ 23 - 0
src/gfile/petitfs_wrapper.c

@@ -0,0 +1,23 @@
1
+/*
2
+ * This file is subject to the terms of the GFX License. If a copy of
3
+ * the license was not distributed with this file, you can obtain one at:
4
+ *
5
+ *              http://ugfx.org/license.html
6
+ */
7
+
8
+/**
9
+ * @file    src/gfile/petitfs_wrapper.c
10
+ * @brief   GFILE PETITFS wrapper.
11
+ *
12
+ */
13
+
14
+#include "gfx.h"
15
+
16
+#if GFX_USE_GFILE && GFILE_NEED_PETITFS
17
+
18
+#include "petitfs_wrapper.h"
19
+
20
+// Include the source we want
21
+#include "3rdparty/petitfs-0.03/src/pff.c"
22
+
23
+#endif // GFX_USE_GFILE && GFILE_NEED_PETITFS

+ 26 - 0
src/gfile/petitfs_wrapper.h

@@ -0,0 +1,26 @@
1
+/*
2
+ * This file is subject to the terms of the GFX License. If a copy of
3
+ * the license was not distributed with this file, you can obtain one at:
4
+ *
5
+ *              http://ugfx.org/license.html
6
+ */
7
+
8
+/**
9
+ * @file    src/gfile/petitfs_wrapper.h
10
+ * @brief   GFILE PETITFS wrapper.
11
+ *
12
+ */
13
+
14
+#ifndef _PETITFS_WRAPPER
15
+#define _PETITFS_WRAPPER
16
+
17
+// Include the petitfs configuration from the local directory not the original source folder
18
+#include "pffconf.h"
19
+
20
+// Include the petitfs API
21
+#include "3rdparty/petitfs-0.03/src/pff.h"
22
+
23
+// Include the petitfs diskio API
24
+#include "3rdparty/petitfs-0.03/src/diskio.h"
25
+
26
+#endif //_PETITFS_WRAPPER

+ 6 - 1
src/gfile/sys_make.mk

@@ -3,6 +3,7 @@ GFXSRC +=   $(GFXLIB)/src/gfile/gfile.c \
3 3
             $(GFXLIB)/src/gfile/inc_ramfs.c \
4 4
             $(GFXLIB)/src/gfile/inc_romfs.c \
5 5
             $(GFXLIB)/src/gfile/inc_fatfs.c \
6
+            $(GFXLIB)/src/gfile/inc_petitfs.c \
6 7
             $(GFXLIB)/src/gfile/inc_memfs.c \
7 8
             $(GFXLIB)/src/gfile/inc_chibiosfs.c \
8 9
             $(GFXLIB)/src/gfile/inc_strings.c \
@@ -10,4 +11,8 @@ GFXSRC +=   $(GFXLIB)/src/gfile/gfile.c \
10 11
             $(GFXLIB)/src/gfile/inc_scang.c \
11 12
             $(GFXLIB)/src/gfile/inc_stdio.c \
12 13
             $(GFXLIB)/src/gfile/fatfs_wrapper.c \
13
-            $(GFXLIB)/src/gfile/fatfs_chibios_diskio.c
14
+            $(GFXLIB)/src/gfile/fatfs_chibios_diskio.c \
15
+            $(GFXLIB)/src/gfile/petitfs_wrapper.c \
16
+            $(GFXLIB)/src/gfile/petitfs_chibios_diskio.c \
17
+
18
+            

+ 20 - 2
src/gfile/sys_options.h

@@ -101,16 +101,34 @@
101 101
 		#define GFILE_NEED_RAMFS		FALSE
102 102
 	#endif
103 103
 	/**
104
-	 * @brief   Include the FAT file system driver
104
+	 * @brief   Include the FAT file system driver based on the FATFS library
105 105
 	 * @details	Defaults to FALSE
106 106
 	 * @note	If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are
107 107
 	 * 			opening a file on the FAT file system by prefixing
108 108
 	 * 			its name with "F|" (the letter 'F', followed by a vertical bar).
109
-	 * @note	You must separately include the FATFS library and code.
109
+	 * @note	FATFS and PETITFS offer the same FAT file system support. They just use
110
+	 * 			different constraints. PETITFS is smaller but has less features. Only
111
+	 * 			one can be used at a time. The block interfaces are also different.
110 112
 	 */
111 113
 	#ifndef GFILE_NEED_FATFS
112 114
 		#define GFILE_NEED_FATFS		FALSE
113 115
 	#endif
116
+	/**
117
+	 * @brief   Include the FAT file system driver based on the PETITFS library
118
+	 * @details	Defaults to FALSE
119
+	 * @note	If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are
120
+	 * 			opening a file on the FAT file system by prefixing
121
+	 * 			its name with "F|" (the letter 'F', followed by a vertical bar).
122
+	 * @note	FATFS and PETITFS offer the same FAT file system support. They just use
123
+	 * 			different constraints. PETITFS is smaller but has less features. Only
124
+	 * 			one can be used at a time. The block interfaces are also different.
125
+	 * @note	Due to the restrictions on the PETITFS library on writing, we do not implement
126
+	 * 			writing.
127
+	 * @note	PETITFS can only have one file open at a time.
128
+	 */
129
+	#ifndef GFILE_NEED_PETITFS
130
+		#define GFILE_NEED_FATFS		FALSE
131
+	#endif
114 132
 	/**
115 133
 	 * @brief   Include the operating system's native file system
116 134
 	 * @details	Defaults to FALSE

+ 3 - 0
src/gfile/sys_rules.h

@@ -17,6 +17,9 @@
17 17
 #define _GFILE_RULES_H
18 18
 
19 19
 #if GFX_USE_GFILE
20
+	#if GFILE_NEED_PETITFS && GFILE_NEED_FATFS
21
+		#error "GFILE: Both GFILE_NEED_PETITFS and GFILE_NEED_FATFS cannot both be turned on at the same time."
22
+	#endif
20 23
 #endif
21 24
 
22 25
 #endif /* _GFILE_RULES_H */