Src/stm32f1xx_hal_msp.c
/**
  * @brief UART MSP Initialization
  *        This function configures the hardware resources used in this example:
  *           - Peripheral's clock enable
  *           - Peripheral's GPIO Configuration
  * @param huart: UART handle pointer
  * @retval None
  */
@brief UART MSP Initialization
This function configures the hardware resources used in this example:
- Peripheral's clock enable
- Peripheral's GPIO Configuration
@param huart: UART handle pointer
@retval None
@brief UART MSP Initialization This function configures the hardware resources used in this example : - Peripheral ' s clock enable - Peripheral ' s GPIO Configuration @param huart : UART handle pointer @retval None
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{
  GPIO_InitTypeDef GPIO_InitStruct;
  USARTx_TX_GPIO_CLK_ENABLE();
  USARTx_RX_GPIO_CLK_ENABLE();
  USARTx_CLK_ENABLE();
  DMAx_CLK_ENABLE();
  GPIO_InitStruct.Pin       = USARTx_TX_PIN;
  GPIO_InitStruct.Mode      = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull      = GPIO_PULLUP;
  GPIO_InitStruct.Speed     = GPIO_SPEED_FREQ_HIGH;
  HAL_GPIO_Init(USARTx_TX_GPIO_PORT, &GPIO_InitStruct);
  GPIO_InitStruct.Pin = USARTx_RX_PIN;
  GPIO_InitStruct.Mode      = GPIO_MODE_INPUT;
  HAL_GPIO_Init(USARTx_RX_GPIO_PORT, &GPIO_InitStruct);
  hdma_rx.Instance                 = USARTx_RX_DMA_CHANNEL;
  hdma_rx.Init.Direction           = DMA_PERIPH_TO_MEMORY;
  hdma_rx.Init.PeriphInc           = DMA_PINC_DISABLE;
  hdma_rx.Init.MemInc              = DMA_MINC_ENABLE;
  hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
  hdma_rx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
  hdma_rx.Init.Mode                = DMA_NORMAL;
  hdma_rx.Init.Priority            = DMA_PRIORITY_HIGH;
  HAL_DMA_Init(&hdma_rx);
  __HAL_LINKDMA(huart, hdmarx, hdma_rx);
  __HAL_UART_ENABLE_IT(&UartHandle, UART_IT_IDLE);
  HAL_NVIC_SetPriority(USARTx_IRQn, 0, 1);
  HAL_NVIC_EnableIRQ(USARTx_IRQn);}
void HAL_UART_MspInit ( UART_HandleTypeDef * huart ) { GPIO_InitTypeDef GPIO_InitStruct ; USARTx_TX_GPIO_CLK_ENABLE ( ) ; USARTx_RX_GPIO_CLK_ENABLE ( ) ; USARTx_CLK_ENABLE ( ) ; DMAx_CLK_ENABLE ( ) ; GPIO_InitStruct . Pin = USARTx_TX_PIN ; GPIO_InitStruct . Mode = GPIO_MODE_AF_PP ; GPIO_InitStruct . Pull = GPIO_PULLUP ; GPIO_InitStruct . Speed = GPIO_SPEED_FREQ_HIGH ; HAL_GPIO_Init ( USARTx_TX_GPIO_PORT , & GPIO_InitStruct ) ; GPIO_InitStruct . Pin = USARTx_RX_PIN ; GPIO_InitStruct . Mode = GPIO_MODE_INPUT ; HAL_GPIO_Init ( USARTx_RX_GPIO_PORT , & GPIO_InitStruct ) ; hdma_rx . Instance = USARTx_RX_DMA_CHANNEL ; hdma_rx . Init . Direction = DMA_PERIPH_TO_MEMORY ; hdma_rx . Init . PeriphInc = DMA_PINC_DISABLE ; hdma_rx . Init . MemInc = DMA_MINC_ENABLE ; hdma_rx . Init . PeriphDataAlignment = DMA_PDATAALIGN_BYTE ; hdma_rx . Init . MemDataAlignment = DMA_MDATAALIGN_BYTE ; hdma_rx . Init . Mode = DMA_NORMAL ; hdma_rx . Init . Priority = DMA_PRIORITY_HIGH ; HAL_DMA_Init ( & hdma_rx ) ; __HAL_LINKDMA ( huart , hdmarx , hdma_rx ) ; __HAL_UART_ENABLE_IT ( & UartHandle , UART_IT_IDLE ) ; HAL_NVIC_SetPriority ( USARTx_IRQn , 0 , 1 ) ; HAL_NVIC_EnableIRQ ( USARTx_IRQn ) ; }
@brief UART MSP Initialization
        This function configures the hardware resources used in this example:
           - Peripheral's clock enable
           - Peripheral's GPIO Configuration
 @param huart: UART handle pointer
 @retval None
@brief UART MSP Initialization This function configures the hardware resources used in this example : - Peripheral ' s clock enable - Peripheral ' s GPIO Configuration @param huart : UART handle pointer @retval None
/*-1- Enable peripherals and GPIO Clocks */ /* Enable GPIO clock */ /* Enable USARTx clock */ /* Enable DMA clock */ /*-2- Configure peripheral GPIO */ /* UART TX GPIO pin configuration  */ /* UART RX GPIO pin configuration  */ /* Configure the DMA handler for reception process */ /* Associate the initialized DMA handle to the the UART handle */ /*-4- Configure the NVIC for DMA */ /* NVIC for USART */