Question
GPIO UART disable and enable
Hi I use UART very rarely and I would like to disable gpio:
void Disable_Not_Used_Pins(void) {
/* Disable UART pins*/
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}How to enable this pins and uart again?
void enableUART() {
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
MX_USART2_UART_Init(); //init uart 2
__HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE);
}After using the function above uart does not work
