Custom interrupt callbacks

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ipek
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked
Is it possible to customize interrupt callbacks ? For example when an interrupt occurs I want my_func to be called instead of IRQx_Handler.
0 Likes
1 Reply
ipek
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked
I solve this problem. It is not the best solution but since I don't know all dynamics of this product and someone who knows didn't answer..

--------------- .h file:
void (*_IRQHandlerArray[32])(); //function pointer array

#define IRQ_HANDLER_DEFINE(IRQNO) \
void IRQ##IRQNO##_Handler(void) \
{ \
_IRQHandlerArray[IRQNO](); \
}
void registerIRQHandler(uint32_t irqNo, void(*foo)());
------------------------

--------.c file:
IRQ_HANDLER_DEFINE(0);
IRQ_HANDLER_DEFINE(1);
IRQ_HANDLER_DEFINE(2);
IRQ_HANDLER_DEFINE(3);
IRQ_HANDLER_DEFINE(4);
IRQ_HANDLER_DEFINE(5);
IRQ_HANDLER_DEFINE(6);
IRQ_HANDLER_DEFINE(7);
IRQ_HANDLER_DEFINE(8);
IRQ_HANDLER_DEFINE(9);
IRQ_HANDLER_DEFINE(10);
IRQ_HANDLER_DEFINE(11);
IRQ_HANDLER_DEFINE(12);
IRQ_HANDLER_DEFINE(13);
IRQ_HANDLER_DEFINE(14);
IRQ_HANDLER_DEFINE(15);
IRQ_HANDLER_DEFINE(16);
IRQ_HANDLER_DEFINE(17);
IRQ_HANDLER_DEFINE(18);
IRQ_HANDLER_DEFINE(19);
IRQ_HANDLER_DEFINE(20);
IRQ_HANDLER_DEFINE(21);
IRQ_HANDLER_DEFINE(22);
IRQ_HANDLER_DEFINE(23);
IRQ_HANDLER_DEFINE(24);
IRQ_HANDLER_DEFINE(25);
IRQ_HANDLER_DEFINE(26);
IRQ_HANDLER_DEFINE(27);
IRQ_HANDLER_DEFINE(28);
IRQ_HANDLER_DEFINE(29);
IRQ_HANDLER_DEFINE(30);
IRQ_HANDLER_DEFINE(31);


void registerIRQHandler(uint32_t irqno, void(*foo)())
{
_IRQHandlerArray[irqno] = foo;
}
----------

When I am using it, I call registerIRQHandler function with enabled interrupt line number and my function whose signature is compatible with a regular interrupt handler (ex: void foo(void); )
0 Likes