Embedded Artists


We are the leading providers of products and services around prototyping, evaluation and OEM platforms using NXP's ARM-based microcontrollers.

LPC4088DM Using the Registry

The LPC4088 MCU on the display modules have an internal 4032 byte EEPROM that can be used to store data persistently.

The InternalEEPROM is described here.

The memory is ideally suited to store small bits of configuration data between program runs. It could be last played file in a music player, last shown image in a slideshow, network settings etc.

The DMSupport library has a Registry class to help with this.

Import library

Public Member Functions

RegistryError load ()
Loads all (if any) values from the internal EEPROM.
RegistryError setValue (const char *key, const char *val)
Sets (or replaces if existing) the value for the key.
RegistryError getValue (const char *key, char **pVal)
Gets (if any) the the value for the key.
RegistryError entryAt (int pos, char **pKey, char **pVal)
Retrieves the key-value pair at the specified index.
int numEntries ()
Returns the number of key-value pairs in the registry.
RegistryError store ()
Stores the registry in the internal EEPROM.

Static Public Member Functions

static Registry & instance ()
Get the only instance of the Registry .

The Registry is intended to be used in the RTOS so all operations are thread safe. One of the purposes with the Registry is to allow one thread to store data that another thread needs. An example is to have the GUI thread store the network configuration in the Registry so that the networking thread can read it and setup the network accordingly.

To use the Registry it must first be enabled in the dm_board_config.h file:

#define DM_BOARD_USE_REGISTRY


It is then initialized and all (if any) existing key-value pairs are loaded by the init() function in DMBoard.

static void testRegistry()
{
  Registry* reg = DMBoard::instance().registry();
  RtosLog* log = DMBoard::instance().logger();
  char* key;
  char* val;
  Registry::RegistryError err;

  // Print all existing values
  for (int i = 0; i < reg->numEntries(); i++) {
    err = reg->entryAt(i, &key, &val);
    if (err == Registry::Ok) {
      log->printf("[%2d] '%s' = '%s'\n", i, key, val);
      free(key);
      free(val);
    }
  }
  
  // Reading a value:
  err = reg->getValue("IP Address", &val);
  if (err == Registry::Ok) {
    log->printf("'IP Address' = '%s'\n", val);
    free(val);
  } else if (err == Registry::NoSuchKeyError) {
    log->printf("'IP Address' has no value in registry\n");
  } else {
    log->printf("'IP Address' got error %d\n", err);
  }
  
  // Write a value (possibly overwriting the old value)
  err = reg->setValue("IP Address", "192.168.0.10");
  if (err == Registry::Ok) {
    log->printf("'IP Address' set to 192.168.0.10\n");
  } else {
    log->printf("Failed to set 'IP Address', got error %d\n", err);
  }

  // Store the values in the EEPROM
  log->printf("Storing values persistently\n");
  err = reg->store();
  if (err != Registry::Ok) {
    log->printf("Failed to store values, got error %d\n", err);
  }
}


Note

The Registry occupies the entire onchip EEPROM so use either the Registry or the InternalEEPROM - not both at the same time.


All wikipages