您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

197 行
7.0KB

  1. /* Arduino SdFat Library
  2. * Copyright (C) 2012 by William Greiman
  3. *
  4. * This file is part of the Arduino SdFat Library
  5. *
  6. * This Library is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This Library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the Arduino SdFat Library. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file
  22. * \brief configuration definitions
  23. */
  24. #ifndef SdFatConfig_h
  25. #define SdFatConfig_h
  26. #include <stdint.h>
  27. //------------------------------------------------------------------------------
  28. /**
  29. * Set USE_SEPARATE_FAT_CACHE nonzero to use a second 512 byte cache
  30. * for FAT table entries. Improves performance for large writes that
  31. * are not a multiple of 512 bytes.
  32. */
  33. #ifdef __arm__
  34. #define USE_SEPARATE_FAT_CACHE 1
  35. #else // __arm__
  36. #define USE_SEPARATE_FAT_CACHE 0
  37. #endif // __arm__
  38. //------------------------------------------------------------------------------
  39. /**
  40. * Set USE_MULTI_BLOCK_SD_IO nonzero to use multi-block SD read/write.
  41. *
  42. * Don't use mult-block read/write on small AVR boards.
  43. */
  44. #if defined(RAMEND) && RAMEND < 3000
  45. #define USE_MULTI_BLOCK_SD_IO 0
  46. #else
  47. #define USE_MULTI_BLOCK_SD_IO 1
  48. #endif
  49. //------------------------------------------------------------------------------
  50. /**
  51. * To enable SD card CRC checking set USE_SD_CRC nonzero.
  52. *
  53. * Set USE_SD_CRC to 1 to use a smaller slower CRC-CCITT function.
  54. *
  55. * Set USE_SD_CRC to 2 to used a larger faster table driven CRC-CCITT function.
  56. */
  57. #define USE_SD_CRC 0
  58. //------------------------------------------------------------------------------
  59. /**
  60. * To use multiple SD cards set USE_MULTIPLE_CARDS nonzero.
  61. *
  62. * Using multiple cards costs about 200 bytes of flash.
  63. *
  64. * Each card requires about 550 bytes of SRAM so use of a Mega is recommended.
  65. */
  66. #define USE_MULTIPLE_CARDS 0
  67. //------------------------------------------------------------------------------
  68. /**
  69. * Set DESTRUCTOR_CLOSES_FILE nonzero to close a file in its destructor.
  70. *
  71. * Causes use of lots of heap in ARM.
  72. */
  73. #define DESTRUCTOR_CLOSES_FILE 0
  74. //------------------------------------------------------------------------------
  75. /**
  76. * For AVR
  77. *
  78. * Set USE_SERIAL_FOR_STD_OUT nonzero to use Serial (the HardwareSerial class)
  79. * for error messages and output from print functions like ls().
  80. *
  81. * If USE_SERIAL_FOR_STD_OUT is zero, a small non-interrupt driven class
  82. * is used to output messages to serial port zero. This allows an alternate
  83. * Serial library like SerialPort to be used with SdFat.
  84. *
  85. * You can redirect stdOut with SdFat::setStdOut(Print* stream) and
  86. * get the current stream with SdFat::stdOut().
  87. */
  88. #define USE_SERIAL_FOR_STD_OUT 0
  89. //------------------------------------------------------------------------------
  90. /**
  91. * Call flush for endl if ENDL_CALLS_FLUSH is nonzero
  92. *
  93. * The standard for iostreams is to call flush. This is very costly for
  94. * SdFat. Each call to flush causes 2048 bytes of I/O to the SD.
  95. *
  96. * SdFat has a single 512 byte buffer for SD I/O so it must write the current
  97. * data block to the SD, read the directory block from the SD, update the
  98. * directory entry, write the directory block to the SD and read the data
  99. * block back into the buffer.
  100. *
  101. * The SD flash memory controller is not designed for this many rewrites
  102. * so performance may be reduced by more than a factor of 100.
  103. *
  104. * If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force
  105. * all data to be written to the SD.
  106. */
  107. #define ENDL_CALLS_FLUSH 0
  108. //------------------------------------------------------------------------------
  109. /**
  110. * Allow FAT12 volumes if FAT12_SUPPORT is nonzero.
  111. * FAT12 has not been well tested.
  112. */
  113. #define FAT12_SUPPORT 0
  114. //------------------------------------------------------------------------------
  115. /**
  116. * SPI SCK divisor for SD initialization commands.
  117. * or greater
  118. */
  119. #ifdef __AVR__
  120. const uint8_t SPI_SCK_INIT_DIVISOR = 64;
  121. #else
  122. const uint8_t SPI_SCK_INIT_DIVISOR = 128;
  123. #endif
  124. //------------------------------------------------------------------------------
  125. /**
  126. * Set ENABLE_SPI_TRANSACTION nonzero to enable the SPI transaction feature
  127. * of the standard Arduino SPI library. You must include SPI.h in your
  128. * sketches when ENABLE_SPI_TRANSACTION is nonzero.
  129. */
  130. #define ENABLE_SPI_TRANSACTION 0
  131. //------------------------------------------------------------------------------
  132. /**
  133. * Set ENABLE_SPI_YIELD nonzero to enable release of the SPI bus during
  134. * SD card busy waits.
  135. *
  136. * This will allow interrupt routines to access the SPI bus if
  137. * ENABLE_SPI_TRANSACTION is nonzero.
  138. *
  139. * Setting ENABLE_SPI_YIELD will introduce some extra overhead and will
  140. * slightly slow transfer rates. A few older SD cards may fail when
  141. * ENABLE_SPI_YIELD is nonzero.
  142. */
  143. #define ENABLE_SPI_YIELD 0
  144. //------------------------------------------------------------------------------
  145. /**
  146. * Force use of Arduino Standard SPI library if USE_ARDUINO_SPI_LIBRARY
  147. * is nonzero. This will override native and software SPI for all boards.
  148. */
  149. #define USE_ARDUINO_SPI_LIBRARY 0
  150. //------------------------------------------------------------------------------
  151. /**
  152. * Define AVR_SOF_SPI nonzero to use software SPI on all AVR Arduinos.
  153. */
  154. #define AVR_SOFT_SPI 0
  155. //------------------------------------------------------------------------------
  156. /**
  157. * Define DUE_SOFT_SPI nonzero to use software SPI on Due Arduinos.
  158. */
  159. #define DUE_SOFT_SPI 0
  160. //------------------------------------------------------------------------------
  161. /**
  162. * Define LEONARDO_SOFT_SPI nonzero to use software SPI on Leonardo Arduinos.
  163. * LEONARDO_SOFT_SPI allows an unmodified 328 Shield to be used
  164. * on Leonardo Arduinos.
  165. */
  166. #define LEONARDO_SOFT_SPI 0
  167. //------------------------------------------------------------------------------
  168. /**
  169. * Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos.
  170. * MEGA_SOFT_SPI allows an unmodified 328 Shield to be used
  171. * on Mega Arduinos.
  172. */
  173. #define MEGA_SOFT_SPI 0
  174. //------------------------------------------------------------------------------
  175. /**
  176. * Set TEENSY3_SOFT_SPI nonzero to use software SPI on Teensy 3.x boards.
  177. */
  178. #define TEENSY3_SOFT_SPI 0
  179. //------------------------------------------------------------------------------
  180. /**
  181. * Define software SPI pins. Default allows Uno shields to be used on other
  182. * boards.
  183. */
  184. // define software SPI pins
  185. /** Default Software SPI chip select pin */
  186. uint8_t const SOFT_SPI_CS_PIN = 10;
  187. /** Software SPI Master Out Slave In pin */
  188. uint8_t const SOFT_SPI_MOSI_PIN = 11;
  189. /** Software SPI Master In Slave Out pin */
  190. uint8_t const SOFT_SPI_MISO_PIN = 12;
  191. /** Software SPI Clock pin */
  192. uint8_t const SOFT_SPI_SCK_PIN = 13;
  193. #endif // SdFatConfig_h