avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] generic queue library for AVR GCC?


From: gouy yann
Subject: Re: [avr-gcc-list] generic queue library for AVR GCC?
Date: Tue, 16 Nov 2004 09:20:59 +0100 (CET)

Hi,

I have a question concerning the other bits of SREG.

Saving it before the cli opcode and restoring it at
the end of your critical section is quite nice, but
you seem only interested in preserving the I-bit, what
about the other bits?
Is GCC clever enough to handle them correctly?

best regards.
   Yann

 --- Richard Urwin <address@hidden> a écrit :

> On Monday 15 Nov 2004 11:33 pm, Bruce D. Lightner
> wrote:
> > How about this...
> >
> >      #include <avr/io.h>
> >      #include <avr/interrupt.h>
> >      #include <inttypes.h>
> >      #define begin_critical_section()  SREG; cli()
> >      #define end_critical_section(val) SREG = val
> >      ....
> >      {
> >          unsigned char sreg =
> begin_critical_section();
> >          sm_qin = sm_qout = 0;   // reset queue
> pointers
> >          end_critical_section(sreg);
> >      }
> >
> > This gets you the same, optimally efficient AVR
> code.
> 
> Another option:
> 
> >      #define begin_critical_section() {unsigned
> char sreg = SREG; cli()
> >      #define end_critical_section(val) SREG =
> val;}
> >      ....
> >      {
> >          begin_critical_section();
> >          sm_qin = sm_qout = 0;   // reset queue
> pointers
> >          end_critical_section(sreg);
> >      }
> 
> That will give a C error if you don't match the
> calls up, but requires both
> calls to be at the same block level.
> 
> -- 
> Richard Urwin
> 
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
>  

=====



        

        
                
Vous manquez d’espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour 
dialoguer instantanément avec vos amis. A télécharger gratuitement sur 
http://fr.messenger.yahoo.com


reply via email to

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