diff options
Diffstat (limited to 'platforms/chibios/eeprom_stm32_defs.h')
| -rw-r--r-- | platforms/chibios/eeprom_stm32_defs.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/platforms/chibios/eeprom_stm32_defs.h b/platforms/chibios/eeprom_stm32_defs.h new file mode 100644 index 000000000..66904f247 --- /dev/null +++ b/platforms/chibios/eeprom_stm32_defs.h | |||
| @@ -0,0 +1,74 @@ | |||
| 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 | |||
| 18 | #include <hal.h> | ||
| 19 | |||
| 20 | #if !defined(FEE_PAGE_SIZE) || !defined(FEE_PAGE_COUNT) | ||
| 21 | # if defined(STM32F103xB) || defined(STM32F042x6) || defined(GD32VF103C8) || defined(GD32VF103CB) | ||
| 22 | # ifndef FEE_PAGE_SIZE | ||
| 23 | # define FEE_PAGE_SIZE 0x400 // Page size = 1KByte | ||
| 24 | # endif | ||
| 25 | # ifndef FEE_PAGE_COUNT | ||
| 26 | # define FEE_PAGE_COUNT 2 // How many pages are used | ||
| 27 | # endif | ||
| 28 | # elif defined(STM32F103xE) || defined(STM32F303xC) || defined(STM32F072xB) || defined(STM32F070xB) | ||
| 29 | # ifndef FEE_PAGE_SIZE | ||
| 30 | # define FEE_PAGE_SIZE 0x800 // Page size = 2KByte | ||
| 31 | # endif | ||
| 32 | # ifndef FEE_PAGE_COUNT | ||
| 33 | # define FEE_PAGE_COUNT 4 // How many pages are used | ||
| 34 | # endif | ||
| 35 | # elif defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xG) || defined(STM32F411xE) | ||
| 36 | # ifndef FEE_PAGE_SIZE | ||
| 37 | # define FEE_PAGE_SIZE 0x4000 // Page size = 16KByte | ||
| 38 | # endif | ||
| 39 | # ifndef FEE_PAGE_COUNT | ||
| 40 | # define FEE_PAGE_COUNT 1 // How many pages are used | ||
| 41 | # endif | ||
| 42 | # endif | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #if !defined(FEE_MCU_FLASH_SIZE) | ||
| 46 | # if defined(STM32F042x6) | ||
| 47 | # define FEE_MCU_FLASH_SIZE 32 // Size in Kb | ||
| 48 | # elif defined(GD32VF103C8) | ||
| 49 | # define FEE_MCU_FLASH_SIZE 64 // Size in Kb | ||
| 50 | # elif defined(STM32F103xB) || defined(STM32F072xB) || defined(STM32F070xB) || defined(GD32VF103CB) | ||
| 51 | # define FEE_MCU_FLASH_SIZE 128 // Size in Kb | ||
| 52 | # elif defined(STM32F303xC) || defined(STM32F401xC) | ||
| 53 | # define FEE_MCU_FLASH_SIZE 256 // Size in Kb | ||
| 54 | # elif defined(STM32F103xE) || defined(STM32F401xE) || defined(STM32F411xE) | ||
| 55 | # define FEE_MCU_FLASH_SIZE 512 // Size in Kb | ||
| 56 | # elif defined(STM32F405xG) | ||
| 57 | # define FEE_MCU_FLASH_SIZE 1024 // Size in Kb | ||
| 58 | # endif | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* Start of the emulated eeprom */ | ||
| 62 | #if !defined(FEE_PAGE_BASE_ADDRESS) | ||
| 63 | # if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xG) || defined(STM32F411xE) | ||
| 64 | # ifndef FEE_PAGE_BASE_ADDRESS | ||
| 65 | # define FEE_PAGE_BASE_ADDRESS 0x08004000 // bodge to force 2nd 16k page | ||
| 66 | # endif | ||
| 67 | # else | ||
| 68 | # ifndef FEE_FLASH_BASE | ||
| 69 | # define FEE_FLASH_BASE 0x8000000 | ||
| 70 | # endif | ||
| 71 | /* Default to end of flash */ | ||
| 72 | # define FEE_PAGE_BASE_ADDRESS ((uintptr_t)(FEE_FLASH_BASE) + FEE_MCU_FLASH_SIZE * 1024 - (FEE_PAGE_COUNT * FEE_PAGE_SIZE)) | ||
| 73 | # endif | ||
| 74 | #endif | ||
