2017-10-22 03:32 PM
Hi Everyone.
I mostly work with a C environment when I create a STM32 project but in the last few days I have been
creating STM32 C++ projects by selecting a C++ project instead of a C project, and I can see in the properties, tool settings, C++ parameters are there. Also I have created very simple classes and so far the simple stuff works, but I have to rename my files from .C to .CPP extension otherwise I cant include code from a (.c) file? and I cant call a function located in a (.cpp) file from a (.c) file?The project I have created now has a uart serial class that has the usual transmit and receive routines plus theinterrupt handler. The problem is if I leave the interrupt service routine in the traditional stm32f0xx_it.c fileI can see that the ISR handler will be executed, but if I transfer the handler in one of the .C++ fileslike within the serial class, I cant get it to work?Similarly if I rename the stm32f0xx_it.c to stm32f0xx_it.cpp, again the handle will not executed.Can anyone help out with a solution on how to call other functions from either file type or how to get the ISR handler to be executed from within the serial class, or any c++ file?Cheers
martin2017-10-22 04:26 PM
C++ mangles names so you need to define your handlers thusly so they are bound to the Vector Table entries by the Linker
extern 'C' void USART1_IRQHandler(void)
{
// Insert your code
}
2017-10-23 05:53 PM
Thanks Clive, that did it, in fact it prompted me to look into this, so it was a good outcome.
Cheers
mb