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.

80 lines
2.4 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. The slave select pin of the EEPROM.
  19. This needs to be a normal GPIO pin_t value, such as A7.
  20. */
  21. #ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN
  22. # error "No chip select pin defined -- missing EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN"
  23. #endif
  24. /*
  25. The clock divisor for SPI to ensure that the MCU is within the
  26. specifications of the EEPROM chip. Generally this will be PCLK divided by
  27. the intended divisor -- check your clock settings and the datasheet of
  28. your EEPROM.
  29. */
  30. #ifndef EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR
  31. # ifdef __AVR__
  32. # define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8
  33. # else
  34. # define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 64
  35. # endif
  36. #endif
  37. /*
  38. The SPI mode to communicate with the EEPROM.
  39. */
  40. #ifndef EXTERNAL_EEPROM_SPI_MODE
  41. # define EXTERNAL_EEPROM_SPI_MODE 0
  42. #endif
  43. /*
  44. Whether or not the SPI communication between the MCU and EEPROM should be
  45. LSB-first.
  46. */
  47. #ifndef EXTERNAL_EEPROM_SPI_LSBFIRST
  48. # define EXTERNAL_EEPROM_SPI_LSBFIRST false
  49. #endif
  50. /*
  51. The total size of the EEPROM, in bytes. The EEPROM datasheet will usually
  52. specify this value in kbits, and will require conversion to bytes.
  53. */
  54. #ifndef EXTERNAL_EEPROM_BYTE_COUNT
  55. # define EXTERNAL_EEPROM_BYTE_COUNT 8192
  56. #endif
  57. /*
  58. The page size in bytes of the EEPROM, as specified in the datasheet.
  59. */
  60. #ifndef EXTERNAL_EEPROM_PAGE_SIZE
  61. # define EXTERNAL_EEPROM_PAGE_SIZE 32
  62. #endif
  63. /*
  64. The address size in bytes of the EEPROM. For EEPROMs with <=256 bytes, this
  65. will likely be 1. For EEPROMs >256 and <=65536, this will be 2. For EEPROMs
  66. >65536, this will likely need to be 4.
  67. As expected, consult the datasheet for specifics of your EEPROM.
  68. */
  69. #ifndef EXTERNAL_EEPROM_ADDRESS_SIZE
  70. # define EXTERNAL_EEPROM_ADDRESS_SIZE 2
  71. #endif