name=NVM3 Library
description=The NVM3 provides a means to store and retrieve objects (key/value pair) from the flash and provides wear leveling to reduce erase and write cycles to maximise the lifetime of the flash pages. Objects in NVM3 can either be accessed directly through the native NVM3 API or through the token API in the same way as SimEE1 or SimEE2 based tokens. This library requires the Simulated EEPROM version 2 to NVM3 upgrade library or stub upgrade library. The number of flash pages to use for the NVM3 storage is configurable through the plugin options. IMPORTANT When compiling for a device which already contains NVM3 data, the number of flash pages configured for the compilation must match the number of flash pages used for the existing NVM3 instance on the device.
category=HAL

qualityString=Production Ready
quality=Production

architecture=efr32, simulation

providedApis=nvm3, token-storage, ble-token-storage

requiredApis=sim-eeprom2-to-nvm3-upgrade

api.nvm3.header= $HAL/plugin/nvm3/nvm3-token.h

libraryFiles(efr32~series[1]+iar)=$EMDRV/nvm3/lib/libnvm3_CM4_iar.a
libraryFiles(efr32~series[1]+gcc)=$EMDRV/nvm3/lib/libnvm3_CM4_gcc.a
libraryFiles(efr32~series[2]+iar)=$EMDRV/nvm3/lib/libnvm3_CM33_iar.a
libraryFiles(efr32~series[2]+gcc)=$EMDRV/nvm3/lib/libnvm3_CM33_gcc.a

$EMDRV/nvm3/src/nvm3_default.c    (efr32)
$EMDRV/nvm3/src/nvm3_hal_flash.c  (efr32)
$EMDRV/nvm3/src/nvm3_lock.c

setup(additionalFiles) {
  PATH(ABSOLUTE):$EMDRV/nvm3/inc
  PATH(ABSOLUTE):$EMDRV/nvm3/config
}

options=flashPages, cacheSize, maxObjectSize, userRepackHeadroom

flashPages.name=Flash Pages
flashPages.description= Number of flash pages to use for data storage in NVM3. When compiling for a device which already contains NVM3 data, the number of flash pages configured for the compilation must match the number of flash pages used for the existing NVM3 instance on the device.
flashPages.type=NUMBER:3
flashPages.macro=-DNVM3_FLASH_PAGES
flashPages.default(efr32~series[1])=18
flashPages.default(efr32~series[2])=4

cacheSize.name=Cache Size
cacheSize.description= Number of NVM3 objects to cache. To reduce access times this number should be equal to or higher than the number of NVM3 objects in the default NVM3 instance, including tokens.
cacheSize.type=NUMBER
cacheSize.macro=-DNVM3_DEFAULT_CACHE_SIZE
cacheSize.default=100

maxObjectSize.name=Max Object Size
maxObjectSize.description= Max NVM3 object size that can be stored. Note that only objects with size up to 254 bytes can be defined and accessed through the token API. For larger objects the native NVM3 API must be used.
maxObjectSize.type=NUMBER:208,1900
maxObjectSize.macro=-DNVM3_DEFAULT_MAX_OBJECT_SIZE
maxObjectSize.default=254

userRepackHeadroom.name=User Repack Headroom
userRepackHeadroom.description= Headroom determining how many bytes below the forced repack limit the user repack limit should be placed. The default is 0, which means the user and forced repack limits are equal.
userRepackHeadroom.type=NUMBER
userRepackHeadroom.macro=-DNVM3_DEFAULT_REPACK_HEADROOM
userRepackHeadroom.default=0

setup(macros) {
    -DUSE_NVM3
    -DNVM3_DEFAULT_NVM_SIZE=NVM3_FLASH_PAGES*FLASH_PAGE_SIZE
  }

setup(template) {
  simeepromSize=$--(nvm3_flashPages*pageSize)--$
}
