You can use C++ for MSPM0 designs.
There's one watch-out: if you have your event handlers in a .cpp file, you have to wrap those functions in an extern "C" {} wrapper.
The SysConfig mechanism expect that the handlers have a particular name. But the C++ compiler will "mangle" function names in .cpp files. Surrounding the functions with the extern directive, tells the compiler to leave the function signature alone.
In this example, I have a handler for a DMA interrupt. The SDK expects signature void DMA_IRQHandler (void).
|
If you don't wrap your handler, the linker will call the (predefined as weak) handler in the controller SDK's startup file. And that's a catchall handler (called Default_Handler) that 'll make the controller loop forever. Because the default one in the SDK is flagged as weak, and your implementation not, the linker will ignore the SDK one and link in your function. |
There are a few ways to wrap your handlers:
Surround the function
extern "C" {
void DMA_IRQHandler(void)
{
/* Example interrupt code -- just used to break the WFI in this example */
switch (DL_DMA_getPendingInterrupt(DMA)) {
case DL_DMA_EVENT_IIDX_DMACH0:
gChannel0InterruptTaken = true;
break;
default:
break;
}
}
}
Mark as external in with forward declaration
extern "C" {
void DMA_IRQHandler(void);
}
// ...
int main(void)
{
// ...
}
void DMA_IRQHandler(void)
{
// ...
}
Both constructs have the same effect.
There is no runtime cost. This is a build time mechanism to notify the toolchain. No code or data is added to your firmware.

-
shabaz
-
Cancel
-
Vote Up
0
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
Comment-
shabaz
-
Cancel
-
Vote Up
0
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
Children