stm32: Only declare alternate usart2 on stm32f0

Also, try to improve the structure of the #if/#else/#endif layout in
serial.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-01-23 11:33:11 -05:00
parent c8a93cb3bf
commit aea15250ae
3 changed files with 41 additions and 49 deletions

View File

@ -157,7 +157,7 @@ choice
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
bool "USART2 (on PA15/PA14)" bool "USART2 (on PA15/PA14)" if MACH_STM32F0
config STM32_SERIAL_USART3 config STM32_SERIAL_USART3
bool "USART3" bool "USART3"
config STM32_SERIAL_USART3_ALT config STM32_SERIAL_USART3_ALT
@ -165,10 +165,8 @@ choice
endchoice endchoice
config SERIAL_PORT config SERIAL_PORT
int int
default 103 if STM32_SERIAL_USART3_ALT default 3 if STM32_SERIAL_USART3 || STM32_SERIAL_USART3_ALT
default 3 if STM32_SERIAL_USART3 default 2 if STM32_SERIAL_USART2 || STM32_SERIAL_USART2_ALT
default 102 if STM32_SERIAL_USART2_ALT
default 2 if STM32_SERIAL_USART2
default 1 default 1
endif endif

View File

@ -24,22 +24,16 @@ DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA3,PA2");
#define GPIO_Tx GPIO('A', 2) #define GPIO_Tx GPIO('A', 2)
#define USARTx USART2 #define USARTx USART2
#define USARTx_IRQn USART2_IRQn #define USARTx_IRQn USART2_IRQn
#elif CONFIG_SERIAL_PORT == 102 #elif CONFIG_SERIAL_PORT == 3
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA14,PA15"); #if STM32_SERIAL_USART3_ALT
#define GPIO_Rx GPIO('A', 14)
#define GPIO_Tx GPIO('A', 15)
#define USARTx USART2b
#define USARTx_IRQn USART2_IRQn
#elif CONFIG_SERIAL_PORT == 103
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PD9,PD8"); DECL_CONSTANT_STR("RESERVE_PINS_serial", "PD9,PD8");
#define GPIO_Rx GPIO('D', 9) #define GPIO_Rx GPIO('D', 9)
#define GPIO_Tx GPIO('D', 8) #define GPIO_Tx GPIO('D', 8)
#define USARTx USART3
#define USARTx_IRQn USART3_IRQn
#else #else
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB11,PB10"); DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB11,PB10");
#define GPIO_Rx GPIO('B', 11) #define GPIO_Rx GPIO('B', 11)
#define GPIO_Tx GPIO('B', 10) #define GPIO_Tx GPIO('B', 10)
#endif
#define USARTx USART3 #define USARTx USART3
#define USARTx_IRQn USART3_IRQn #define USARTx_IRQn USART3_IRQn
#endif #endif

View File

@ -19,15 +19,15 @@ DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA10,PA9");
#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
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA3,PA2"); #if STM32_SERIAL_USART2_ALT
#define GPIO_Rx GPIO('A', 3)
#define GPIO_Tx GPIO('A', 2)
#define USARTx USART2
#define USARTx_IRQn USART2_IRQn
#elif CONFIG_SERIAL_PORT == 102
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA15,PA14"); DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA15,PA14");
#define GPIO_Rx GPIO('A', 15) #define GPIO_Rx GPIO('A', 15)
#define GPIO_Tx GPIO('A', 14) #define GPIO_Tx GPIO('A', 14)
#else
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA3,PA2");
#define GPIO_Rx GPIO('A', 3)
#define GPIO_Tx GPIO('A', 2)
#endif
#define USARTx USART2 #define USARTx USART2
#define USARTx_IRQn USART2_IRQn #define USARTx_IRQn USART2_IRQn
#endif #endif