|
From: | E. Weddington |
Subject: | Re: [avr-gcc-list] generic queue library for AVR GCC? |
Date: | Mon, 15 Nov 2004 16:44:16 -0700 |
User-agent: | Mozilla Thunderbird 0.7.3 (Windows/20040803) |
Bruce D. Lightner wrote:
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...
You're right. I misspoke. (and mentioned this in another response).
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. :-)
Oh, well that makes sense....
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.
Absolutely. :-) Eric
[Prev in Thread] | Current Thread | [Next in Thread] |