[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: |
Bruce D. Lightner |
Subject: |
Re: [avr-gcc-list] generic queue library for AVR GCC? |
Date: |
Mon, 15 Nov 2004 15:33:11 -0800 |
User-agent: |
Mozilla Thunderbird 0.5 (Windows/20040207) |
E. Weddington wrote:
I agree with Bruce's method; it's better in that it preserves the
original state of the interrupt flag.
I believe that the "push/pop" method did as well...
The push/pop is not required, and probably wasteful.
Though you don't have to do it in inline assembly. It can be done all in C:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
....
{
uint8_t sreg = SREG;
cli();
sm_qin = sm_qout = 0; // reset queue pointers.
SREG = sreg; }
Yeah. I like yours better. The resultant AVR code is identical.
I've got to "get onboard" with the "new" gcc 3.x AVR I/O syntax.
I still have a number of active mixed AVR assembly/avr-gcc
projects, which only work with the gcc 2.95 I/O definitions, so
I guess I gravitate to inline assembly more often than I probably
should. :-)
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.
Best regards,
Bruce
--
Bruce D. Lightner
Lightner Engineering
La Jolla, California
Voice: +1-858-551-4011
FAX: +1-858-551-0777
Email: address@hidden
URL: http://www.lightner.net/lightner/bruce/
- [avr-gcc-list] generic queue library for AVR GCC?, David Morrison, 2004/11/11
- Re: [avr-gcc-list] generic queue library for AVR GCC?, E. Weddington, 2004/11/11
- 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 <=
- 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, 2004/11/16
- 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