d00616 / arduino-NVM

Direct flash memory access, round robin virtual pages and EEPROM like memory.
GNU Lesser General Public License v2.1
25 stars 4 forks source link

Read/write simple example #7

Closed tonialomar closed 1 year ago

tonialomar commented 1 year ago

Hello,

I just want to do the following:

Before I power off device save to a variable let's say value 0x69

Once the device wakes up I want to read the exact same address and read the content to modify it.

How can I do it?

I don't understand any of the examples.. what are the pages?

Any help would be appreciated.

Toni

d00616 commented 1 year ago

Hello Toni,

this library hides complexity of managing flash pages i a manner to allow a lot of writes like eeprom. You can ignore pages and nvram and use the eeprom emulation layer.

To read and write only one Byte, you can use "eeprom_write_byte(0, 0x69)" and "eeprom_read_byte(0)"

If your structure is logner than a byte, you can use eeprom_write_block(&vour_variable, 0, sizeof(your_variable)) and eeprom_read_block(&your_variable, 1, sizeof(your_variable));

If you want to have more control for time critical implementations, you can use the NVRAM class. The NVRAM-Class allows to control page cleanup, which can block for up to 5 seconds (nrf51).