Forum Discussion
Altera_Forum
Honored Contributor
20 years agoC++ & ISR
Dear all, I develop my project with C++ language. But I encounter a problem: how to register a ISR? For example: I define a UART class class UART { //Internal Data ...
Altera_Forum
Honored Contributor
20 years agoThanks for your reply. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/tongue.gif
I'll complete the answer(I got it from Scott McNutt), hope it will be useful for someone who encounter the same problem. Make the UartIsr() operation class static. E.g.: static void UartIsr(void* pClass, alt_u32 id); Remember, the 'this' pointer is implicitly passed to non-static member functions -- so non-static member functions can never match a 'C' language prototype. As long as UartIsr is a class member, it can always invoke other member functions regardless of their visibility: class UART { private: void doISR (alt_u32 id); protected: static void UartIsr (void *pClass, alt_u32 id) { UART *uart = (UART *)pClass; uart->doISR (id); // ... and other calls as needed ... } // ... and so on. }; Thanks Scott McNutt again, David