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

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

Re: [avr-libc-dev] eeprom_rb strangeness??


From: E. Weddington
Subject: Re: [avr-libc-dev] eeprom_rb strangeness??
Date: Fri, 01 Nov 2002 11:08:12 -0700

On 1 Nov 2002 at 9:53, Theodore A. Roth wrote:

> 
> 
> On Fri, 1 Nov 2002, Joerg Wunsch wrote:
> 
> :) As Thedore A. Roth wrote:
> :)
> :) > I would think that this should be:
> :) >
> :) >   unsigned char eeprom_rb (unsigned char *addr);
> :)
> :) I'd prefer uint8_t *addr.  Both are the same, but the term "char"
> :) mnemonically refers to a character you can display, while "uint8_t"
> :) rather means a small integer type.  Also, since C99 now
> standardizes :) integer types of certain bit width, we can give a good
> example for :) what is preferable over all those home-brewn "u8" etc.
> data types. :) :) Or, just use "void *".  In particular for
> eeprom_read_block(), this :) would allow passing the address of a
> structure without any typecast. :) :) Maybe uint8_t * for the
> single-byte operations, and void * for the :) block operation(s)?
> 
> Ok, here's the new prototypes I propose then:
> 
> 
>   #include <inttypes.h>
> 
>   uint8_t eeprom_rb (uint8_t *addr);
>   void eeprom_wb (uint8_t *addr, uint8_t val);
> 
>   uint16_t eeprom_rw (uint16_t *addr);
> 
>   void eeprom_read_block (void *to_buf, void *from_addr, size_t n);
> 
> And for completeness, I propose adding these:
> 
>   void eeprom_ww (uint16_t *addr, uint16_t val);
>   void eeprom_write_block (void *to_addr, void *from_buf, size_t n);
> 

For readability it would be nice to have

eeprom_read_byte
eeprom_write_byte
eeprom_read_word
eeprom_write_word
eeprom_read_block
eeprom_write_block

Why would read_block and write_block be spelled out and the others 
abbreviated? It makes for a non-mnemonically optimal API.

Eric




reply via email to

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