lpcware

Redefine a weak IRQ handler using linker directives/macros or any other trick

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by gnxp on Wed Feb 18 08:39:19 MST 2015
Environment - KEIL ARMcc v5.05 compiler, ARMlink v5.05 linker
Hello experts,
This is not a lpc17xx but  a more generic question.
I want to create  a base project which can be reused for same or similar processors.
I am trying to create interrupt handlers which can be defined/declared by a macro and can over-ride the default weak definition.

For. e.g  I want to write DBG port handler but I want the next person to chose what UART he wants by just changing a macro in header file.

#define DBG_UART    UART0
/* The following macro will create  text void UART0_IRQhandler */
#define MAKE_IRQH(x)void x##_IRQHandler(void)
#define IRQH(x)MAKE_IRQH(x)


So in my dbg.c file I write

IRQH(DBG_UART)
{
/........ UART handling stuff ...../
}


My intention is that next person can take this project and just change say UART0 to UART1 and won't need to change dbg.c file.

The above thing doesn't work, and my code still hits default handler as though void UART0_IRQhandler has not been defined.
Do you guys have any other way of accomplishing this?


Outcomes