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: Richard Urwin
Subject: Re: [avr-gcc-list] generic queue library for AVR GCC?
Date: Tue, 16 Nov 2004 07:44:31 +0000
User-agent: KMail/1.5.3

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


reply via email to

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