eeprom_read_* functions: address parameter of different sizes ??? (byte/word/dword)

Status
Not open for further replies.

pramilo

Well-known member
Hi

I've been using the direct implementation of the eeprom_read_* and eeprom_write_* functions.

However, the functions have a strange design/declaration that seems to limit the addresses on which you can read/write, depending on the size of the variable you're reading.

For example, to read a byte:
uint8_t eeprom_read_byte(const uint8_t *addr) __attribute__ ((pure));

With this declaration it seems I can only read bytes up to address 255 (???)

The full declaration of all functions is below:

uint8_t eeprom_read_byte(const uint8_t *addr) __attribute__ ((pure));
uint16_t eeprom_read_word(const uint16_t *addr) __attribute__ ((pure));
uint32_t eeprom_read_dword(const uint32_t *addr) __attribute__ ((pure));
void eeprom_write_byte(uint8_t *addr, uint8_t value);
void eeprom_write_word(uint16_t *addr, uint16_t value);
void eeprom_write_dword(uint32_t *addr, uint32_t value);


(the issue/question applies to read and write functions).

Since the Teensy has 2K of EEPROM, it would make sense that in all declarations the *addr parameter would be declared as uint16_t *addr for all functions.
Do you know why this is not the case? Is it a bug or a limitation??

Thank you in advance for your clarification.

Pedro
 
...

For example, to read a byte:
uint8_t eeprom_read_byte(const uint8_t *addr) __attribute__ ((pure));
...

This says that the given pointer is to an element of size uint8_t. The pointer itself can go anywhere, but all data referenced will only reflect the 8 bits at that byte location, treated as an uint8_t. And if it applied, any increments needed to following elements would be indexed 8 bits at a time from that address.

If you have a complete sketch showing your use giving different results that would be needed.
 
Status
Not open for further replies.
Back
Top