Environment - KEIL ARMcc v5.05 compiler, ARMlink v5.05 linker for LPC1769
Hello experts,
I asked this question on NXP forum too, if this looks familiar.
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 a 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 see any other way of accomplishing this?
Thanks.
---------------------------------------
Posted through http://www.EmbeddedRelated.com
Redefine a weak IRQ handler using linker directives/macros or any other trick
Started by ●February 18, 2015
Reply by ●February 19, 20152015-02-19
On Wednesday, 18 February 2015 18:34:26 UTC, gnxp wrote:> Environment - KEIL ARMcc v5.05 compiler, ARMlink v5.05 linker for LPC1769 > Hello experts, > I asked this question on NXP forum too, if this looks familiar. > 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 a header file. > > #define DBG_UART UART0 > /* The following macro will create text void UART0_IRQhandler */ > #define MAKE_IRQH(x) void x##_IRQHandler(void)This should probably be: #define MAKE_IRQH(x) __irq 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 see any other way of accomplishing this?
Reply by ●February 19, 20152015-02-19
>On Wednesday, 18 February 2015 18:34:26 UTC, gnxp wrote: >> Environment - KEIL ARMcc v5.05 compiler, ARMlink v5.05 linker forLPC1769>> Hello experts, >> I asked this question on NXP forum too, if this looks familiar. >> 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/declaredby 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 a header file. >> >> #define DBG_UART UART0 >> /* The following macro will create text void UART0_IRQhandler */ >> #define MAKE_IRQH(x) void x##_IRQHandler(void) > >This should probably be: > >#define MAKE_IRQH(x) __irq 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 changesay>> 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 see any other way of accomplishing this? >Thank you. It was error on my side. I was using same UART in two different handlers. Looking at map file revealed it and it works now. --------------------------------------- Posted through http://www.EmbeddedRelated.com







