Functions | |
int | Eeprom_SetActive (int state) |
Set the active state of the EEPROM subsystem. | |
int | Eeprom_GetActive () |
Read the active state of the EEPROM. | |
int | Eeprom_Write (int address, uchar *buffer, int count) |
Write data to the EEPROM. | |
int | Eeprom_Read (int address, uchar *buffer, int count) |
Read data from the EEPROM. |
The last 1k (1024) bytes of this space are reserved for Make Controller system use, storing things like the board's IP address, serial number, build version, etc.
The symbol EEPROM_SYSTEM_BASE provides the last available address before the reserved section. Use it to locate your own locations in EEPROM by subracting from it as appropriate for your data. For example, if you're storing integers, you can use code like
#define MY_FIRST_VALUE (EEPROM_SYSTEM_BASE - 4) #define MY_SECOND_VALUE (MY_FIRST_VALUE - 8)
You can then use those values as the addresses to read and write from, like
Use Eeprom_Write() and Eeprom_Read() to store and retrieve characters. These both internally set the EEPROM system to active automatically.
Internally, Eeprom relies on SPI, so activating Eeprom also activates SPI.
int Eeprom_GetActive | ( | void | ) |
int Eeprom_Read | ( | int | address, | |
uchar * | buffer, | |||
int | count | |||
) |
Read data from the EEPROM.
address | An integer specifying the address to read from. | |
buffer | A pointer to the buffer to read into. | |
count | An integer specifying the number of bytes to read. |
#define MY_STORED_VALUE (EEPROM_SYSTEM_BASE - 4) int my_stored_number; int size = 4; // ints are 4 if(Eeprom_Read( MY_STORED_VALUE, (uchar*)&my_stored_number, size ) < 0) { // then there was an error... } else { // my_stored_number now has the stored value }
int Eeprom_SetActive | ( | int | state | ) |
int Eeprom_Write | ( | int | address, | |
uchar * | buffer, | |||
int | count | |||
) |
Write data to the EEPROM.
address | An integer specifying the address. | |
buffer | A pointer to the buffer to write from. | |
count | An integer specifying the number of bytes to write. |
#define MY_STORED_VALUE (EEPROM_SYSTEM_BASE - 4) int my_number_to_store = 1234; int size = 4; // ints are 4 if(Eeprom_Write( MY_STORED_VALUE, (uchar*)&my_number_to_store, size ); < 0) { // then there was an error... } else { // my_stored_number now has the stored value }