FatFs R0.14b, released April 17, 2021

This commit is contained in:
Christopher Williams
2021-04-20 17:26:13 -07:00
parent 731687b3fb
commit 074e3603ef
25 changed files with 860 additions and 699 deletions
+38 -23
View File
@@ -39,7 +39,7 @@ int f_printf (
<div class="para ret">
<h4>Return Values</h4>
<p>When the string was written successfuly, it returns number of character encoding units written to the file. When the function failed due to disk full or any error, a negative value will be returned.</p>
<p>When the string was written successfuly, it returns number of character encoding units written to the file. When the function failed due to disk full or an error, a negative value will be returned.</p>
</div>
@@ -47,13 +47,27 @@ int f_printf (
<h4>Description</h4>
<p>The format control directive is a sub-set of standard library shown as follows:</p>
<pre>
%[flag][width][prefix][type]
%[flag][width][precision][size]type
</pre>
<dl>
<dt>flag</dt><dd>Padding options. A <tt>'0'</tt> specifies zero padded. A <tt>'-'</tt> specifies left justified.</dd>
<dt>width</dt><dd>Minimum width of the field, <tt>'1'-'99'</tt> or <tt>'*'</tt>. If the width of generated string is less than the specified value, rest field is padded with white spaces or zeros. An <tt>*</tt> specifies the value comes from an argument in int type. The default value is zero.</dd>
<dt>prefix</dt><dd>Size prefix <tt>'l'</tt> for long integer argument. If <tt>sizeof (long) == sizeof (int)</tt> (this is typical of 32-bit systems), the size prefix can be omitted.</dd>
<dt>type</dt><dd><tt>'c','s','d','u','o','x','b'</tt>, specify type of the argument and output format, character, string, signed integer in decimal, unsigned integer in decimal, unsigned integer in octal, unsigned integer in hexdecimal and unsigned integer in binary respectively. These characters except <tt>'x'</tt> are case insensitive. An <tt>'X'</tt> generates a hexdecimal in up-case.</dd>
<dt>flag</dt><dd>Padding options. A <tt>-</tt> specifies left-aligned. A <tt>0</tt> specifies zero padded. The default setting is in right-aligned and space padded.</dd>
<dt>width</dt><dd>Minimum width of the field, <tt>1-99</tt> or <tt>*</tt>. If the width of generated string is less than the specified value, rest field is padded with spaces or zeros. An <tt>*</tt> specifies the value comes from an argument in int type.</dd>
<dt>precision</dt><dd>Specifies number of fractional digits or maximum width of string, <tt>.0-.99</tt> or <tt>.*</tt>. If number is omitted, it will be same as <tt>.0</tt>. Default setting is 6 for number and no limit for string.</dd>
<dt>size</dt><dd>Specifies size of integer argument, <tt>l</tt>(long) and <tt>ll</tt>(long long). If <tt>sizeof (long) == sizeof (int)</tt> is true (this is typical of 32-bit systems), prefix <tt>l</tt> can be omitted for long integer argument. The default size is int for integer arrument and floating point argument is always assumed double.</dd>
<dt>type</dt><dd>Specifies type of the output format and the argument as shown below. The length of generated string is in assumtion of int is 32-bit.
<table class="lst1">
<tr><th>Type</th><th>Format</th><th>Argument</th><th>Length</th></tr>
<tr><td><tt>c</tt></td><td>Character</td><td rowspan="6"><tt>int</tt>,<br><tt>long</tt>,<br><tt>long long</tt></td><td>1 character.</td></tr>
<tr><td><tt>d</tt></td><td>Signed&nbsp;decimal</td><td>1 to 11 (20 for ll) characters.</td></tr>
<tr><td><tt>u</tt></td><td>Unsigned&nbsp;decimal</td><td>1 to 10 (20 for ll) characters.</td></tr>
<tr><td><tt>o</tt></td><td>Unsigned&nbsp;octal</td><td>1 to 11 (22 for ll) characters.</td></tr>
<tr><td><tt>x X</tt></td><td>Unsigned&nbsp;hexdecimal</td><td>1 to 8 (16 for ll) characters.</td></tr>
<tr><td><tt>b</tt></td><td>Unsigned&nbsp;binary</td><td>1 to 32 characters. Limited to lower 32 digits when ll is specified.</td></tr>
<tr><td><tt>s</tt></td><td>String</td><td><tt>TCHAR*</tt></td><td>As input string. Null pointer generates a null string.</td></tr>
<tr><td><tt>f</tt></td><td>Floating point<br>(decimal)</td><td rowspan="2"><tt>double</tt></td><td>1 to 31 characters. If the number of characters exceeds 31, it writes <tt>"±OV"</tt>. Not a number and infinite write <tt>"NaN"</tt> and <tt>"±INF"</tt>.</td></tr>
<tr><td><tt>e E</tt></td><td>Floating point<br>(e notation)</td><td>4 to 31 characters. If the number of characters exceeds 31 or exponent exceeds +99, it writes <tt>"±OV"</tt>.</td></tr>
</table>
</dd>
</dl>
<p>When FatFs is configured for Unicode API (<tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> &gt;= 1</tt>), character encoding on the string fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt> function, is also switched to Unicode. The Unicode characters in multiple encoding unit, such as surrogate pair and multi-byte sequence, should not be divided into two function calls, or the character will be lost. The character encoding <em>on the file</em> to be written via this function is selected by <tt><a href="config.html#strf_encode">FF_STRF_ENCODE</a></tt>. The characters with wrong encoding or invalid for the output encoding will be lost.</p>
</div>
@@ -68,23 +82,24 @@ int f_printf (
<div class="para use">
<h4>Example</h4>
<pre>
<em>f_printf</em>(&amp;fil, "%d", 1234); <span class="c">/* "1234" */</span>
<em>f_printf</em>(&amp;fil, "%6d,%3d%%", -200, 5); <span class="c">/* " -200, 5%" */</span>
<em>f_printf</em>(&amp;fil, "%ld", 12345L); <span class="c">/* "12345" */</span>
<em>f_printf</em>(&amp;fil, "%06d", 25); <span class="c">/* "000025" */</span>
<em>f_printf</em>(&amp;fil, "%06d", -25); <span class="c">/* "000-25" */</span>
<em>f_printf</em>(&amp;fil, "%*d", 5, 100); <span class="c">/* " 100" */</span>
<em>f_printf</em>(&amp;fil, "%-6d", 25); <span class="c">/* "25 " */</span>
<em>f_printf</em>(&amp;fil, "%u", -1); <span class="c">/* "65535" or "4294967295" */</span>
<em>f_printf</em>(&amp;fil, "%04x", 0xAB3); <span class="c">/* "0ab3" */</span>
<em>f_printf</em>(&amp;fil, "%08lX", 0x123ABCL); <span class="c">/* "00123ABC" */</span>
<em>f_printf</em>(&amp;fil, "%04o", 255); <span class="c">/* "0377" */</span>
<em>f_printf</em>(&amp;fil, "%016b", 0x550F); <span class="c">/* "0101010100001111" */</span>
<em>f_printf</em>(&amp;fil, "%s", "String"); <span class="c">/* "String" */</span>
<em>f_printf</em>(&amp;fil, "%8s", "abc"); <span class="c">/* " abc" */</span>
<em>f_printf</em>(&amp;fil, "%-8s", "abc"); <span class="c">/* "abc " */</span>
<em>f_printf</em>(&amp;fil, "%c", 'a'); <span class="c">/* "a" */</span>
<em>f_printf</em>(&amp;fil, "%f", 10.0); <span class="c">/* f_printf lacks floating point support */</span>
<em>f_printf</em>("%d", 1234); <span class="c">/* "1234" */</span>
<em>f_printf</em>("%6d,%3d%%", -200, 5); <span class="c">/* " -200, 5%" */</span>
<em>f_printf</em>("%-6u", 100); <span class="c">/* "100 " */</span>
<em>f_printf</em>("%ld", 12345678); <span class="c">/* "12345678" */</span>
<em>f_printf</em>("%llu", 0x100000000); <span class="c">/* "4294967296" (<a href="config.html#print_lli">FF_PRINT_LLI</a>) */</span>
<em>f_printf</em>("%lld", -1LL); <span class="c">/* "-1" (FF_PRINT_LLI) */</span>
<em>f_printf</em>("%04x", 0xA3); <span class="c">/* "00a3" */</span>
<em>f_printf</em>("%08lX", 0x123ABC); <span class="c">/* "00123ABC" */</span>
<em>f_printf</em>("%016b", 0x550F); <span class="c">/* "0101010100001111" */</span>
<em>f_printf</em>("%*d", 6, 100); <span class="c">/* " 100" */</span>
<em>f_printf</em>("%s", "abcdefg"); <span class="c">/* "abcdefg" */</span>
<em>f_printf</em>("%5s", "abc"); <span class="c">/* " abc" */</span>
<em>f_printf</em>("%-5s", "abc"); <span class="c">/* "abc " */</span>
<em>f_printf</em>("%.5s", "abcdefg"); <span class="c">/* "abcde" */</span>
<em>f_printf</em>("%-5.2s", "abcdefg"); <span class="c">/* "ab " */</span>
<em>f_printf</em>("%c", 'a'); <span class="c">/* "a" */</span>
<em>f_printf</em>("%12f", 10.0); <span class="c">/* " 10.000000" (<a href="config.html#print_fp">FF_PRINT_FLOAT</a>) */</span>
<em>f_printf</em>("%.4E", 123.45678); <span class="c">/* "1.2346E+02" (FF_PRINT_FLOAT) */</span>
</pre>
</div>