[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] interrupt enable functions
From: |
E. Weddington |
Subject: |
Re: [avr-libc-dev] interrupt enable functions |
Date: |
Wed, 07 Aug 2002 16:41:00 -0600 |
On 8 Aug 2002 at 0:09, Joerg Wunsch wrote:
> While i've fixed Ted's FIXME item above, how do others feel about
> these functions? I don't value them much because they always clobber
> the respective interrupt enable register completely, so when working
> with more than one of each respective interrupt source (timer vs.
> external), one has to manually keep track about which interrupt
> sources are currently enabled.
>
> IMHO, we should deprecate those interfaces, and write a real "enable/
> disable one interrupt source" interface instead, like
>
> timer_enable_int(int bit)
> {
> TIMSK |= BV(bit);
> }
>
> timer_disable_int(int bit)
> {
> TIMSK &= ~BV(bit);
> }
>
> Opinions?
I agree in that those interfaces should be deprecated and should
write a real "enable/disable one interrupt source".
However, in the example above, the programmer is still required to
know the structure of the TIMSK register and ensure that s/he is
setting the correct bit.
As a counter example, it would require a bit more effort but could be
implemented in macros:
// Example for ATmega128
#define timer_1_IC_interrupt_enable() (TIMSK |= BV(5))
#define timer_1_IC_interrupt_disable() (TIMSK &= ~BV(5))
#define timer_1_OCA_interrupt_enable() (TIMSK |= BV(4))
#define timer_1_OCA_interrupt_disable() (TIMSK &= ~BV(4))
#define timer_1_OCB_interrupt_enable() (TIMSK |= BV(3))
#define timer_1_OCB_interrupt_disable() (TIMSK &= ~BV(3))
These macros take care of a single source interrupt.
This could be taken a step further and the numbers for the bit values
could be gotten from the #defines in the processor-specific header
files (i.e. iom128.h, and for that matter these macros could be
placed in the processor-specific files.
Also this brings up another question, in your example Joerg, you do
direct-assignment to the registers. I prefer that as well, using the
"new headers" from Chris Morse and Don Carveth. This method is used
frequently in other cross-compilers (at least on Windows). How about
deprecating the io macros? The compiled output is the same for direct-
assignment vs. macros, and the assignment is easier to read and
understand. See the file newhdrs.txt from the above authors for
discussion.
Eric
- [avr-libc-dev] interrupt enable functions, Joerg Wunsch, 2002/08/07
- Re: [avr-libc-dev] interrupt enable functions,
E. Weddington <=
- Re: [avr-libc-dev] interrupt enable functions, Theodore A. Roth, 2002/08/07
- Re: [avr-libc-dev] interrupt enable functions, Joerg Wunsch, 2002/08/09
- Re: [avr-libc-dev] interrupt enable functions, E. Weddington, 2002/08/09
- Re: [avr-libc-dev] interrupt enable functions, Theodore A. Roth, 2002/08/09
- [avr-libc-dev] compatibility headers, Joerg Wunsch, 2002/08/11
- Re: [avr-libc-dev] interrupt enable functions, Marek Michalkiewicz, 2002/08/10