avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] [RFC] New macros for pgmspace.h


From: E. Weddington
Subject: [avr-libc-dev] [RFC] New macros for pgmspace.h
Date: Thu, 05 Jun 2003 11:42:57 -0600

It was suggested to me to add a couple of new macros to pgmspace.h:

pgm_read_byte_next();
pgm_read_word_next();

These would only be applicable to the Enhanced architecture where [E]LPM Z+ is 
available. These macros would take advantage of the pgm_read_[byte|word]() 
macros and the Z post increment to read the next [byte|word] that the Z reg 
currently points to and then also do a Z increment. In other words the 
pgm_read_[byte|word]() macro sets up the beginning address and reads the first 
value, then the pgm_read_[byte|word]_next() macro reads in subsequent values 
without specifying a flash address:

value[0] = pgm_read_word(address);
value[1] = pgm_read_word_next();
value[2] = pgm_read_word_next();

My only concern would be if a user called the _next() macros without 
originating the beginning address, then the value would be whatever happened to 
be in the Z reg at the time. This issue could be addressed by documentation and 
caveat emptor. 

But I have no strong feelings either way to add this or not.

Comments?

Eric Weddington




reply via email to

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