Altera_Forum
Honored Contributor
19 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 protected: const alt_u32 UART_BASE_ADDRESS; const alt_u32 UART_IRQ_NUMBER; alt_u8 bUARTReceiveData; bool bReceiveNewData; public: UART(alt_u32 BaseAddress, alt_u32 IRQNumber):UART_BASE_ADDRESS(BaseAddress),UART_IRQ_NUMBER(IRQNumber) { alt_irq_register(UART_IRQ_NUMBER, this, UartIsr); } ~UART() {;} void UartIsr(void* pClass, alt_u32 id) { } bool IsReceiveNewData(void) { return bReceiveNewData; } alt_u8 GetData(void) { return bUARTReceiveData; } }; But the compiler report that: error: argument of type `void (UART:: )(void*, alt_u32)' does not match `void (*)(void*, alt_u32)' I also try: alt_irq_register(UART_IRQ_NUMBER, this, (void(*)(void*, alt_u32))UartIsr); But the error still occurred. Anybody help? David