diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig index 19da0e22..aa86cfeb 100644 --- a/src/stm32/Kconfig +++ b/src/stm32/Kconfig @@ -7,9 +7,9 @@ config STM32_SELECT default y select HAVE_GPIO select HAVE_GPIO_ADC - select HAVE_GPIO_I2C - select HAVE_GPIO_SPI - select HAVE_GPIO_BITBANGING + select HAVE_GPIO_I2C if !MACH_STM32F031 + select HAVE_GPIO_SPI if !MACH_STM32F031 + select HAVE_GPIO_BITBANGING if !MACH_STM32F031 select HAVE_STRICT_TIMING select HAVE_CHIPID @@ -37,6 +37,9 @@ choice config MACH_STM32F446 bool "STM32F446" select MACH_STM32F4 + config MACH_STM32F031 + bool "STM32F031" + select MACH_STM32F0 config MACH_STM32F042 bool "STM32F042" select MACH_STM32F0 @@ -64,6 +67,7 @@ config HAVE_STM32_USBOTG config MCU string + default "stm32f031x6" if MACH_STM32F031 default "stm32f042x6" if MACH_STM32F042 default "stm32f070xb" if MACH_STM32F070 default "stm32f103xe" if MACH_STM32F103 @@ -85,6 +89,7 @@ config CLOCK_FREQ config FLASH_SIZE hex + default 0x4000 if MACH_STM32F031 default 0x8000 if MACH_STM32F042 default 0x20000 if MACH_STM32F070 default 0x10000 if MACH_STM32F103 # Flash size of stm32f103x8 (64KiB) @@ -97,6 +102,7 @@ config RAM_START config RAM_SIZE hex + default 0x1000 if MACH_STM32F031 default 0x1800 if MACH_STM32F042 default 0x4000 if MACH_STM32F070 default 0x5000 if MACH_STM32F103 # Ram size of stm32f103x8 (20KiB) @@ -221,6 +227,8 @@ choice Select the serial device to use. config STM32_SERIAL_USART1 bool "USART1" + config STM32_SERIAL_USART1_ALT + bool "USART1 (on PA15/PA14)" if MACH_STM32F0 config STM32_SERIAL_USART2 bool "USART2 (on PA3/PA2)" config STM32_SERIAL_USART2_ALT diff --git a/src/stm32/stm32f0.c b/src/stm32/stm32f0.c index 0232b602..b876db35 100644 --- a/src/stm32/stm32f0.c +++ b/src/stm32/stm32f0.c @@ -149,9 +149,10 @@ pll_setup(void) // Setup CFGR3 register uint32_t cfgr3 = RCC_CFGR3_I2C1SW; - if (CONFIG_USBSERIAL) +#if CONFIG_USBSERIAL // Select PLL as source for USB clock cfgr3 |= RCC_CFGR3_USBSW; +#endif RCC->CFGR3 = cfgr3; } diff --git a/src/stm32/stm32f0_serial.c b/src/stm32/stm32f0_serial.c index 2ea71f0c..5736e109 100644 --- a/src/stm32/stm32f0_serial.c +++ b/src/stm32/stm32f0_serial.c @@ -13,9 +13,15 @@ // Select the configured serial port #if CONFIG_SERIAL_PORT == 1 - DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA10,PA9"); - #define GPIO_Rx GPIO('A', 10) - #define GPIO_Tx GPIO('A', 9) + #if CONFIG_STM32_SERIAL_USART1_ALT + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA15,PA14"); + #define GPIO_Rx GPIO('A', 15) + #define GPIO_Tx GPIO('A', 14) + #else + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA10,PA9"); + #define GPIO_Rx GPIO('A', 10) + #define GPIO_Tx GPIO('A', 9) + #endif #define USARTx USART1 #define USARTx_IRQn USART1_IRQn #elif CONFIG_SERIAL_PORT == 2 diff --git a/test/configs/stm32f031.config b/test/configs/stm32f031.config new file mode 100644 index 00000000..8bed1a5b --- /dev/null +++ b/test/configs/stm32f031.config @@ -0,0 +1,4 @@ +# Base config file for STM32F031 boards +CONFIG_MACH_STM32=y +CONFIG_MACH_STM32F031=y +CONFIG_USBSERIAL=n