You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.8 KiB

  1. /* Copyright 2020 Nick Brassel (tzarc)
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. /*
  18. Default device configurations:
  19. For the Adafruit SPI Non-Volatile FRAM Breakout: https://www.adafruit.com/product/1897
  20. #define EEPROM_SPI_MB85RS64V
  21. */
  22. #if defined(EEPROM_SPI_MB85RS64V)
  23. # define EXTERNAL_EEPROM_BYTE_COUNT 8192
  24. # define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer
  25. # define EXTERNAL_EEPROM_ADDRESS_SIZE 2
  26. #endif
  27. /*
  28. The slave select pin of the EEPROM.
  29. This needs to be a normal GPIO pin_t value, such as A7.
  30. */
  31. #ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN
  32. # error "No chip select pin defined -- missing EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN"
  33. #endif
  34. /*
  35. The clock divisor for SPI to ensure that the MCU is within the
  36. specifications of the EEPROM chip. Generally this will be PCLK divided by
  37. the intended divisor -- check your clock settings and the datasheet of
  38. your EEPROM.
  39. */
  40. #ifndef EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR
  41. # ifdef __AVR__
  42. # define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8
  43. # else
  44. # define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 64
  45. # endif
  46. #endif
  47. /*
  48. The SPI mode to communicate with the EEPROM.
  49. */
  50. #ifndef EXTERNAL_EEPROM_SPI_MODE
  51. # define EXTERNAL_EEPROM_SPI_MODE 0
  52. #endif
  53. /*
  54. Whether or not the SPI communication between the MCU and EEPROM should be
  55. LSB-first.
  56. */
  57. #ifndef EXTERNAL_EEPROM_SPI_LSBFIRST
  58. # define EXTERNAL_EEPROM_SPI_LSBFIRST false
  59. #endif
  60. /*
  61. The total size of the EEPROM, in bytes. The EEPROM datasheet will usually
  62. specify this value in kbits, and will require conversion to bytes.
  63. */
  64. #ifndef EXTERNAL_EEPROM_BYTE_COUNT
  65. # define EXTERNAL_EEPROM_BYTE_COUNT 8192
  66. #endif
  67. /*
  68. The page size in bytes of the EEPROM, as specified in the datasheet.
  69. */
  70. #ifndef EXTERNAL_EEPROM_PAGE_SIZE
  71. # define EXTERNAL_EEPROM_PAGE_SIZE 32
  72. #endif
  73. /*
  74. The address size in bytes of the EEPROM. For EEPROMs with <=256 bytes, this
  75. will likely be 1. For EEPROMs >256 and <=65536, this will be 2. For EEPROMs
  76. >65536, this will likely need to be 4.
  77. As expected, consult the datasheet for specifics of your EEPROM.
  78. */
  79. #ifndef EXTERNAL_EEPROM_ADDRESS_SIZE
  80. # define EXTERNAL_EEPROM_ADDRESS_SIZE 2
  81. #endif