NVM#

Functions#

sl_status_t 

sl_bt_nvm_save (uint16_t key, size_t value_len, const uint8_t *value)

sl_status_t 

sl_bt_nvm_load (uint16_t key, size_t max_value_size, size_t *value_len, uint8_t *value)

sl_status_t 

sl_bt_nvm_erase (uint16_t key)

sl_status_t 

sl_bt_nvm_erase_all ()

Defined Keys#

#define 

NVM_KEY_CTUNE   0x32

Detailed Description#

NVM.

Provide an interface to manage user data objects (key/value pairs) in the flash memory. User data stored within the flash memory is persistent across reset and power cycling of the device. Because Bluetooth bondings are also stored in this flash area, in addition to the flash storage size, the space available for user data also depends on the number of bondings the device has at the time.

On EFR32[B|M]G1x devices, either PS Store or NVM3 data storage driver can be used. As PS Store is supported by the Bluetooth stack only, using NVM3 is recommended if the device needs to support Dynamic Multiple Protocol (DMP) cases. On EFR32[B|M]G2x devices, only NVM3 is supported. When NVM3 is used, applications can also use the NVM3 APIs directly.

In PS Store, the flash storage size is fixed at 2048 bytes. The maximum data object size associated to a key is 56 bytes. A Bluetooth bonding uses at maximum 138 bytes for secure connections and 174 bytes for legacy pairing.

In NVM3, the flash store size is configurable, and the minimum is 3 flash pages. The maximum data object size is configurable up to 4096 bytes. A Bluetooth bonding uses at maximum 110 bytes for secure connections and 138 bytes for legacy pairing. See more details in AN1135 "Using Third Generation NonVolatile Memory (NVM3) Data Storage".

Macro Definition Documentation#

NVM_KEY_CTUNE#

#define NVM_KEY_CTUNE   0x32

Crystal tuning value override

Function Documentation#

sl_bt_nvm_save()#

sl_status_t sl_bt_nvm_save

(

uint16_t 

key,

size_t 

value_len,

const uint8_t * 

value

)

Store a value into the specified NVM key. Allowed NVM keys are in range from 0x4000 to 0x407F. At most, 56 bytes user data can be stored in one NVM key. Error code 0x018a (command_too_long) is returned if the value data is more than 56 bytes.

Parameters

[in]

key

NVM key

[in]

value_len

Array length

[in]

value

Value to store into the specified NVM key

Returns#

SL_STATUS_OK if successful. Error code otherwise.

sl_bt_nvm_load()#

sl_status_t sl_bt_nvm_load

(

uint16_t 

key,

size_t 

max_value_size,

size_t * 

value_len,

uint8_t * 

value

)

Retrieve the value of the specified NVM key.

Parameters

[in]

key

NVM key of the value to be retrieved

[in]

max_value_size

Size of output buffer passed in value

[out]

value_len

On return, set to the length of output data written to value

[out]

value

The returned value of the specified NVM key

Returns#

SL_STATUS_OK if successful. Error code otherwise.

sl_bt_nvm_erase()#

sl_status_t sl_bt_nvm_erase

(

uint16_t 

key

)

Delete a single NVM key and its value from the persistent store.

Parameters

[in]

key

NVM key to delete

Returns#

SL_STATUS_OK if successful. Error code otherwise.

sl_bt_nvm_erase_all()#

sl_status_t sl_bt_nvm_erase_all

(

)

Delete all NVM keys and their corresponding values.

Returns#

SL_STATUS_OK if successful. Error code otherwise.