/** * @brief UART MSP De-Initialization * This function frees the hardware resources used in this example: * - Disable the Peripheral's clock * - Revert GPIO, DMA and NVIC configuration to their default state * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) { /*##-1- Reset peripherals ##################################################*/ USARTx_FORCE_RESET(); USARTx_RELEASE_RESET(); /*##-2- Disable peripherals and GPIO Clocks #################################*/ /* Configure USARTx Tx as alternate function */ HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN); /* Configure USARTx Rx as alternate function */ HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN); /*##-3- Disable the DMA #####################################################*/ /* De-Initialize the DMA channel associated to reception process */ if(huart->hdmarx != 0) { HAL_DMA_DeInit(huart->hdmarx); } /* De-Initialize the DMA channel associated to transmission process */ if(huart->hdmatx != 0) { HAL_DMA_DeInit(huart->hdmatx); } /*##-4- Disable the NVIC for DMA ###########################################*/ HAL_NVIC_DisableIRQ(USARTx_DMA_TX_IRQn); HAL_NVIC_DisableIRQ(USARTx_DMA_RX_IRQn); }
/** * @brief UART MSP De-Initialization * This function frees the hardware resources used in this example: * - Disable the Peripheral's clock * - Revert GPIO, DMA and NVIC configuration to their default state * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) { static DMA_HandleTypeDef hdma_tx; static DMA_HandleTypeDef hdma_rx; /*##-1- Reset peripherals ##################################################*/ USARTx_FORCE_RESET(); USARTx_RELEASE_RESET(); /*##-2- Disable peripherals and GPIO Clocks #################################*/ /* Configure UART Tx as alternate function */ HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN); /* Configure UART Rx as alternate function */ HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN); /*##-3- Disable the DMA Streams ############################################*/ /* De-Initialize the DMA Stream associate to transmission process */ HAL_DMA_DeInit(&hdma_tx); /* De-Initialize the DMA Stream associate to reception process */ HAL_DMA_DeInit(&hdma_rx); /*##-4- Disable the NVIC for DMA ###########################################*/ HAL_NVIC_DisableIRQ(USARTx_DMA_TX_IRQn); HAL_NVIC_DisableIRQ(USARTx_DMA_RX_IRQn); }
/** * @brief UART MSP De-Initialization * This function frees the hardware resources used in this example: * - Disable the Peripheral's clock * - Revert GPIO and NVIC configuration to their default state * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) { if( huart == &UartHandle ){ USARTx_FORCE_RESET(); USARTx_RELEASE_RESET(); /*##-2- Disable peripherals and GPIO Clocks ################################*/ /* Configure UART Tx as alternate function */ HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN); /* Configure UART Rx as alternate function */ HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN); /*##-3- Disable the DMA Streams ############################################*/ /* De-Initialize the DMA Stream associate to transmission process */ HAL_DMA_DeInit(&hdma_tx); /* De-Initialize the DMA Stream associate to reception process */ HAL_DMA_DeInit(&hdma_rx); /*##-3- Disable the NVIC for UART ##########################################*/ /*##-4- Configure the NVIC for DMA #########################################*/ /* NVIC configuration for DMA transfer complete interrupt (USARTx_TX) */ HAL_NVIC_DisableIRQ(USARTx_DMA_TX_IRQn); HAL_NVIC_DisableIRQ(USARTx_DMA_RX_IRQn); HAL_NVIC_DisableIRQ(USARTx_IRQn); } }
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) { (void)huart; USARTx_FORCE_RESET(); USARTx_RELEASE_RESET(); HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN); HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN); }
void prvHardwareUartGpioDeinit(UART_HandleTypeDef *huart) { USARTx_FORCE_RESET(); USARTx_RELEASE_RESET(); /* Configure UART Tx as alternate function */ HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN); /* Configure UART Rx as alternate function */ HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN); }
/** * @brief UART MSP De-Initialization * This function frees the hardware resources used in this example: * - Disable the Peripheral's clock * - Revert GPIO configuration to their default state * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) { /*##-1- Reset peripherals ##################################################*/ USARTx_FORCE_RESET(); USARTx_RELEASE_RESET(); /*##-2- Disable peripherals and GPIO Clocks #################################*/ /* Configure UART Tx as alternate function */ HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN); /* Configure UART Rx as alternate function */ HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN); }
/** * @brief UART MSP De-Initialization * This function frees the hardware resources used in this example: * - Disable the Peripheral's clock * - Revert GPIO, DMA and NVIC configuration to their default state * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) { /*##-1- Reset peripherals ##################################################*/ USARTx_FORCE_RESET(); USARTx_RELEASE_RESET(); /*##-2- Disable peripherals and GPIO Clocks #################################*/ /* Configure UART Tx as alternate function */ HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN); /* Configure UART Rx as alternate function */ HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN); /*##-4- Disable the NVIC for DMA ###########################################*/ HAL_NVIC_DisableIRQ(USARTx_DMA_TX_IRQn); /*##-4- Reset TIM peripheral ###############################################*/ TIMx_FORCE_RESET(); TIMx_RELEASE_RESET(); }