EEPROM emulation in flash memory.
More...
EEPROM emulation in flash memory.
Eeprom is first initialized at boot time by the system calling eeprom_setup(), which copies the last saved version of the data from flash to an dedicated RAM area. This area can then be read or modified. If modified, the RAM area must be written back to flash with eeprom_commit().
The fraise_eeprom API reserves some bytes at the beginning of the emulated EEPROM to store fraise system data, such as the "name" and the "ID" of the device.
◆ eeprom_declare_main()
void eeprom_declare_main |
( |
| ) |
|
User defined function where to declare the parameters.
- Note
- User has to define this function, which must be a list of eeprom_declare_*() calls. Example:
◆ eeprom_declare_data()
void eeprom_declare_data |
( |
char * |
data, |
|
|
uint8_t |
size |
|
) |
| |
Declare data of arbitrary size.
- Note
- use in eeprom_declare_main() only
- Parameters
-
data | the address of the declared data |
size | the size of the data |
◆ eeprom_declare_int8()
void eeprom_declare_int8 |
( |
int8_t * |
data | ) |
|
|
inline |
Declare a 8-bit signed parameter.
- Note
- use in eeprom_declare_main() only
- Parameters
-
data | the address of the declared parameter |
◆ eeprom_declare_uint8()
void eeprom_declare_uint8 |
( |
uint8_t * |
data | ) |
|
|
inline |
Declare a 8-bit unsigned parameter.
- Note
- use in eeprom_declare_main() only
- Parameters
-
data | the address of the declared parameter |
◆ eeprom_declare_int16()
void eeprom_declare_int16 |
( |
int16_t * |
data | ) |
|
|
inline |
Declare a 16-bit signed parameter.
- Note
- use in eeprom_declare_main() only
- Parameters
-
data | the address of the declared parameter |
◆ eeprom_declare_uint16()
void eeprom_declare_uint16 |
( |
uint16_t * |
data | ) |
|
|
inline |
Declare a 16-bit unsigned parameter.
- Note
- use in eeprom_declare_main() only
- Parameters
-
data | the address of the declared parameter |
◆ eeprom_declare_int32()
void eeprom_declare_int32 |
( |
int32_t * |
data | ) |
|
|
inline |
Declare a 32-bit signed parameter.
- Note
- use in eeprom_declare_main() only
- Parameters
-
data | the address of the declared parameter |
◆ eeprom_declare_uint32()
void eeprom_declare_uint32 |
( |
uint32_t * |
data | ) |
|
|
inline |
Declare a 32-bit unsigned parameter.
- Note
- use in eeprom_declare_main() only
- Parameters
-
data | the address of the declared parameter |
◆ eeprom_load()
Reload all the parameters from eeprom.
- Note
- You might want to call this function in your setup().
◆ eeprom_save()
◆ eeprom_setup()
Initialize the eeprom by copying data from flash to RAM.
- Note
- This function is automatically called at startup. You shouldn't need to call it manually.
◆ eeprom_user_read()
char eeprom_user_read |
( |
int |
address | ) |
|
Read a byte from eeprom user space.
- Parameters
-
address | the address to read |
- Returns
- the data at this address
◆ eeprom_user_write()
void eeprom_user_write |
( |
int |
address, |
|
|
char |
data |
|
) |
| |
Write a byte to eeprom user space.
- Parameters
-
address | the address to write to |
data | the value of the byte to write |
◆ eeprom_write_name()
void eeprom_write_name |
( |
char * |
newname | ) |
|
Change the device name in eeprom.
- Parameters
-
newname | the new name to store (no more than 16 chars) |
◆ eeprom_get_name()
const char* eeprom_get_name |
( |
| ) |
|
Read the device name stored in eeprom.
- Returns
- the currently stored name
◆ eeprom_set_id()
void eeprom_set_id |
( |
uint8_t |
newid | ) |
|
Change the device ID in eeprom.
- Parameters
-
newid | the new ID to store (must be in range [1:126]) |
◆ eeprom_get_id()
uint8_t eeprom_get_id |
( |
| ) |
|
Read the device ID stored in eeprom.
- Returns
- the currently stored ID
◆ eeprom_commit()
Actually write the eeprom area to flash.
- Note
- This function is protected with a critical section, which ensures that interrupt are fully disabled during actual flash writing.