diff options
author | Joel Challis <git@zvecr.com> | 2021-08-31 00:25:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-31 00:25:41 +0100 |
commit | f2c9e82e5b3887ed28c3a5c68d27c4efaca54201 (patch) | |
tree | 42e04b09167623a8d3809e3dbd4e435bc877a5a5 /tmk_core/common | |
parent | 1e7117317fd8a51f9ca6e926777694b930c9502b (diff) | |
download | qmk_firmware-f2c9e82e5b3887ed28c3a5c68d27c4efaca54201.tar.gz qmk_firmware-f2c9e82e5b3887ed28c3a5c68d27c4efaca54201.zip |
cherry pick tidy up (#14244)
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/chibios/eeprom_stm32.c | 12 | ||||
-rw-r--r-- | tmk_core/common/chibios/flash_stm32.c | 31 | ||||
-rw-r--r-- | tmk_core/common/chibios/flash_stm32.h | 1 | ||||
-rw-r--r-- | tmk_core/common/test/flash_stm32_mock.c | 1 |
4 files changed, 6 insertions, 39 deletions
diff --git a/tmk_core/common/chibios/eeprom_stm32.c b/tmk_core/common/chibios/eeprom_stm32.c index 5bf852fde..64d7d79ba 100644 --- a/tmk_core/common/chibios/eeprom_stm32.c +++ b/tmk_core/common/chibios/eeprom_stm32.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | #include "util.h" | ||
23 | #include "debug.h" | 24 | #include "debug.h" |
24 | #include "eeprom_stm32.h" | 25 | #include "eeprom_stm32.h" |
25 | #include "flash_stm32.h" | 26 | #include "flash_stm32.h" |
@@ -188,9 +189,6 @@ | |||
188 | # endif | 189 | # endif |
189 | #endif | 190 | #endif |
190 | 191 | ||
191 | #define FEE_XSTR(x) FEE_STR(x) | ||
192 | #define FEE_STR(x) #x | ||
193 | |||
194 | /* Size of combined compacted eeprom and write log pages */ | 192 | /* Size of combined compacted eeprom and write log pages */ |
195 | #define FEE_DENSITY_MAX_SIZE (FEE_DENSITY_PAGES * FEE_PAGE_SIZE) | 193 | #define FEE_DENSITY_MAX_SIZE (FEE_DENSITY_PAGES * FEE_PAGE_SIZE) |
196 | /* Addressable range 16KByte: 0 <-> (0x1FFF << 1) */ | 194 | /* Addressable range 16KByte: 0 <-> (0x1FFF << 1) */ |
@@ -198,7 +196,7 @@ | |||
198 | 196 | ||
199 | #ifndef EEPROM_START_ADDRESS /* *TODO: Get rid of this check */ | 197 | #ifndef EEPROM_START_ADDRESS /* *TODO: Get rid of this check */ |
200 | # if FEE_DENSITY_MAX_SIZE > (FEE_MCU_FLASH_SIZE * 1024) | 198 | # if FEE_DENSITY_MAX_SIZE > (FEE_MCU_FLASH_SIZE * 1024) |
201 | # pragma message FEE_XSTR(FEE_DENSITY_MAX_SIZE) " > " FEE_XSTR(FEE_MCU_FLASH_SIZE * 1024) | 199 | # pragma message STR(FEE_DENSITY_MAX_SIZE) " > " STR(FEE_MCU_FLASH_SIZE * 1024) |
202 | # error emulated eeprom: FEE_DENSITY_PAGES is greater than available flash size | 200 | # error emulated eeprom: FEE_DENSITY_PAGES is greater than available flash size |
203 | # endif | 201 | # endif |
204 | #endif | 202 | #endif |
@@ -206,15 +204,15 @@ | |||
206 | /* Size of emulated eeprom */ | 204 | /* Size of emulated eeprom */ |
207 | #ifdef FEE_DENSITY_BYTES | 205 | #ifdef FEE_DENSITY_BYTES |
208 | # if (FEE_DENSITY_BYTES > FEE_DENSITY_MAX_SIZE) | 206 | # if (FEE_DENSITY_BYTES > FEE_DENSITY_MAX_SIZE) |
209 | # pragma message FEE_XSTR(FEE_DENSITY_BYTES) " > " FEE_XSTR(FEE_DENSITY_MAX_SIZE) | 207 | # pragma message STR(FEE_DENSITY_BYTES) " > " STR(FEE_DENSITY_MAX_SIZE) |
210 | # error emulated eeprom: FEE_DENSITY_BYTES exceeds FEE_DENSITY_MAX_SIZE | 208 | # error emulated eeprom: FEE_DENSITY_BYTES exceeds FEE_DENSITY_MAX_SIZE |
211 | # endif | 209 | # endif |
212 | # if (FEE_DENSITY_BYTES == FEE_DENSITY_MAX_SIZE) | 210 | # if (FEE_DENSITY_BYTES == FEE_DENSITY_MAX_SIZE) |
213 | # pragma message FEE_XSTR(FEE_DENSITY_BYTES) " == " FEE_XSTR(FEE_DENSITY_MAX_SIZE) | 211 | # pragma message STR(FEE_DENSITY_BYTES) " == " STR(FEE_DENSITY_MAX_SIZE) |
214 | # warning emulated eeprom: FEE_DENSITY_BYTES leaves no room for a write log. This will greatly increase the flash wear rate! | 212 | # warning emulated eeprom: FEE_DENSITY_BYTES leaves no room for a write log. This will greatly increase the flash wear rate! |
215 | # endif | 213 | # endif |
216 | # if FEE_DENSITY_BYTES > FEE_ADDRESS_MAX_SIZE | 214 | # if FEE_DENSITY_BYTES > FEE_ADDRESS_MAX_SIZE |
217 | # pragma message FEE_XSTR(FEE_DENSITY_BYTES) " > " FEE_XSTR(FEE_ADDRESS_MAX_SIZE) | 215 | # pragma message STR(FEE_DENSITY_BYTES) " > " STR(FEE_ADDRESS_MAX_SIZE) |
218 | # error emulated eeprom: FEE_DENSITY_BYTES is greater than FEE_ADDRESS_MAX_SIZE allows | 216 | # error emulated eeprom: FEE_DENSITY_BYTES is greater than FEE_ADDRESS_MAX_SIZE allows |
219 | # endif | 217 | # endif |
220 | # if ((FEE_DENSITY_BYTES) % 2) == 1 | 218 | # if ((FEE_DENSITY_BYTES) % 2) == 1 |
diff --git a/tmk_core/common/chibios/flash_stm32.c b/tmk_core/common/chibios/flash_stm32.c index 66f2b1376..6b80ff71c 100644 --- a/tmk_core/common/chibios/flash_stm32.c +++ b/tmk_core/common/chibios/flash_stm32.c | |||
@@ -16,22 +16,7 @@ | |||
16 | * Modifications for QMK and STM32F303 by Yiancar | 16 | * Modifications for QMK and STM32F303 by Yiancar |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #if defined(EEPROM_EMU_STM32F303xC) | 19 | #include <hal.h> |
20 | # define STM32F303xC | ||
21 | # include "stm32f3xx.h" | ||
22 | #elif defined(EEPROM_EMU_STM32F103xB) | ||
23 | # define STM32F103xB | ||
24 | # include "stm32f1xx.h" | ||
25 | #elif defined(EEPROM_EMU_STM32F072xB) | ||
26 | # define STM32F072xB | ||
27 | # include "stm32f0xx.h" | ||
28 | #elif defined(EEPROM_EMU_STM32F042x6) | ||
29 | # define STM32F042x6 | ||
30 | # include "stm32f0xx.h" | ||
31 | #else | ||
32 | # error "not implemented." | ||
33 | #endif | ||
34 | |||
35 | #include "flash_stm32.h" | 20 | #include "flash_stm32.h" |
36 | 21 | ||
37 | #if defined(EEPROM_EMU_STM32F103xB) | 22 | #if defined(EEPROM_EMU_STM32F103xB) |
@@ -177,17 +162,3 @@ void FLASH_Lock(void) { | |||
177 | /* Set the Lock Bit to lock the FPEC and the FCR */ | 162 | /* Set the Lock Bit to lock the FPEC and the FCR */ |
178 | FLASH->CR |= FLASH_CR_LOCK; | 163 | FLASH->CR |= FLASH_CR_LOCK; |
179 | } | 164 | } |
180 | |||
181 | /** | ||
182 | * @brief Clears the FLASH's pending flags. | ||
183 | * @param FLASH_FLAG: specifies the FLASH flags to clear. | ||
184 | * This parameter can be any combination of the following values: | ||
185 | * @arg FLASH_FLAG_PGERR: FLASH Programming error flag flag | ||
186 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag | ||
187 | * @arg FLASH_FLAG_EOP: FLASH End of Programming flag | ||
188 | * @retval None | ||
189 | */ | ||
190 | void FLASH_ClearFlag(uint32_t FLASH_FLAG) { | ||
191 | /* Clear the flags */ | ||
192 | FLASH->SR = FLASH_FLAG; | ||
193 | } | ||
diff --git a/tmk_core/common/chibios/flash_stm32.h b/tmk_core/common/chibios/flash_stm32.h index 9c6a7cc50..6c66642ec 100644 --- a/tmk_core/common/chibios/flash_stm32.h +++ b/tmk_core/common/chibios/flash_stm32.h | |||
@@ -38,7 +38,6 @@ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data); | |||
38 | 38 | ||
39 | void FLASH_Unlock(void); | 39 | void FLASH_Unlock(void); |
40 | void FLASH_Lock(void); | 40 | void FLASH_Lock(void); |
41 | void FLASH_ClearFlag(uint32_t FLASH_FLAG); | ||
42 | 41 | ||
43 | #ifdef __cplusplus | 42 | #ifdef __cplusplus |
44 | } | 43 | } |
diff --git a/tmk_core/common/test/flash_stm32_mock.c b/tmk_core/common/test/flash_stm32_mock.c index 1b81d81f9..222a004bc 100644 --- a/tmk_core/common/test/flash_stm32_mock.c +++ b/tmk_core/common/test/flash_stm32_mock.c | |||
@@ -47,4 +47,3 @@ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) { | |||
47 | FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout) { return FLASH_COMPLETE; } | 47 | FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout) { return FLASH_COMPLETE; } |
48 | void FLASH_Unlock(void) { flash_locked = false; } | 48 | void FLASH_Unlock(void) { flash_locked = false; } |
49 | void FLASH_Lock(void) { flash_locked = true; } | 49 | void FLASH_Lock(void) { flash_locked = true; } |
50 | void FLASH_ClearFlag(uint32_t FLASH_FLAG) {} | ||