stm32f4xx_hal_msp.c 역할

2019. 6. 26. 16:51임베디드/32F429IDISCOVERY

MSPs are user callback functions to perform system level initializations such as (Clock, GPIOs, DMA, interrupts). The peripheral initialization is done through HAL_PPP_Init() while the hardware resources initialization used by a peripheral (PPP) is performed during this initialization by calling MSP callback function HAL_PPP_MspInit(). The MspInit callback performs the low-level initialization related to the different additional hardware resources: RCC, GPIO, NVIC and DMA.

 

소스파일 중 main.c 밑에 있는 stm32f4xx_hal_msp.c의 역할에 대해서 다음과 같이 기술되어 있다.

요약하자면 HAL_PPP_Init()을 하기 전에 반드시 HAL_PPP_MspInit()이 수행된다. 그 이유는 HAL_PPP_MspInit()는 하드웨어 자원과(RCC, GPIO, NVIC and DMA) 연관된 로우 레벨에서의 초기화 함수다

 

예를 들어, UART를 초기화 한다고 하면 HAL_PPP_Init()에서는 단순히 UART 속성을 정해주지만 HAL_PPP_MspInit()에서 이미 GPIO_AF 선언을 해서 해당 GPIO 핀을 UART로 사용할 수 있게 초기화 시켜주고 있다