wear_leveling_flash_spi_config.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2022 Nick Brassel (@tzarc)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #ifndef __ASSEMBLER__
  5. # include <stdlib.h>
  6. # include <stdint.h>
  7. # include "flash_spi.h"
  8. #endif
  9. // Use 1 block -- check the config for the SPI flash to determine how big it is
  10. #ifndef WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT
  11. # define WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT 1
  12. #endif // WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT
  13. // Start at the first block of the external flash
  14. #ifndef WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET
  15. # define WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET 0
  16. #endif // WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET
  17. // 8-byte writes by default
  18. #ifndef BACKING_STORE_WRITE_SIZE
  19. # define BACKING_STORE_WRITE_SIZE 8
  20. #endif
  21. // The space allocated by the block
  22. #ifndef WEAR_LEVELING_BACKING_SIZE
  23. # define WEAR_LEVELING_BACKING_SIZE ((EXTERNAL_FLASH_BLOCK_SIZE) * (WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT))
  24. #endif // WEAR_LEVELING_BACKING_SIZE
  25. // Use half of the backing size for logical EEPROM
  26. #ifndef WEAR_LEVELING_LOGICAL_SIZE
  27. # define WEAR_LEVELING_LOGICAL_SIZE ((WEAR_LEVELING_BACKING_SIZE) / 2)
  28. #endif // WEAR_LEVELING_LOGICAL_SIZE