stm32: Adding support for STM32F031x6 (#3871)

Add support for alt usart 1

Do not select all functions on 16 K mcu

Signed-off-by: Elias Bakken <elias@iagent.no>
This commit is contained in:
Elias Bakken 2021-02-03 18:23:17 +01:00 committed by GitHub
parent 3162f4746f
commit 8b443acae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 7 deletions

View File

@ -7,9 +7,9 @@ config STM32_SELECT
default y default y
select HAVE_GPIO select HAVE_GPIO
select HAVE_GPIO_ADC select HAVE_GPIO_ADC
select HAVE_GPIO_I2C select HAVE_GPIO_I2C if !MACH_STM32F031
select HAVE_GPIO_SPI select HAVE_GPIO_SPI if !MACH_STM32F031
select HAVE_GPIO_BITBANGING select HAVE_GPIO_BITBANGING if !MACH_STM32F031
select HAVE_STRICT_TIMING select HAVE_STRICT_TIMING
select HAVE_CHIPID select HAVE_CHIPID
@ -37,6 +37,9 @@ choice
config MACH_STM32F446 config MACH_STM32F446
bool "STM32F446" bool "STM32F446"
select MACH_STM32F4 select MACH_STM32F4
config MACH_STM32F031
bool "STM32F031"
select MACH_STM32F0
config MACH_STM32F042 config MACH_STM32F042
bool "STM32F042" bool "STM32F042"
select MACH_STM32F0 select MACH_STM32F0
@ -64,6 +67,7 @@ config HAVE_STM32_USBOTG
config MCU config MCU
string string
default "stm32f031x6" if MACH_STM32F031
default "stm32f042x6" if MACH_STM32F042 default "stm32f042x6" if MACH_STM32F042
default "stm32f070xb" if MACH_STM32F070 default "stm32f070xb" if MACH_STM32F070
default "stm32f103xe" if MACH_STM32F103 default "stm32f103xe" if MACH_STM32F103
@ -85,6 +89,7 @@ config CLOCK_FREQ
config FLASH_SIZE config FLASH_SIZE
hex hex
default 0x4000 if MACH_STM32F031
default 0x8000 if MACH_STM32F042 default 0x8000 if MACH_STM32F042
default 0x20000 if MACH_STM32F070 default 0x20000 if MACH_STM32F070
default 0x10000 if MACH_STM32F103 # Flash size of stm32f103x8 (64KiB) default 0x10000 if MACH_STM32F103 # Flash size of stm32f103x8 (64KiB)
@ -97,6 +102,7 @@ config RAM_START
config RAM_SIZE config RAM_SIZE
hex hex
default 0x1000 if MACH_STM32F031
default 0x1800 if MACH_STM32F042 default 0x1800 if MACH_STM32F042
default 0x4000 if MACH_STM32F070 default 0x4000 if MACH_STM32F070
default 0x5000 if MACH_STM32F103 # Ram size of stm32f103x8 (20KiB) default 0x5000 if MACH_STM32F103 # Ram size of stm32f103x8 (20KiB)
@ -221,6 +227,8 @@ choice
Select the serial device to use. Select the serial device to use.
config STM32_SERIAL_USART1 config STM32_SERIAL_USART1
bool "USART1" bool "USART1"
config STM32_SERIAL_USART1_ALT
bool "USART1 (on PA15/PA14)" if MACH_STM32F0
config STM32_SERIAL_USART2 config STM32_SERIAL_USART2
bool "USART2 (on PA3/PA2)" bool "USART2 (on PA3/PA2)"
config STM32_SERIAL_USART2_ALT config STM32_SERIAL_USART2_ALT

View File

@ -149,9 +149,10 @@ pll_setup(void)
// Setup CFGR3 register // Setup CFGR3 register
uint32_t cfgr3 = RCC_CFGR3_I2C1SW; uint32_t cfgr3 = RCC_CFGR3_I2C1SW;
if (CONFIG_USBSERIAL) #if CONFIG_USBSERIAL
// Select PLL as source for USB clock // Select PLL as source for USB clock
cfgr3 |= RCC_CFGR3_USBSW; cfgr3 |= RCC_CFGR3_USBSW;
#endif
RCC->CFGR3 = cfgr3; RCC->CFGR3 = cfgr3;
} }

View File

@ -13,9 +13,15 @@
// Select the configured serial port // Select the configured serial port
#if CONFIG_SERIAL_PORT == 1 #if CONFIG_SERIAL_PORT == 1
#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"); DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA10,PA9");
#define GPIO_Rx GPIO('A', 10) #define GPIO_Rx GPIO('A', 10)
#define GPIO_Tx GPIO('A', 9) #define GPIO_Tx GPIO('A', 9)
#endif
#define USARTx USART1 #define USARTx USART1
#define USARTx_IRQn USART1_IRQn #define USARTx_IRQn USART1_IRQn
#elif CONFIG_SERIAL_PORT == 2 #elif CONFIG_SERIAL_PORT == 2

View File

@ -0,0 +1,4 @@
# Base config file for STM32F031 boards
CONFIG_MACH_STM32=y
CONFIG_MACH_STM32F031=y
CONFIG_USBSERIAL=n