Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

206 rindas
16KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.16"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>SdFat: Arduino SdFat Library</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="search/searchdata.js"></script>
  14. <script type="text/javascript" src="search/search.js"></script>
  15. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  19. <div id="titlearea">
  20. <table cellspacing="0" cellpadding="0">
  21. <tbody>
  22. <tr style="height: 56px;">
  23. <td id="projectalign" style="padding-left: 0.5em;">
  24. <div id="projectname">SdFat
  25. </div>
  26. </td>
  27. </tr>
  28. </tbody>
  29. </table>
  30. </div>
  31. <!-- end header part -->
  32. <!-- Generated by Doxygen 1.8.16 -->
  33. <script type="text/javascript">
  34. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  35. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  36. /* @license-end */
  37. </script>
  38. <script type="text/javascript" src="menudata.js"></script>
  39. <script type="text/javascript" src="menu.js"></script>
  40. <script type="text/javascript">
  41. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  42. $(function() {
  43. initMenu('',true,false,'search.php','Search');
  44. $(document).ready(function() { init_search(); });
  45. });
  46. /* @license-end */</script>
  47. <div id="main-nav"></div>
  48. </div><!-- top -->
  49. <!-- window showing the filter options -->
  50. <div id="MSearchSelectWindow"
  51. onmouseover="return searchBox.OnSearchSelectShow()"
  52. onmouseout="return searchBox.OnSearchSelectHide()"
  53. onkeydown="return searchBox.OnSearchSelectKey(event)">
  54. </div>
  55. <!-- iframe showing the search results (closed by default) -->
  56. <div id="MSearchResultsWindow">
  57. <iframe src="javascript:void(0)" frameborder="0"
  58. name="MSearchResults" id="MSearchResults">
  59. </iframe>
  60. </div>
  61. <div class="PageDoc"><div class="header">
  62. <div class="headertitle">
  63. <div class="title">Arduino SdFat Library </div> </div>
  64. </div><!--header-->
  65. <div class="contents">
  66. <div class="textblock"><p>Copyright (c) 2011-2019 Bill Greiman This file is part of the SdFat library for SD memory cards.</p>
  67. <p>MIT License</p>
  68. <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
  69. <p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
  70. <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
  71. <h1><a class="anchor" id="Warn"></a>
  72. Warnings for SdFat V2 Alpha/Beta</h1>
  73. <p>This is a development version of SdFat V2 and any feature may change. There are bound to be serious bugs, and stability/compatibility problems. <br />
  74. </p>
  75. <p>Initially this is closer to an alpha test so expect stability problems.</p>
  76. <p>You can help by posting issues for bugs you find. I am doing a great deal of testing but actual applications make the best test cases.</p>
  77. <p>Please try to isolate the bug and post code that demonstrates the bug.</p>
  78. <p>The purpose of this release is to get feedback on features and address compatibility problems.</p>
  79. <p>You should edit <a class="el" href="_sd_fat_config_8h.html" title="configuration definitions">SdFatConfig.h</a> to select features. <a class="el" href="_sd_fat_config_8h.html" title="configuration definitions">SdFatConfig.h</a> is suitable for UNO and other small AVR boards.</p>
  80. <h1><a class="anchor" id="Intro"></a>
  81. Introduction</h1>
  82. <p>The Arduino SdFat library supports FAT16, FAT32, and exFAT file systems on Standard SD, SDHC, and SDXC cards.</p>
  83. <p>In SdFat version 1, SdFat and File are the main classes.</p>
  84. <p>In SdFat version 2, SdFat and File are defined by typedefs in terms of the following classes.</p>
  85. <p>The file system classes in the SdFat library are <a class="el" href="class_sd_fat32.html" title="SD file system class for FAT volumes.">SdFat32</a>, <a class="el" href="class_sd_ex_fat.html" title="SD file system class for exFAT volumes.">SdExFat</a>, and <a class="el" href="class_sd_fs.html" title="SD file system class for FAT16, FAT32, and exFAT volumes.">SdFs</a>. <a class="el" href="class_sd_fat32.html" title="SD file system class for FAT volumes.">SdFat32</a> supports FAT16 and FAT32. <a class="el" href="class_sd_ex_fat.html" title="SD file system class for exFAT volumes.">SdExFat</a> supports exFAT, <a class="el" href="class_sd_fs.html" title="SD file system class for FAT16, FAT32, and exFAT volumes.">SdFs</a> supports FAT16, FAT32, and exFAT.</p>
  86. <p>The corresponding file classes are <a class="el" href="class_file32.html" title="FAT16/FAT32 file with Arduino Stream.">File32</a>, <a class="el" href="class_ex_file.html" title="exFAT file with Arduino Stream.">ExFile</a>, and <a class="el" href="class_fs_file.html" title="FsBaseFile file with Arduino Stream.">FsFile</a>.</p>
  87. <p>The types for SdFat and File are defined in <a class="el" href="_sd_fat_config_8h.html" title="configuration definitions">SdFatConfig.h</a>. This version uses FAT16/FAT32 for small AVR boards and FAT16/FAT32/exFAT for all other boards.</p>
  88. <div class="fragment"><div class="line"><span class="comment">// File types for SdFat, File, SdFile, SdBaseFile, fstream,</span></div>
  89. <div class="line"><span class="comment">// ifstream, and ofstream.</span></div>
  90. <div class="line"><span class="comment">//</span></div>
  91. <div class="line"><span class="comment">// Set SDFAT_FILE_TYPE to:</span></div>
  92. <div class="line"><span class="comment">// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.</span></div>
  93. <div class="line"><span class="comment">//</span></div>
  94. <div class="line"><span class="preprocessor">#if defined(__AVR__) &amp;&amp; FLASHEND &lt; 0X8000</span></div>
  95. <div class="line"><span class="comment">// FAT16/FAT32 for 32K AVR boards.</span></div>
  96. <div class="line"><span class="preprocessor">#define SDFAT_FILE_TYPE 1</span></div>
  97. <div class="line"><span class="preprocessor">#else // defined(__AVR__) &amp;&amp; FLASHEND &lt; 0X8000</span></div>
  98. <div class="line"><span class="comment">// FAT16/FAT32 and exFAT for all other boards.</span></div>
  99. <div class="line"><span class="preprocessor">#define SDFAT_FILE_TYPE 3</span></div>
  100. <div class="line"><span class="preprocessor">#endif // defined(__AVR__) &amp;&amp; FLASHEND &lt; 0X8000</span></div>
  101. </div><!-- fragment --><p>It is possible to use option three, support or FAT16/FAT32 and exFat on an Uno or other AVR board with 32KB flash and 2KB SRAM but memory will be very limited.</p>
  102. <p>Uno memory use for a simple data logger is:</p>
  103. <blockquote class="doxtable">
  104. <p>option 1, FAT16/FAT32, 11902 bytes of flash and 855 bytes of SRAM.</p>
  105. <p>option 2, exFAT, 14942 bytes of flash and 895 bytes of SRAM.</p>
  106. <p>option 3, FAT16/FAT32 and exFAT, 21834 bytes of flash and 908 bytes of SRAM. </p>
  107. </blockquote>
  108. <p>Please read documentation under the above classes tab for more information.</p>
  109. <p>A number of example are provided in the SdFat/examples folder. These were developed to test SdFat and illustrate its use.</p>
  110. <h1><a class="anchor" id="exFAT"></a>
  111. exFAT Features</h1>
  112. <p>exFAT has many features not available in FAT16/FAT32.</p>
  113. <p>Files larger than 4GiB, 64-bit file size and file position.</p>
  114. <p>Free space allocation performance improved by using a free space bitmap.</p>
  115. <p>Removal of the physical "." and ".." directory entries that appear in FAT16/FAT32 subdirectories.</p>
  116. <p>Better support for large flash pages with boundary alignment offsets for the FAT table and data region.</p>
  117. <p>exFAT files have two separate 64-bit length fields. The DataLength field indicate how much space is allocate to the file. The ValidDataLength field indicates how much actual data has been written to the file.</p>
  118. <p>An exFAT file can be contiguous with pre-allocate clusters and bypass the use of the FAT table. In this case the contiguous flag is set in the directory entry. This allows an entire file to be written as one large multi-block write.</p>
  119. <h1><a class="anchor" id="SDPath"></a>
  120. Paths and Working Directories</h1>
  121. <p>Relative paths in SdFat are resolved in a manner similar to Windows.</p>
  122. <p>Each instance of <a class="el" href="class_sd_fat32.html" title="SD file system class for FAT volumes.">SdFat32</a>, <a class="el" href="class_sd_ex_fat.html" title="SD file system class for exFAT volumes.">SdExFat</a>, and <a class="el" href="class_sd_fs.html" title="SD file system class for FAT16, FAT32, and exFAT volumes.">SdFs</a> has a current directory. <br />
  123. This directory is called the volume working directory, vwd. <br />
  124. Initially this directory is the root directory for the volume.</p>
  125. <p>The volume working directory is changed by calling the chdir(path).</p>
  126. <p>The call sd.chdir("/2014") will change the volume working directory for sd to "/2014", assuming "/2014" exists.</p>
  127. <p>Relative paths for member functions are resolved by starting at the volume working directory.</p>
  128. <p>For example, the call sd.mkdir("April") will create the directory "/2014/April" assuming the volume working directory is "/2014".</p>
  129. <p>There is current working directory, cwd, that is used to resolve paths for file.open() calls.</p>
  130. <p>For a single SD card, the current working directory is always the volume working directory for that card.</p>
  131. <p>For multiple SD cards the current working directory is set to the volume working directory of a card by calling the chvol() member function. The chvol() call is like the Windows &lt;drive letter&gt;: command.</p>
  132. <p>The call sd2.chvol() will set the current working directory to the volume working directory for sd2.</p>
  133. <p>If the volume working directory for sd2 is "/music" the call</p>
  134. <p>file.open("BigBand.wav", O_READ);</p>
  135. <p>will open "/music/BigBand.wav" on sd2.</p>
  136. <h1><a class="anchor" id="Install"></a>
  137. Installation</h1>
  138. <p>You must manually install SdFat by renaming the download folder SdFat and copy the SdFat folder to the Arduino libraries folder in your sketchbook folder.</p>
  139. <p>It will be necessary to unzip and rename the folder if you download a zip file from GitHub.</p>
  140. <p>See the Manual installation section of this guide.</p>
  141. <p><a href="http://arduino.cc/en/Guide/Libraries">http://arduino.cc/en/Guide/Libraries</a></p>
  142. <h1><a class="anchor" id="SDconfig"></a>
  143. SdFat Configuration</h1>
  144. <p>Several configuration options may be changed by editing the <a class="el" href="_sd_fat_config_8h.html" title="configuration definitions">SdFatConfig.h</a> file in the SdFat/src folder.</p>
  145. <p>Here are a few of the key options.</p>
  146. <p>If the symbol ENABLE_DEDICATED_SPI is nonzero, multi-block SD I/O may be used for better performance. The SPI bus may not be shared with other devices in this mode.</p>
  147. <p>The symbol SPI_DRIVER_SELECT is used to select the SPI driver.</p>
  148. <blockquote class="doxtable">
  149. <p>If the symbol SPI_DRIVER_SELECT is:</p>
  150. <p>0 - An optimized custom SPI driver is used if it exists else the standard library driver is used.</p>
  151. <p>1 - The standard library driver is always used.</p>
  152. <p>2 - The software SPI driver is always used. </p>
  153. </blockquote>
  154. <p>To enable SD card CRC checking in SPI mode set USE_SD_CRC nonzero.</p>
  155. <p>See <a class="el" href="_sd_fat_config_8h.html" title="configuration definitions">SdFatConfig.h</a> for other options.</p>
  156. <h1><a class="anchor" id="Hardware"></a>
  157. Hardware Configuration</h1>
  158. <p>The hardware interface to the SD card should not use a resistor based level shifter. Resistor based level shifters results in signal rise times that are too slow for many newer SD cards.</p>
  159. <h1><a class="anchor" id="HowTo"></a>
  160. How to format SD Cards as FAT Volumes</h1>
  161. <p>The best way to restore an SD card's format on a PC or Mac is to use SDFormatter which can be downloaded from:</p>
  162. <p><a href="http://www.sdcard.org/downloads">http://www.sdcard.org/downloads</a></p>
  163. <p>A formatter program, SdFormatter.ino, is included in the SdFat/examples/SdFormatter directory. This program attempts to emulate SD Association's SDFormatter.</p>
  164. <p>SDFormatter aligns flash erase boundaries with file system structures which reduces write latency and file system overhead.</p>
  165. <p>The PC/Mac SDFormatter does not have an option for FAT type so it may format very small cards as FAT12. Use the SdFormatter example to force FAT16 formatting of small cards.</p>
  166. <p>Do not format the SD card with an OS utility, OS utilities do not format SD cards in conformance with the SD standard.</p>
  167. <p>You should use a freshly formatted SD card for best performance. FAT file systems become slower if many files have been created and deleted. This is because the directory entry for a deleted file is marked as deleted, but is not deleted. When a new file is created, these entries must be scanned before creating the file. Also files can become fragmented which causes reads and writes to be slower.</p>
  168. <h1><a class="anchor" id="ExampleFiles"></a>
  169. Examples</h1>
  170. <p>A number of examples are provided in the SdFat/examples folder.</p>
  171. <p>To access these examples from the Arduino development environment go to: File -&gt; Examples -&gt; SdFat -&gt; &lt;program Name&gt;</p>
  172. <p>Compile, upload to your Arduino and click on Serial Monitor to run the example.</p>
  173. <p>Here is a list:</p>
  174. <p>AvrAdcLogger - Fast AVR ADC logger using Timer/ADC interrupts.</p>
  175. <p>BackwardCompatibility - Demonstrate SD.h compatibility with SdFat.h.</p>
  176. <p>bench - A read/write benchmark.</p>
  177. <p><a class="el" href="class_buffered_print.html" title="Fast buffered print template.">BufferedPrint</a> - Demo a buffered print class for AVR loggers.</p>
  178. <p>debug folder - Some of my debug programs - will be remove in the future.</p>
  179. <p>DirectoryFunctions - Use of chdir(), ls(), mkdir(), and rmdir().</p>
  180. <p>examplesV1 folder - Examples from SdFat V1 for compatibility tests.</p>
  181. <p>ExFatFormatter - Produces optimal exFAT format for smaller SD cards.</p>
  182. <p>ExFatLogger - A data-logger optimized for exFAT features.</p>
  183. <p>ExFatUnicodeTest - Test program for Unicode file names.</p>
  184. <p>OpenNext - Open all files in the root dir and print their filename.</p>
  185. <p>ReadCsvFile - Function to read a CSV text file one field at a time.</p>
  186. <p>RtcTimestampTest - Demonstration of timestamps with RTClib.</p>
  187. <p>SdErrorCodes - Produce a list of error codes.</p>
  188. <p>SdFormatter - This program will format an SD, SDHC, or SDXC card.</p>
  189. <p>SdInfo - Initialize an SD card and analyze its structure for trouble shooting.</p>
  190. <p>SoftwareSpi - Demo of limited Software SPI support in SdFat V2.</p>
  191. <p>STM32Test - Example use of two SPI ports on an STM32 board.</p>
  192. <p>TeensyRtcTimestamp - File timestamps for Teensy3.</p>
  193. <p>TeensySdioDemo - Demo of SDIO and SPI modes for the Teensy 3.5/3.6 built-in SD. </p>
  194. </div></div><!-- PageDoc -->
  195. </div><!-- contents -->
  196. <!-- start footer part -->
  197. <hr class="footer"/><address class="footer"><small>
  198. Generated on Fri Dec 6 2019 09:45:12 for SdFat by &#160;<a href="http://www.doxygen.org/index.html">
  199. <img class="footer" src="doxygen.png" alt="doxygen"/>
  200. </a> 1.8.16
  201. </small></address>
  202. </body>
  203. </html>