SW4STM32 and C++
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-10-22 3:32 PM
Posted on October 23, 2017 at 00:32
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
martin
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-10-22 4:26 PM
Posted on October 23, 2017 at 01:26
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
}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-10-23 5:53 PM
Posted on October 24, 2017 at 02:53
Thanks Clive, that did it, in fact it prompted me to look into this, so it was a good outcome.
Cheers
mb
