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

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

[avr-libc-dev] [RFC] Solution for bug #3508


From: E. Weddington
Subject: [avr-libc-dev] [RFC] Solution for bug #3508
Date: Thu, 12 Jun 2003 11:21:33 -0600

In thinking about a solution for bug #3508 
<http://savannah.nongnu.org/bugs/?func=detailbug&bug_id=3508&group_id=2140>,
 the code in avr/interrupt.h that is the problem is:

extern inline void enable_external_int (unsigned char ints)
{
#if defined(EIMSK)
  EIMSK = ints;
#elif defined(GIMSK)
  GIMSK = ints;
#elif defined(GICR)
  GICR = ints;
#else
# error "No valid external interrupt control register defined."
#endif
}

The problem being that the 86RF401 has no external interrupt control 
register. When using this processor and avr/interrupt.h is included, it 
generates the above error which is bogus for this processor.

I propose a solution that does away with implementing this as an inline 
function, and implements it as a macro instead. 

/* Define common register definition if available. */
#ifdef EIMSK
#define __EICR  EIMSK
#endif
#ifdef GIMSK
#define __EICR  GIMSK
#endif
#ifdef GICR
#define __EICR  GICR
#endif

/* If common register defined, define macro. */
#ifdef __EICR
#define enable_external_int(mask)               (__EICR = mask)
#endif

It's not necessary to implement as an inline function and this achieves the 
same results with the added benefit that if the register does not exist, 
the API does not exist for that processor. Without ifdefing on a specific 
processor ID. It also scalable; if Atmel defines new processors with 
different names for an external interrupt control register, it can be 
easily added.

Comments?

Eric Weddington




reply via email to

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