35 lines
968 B
C
35 lines
968 B
C
|
#include "main.h"
|
||
|
|
||
|
void HAL_MspInit(void)
|
||
|
{
|
||
|
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
||
|
__HAL_RCC_PWR_CLK_ENABLE();
|
||
|
|
||
|
HAL_SYSCFG_StrobeDBattpinsConfig(SYSCFG_CFGR1_UCPD1_STROBE | SYSCFG_CFGR1_UCPD2_STROBE);
|
||
|
}
|
||
|
|
||
|
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||
|
{
|
||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||
|
if(huart->Instance == USART2) {
|
||
|
__HAL_RCC_USART2_CLK_ENABLE();
|
||
|
|
||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||
|
GPIO_InitStruct.Pin = USART2_TX_Pin | USART2_RX_Pin;
|
||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||
|
GPIO_InitStruct.Alternate = GPIO_AF1_USART2;
|
||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||
|
{
|
||
|
if(huart->Instance == USART2) {
|
||
|
__HAL_RCC_USART2_CLK_DISABLE();
|
||
|
|
||
|
HAL_GPIO_DeInit(GPIOA, USART2_TX_Pin | USART2_RX_Pin);
|
||
|
}
|
||
|
}
|