aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-10-06 19:48:03 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-10-06 19:56:46 -0400
commite3905eb2419b4d7bc8200a87e1dcac5c6eba9064 (patch)
tree677038e1fc54d91dd57368b01d2afb92f3c579a2 /src/stm32
parentc1136bef10f43b2c69400af38c4404e2d20e9180 (diff)
downloadkutter-e3905eb2419b4d7bc8200a87e1dcac5c6eba9064.tar.gz
kutter-e3905eb2419b4d7bc8200a87e1dcac5c6eba9064.tar.xz
kutter-e3905eb2419b4d7bc8200a87e1dcac5c6eba9064.zip
stm32: Add an MACH_STM32F4x5 alias for F405, F407, and F429 chips
The F405, F407, and F429 chips are in the same series and almost all code definitions should apply to all chips in that series. Implement the alias and fix defintions in adc.c and Kconfig that were only applying to a subset of that series. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32')
-rw-r--r--src/stm32/Kconfig21
-rw-r--r--src/stm32/adc.c6
-rw-r--r--src/stm32/stm32f4.c6
3 files changed, 18 insertions, 15 deletions
diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig
index 68adab7d..ecb6a0e1 100644
--- a/src/stm32/Kconfig
+++ b/src/stm32/Kconfig
@@ -37,12 +37,15 @@ choice
config MACH_STM32F405
bool "STM32F405"
select MACH_STM32F4
+ select MACH_STM32F4x5
config MACH_STM32F407
bool "STM32F407"
select MACH_STM32F4
+ select MACH_STM32F4x5
config MACH_STM32F429
bool "STM32F429"
select MACH_STM32F4
+ select MACH_STM32F4x5
config MACH_STM32F446
bool "STM32F446"
select MACH_STM32F4
@@ -72,6 +75,8 @@ config MACH_STM32F2
bool
config MACH_STM32F4
bool
+config MACH_STM32F4x5 # F405, F407, F429 series
+ bool
config MACH_STM32H7
bool
config HAVE_STM32_USBFS
@@ -106,7 +111,7 @@ config CLOCK_FREQ
default 72000000 if MACH_STM32F103
default 120000000 if MACH_STM32F207
default 84000000 if MACH_STM32F401
- default 168000000 if MACH_STM32F405 || MACH_STM32F407 || MACH_STM32F429
+ default 168000000 if MACH_STM32F4x5
default 180000000 if MACH_STM32F446
default 480000000 if MACH_STM32H750
@@ -117,7 +122,7 @@ config FLASH_SIZE
default 0x20000 if MACH_STM32F070 || MACH_STM32F072
default 0x10000 if MACH_STM32F103 # Flash size of stm32f103x8 (64KiB)
default 0x40000 if MACH_STM32F2 || MACH_STM32F401
- default 0x80000 if MACH_STM32F405 || MACH_STM32F407 || MACH_STM32F429 || MACH_STM32F446
+ default 0x80000 if MACH_STM32F4x5 || MACH_STM32F446
default 0x20000 if MACH_STM32H7 # Flash size of stm32h750 (128KiB)
config RAM_START
@@ -132,7 +137,7 @@ config RAM_SIZE
default 0x5000 if MACH_STM32F103 # Ram size of stm32f103x8 (20KiB)
default 0x20000 if MACH_STM32F207
default 0x10000 if MACH_STM32F401
- default 0x20000 if MACH_STM32F405 || MACH_STM32F407 || MACH_STM32F429 || MACH_STM32F446
+ default 0x20000 if MACH_STM32F4x5 || MACH_STM32F446
default 0x20000 if MACH_STM32H7
config STACK_SIZE
@@ -145,7 +150,7 @@ config STACK_SIZE
######################################################################
choice
- prompt "Bootloader offset" if MACH_STM32F207 || MACH_STM32F401 || MACH_STM32F407 || MACH_STM32F405 || MACH_STM32F446 || MACH_STM32F103 || MACH_STM32F070
+ prompt "Bootloader offset" if MACH_STM32F1 || MACH_STM32F2 || MACH_STM32F4 || MACH_STM32F070
config STM32_FLASH_START_2000
bool "8KiB bootloader (stm32duino)" if MACH_STM32F103 || MACH_STM32F070
config STM32_FLASH_START_5000
@@ -153,20 +158,20 @@ choice
config STM32_FLASH_START_7000
bool "28KiB bootloader" if MACH_STM32F103
config STM32_FLASH_START_8000
- bool "32KiB bootloader" if MACH_STM32F207 || MACH_STM32F407 || MACH_STM32F446
+ bool "32KiB bootloader" if MACH_STM32F207 || MACH_STM32F4x5 || MACH_STM32F446
config STM32_FLASH_START_8800
bool "34KiB bootloader (Chitu v6 Bootloader)" if MACH_STM32F103
config STM32_FLASH_START_20200
- bool "128KiB bootloader with 512 byte offset (Prusa Buddy)" if MACH_STM32F407
+ bool "128KiB bootloader with 512 byte offset (Prusa Buddy)" if MACH_STM32F4x5
config STM32_FLASH_START_C000
- bool "48KiB bootloader (MKS Robin Nano V3)" if MACH_STM32F407
+ bool "48KiB bootloader (MKS Robin Nano V3)" if MACH_STM32F4x5
config STM32_FLASH_START_10000
bool "64KiB bootloader" if MACH_STM32F103 || MACH_STM32F446
config STM32_FLASH_START_800
bool "2KiB bootloader (HID Bootloader)" if MACH_STM32F103
config STM32_FLASH_START_4000
- bool "16KiB bootloader (HID Bootloader)" if MACH_STM32F207 || MACH_STM32F401 || MACH_STM32F405 || MACH_STM32F407 || MACH_STM32F103
+ bool "16KiB bootloader (HID Bootloader)" if MACH_STM32F207 || MACH_STM32F401 || MACH_STM32F4x5 || MACH_STM32F103
config STM32_FLASH_START_0000
bool "No bootloader"
diff --git a/src/stm32/adc.c b/src/stm32/adc.c
index 93a5309c..02e54fba 100644
--- a/src/stm32/adc.c
+++ b/src/stm32/adc.c
@@ -26,13 +26,13 @@ static const uint8_t adc_pins[] = {
#if CONFIG_MACH_STM32F1
ADC_TEMPERATURE_PIN,
-#elif CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F405 || CONFIG_MACH_STM32F407
+#elif CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4x5
ADC_TEMPERATURE_PIN, 0x00, 0x00,
#elif CONFIG_MACH_STM32F446
0x00, 0x00, ADC_TEMPERATURE_PIN,
#endif
-#if CONFIG_MACH_STM32F405 || CONFIG_MACH_STM32F407 || CONFIG_MACH_STM32F446
+#if CONFIG_MACH_STM32F4x5 || CONFIG_MACH_STM32F446
0x00, 0x00, 0x00, 0x00,
GPIO('F', 6), GPIO('F', 7), GPIO('F', 8), GPIO('F', 9),
GPIO('F', 10), GPIO('F', 3), 0x00, 0x00,
@@ -83,7 +83,7 @@ gpio_adc_setup(uint32_t pin)
// Determine which ADC block to use
ADC_TypeDef *adc = ADC1;
uint32_t adc_base = ADC1_BASE;
-#if CONFIG_MACH_STM32F405 || CONFIG_MACH_STM32F407 || CONFIG_MACH_STM32F446
+#if CONFIG_MACH_STM32F4x5 || CONFIG_MACH_STM32F446
if (chan >= 19) {
// On the STM32F4, some ADC channels are only available from ADC3
adc = ADC3;
diff --git a/src/stm32/stm32f4.c b/src/stm32/stm32f4.c
index 4bab40bc..06312832 100644
--- a/src/stm32/stm32f4.c
+++ b/src/stm32/stm32f4.c
@@ -144,8 +144,7 @@ enable_clock_stm32f20x(void)
static void
enable_clock_stm32f40x(void)
{
-#if CONFIG_MACH_STM32F405 || CONFIG_MACH_STM32F407 \
- || CONFIG_MACH_STM32F401 || CONFIG_MACH_STM32F429
+#if CONFIG_MACH_STM32F401 || CONFIG_MACH_STM32F4x5
uint32_t pll_base = (CONFIG_STM32_CLOCK_REF_25M) ? 1000000 : 2000000;
uint32_t pllp = (CONFIG_MACH_STM32F401) ? 4 : 2;
uint32_t pll_freq = CONFIG_CLOCK_FREQ * pllp, pllcfgr;
@@ -222,8 +221,7 @@ clock_setup(void)
// Configure and enable PLL
if (CONFIG_MACH_STM32F207)
enable_clock_stm32f20x();
- else if (CONFIG_MACH_STM32F405 || CONFIG_MACH_STM32F407
- || CONFIG_MACH_STM32F401 || CONFIG_MACH_STM32F429)
+ else if (CONFIG_MACH_STM32F401 || CONFIG_MACH_STM32F4x5)
enable_clock_stm32f40x();
else
enable_clock_stm32f446();