Electronic – what is the purpose of __weak reference used on Keil MDK ARM

armccortex-m4microcontroller

Got a little messy with a function defined in two files and one with a __weak symbol.
I called the below function to load the settings of UART1 in STM32L476RG from my main file

 if(HAL_UART_Init(&UartHandle) != HAL_OK) and this function is defined at 
  {
    Error_Handler();
  }

I found that this function calls another funciton named HAL_UART_MspInit(huart);
This is defined at two places ,

 1. in stm32l4xx_hal_msp.c as void HAL_UART_MspInit(UART_HandleTypeDef
    *huart)
 2. in stm32l4xx_hal_uart.c as __weak void HAL_UART_MspInit(UART_HandleTypeDef *huart)

My problem is that the whenever I load the UART setting the __weak function is called. I did it by referring an example, UART_WakeUpFromStop given in the [STM32F476RG Product page]. where in the example the function in nstm32l4xx_hal_msp.c , void HAL_UART_MspInit(UART_HandleTypeDef *huart) is called. What is going wrong in my code? what is the influence of __weak symbol?

STM32L476RG Reference manual

Best Answer

Soo that The definition and implementation can be overridden with a non weak type, aka user defined one.

Check the manual to bee suit..