Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

193 lines
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. #ifdef __AVR__
  28. #include <avr/io.h>
  29. #endif // __AVR__
  30. //------------------------------------------------------------------------------
  31. /**
  32. * Set USE_MULTIPLE_SPI_TYPES nonzero to enable the SdFatSoftSpi and
  33. * SdFatLibSpi classes. SdFatSoftSpi uses software SPI and SdFatLibSpi
  34. * uses the standard Arduino SPI library.
  35. */
  36. #define USE_MULTIPLE_SPI_TYPES 0
  37. //------------------------------------------------------------------------------
  38. /**
  39. * To enable SD card CRC checking set USE_SD_CRC nonzero.
  40. *
  41. * Set USE_SD_CRC to 1 to use a smaller slower CRC-CCITT function.
  42. *
  43. * Set USE_SD_CRC to 2 to used a larger faster table driven CRC-CCITT function.
  44. */
  45. #define USE_SD_CRC 0
  46. //------------------------------------------------------------------------------
  47. /**
  48. * Set ENABLE_SPI_TRANSACTION nonzero to enable the SPI transaction feature
  49. * of the standard Arduino SPI library. You must include SPI.h in your
  50. * sketches when ENABLE_SPI_TRANSACTION is nonzero.
  51. */
  52. #define ENABLE_SPI_TRANSACTION 0
  53. //------------------------------------------------------------------------------
  54. /**
  55. * Set ENABLE_SPI_YIELD nonzero to enable release of the SPI bus during
  56. * SD card busy waits.
  57. *
  58. * This will allow interrupt routines to access the SPI bus if
  59. * ENABLE_SPI_TRANSACTION is nonzero.
  60. *
  61. * Setting ENABLE_SPI_YIELD will introduce some extra overhead and will
  62. * slightly slow transfer rates. A few older SD cards may fail when
  63. * ENABLE_SPI_YIELD is nonzero.
  64. */
  65. #define ENABLE_SPI_YIELD 0
  66. //------------------------------------------------------------------------------
  67. /**
  68. * Set USE_ARDUINO_SPI_LIBRARY nonzero to force use of the Arduino Standard
  69. * SPI library in the SdFat class. This will override native and software
  70. * SPI for all boards.
  71. */
  72. #define USE_ARDUINO_SPI_LIBRARY 0
  73. //------------------------------------------------------------------------------
  74. /**
  75. * Set AVR_SOFT_SPI nonzero to use software SPI in the SdFat class
  76. * on all AVR Arduinos. Set the soft SPI pins below.
  77. */
  78. #define AVR_SOFT_SPI 0
  79. //------------------------------------------------------------------------------
  80. /**
  81. * Set DUE_SOFT_SPI nonzero to use software SPI in the SdFat class
  82. * on Due Arduinos. Set the soft SPI pins below.
  83. */
  84. #define DUE_SOFT_SPI 0
  85. //------------------------------------------------------------------------------
  86. /**
  87. * Set LEONARDO_SOFT_SPI nonzero to use software SPI in the SdFat class
  88. * on Leonardo Arduinos. Set the soft SPI pins below.
  89. *
  90. * LEONARDO_SOFT_SPI allows an unmodified 328 Shield to be used
  91. * on Leonardo Arduinos.
  92. */
  93. #define LEONARDO_SOFT_SPI 0
  94. //------------------------------------------------------------------------------
  95. /**
  96. * Set MEGA_SOFT_SPI nonzero to use software SPI in the SdFat class
  97. * on Mega Arduinos. Set the soft SPI pins below.
  98. *
  99. * MEGA_SOFT_SPI allows an unmodified 328 Shield to be used
  100. * on Mega Arduinos. Set the soft SPI pins below.
  101. */
  102. #define MEGA_SOFT_SPI 0
  103. //------------------------------------------------------------------------------
  104. /**
  105. * Set TEENSY3_SOFT_SPI nonzero to use software SPI in the SdFat class
  106. * on Teensy 3.x boards. Set the soft SPI pins below.
  107. */
  108. #define TEENSY3_SOFT_SPI 0
  109. //------------------------------------------------------------------------------
  110. /**
  111. * Define software SPI pins. Default allows Uno shields to be used on other
  112. * boards.
  113. */
  114. // define software SPI pins
  115. /** Software SPI Master Out Slave In pin */
  116. uint8_t const SOFT_SPI_MOSI_PIN = 11;
  117. /** Software SPI Master In Slave Out pin */
  118. uint8_t const SOFT_SPI_MISO_PIN = 12;
  119. /** Software SPI Clock pin */
  120. uint8_t const SOFT_SPI_SCK_PIN = 13;
  121. //------------------------------------------------------------------------------
  122. /**
  123. * Set FAT12_SUPPORT nonzero to enable use if FAT12 volumes.
  124. * FAT12 has not been well tested and requires additional flash.
  125. */
  126. #define FAT12_SUPPORT 0
  127. //------------------------------------------------------------------------------
  128. /**
  129. * Set DESTRUCTOR_CLOSES_FILE nonzero to close a file in its destructor.
  130. *
  131. * Causes use of lots of heap in ARM.
  132. */
  133. #define DESTRUCTOR_CLOSES_FILE 0
  134. //------------------------------------------------------------------------------
  135. /**
  136. * Call flush for endl if ENDL_CALLS_FLUSH is nonzero
  137. *
  138. * The standard for iostreams is to call flush. This is very costly for
  139. * SdFat. Each call to flush causes 2048 bytes of I/O to the SD.
  140. *
  141. * SdFat has a single 512 byte buffer for SD I/O so it must write the current
  142. * data block to the SD, read the directory block from the SD, update the
  143. * directory entry, write the directory block to the SD and read the data
  144. * block back into the buffer.
  145. *
  146. * The SD flash memory controller is not designed for this many rewrites
  147. * so performance may be reduced by more than a factor of 100.
  148. *
  149. * If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force
  150. * all data to be written to the SD.
  151. */
  152. #define ENDL_CALLS_FLUSH 0
  153. //------------------------------------------------------------------------------
  154. /**
  155. * Set SD_FILE_USES_STREAM nonzero to use Stream instead of Print for SdFile.
  156. * Using Stream will use more flash and may cause compatibility problems
  157. * with code written for older versions of SdFat.
  158. */
  159. #define SD_FILE_USES_STREAM 0
  160. //------------------------------------------------------------------------------
  161. /**
  162. * SPI SCK divisor for SD initialization commands.
  163. * or greater
  164. */
  165. #ifdef __AVR__
  166. const uint8_t SPI_SCK_INIT_DIVISOR = 64;
  167. #else
  168. const uint8_t SPI_SCK_INIT_DIVISOR = 128;
  169. #endif
  170. //------------------------------------------------------------------------------
  171. /**
  172. * Set USE_SEPARATE_FAT_CACHE nonzero to use a second 512 byte cache
  173. * for FAT table entries. Improves performance for large writes that
  174. * are not a multiple of 512 bytes.
  175. */
  176. #ifdef __arm__
  177. #define USE_SEPARATE_FAT_CACHE 1
  178. #else // __arm__
  179. #define USE_SEPARATE_FAT_CACHE 0
  180. #endif // __arm__
  181. //------------------------------------------------------------------------------
  182. /**
  183. * Set USE_MULTI_BLOCK_SD_IO nonzero to use multi-block SD read/write.
  184. *
  185. * Don't use mult-block read/write on small AVR boards.
  186. */
  187. #if defined(RAMEND) && RAMEND < 3000
  188. #define USE_MULTI_BLOCK_IO 0
  189. #else // RAMEND
  190. #define USE_MULTI_BLOCK_IO 1
  191. #endif // RAMEND
  192. #endif // SdFatConfig_h