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.

74 lines
3.0 KiB

  1. /* Copyright 2021 QMK
  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 3 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. #include <hal.h>
  18. #if !defined(FEE_PAGE_SIZE) || !defined(FEE_PAGE_COUNT)
  19. # if defined(STM32F103xB) || defined(STM32F042x6) || defined(GD32VF103C8) || defined(GD32VF103CB)
  20. # ifndef FEE_PAGE_SIZE
  21. # define FEE_PAGE_SIZE 0x400 // Page size = 1KByte
  22. # endif
  23. # ifndef FEE_PAGE_COUNT
  24. # define FEE_PAGE_COUNT 2 // How many pages are used
  25. # endif
  26. # elif defined(STM32F103xE) || defined(STM32F303xC) || defined(STM32F072xB) || defined(STM32F070xB)
  27. # ifndef FEE_PAGE_SIZE
  28. # define FEE_PAGE_SIZE 0x800 // Page size = 2KByte
  29. # endif
  30. # ifndef FEE_PAGE_COUNT
  31. # define FEE_PAGE_COUNT 4 // How many pages are used
  32. # endif
  33. # elif defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xG) || defined(STM32F411xE)
  34. # ifndef FEE_PAGE_SIZE
  35. # define FEE_PAGE_SIZE 0x4000 // Page size = 16KByte
  36. # endif
  37. # ifndef FEE_PAGE_COUNT
  38. # define FEE_PAGE_COUNT 1 // How many pages are used
  39. # endif
  40. # endif
  41. #endif
  42. #if !defined(FEE_MCU_FLASH_SIZE)
  43. # if defined(STM32F042x6)
  44. # define FEE_MCU_FLASH_SIZE 32 // Size in Kb
  45. # elif defined(GD32VF103C8)
  46. # define FEE_MCU_FLASH_SIZE 64 // Size in Kb
  47. # elif defined(STM32F103xB) || defined(STM32F072xB) || defined(STM32F070xB) || defined(GD32VF103CB)
  48. # define FEE_MCU_FLASH_SIZE 128 // Size in Kb
  49. # elif defined(STM32F303xC) || defined(STM32F401xC)
  50. # define FEE_MCU_FLASH_SIZE 256 // Size in Kb
  51. # elif defined(STM32F103xE) || defined(STM32F401xE) || defined(STM32F411xE)
  52. # define FEE_MCU_FLASH_SIZE 512 // Size in Kb
  53. # elif defined(STM32F405xG)
  54. # define FEE_MCU_FLASH_SIZE 1024 // Size in Kb
  55. # endif
  56. #endif
  57. /* Start of the emulated eeprom */
  58. #if !defined(FEE_PAGE_BASE_ADDRESS)
  59. # if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xG) || defined(STM32F411xE)
  60. # ifndef FEE_PAGE_BASE_ADDRESS
  61. # define FEE_PAGE_BASE_ADDRESS 0x08004000 // bodge to force 2nd 16k page
  62. # endif
  63. # else
  64. # ifndef FEE_FLASH_BASE
  65. # define FEE_FLASH_BASE 0x8000000
  66. # endif
  67. /* Default to end of flash */
  68. # define FEE_PAGE_BASE_ADDRESS ((uintptr_t)(FEE_FLASH_BASE) + FEE_MCU_FLASH_SIZE * 1024 - (FEE_PAGE_COUNT * FEE_PAGE_SIZE))
  69. # endif
  70. #endif