diff options
Diffstat (limited to 'src/stm32/serial.c')
-rw-r--r-- | src/stm32/serial.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/stm32/serial.c b/src/stm32/serial.c index 19aa048e..b78b5afb 100644 --- a/src/stm32/serial.c +++ b/src/stm32/serial.c @@ -16,38 +16,58 @@ DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA10,PA9"); #define GPIO_Rx GPIO('A', 10) #define GPIO_Tx GPIO('A', 9) + #define GPIO_AF_MODE 7 #define USARTx USART1 #define USARTx_IRQn USART1_IRQn #elif CONFIG_STM32_SERIAL_USART1_ALT_PB7_PB6 DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB7,PB6"); #define GPIO_Rx GPIO('B', 7) #define GPIO_Tx GPIO('B', 6) + #define GPIO_AF_MODE 7 #define USARTx USART1 #define USARTx_IRQn USART1_IRQn #elif CONFIG_STM32_SERIAL_USART2 DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA3,PA2"); #define GPIO_Rx GPIO('A', 3) #define GPIO_Tx GPIO('A', 2) + #define GPIO_AF_MODE 7 #define USARTx USART2 #define USARTx_IRQn USART2_IRQn #elif CONFIG_STM32_SERIAL_USART2_ALT_PD6_PD5 DECL_CONSTANT_STR("RESERVE_PINS_serial", "PD6,PD5"); #define GPIO_Rx GPIO('D', 6) #define GPIO_Tx GPIO('D', 5) + #define GPIO_AF_MODE 7 #define USARTx USART2 #define USARTx_IRQn USART2_IRQn #elif CONFIG_STM32_SERIAL_USART3 DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB11,PB10"); #define GPIO_Rx GPIO('B', 11) #define GPIO_Tx GPIO('B', 10) + #define GPIO_AF_MODE 7 #define USARTx USART3 #define USARTx_IRQn USART3_IRQn #elif CONFIG_STM32_SERIAL_USART3_ALT_PD9_PD8 DECL_CONSTANT_STR("RESERVE_PINS_serial", "PD9,PD8"); #define GPIO_Rx GPIO('D', 9) #define GPIO_Tx GPIO('D', 8) + #define GPIO_AF_MODE 7 #define USARTx USART3 #define USARTx_IRQn USART3_IRQn +#elif CONFIG_STM32_SERIAL_USART6 + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA12,PA11"); + #define GPIO_Rx GPIO('A', 12) + #define GPIO_Tx GPIO('A', 11) + #define GPIO_AF_MODE 8 + #define USARTx USART6 + #define USARTx_IRQn USART6_IRQn +#elif CONFIG_STM32_SERIAL_USART6_ALT_PC7_PC6 + DECL_CONSTANT_STR("RESERVE_PINS_serial", "PC7,PC6"); + #define GPIO_Rx GPIO('C', 7) + #define GPIO_Tx GPIO('C', 6) + #define GPIO_AF_MODE 8 + #define USARTx USART6 + #define USARTx_IRQn USART6_IRQn #endif #define CR1_FLAGS (USART_CR1_UE | USART_CR1_RE | USART_CR1_TE \ @@ -90,7 +110,7 @@ serial_init(void) USARTx->CR1 = CR1_FLAGS; armcm_enable_irq(USARTx_IRQHandler, USARTx_IRQn, 0); - gpio_peripheral(GPIO_Rx, GPIO_FUNCTION(7), 1); - gpio_peripheral(GPIO_Tx, GPIO_FUNCTION(7), 0); + gpio_peripheral(GPIO_Rx, GPIO_FUNCTION(GPIO_AF_MODE), 1); + gpio_peripheral(GPIO_Tx, GPIO_FUNCTION(GPIO_AF_MODE), 0); } DECL_INIT(serial_init); |