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

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

Re: [avr-libc-dev] interrupt enable functions


From: Theodore A. Roth
Subject: Re: [avr-libc-dev] interrupt enable functions
Date: Wed, 7 Aug 2002 16:29:48 -0700 (PDT)

On Thu, 8 Aug 2002, 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?

Not really, but here goes anyways. ;-)

First, I think that you should be using _BV() instead of the deprecated (I
believe) BV(). That's an off topic nit though.

I vaguely remember Marek telling me that some things like this are only in
there to be used as examples. The documentation should probably say that
this is an example, note the flaw in it and leave it at that. So many
things like this are way too dependant on the target device that it is
hard to make them generic. In the end, the developer still needs to know
what she's doing.

Joerg's proposal is probably valid though for two reasons:

  - makes it harder to shoot one's self in the foot.
  - is a better example of how to do it.

Personally, I wouldn't use these either. I'd just twiddle the bits myself.
;-)

Ted Roth




reply via email to

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