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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,107 Views
lpcware
NXP Employee
NXP Employee
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?


Labels (1)
0 Kudos
Reply
2 Replies

1,039 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gnxp on Thu Feb 19 02:34:59 MST 2015
Thank you. I was using same UART in different places, mistake on my part. It works now.
0 Kudos
Reply

1,039 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Thu Feb 19 01:27:51 MST 2015
Your program is looking good for me.
Have you checked the linker map output file? Which function name is generated for the IRQ handler?
0 Kudos
Reply