[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] Any way to friend an interrupt handler?

From: David Brown
Subject: Re: [avr-chat] Any way to friend an interrupt handler?
Date: Thu, 21 Feb 2013 18:44:24 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 20/02/13 22:24, Rick Mann wrote:

On Feb 20, 2013, at 2:08 , David Brown <address@hidden>

Another option that might be usable (depending on how things are
split within different modules) is to make the ISR just a wrapper
for the "real" code:

class x { friend void ::timerInterrupt(void); private : int i; };

class x the_x;

static void timerInterrupt(void) { the_x.i++; }

ISR(TIMER1_OVF_vect) { timerInterrupt(); }

With non-negligible optimisations enabled, the static
timerInterrupt function will be inlined within the ISR function, so
there is no extra overhead.  (Normally there can be significant
overhead if an interrupt function calls an external function.)

Just a thought for another style.

Yeah, that's how I had been doing it, but I wanted to ensure I didn't
have the overhead in this case, even when no optimizations were

The key point here is never to compile without optimisations enabled. Why would you want to do that anyway? It's like driving your car without ever moving out of first gear. You've got a top-class optimising compiler - don't cripple it by disabling it's optimisations! Even for debugging or analysing code, -O1 is usually easier to work with than -O0.

But if you /really/ want to disable optimisations, then "__attribute__((always_inline))" is your friend here.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]