cancel
Showing results for 
Search instead for 
Did you mean: 

Calling custom function in interrupt handler

norbi1313
Associate
Posted on April 29, 2011 at 08:31

Calling custom function in interrupt handler

1 REPLY 1
cschumann
Associate II
Posted on May 17, 2011 at 14:33

Hi Norbert,

as you are talking about classes and static methods, I assume you are using C++.

In an interrupt handler custom functions can be called (as from any other ''normal'' function). When you are using C++ you have to make sure that the called function uses a C function signature instead of a C++ signature. That can be archived by a forward declaration like

extern ''C''{

  void myFunction(int param);

}

in your .h file. This method works only for function in the global scope and not for class functions/methods.

If you want to invoke a static class method, you need a wrapper function in the .cpp file with a c signature (as mentioned above). Within that function you can call the C++ method:

<file: test.cpp>

void myFunction(int param)

{

  MyClass::function(param);

}

</file: test.cpp>

Carsten