How To Use

Use the EEPROM Emulation module as follows:

1. Selecting Files

Add the following source and header files to the project:

  • Core (mandatory): eeprom_emul_core.c, eeprom_emul_core.h

  • Algorithm (select one algorithm depending on the Flash memory type):

    • FLITF: eeprom_algo_flitf.c, eeprom_algo_flitf.h

    • NVM: eeprom_algo_nvm.c, eeprom_algo_nvm.h

  • Interfaces (at least the Flash interface is required; CRC and ECC interfaces are optional):

    • Flash:

      • FLITF EDATA: eeprom_itfflash_flitf_edata.c

      • NVM EDATA: eeprom_itfflash_nvm_edata.c

      • Template: eeprom_itfflash_template.c

      • Header: eeprom_itf_flash.h

    • CRC:

      • Ready-to-use implementation: eeprom_itfcrc_crc.c

      • Template: eeprom_itfcrc_template.c

      • Header: eeprom_itf_crc.h

    • ECC:

      • BCH-based ready-to-use implementation: eeprom_itfecc_bch.c

      • Template: eeprom_itfecc_template.c

      • Header: eeprom_itf_ecc.h

  • User configuration (mandatory): eeprom_emul_conf.h

2. Configuration

2.1. User Configuration

The following table summarizes the main configuration items in the user configuration header eeprom_emul_conf.h (algorithm selection, capacity, and endurance):

Example minimal custom header eeprom_emul_conf.h for FLITF:

#ifndef EEPROM_EMULATION_CONF_H
#define EEPROM_EMULATION_CONF_H

/* Select algorithm */
#define EE_ALGO_FLITF              (1)

/* Optional features */
#define EE_ECC_CAPABLE             (1)

/* FLITF frame layout */
#define EE_FRAME_LINE_SIZE         (8)

/* Emulation area mapping (adapt to the linker script) */
#define EE_START_PAGE_ADDRESS      (FLASH_EDATA_BASE + FLASH_EDATA_BANK_SIZE)
#define EE_FLASH_BASE_ADDRESS      FLASH_EDATA_BASE
#define EE_FLASH_PAGE_SIZE         FLASH_EDATA_PAGE_SIZE
#define EE_FLASH_BANK_SIZE         (FLASH_EDATA_BANK_SIZE*2)

/* Capacity and endurance */
#define EE_NB_OF_VARIABLES         (1000U)
#define EE_CYCLES_NUMBER           (1U)
#define EE_GUARD_PAGES_NUMBER      (1U)

#endif /* EEPROM_EMULATION_CONF_H */

Example minimal custom header ``eeprom_emul_conf.h`` for NVM:
#ifndef EEPROM_EMULATION_CONF_H
#define EEPROM_EMULATION_CONF_H

/* Select algorithm */
#define EE_ALGO_NVM               (1)

/* Emulation area mapping (adapt to the linker script) */
#define EE_START_PAGE_ADDRESS      (NVM_EDATA_BASE)
#define EE_SECTOR_SIZE             (8U*1024U)

/* Capacity / endurance */
#define EE_NB_OF_VARIABLES         (1000U)
#define EE_NB_OF_8BITS_VARIABLES   (500U)
#define EE_NB_OF_16_32BITS_VARIABLES (500U)
#define EE_CYCLES_NUMBER           (1U)

#endif /* EEPROM_EMULATION_CONF_H */

3. EEPROM Emulation Initialization

Initialize EEPROM Emulation by calling EE_Init() with a pointer to an ee_object_t instance ( ee_obj) and an erase type (erase_type). The ee_obj structure holds the EEPROM Emulation context and runtime state. The erase type defines the erase policy applied during initialization (for example, EE_CONDITIONAL_ERASE erases only when required by the algorithm state). EE_Init() initializes the selected interfaces and performs the algorithm-specific recovery actions (FLITF or NVM).

ee_object_t ee_obj;

EE_Init(&ee_obj, EE_CONDITIONAL_ERASE);

4. EEPROM Emulation Usage

After file selection, interface configuration, and initialization, the EEPROM Emulation module is ready to use. The core API provides functions to read and write variables of different sizes and to perform maintenance tasks.