9 years ago.

Question about void HAL_TIM_Encoder_MspInit()

I'm a bit confused as to how this code is called.

My understanding is that the HAL_TIM_ENCODER_MspInit() function in the mbed header gets overridden but I don't see the "EncoderMspInitFX.cpp" file being included anywhere so how does the compiler know where to look for it?

Question relating to:

Hello World example for interfacing up to four rotary encoders to the STM32's timer/counter hardware, without interrupts.

1 Answer

9 years ago.

You never include .cpp files in your code like you do .h files. The compiler needs to be setup which files to include/where to look for those files. The online compiler simply includes all user files in its compilation. So in the program you link there are three cpp files for that function, with #ifdef guards to make sure only the correct one is actually compiled.

Accepted Answer

Ah ok now I get it, thanks for the answer!

posted by Emil Blixt 16 Apr 2015