From 75e1e7a5e26491e942fb2b25f518d8e2e3112721 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 15 Aug 2014 02:22:02 +1000 Subject: Add GFILE support for PetitFS (a very tiny FAT implementation) --- 3rdparty/petitfs-0.03/doc/00index_p.html | 77 +++++++++++++++++++++ 3rdparty/petitfs-0.03/doc/css_e.css | 65 ++++++++++++++++++ 3rdparty/petitfs-0.03/doc/css_p.css | 1 + 3rdparty/petitfs-0.03/doc/img/layers3.png | Bin 0 -> 2379 bytes 3rdparty/petitfs-0.03/doc/img/rwtest3.png | Bin 0 -> 3011 bytes 3rdparty/petitfs-0.03/doc/pf/appnote.html | 91 ++++++++++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/dinit.html | 40 +++++++++++ 3rdparty/petitfs-0.03/doc/pf/dreadp.html | 59 ++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/dwritep.html | 73 ++++++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/filename.html | 22 ++++++ 3rdparty/petitfs-0.03/doc/pf/lseek.html | 79 +++++++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/mount.html | 65 ++++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/open.html | 103 ++++++++++++++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/opendir.html | 72 +++++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/read.html | 73 ++++++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/readdir.html | 100 +++++++++++++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/sdir.html | 30 ++++++++ 3rdparty/petitfs-0.03/doc/pf/sfatfs.html | 39 +++++++++++ 3rdparty/petitfs-0.03/doc/pf/sfileinfo.html | 62 +++++++++++++++++ 3rdparty/petitfs-0.03/doc/pf/write.html | 86 +++++++++++++++++++++++ 20 files changed, 1137 insertions(+) create mode 100644 3rdparty/petitfs-0.03/doc/00index_p.html create mode 100644 3rdparty/petitfs-0.03/doc/css_e.css create mode 100644 3rdparty/petitfs-0.03/doc/css_p.css create mode 100644 3rdparty/petitfs-0.03/doc/img/layers3.png create mode 100644 3rdparty/petitfs-0.03/doc/img/rwtest3.png create mode 100644 3rdparty/petitfs-0.03/doc/pf/appnote.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/dinit.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/dreadp.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/dwritep.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/filename.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/lseek.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/mount.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/open.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/opendir.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/read.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/readdir.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/sdir.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/sfatfs.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/sfileinfo.html create mode 100644 3rdparty/petitfs-0.03/doc/pf/write.html (limited to '3rdparty/petitfs-0.03/doc') diff --git a/3rdparty/petitfs-0.03/doc/00index_p.html b/3rdparty/petitfs-0.03/doc/00index_p.html new file mode 100644 index 00000000..fe5ada00 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/00index_p.html @@ -0,0 +1,77 @@ + + + + + + + + + + + +Petit FAT File System Module + + + +

Petit FAT File System Module

+
+ +
+layer +

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 here↗.

+ +

Features

+ +
+ + +
+

Application Interface

+

Petit FatFs module provides following functions.

+ +
+ + +
+

Disk I/O Interface

+

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.

+ +
+ + +
+

Resources

+

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.

+ +
+ + +
+

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/css_e.css b/3rdparty/petitfs-0.03/doc/css_e.css new file mode 100644 index 00000000..1b544eb6 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/css_e.css @@ -0,0 +1,65 @@ +* {margin: 0; padding: 0; border-width: 0;} +body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;} +a:link {color: blue;} +a:visited {color: darkmagenta;} +a:hover {background-color: #a0ffff;} +a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;} +abbr {border-width: 1px;} + +p {margin: 0 0 0.3em 1em;} +i {margin: 0 0.3em 0 0;} +b {margin: 0 0.1em;} +em {font-style: normal; font-weight: bold; margin: 0 0.1em;} +strong {} +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;} +pre span.c {color: green;} +pre span.k {color: blue;} +pre span.arg {font-style: italic;} +tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } +tt.arg {font-style: italic;} +ol {margin: 0.5em 2.5em;} +ul {margin: 0.5em 2em;} +dl {margin: 0.5em 1em;} +dd {margin: 0 2em;} +dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} +dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; } +dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} +hr {border-width: 1px; margin: 1em;} +div.abst {font-family: sans-serif;} +div.para {clear: both; font-family: serif;} +div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } +.equ {text-indent: 0; margin: 1em 2em 1em;} +.indent {margin-left: 2em;} +.rset {float: right; margin: 0.3em 0 0.5em 0.5em;} +.lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;} +ul.flat li {list-style-type: none; margin: 0;} +a.imglnk img {border: 1px solid;} +.iequ {white-space: nowrap; font-weight: bold;} +.clr {clear: both;} +.it {font-style: italic;} +.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap} +.ral {text-align: right; } +.lal {text-align: left; } +.cal {text-align: center; } + +h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;} +p.hdd {float: right; text-align: right; margin-top: 0.5em;} +hr.hds {clear: both; margin-bottom: 1em;} + +h2 {font-size: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;} +h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;} +h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;} +h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;} +small {font-size: 80%;} +.indent {margin-left: 2em;} + +/* Tables */ +table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; } +th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;} +td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;} +table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} +table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", 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;} diff --git a/3rdparty/petitfs-0.03/doc/css_p.css b/3rdparty/petitfs-0.03/doc/css_p.css new file mode 100644 index 00000000..bc7b5b09 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/css_p.css @@ -0,0 +1 @@ +body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;} diff --git a/3rdparty/petitfs-0.03/doc/img/layers3.png b/3rdparty/petitfs-0.03/doc/img/layers3.png new file mode 100644 index 00000000..ac439b0b Binary files /dev/null and b/3rdparty/petitfs-0.03/doc/img/layers3.png differ diff --git a/3rdparty/petitfs-0.03/doc/img/rwtest3.png b/3rdparty/petitfs-0.03/doc/img/rwtest3.png new file mode 100644 index 00000000..cbaa3d11 Binary files /dev/null and b/3rdparty/petitfs-0.03/doc/img/rwtest3.png differ diff --git a/3rdparty/petitfs-0.03/doc/pf/appnote.html b/3rdparty/petitfs-0.03/doc/pf/appnote.html new file mode 100644 index 00000000..68df279d --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/appnote.html @@ -0,0 +1,91 @@ + + + + + + + + +FatFs Module Application Note + + + +

Petit FatFs Module Application Note

+
+ +

Basic Considerations

+

The FatFs module is assuming following conditions on portability.

+ + + +
+

Memory Usage (R0.03)

+ + + + + + + + + + + +
AVRx86
Compilergcc(WinAVR)VC6
_WORD_ACCESS11
Code (default)21001720
Code (!_USE_READ)-444-246
Code (_USE_DIR)+1002+420
Code (_USE_LSEEK)+490+228
Code (_USE_WRITE)+518+351
RAM (bss)24
RAM (work)4244
+

This is the size of the Petit FatFs module itself. In addition to this, a low level disk I/O module will be required for a complete function. The size of MMC/SDC module on AVR becomes approximate 620 bytes without write function and 840 bytes with write function.

+
+ +
+

Module Size Reduction

+

Follwing table shows which function is removed by configuration options for the module size reduction.

+ + + + + + + + + + +
Function_USE_READ_USE_DIR_USE_LSEEK_USE_WRITE
0000
pf_mount
pf_open
pf_readx
pf_lseekx
pf_opendirx
pf_readdirx
pf_writex
+
+ +
+

Performance effective file access

+

For good performance on reading a file on the small embedded system, application programmer should consider what process is done in the file system module.

+

The Petit FatFs reads the disk sectors without a sector buffer. This means the file system reads a part of the sector contains the required data every reference point even if they are in the same sector. However the generic storage device are not byte addressable so that the disk I/O layer will read the entire sector and pick up the data bytes from the read data steram.

+

When read 512 byte data from a file at a time, the data sector will be read only a time. When read that data in byte-by-byte, the data sector will be read 512 times. Therefore the byte-by-byte read request will drastically decrease the read performance. To avoid this stupid read controls, the file data should be read in long block as possible. Sector alignment access is not impotant on the Petit FatFs.

+

The tiny microcontrollers targeted by Petit FatFs has a limited size of RAM. It may not able to allocate a certain size of read buffer and most type of text processing will require byte-by-byte read operation. The Petit FatFs supports data forwarding feature for such purpose.

+ +
+ +
+

About FatFs License

+

Petit FatFs has being developped as a personal project of author, ChaN. It is free from the code anyone else wrote. Following code block shows a copy of the license document that included in the source files.

+
/*----------------------------------------------------------------------------/
+/  Petit FatFs - FAT file system module  R0.03                  (C)ChaN, 2014
+/-----------------------------------------------------------------------------/
+/ Petit FatFs module is a generic FAT file system module for small embedded
+/ systems. This is a free software that opened for education, research and
+/ commercial developments under license policy of following trems.
+/
+/  Copyright (C) 2014, ChaN, all right reserved.
+/
+/ * The Petit FatFs module is a free software and there is NO WARRANTY.
+/ * No restriction on use. You can use, modify and redistribute it for
+/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+/ * Redistributions of source code must retain the above copyright notice.
+/
+/-----------------------------------------------------------------------------/
+

Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file, binary library and any form without source code, are not specified in order to extend usability to commercial use. The documentation of the distributions need not include about Petit FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course Petit FatFs is compatible with the projects under GNU GPL. When redistribute the Petit FatFs with any modification, the license can also be changed to GNU GPL or BSD-style license.

+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/dinit.html b/3rdparty/petitfs-0.03/doc/pf/dinit.html new file mode 100644 index 00000000..b7a5f418 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/dinit.html @@ -0,0 +1,40 @@ + + + + + + + + +Petit FatFs - disk_initialize + + + + +
+

disk_initialize

+

The disk_initialize function initializes the disk drive.

+
+DSTATUS disk_initialize (void)
+
+
+ +
+

Return Values

+

The disk status is returned in combination of following flags.

+
+
STA_NOINIT
+
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.
+
STA_NODISK
+
Indicates that no medium in the drive. This is always cleared on fixed disk drive. This flag is not referred by Petit FatFs.
+
+
+ +
+

Description

+

The disk_initialize function initializes the storage device. If the function succeeded, STA_NOINIT flag in the return value is cleared.

+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/dreadp.html b/3rdparty/petitfs-0.03/doc/pf/dreadp.html new file mode 100644 index 00000000..dd97561e --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/dreadp.html @@ -0,0 +1,59 @@ + + + + + + + + +Petit FatFs - disk_readp + + + + +
+

disk_readp

+

The disk_readp function reads a partial sector of the device.

+
+DRESULT disk_readp (
+  BYTE* buff,    /* [OUT] Pointer to the read buffer */
+  DWORD sector,  /* [IN]  Sector number */
+  UINT offset,   /* [IN]  Byte offset in the sector to start to read */
+  UINT count     /* [IN]  Number of bytes to read */
+);
+
+
+ +
+

Parameters

+
+
buff
+
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.
+
sector
+
Specifies the sector number to be read in logical block address (LBA).
+
offset
+
Specifies the byte offset in the sector to start to read. The value can be 0 to 511.
+
count
+
Specifies number of bytes to read. The value can be 0 to 512 and offset + count must not exceed 512.
+
+
+ + +
+

Return Value

+
+
RES_OK (0)
+
The function succeeded.
+
RES_ERROR
+
Any hard error occured during the disk read operation and could not recover it.
+
RES_PARERR
+
Invalid parameter.
+
RES_NOTRDY
+
The device has not been initialized.
+
+
+ + +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/dwritep.html b/3rdparty/petitfs-0.03/doc/pf/dwritep.html new file mode 100644 index 00000000..d3342ce1 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/dwritep.html @@ -0,0 +1,73 @@ + + + + + + + + +Petit FatFs - disk_writep + + + + +
+

disk_writep

+

The disk_writep function writes data to the sector.

+
+DRESULT disk_writep (
+  BYTE* buff,  /* [IN] Pointer to the data to be written */
+  DWORD sc,    /* [IN] Sector number or Number of bytes to wtite */
+);
+
+
+ +
+

Parameters

+
+
buff
+
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.
+
sc
+
Specifies nubmer of bytes to write if buff is not a NULL. If buff is a NULL and sc is not a zero, the function initiates a write transactin to the sector. If buff and sc are zero, the function finalize the current sector write transactin.
+
+
+ + +
+

Return Value

+
+
RES_OK (0)
+
The function succeeded.
+
RES_ERROR
+
Any hard error occured during the write operation and could not recover it or the medium is write protected.
+
RES_PARERR
+
Invalid parameter.
+
RES_NOTRDY
+
The device has not been initialized.
+
+
+ + +
+

Description

+

A sector write operation is done in following sequence.

+
    +
  1. disk_writep(0, sector_number); Initiate a sector write transaction.
  2. +
  3. disk_writep(data, byte_to_write); Start to write data to the sector.
  4. +
  5. disk_writep(data, byte_to_write); And data can be written upto 512 bytes with one or more calls.
  6. +
  7. disk_writep(data, byte_to_write); ...
  8. +
  9. disk_writep(0, 0); Finalize the write transaction. If number of bytes sent is less than 512, left bytes in the sector is filled by zero.
  10. +
+

If a write transaction is in progress, disk_readp() function will fail and disk_initialize() function finalize the current write transaction.

+
+ + +
+

Remarks

+

This funciton is needed when _USE_WRITE == 1.

+
+ + +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/filename.html b/3rdparty/petitfs-0.03/doc/pf/filename.html new file mode 100644 index 00000000..58e42453 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/filename.html @@ -0,0 +1,22 @@ + + + + + + + + +Petit FatFs - Path Names + + + + +
+

Format of the path names

+

The path name format on the Petit FatFs module is similer to MS-DOS as follows.

+
"[/]directory/file"
+

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 _USE_LCC == 1, lower case characters are allowed for the path name.

+

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.

+
+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/lseek.html b/3rdparty/petitfs-0.03/doc/pf/lseek.html new file mode 100644 index 00000000..1dbb0dea --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/lseek.html @@ -0,0 +1,79 @@ + + + + + + + + +Petit FatFs - pf_lseek + + + + +
+

pf_lseek

+

The pf_lseek function moves the file read/write pointer of the open file.

+ +
+FRESULT pf_lseek (
+  DWORD ofs       /* [IN] File offset in unit of byte */
+);
+
+
+ +
+

Parameters

+
+
ofs
+
Number of bytes where from start of the file
+
+
+ + +
+

Return Values

+
+
FR_OK (0)
+
The function succeeded.
+
FR_DISK_ERR
+
The function failed due to an error in the disk function, a wrong FAT structure or an internal error.
+
FR_NOT_OPENED
+
The file has not been opened.
+
+
+ + +
+

Description

+

The pf_lseek() function moves the file read/write pointer of the open file. The offset can be specified in only origin from top of the file.

+
+ + +
+

Example

+
+    /* Move to offset of 5000 from top of the file */
+    res = pf_lseek(5000);
+
+    /* Forward 3000 bytes */
+    res = pf_lseek(fs.fptr + 3000);
+
+    /* Rewind 2000 bytes (take care on wraparound) */
+    res = pf_lseek(fs.fptr - 2000);
+
+
+ +
+

QuickInfo

+

Available when _USE_LSEEK == 1.

+
+ +
+

References

+

pf_open, FATFS

+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/mount.html b/3rdparty/petitfs-0.03/doc/pf/mount.html new file mode 100644 index 00000000..4c0f0210 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/mount.html @@ -0,0 +1,65 @@ + + + + + + + + +Petit FatFs - pf_mount + + + + +
+

pf_mount

+

The pf_mount fucntion mounts a volume.

+
+FRESULT pf_mount (
+  FATFS*  fs  /* [IN] Pointer to the work area */
+);
+
+
+ +
+

Parameters

+
+
fs
+
Pointer to the work area (file system object) to be registered.
+
+
+ +
+

Return Values

+
+
FR_OK (0)
+
The function succeeded.
+
FR_NOT_READY
+
The drive could not be initialized due to a disk error or no medium.
+
FR_DISK_ERR
+
An error occured in the disk function.
+
FR_NO_FILESYSTEM
+
There is no valid FAT partition on the disk.
+
+
+ + +
+

Description

+

The pf_mount() 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.

+
+ + +
+

QuickInfo

+

Always available.

+
+ +
+

References

+

FATFS

+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/open.html b/3rdparty/petitfs-0.03/doc/pf/open.html new file mode 100644 index 00000000..2914467f --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/open.html @@ -0,0 +1,103 @@ + + + + + + + + +Petit FatFs - pf_open + + + + +
+

pf_open

+

The pf_open function opens an existing file.

+
+FRESULT pf_open (
+  const char* path  /* [IN] Pointer to the file neme */
+);
+
+
+ +
+

Parameters

+
+
path
+
Pointer to a null-terminated string that specifies the file name to open.
+
+
+ + +
+

Return Values

+
+
FR_OK (0)
+
The function succeeded.
+
FR_NO_FILE
+
Could not find the file or path.
+
FR_DISK_ERR
+
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
+
FR_NOT_ENABLED
+
The volume has not been mounted.
+
+
+ + +
+

Description

+

The file must be opend prior to use pf_read() and pf_lseek() function. The open file is valid until next open.

+
+ + +
+

Example

+
+int main (void)
+{
+    FATFS fs;          /* Work area (file system object) for the volume */
+    BYTE buff[16];     /* File read buffer */
+    UINT br;           /* File read count */
+    FRESULT res;       /* Petit FatFs function common result code */
+
+
+    /* Mount the volume */
+    pf_mount(&fs);
+    if (res) die(res);
+
+    /* Open a file */
+    res = pf_open("srcfile.dat");
+    if (res) die(res);
+
+    /* Read data to the memory */
+    res = pf_read(buff, 16, &br);    /* Read data to the buff[] */
+    if (res) die(res);               /* Check error */
+    if (br != 16) die(255);          /* Check EOF */
+
+    ....
+
+    /* Forward data to the outgoing stream */
+    do
+        res = pf_read(0, 512, &br);  /* Send data to the stream */
+    while (res || br != 512);        /* Break on error or eof */
+
+    ....
+
+}
+
+
+ +
+

QuickInfo

+

Always available.

+
+ +
+

References

+

pf_read, FATFS

+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/opendir.html b/3rdparty/petitfs-0.03/doc/pf/opendir.html new file mode 100644 index 00000000..6cb71d07 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/opendir.html @@ -0,0 +1,72 @@ + + + + + + + + +Petit FatFs - pf_opendir + + + + +
+

pf_opendir

+

The pf_opendir function opens a directory.

+
+FRESULT pf_opendir (
+  DIR* dp,          /* [OUT] Pointer to the blank directory object structure */
+  const char* path  /* [IN]  Pointer to the directory name */
+);
+
+
+ +
+

Parameters

+
+
dp
+
Pointer to the blank directory object to be created.
+
path
+
Pinter to the null-terminated string that specifies the directory name to be opened.
+
+
+ + +
+

Return Values

+
+
FR_OK (0)
+
The function succeeded and the directory object is created. It is used for subsequent calls to read the directory entries.
+
FR_NO_FILE
+
Could not find the path.
+
FR_NOT_READY
+
The disk drive cannot work due to no medium in the drive or any other reason.
+
FR_DISK_ERR
+
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
+
FR_NOT_ENABLED
+
The volume has no work area.
+
+
+ + +
+

Description

+

The pf_opendir() 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.

+
+ + +
+

QuickInfo

+

Available when _USE_DIR == 1.

+
+ + +
+

References

+

f_readdir, DIR

+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/read.html b/3rdparty/petitfs-0.03/doc/pf/read.html new file mode 100644 index 00000000..a76c8ed3 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/read.html @@ -0,0 +1,73 @@ + + + + + + + + +Petit FatFs - pf_read + + + + +
+

pf_read

+

The pf_read function reads data from the file.

+
+FRESULT pf_read (
+  void* buff,  /* [OUT] Pointer to the read buffer */
+  UINT btr,    /* [IN]  Number of bytes to read */
+  UINT* br     /* [OUT] Number of bytes read */
+);
+
+
+ +
+

Parameters

+
+
buff
+
Pointer to the buffer to store the read data. A NULL specifies the destination is an outgoing stream.
+
btr
+
Number of bytes to read.
+
br
+
Pointer to the variable to return number of bytes read.
+
+
+ + +
+

Return Values

+
+
FR_OK (0)
+
The function succeeded.
+
FR_DISK_ERR
+
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
+
FR_NOT_OPENED
+
The file has not been opened.
+
FR_NOT_ENABLED
+
The volume has not been mounted.
+
+
+ + +
+

Description

+

The file read/write pointer in the file system object advances in number of bytes read. After the function succeeded, *br should be checked to detect end of file. In case of *br < btr, it means the read pointer reached end of file during read operation.

+

If a NULL is given to the buff, the read bytes will be forwarded to the outgoing stream instead of the memory. The streaming function will be typically built-in the disk_readp() function.

+
+ +
+

QuickInfo

+

Available when _USE_READ == 1.

+
+ + +
+

References

+

pf_open, pf_write, FATFS

+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/readdir.html b/3rdparty/petitfs-0.03/doc/pf/readdir.html new file mode 100644 index 00000000..7f778e1d --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/readdir.html @@ -0,0 +1,100 @@ + + + + + + + + +Petit FatFs - pf_readdir + + + + +
+

pf_readdir

+

The pf_readdir function reads directory entries.

+
+FRESULT pf_readdir (
+  DIR* dp,      /* [IN]  Pointer to the open directory object */
+  FILINFO* fno  /* [OUT] Pointer to the file information structure */
+);
+
+
+ +
+

Parameters

+
+
dp
+
Pointer to the open directory object.
+
fno
+
Pointer to the file information structure to store the read item.
+
+
+ + +
+

Return Values

+
+
FR_OK (0)
+
The function succeeded.
+
FR_DISK_ERR
+
The function failed due to an error in the disk function, a wrong FAT structure or an internal error.
+
FR_NOT_OPENED
+
The directory object has not been opened.
+
+
+ + +
+

Description

+

The pf_readdir() 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 f_name[] in the file information structure without error. When a null pointer is given to the fno, the read index of the directory object will be rewinded.

+
+ + +
+

Sample Code

+
+FRESULT scan_files (char* path)
+{
+    FRESULT res;
+    FILINFO fno;
+    DIR dir;
+    int i;
+
+
+    res = pf_opendir(&dir, path);
+    if (res == FR_OK) {
+        i = strlen(path);
+        for (;;) {
+            res = pf_readdir(&dir, &fno);
+            if (res != FR_OK || fno.fname[0] == 0) break;
+            if (fno.fattrib & AM_DIR) {
+                sprintf(&path[i], "/%s", fno.fname);
+                res = scan_files(path);
+                if (res != FR_OK) break;
+                path[i] = 0;
+            } else {
+                printf("%s/%s\n", path, fno.fname);
+            }
+        }
+    }
+
+    return res;
+}
+
+
+ +
+

QuickInfo

+

Available when _USE_DIR == 1.

+
+ +
+

References

+

pf_opendir, FILINFO, DIR

+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/sdir.html b/3rdparty/petitfs-0.03/doc/pf/sdir.html new file mode 100644 index 00000000..e7e7a235 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/sdir.html @@ -0,0 +1,30 @@ + + + + + + + + +Petit FatFs - DIR + + + + +
+

DIR

+

The DIR structure is used for the work area to read a directory by pf_oepndir, pf_readdir function.

+
+typedef struct {
+    WORD    index;     /* Current read/write index number */
+    BYTE*   fn;        /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
+    CLUST   sclust;    /* Table start cluster (0:Static table) */
+    CLUST   clust;     /* Current cluster */
+    DWORD   sect;      /* Current sector */
+} DIR;
+
+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/sfatfs.html b/3rdparty/petitfs-0.03/doc/pf/sfatfs.html new file mode 100644 index 00000000..35d385a3 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/sfatfs.html @@ -0,0 +1,39 @@ + + + + + + + + +Petit FatFs - FATFS + + + + +
+

FATFS

+

The FATFS 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.

+
+typedef struct {
+    BYTE    fs_type;     /* FAT sub type */
+    BYTE    csize;       /* Number of sectors per cluster */
+    BYTE    flag;        /* File status flags */
+    BYTE    pad1;
+    WORD    n_rootdir;   /* Number of root directory entries (0 on FAT32) */
+    CLUST   n_fatent;    /* Number of FAT entries (= number of clusters + 2) */
+    DWORD   fatbase;     /* FAT start sector */
+    DWORD   dirbase;     /* Root directory start sector (Cluster# on FAT32) */
+    DWORD   database;    /* Data start sector */
+    DWORD   fptr;        /* File read/write pointer */
+    DWORD   fsize;       /* File size */
+    CLUST   org_clust;   /* File start cluster */
+    CLUST   curr_clust;  /* File current cluster */
+    DWORD   dsect;       /* File current data sector */
+} FATFS;
+
+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/sfileinfo.html b/3rdparty/petitfs-0.03/doc/pf/sfileinfo.html new file mode 100644 index 00000000..cd0ed7f1 --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/sfileinfo.html @@ -0,0 +1,62 @@ + + + + + + + + +Petit FatFs - FILINFO + + + + +
+

FILINFO

+

The FILINFO structure holds a file information returned by pf_readdir function.

+
+typedef struct {
+    DWORD   fsize;        /* File size */
+    WORD    fdate;        /* Last modified date */
+    WORD    ftime;        /* Last modified time */
+    BYTE    fattrib;      /* Attribute */
+    char    fname[13];    /* File name */
+} FILINFO;
+
+
+ +

Members

+
+
fsize
+
Indicates size of the file in unit of byte. This is always zero when it is a directory.
+
fdate
+
Indicates the date that the file was modified or the directory was created.
+
+
bit15:9
+
Year origin from 1980 (0..127)
+
bit8:5
+
Month (1..12)
+
bit4:0
+
Day (1..31)
+
+
+
ftime
+
Indicates the time that the file was modified or the directory was created.
+
+
bit15:11
+
Hour (0..23)
+
bit10:5
+
Minute (0..59)
+
bit4:0
+
Second / 2 (0..29)
+
+
+
fattrib
+
Indicates the file/directory attribute in combination of AM_DIR, AM_RDO, AM_HID, AM_SYS and AM_ARC.
+
fname[]
+
Indicates the file/directory name in 8.3 format null-terminated string.
+
+ +

Return

+ + diff --git a/3rdparty/petitfs-0.03/doc/pf/write.html b/3rdparty/petitfs-0.03/doc/pf/write.html new file mode 100644 index 00000000..573a298b --- /dev/null +++ b/3rdparty/petitfs-0.03/doc/pf/write.html @@ -0,0 +1,86 @@ + + + + + + + + +Petit FatFs - pf_write + + + + +
+

pf_write

+

The pf_write function writes data to the file.

+
+FRESULT pf_write (
+  const void* buff, /* [IN]  Pointer to the data to be written */
+  UINT btw,         /* [IN]  Number of bytes to write */
+  UINT* bw          /* [OUT] Pointer to the variable to return number of bytes written */
+);
+
+
+ +
+

Parameters

+
+
buff
+
Pointer to the data to be wtitten. A NULL specifies to finalize the current write operation.
+
btw
+
Number of bytes to write.
+
bw
+
Pointer to the variable to return number of bytes read.
+
+
+ + +
+

Return Values

+
+
FR_OK (0)
+
The function succeeded.
+
FR_DISK_ERR
+
The function failed due to a hard error in the disk function, write protected, a wrong FAT structure or an internal error.
+
FR_NOT_OPENED
+
The file has not been opened.
+
FR_NOT_ENABLED
+
The volume has not been mounted.
+
+
+ + +
+

Description

+

The write function has some restrictions listed below:

+ +

File write operation must be done in following sequence.

+
    +
  1. pf_lseek(ofs); read/write pointer must be moved to sector bundary prior to initiate write operation or it will be rounded-down to the sector boundary.
  2. +
  3. pf_write(buff, btw, &bw); Initiate write operation. Write first data to the file.
  4. +
  5. pf_write(buff, btw, &bw); Write next data. Any other file function cannot be used while a write operation is in progress.
  6. +
  7. pf_write(0, 0, &bw); Finalize the write operation. If read/write pointer is not on the sector boundary, left bytes in the sector will be filled with zero.
  8. +
+

The read/write pointer in the file system object advances in number of bytes written. After the function succeeded, *bw should be checked to detect end of file. In case of *bw < btw, 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.

+
+ +
+

QuickInfo

+

Available when _USE_WRITE == 1.

+
+ +
+

References

+

pf_open, FATFS

+
+ +

Return

+ + -- cgit v1.2.3