[Top][All Lists]
[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
- Re: [avr-gcc-list] generic queue library for AVR GCC?, (continued)
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Ned Konz, 2004/11/11
- Re: [avr-gcc-list] generic queue library for AVR GCC?, gouy yann, 2004/11/11
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Bruce D. Lightner, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?, E. Weddington, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Bruce D. Lightner, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?, E. Weddington, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?,
Richard Urwin <=
- Re: [avr-gcc-list] generic queue library for AVR GCC?, gouy yann, 2004/11/16
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Bjarne Laursen, 2004/11/16
- Re: [avr-gcc-list] generic queue library for AVR GCC?, David Brown, 2004/11/16
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Ian Caddy, 2004/11/16
- Re: [avr-gcc-list] generic queue library for AVR GCC?, David Brown, 2004/11/16
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Richard Urwin, 2004/11/16
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Geoffrey Wossum, 2004/11/16
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Richard Urwin, 2004/11/16
- Re: [avr-gcc-list] generic queue library for AVR GCC?, David Brown, 2004/11/17
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Mike Panetta, 2004/11/17