aboutsummaryrefslogtreecommitdiff
path: root/src/uart-test/stm32f4xx_hal_msp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/uart-test/stm32f4xx_hal_msp.c')
-rw-r--r--src/uart-test/stm32f4xx_hal_msp.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/uart-test/stm32f4xx_hal_msp.c b/src/uart-test/stm32f4xx_hal_msp.c
index 7cee9ce..4416195 100644
--- a/src/uart-test/stm32f4xx_hal_msp.c
+++ b/src/uart-test/stm32f4xx_hal_msp.c
@@ -5,6 +5,8 @@
*
* PA9: USART1_TX
* PA10: USART1_RX
+ * PA2: USART2_TX
+ * PA3: USART2_RX
*/
#include "stm32f4xx_hal.h"
@@ -19,14 +21,19 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
__USART1_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* NVIC for interrupt mode */
- HAL_NVIC_SetPriority(USART1_IRQn, 0, 1);
- HAL_NVIC_EnableIRQ(USART1_IRQn);
+ } else if (huart->Instance == USART2) {
+ /* Peripheral clock enable */
+ __USART2_CLK_ENABLE();
+ GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_3;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
+ GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
}
@@ -37,6 +44,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
if (huart->Instance == USART1) {
__USART1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10);
+ } else if (huart->Instance == USART2) {
+ __USART2_CLK_DISABLE();
+ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2 | GPIO_PIN_3);
}
}