avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] Re: C++ Interrupts


From: Ron Kreymborg
Subject: [avr-libc-dev] Re: C++ Interrupts
Date: Tue, 22 Jan 2008 13:02:11 +1100

The macro:

#define CLASS_ISR(vector, ...) { vector(); } ISR(vector)

when used in the class method:

void CTimer0Interrupt::TIMER0_OVF_vect(void) 
            CLASS_ISR(TIMER0_OVF_vect, ISR_BLOCK)
{
    TCNT0 = TIMER0_TIMEOUT;     // restart the timeout
    Timer0.SetOverflowFlag();
}

becomes:

void CTimer0Interrupt::__vector_16(void) { __vector_16(); } 
extern "C" void __vector_16(void) 
        __attribute__ ((signal,used,externally_visible)); 
void __vector_16 (void)
{
    (*(volatile uint8_t *)((0x32) + 0x20)) = 100;
    Timer0.SetOverflowFlag();
}

which, from the interrupt system's point of view, is the same as the code:

ISR(TIMER0_OVF_vect)
{
    TCNT0 = TIMER0_TIMEOUT;     // restart the timeout
    Timer0.SetOverflowFlag();
}

This works fine if SetOverflowFlag is defined as public, but this is
essentially where I started. 

IMHO the only way is to define the interrupt method in the class with
interrupt attributes and then alias the mangled name to the AVR vector so
the compiler can find it during global name reconciliation. This would be
very neat and simple if we could develop a simple name mangling macro.

Ron






reply via email to

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