EEPROM
[Core]

Eeprom allows for the persistent storage of 32k bytes data. More...


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.

Detailed Description

Eeprom allows for the persistent storage of 32k bytes data.

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.


Function Documentation

int Eeprom_GetActive ( void   ) 

Read the active state of the EEPROM.

Returns:
State - 1/non-zero (on) or 0 (off).

Definition at line 106 of file eeprom.c.

int Eeprom_Read ( int  address,
uchar *  buffer,
int  count 
)

Read data from the EEPROM.

Parameters:
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.
Returns:
Status: 0 on success, < 0 on failure.
Example
  #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
  }

Definition at line 193 of file eeprom.c.

int Eeprom_SetActive ( int  state  ) 

Set the active state of the EEPROM subsystem.

This is automatically set to true by any call to Eeprom_Write or Eeprom_Read.

Parameters:
state An integer specifying the active state - 1 (on) or 0 (off).
Returns:
CONTROLLER_OK (=0) on success.

Definition at line 94 of file eeprom.c.

int Eeprom_Write ( int  address,
uchar *  buffer,
int  count 
)

Write data to the EEPROM.

Parameters:
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.
Returns:
Status: 0 on success, < 0 on failure.
Example
  #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
  }

Definition at line 133 of file eeprom.c.