大家好!
现在我遇到一个问题:
CC2540 flash存储一般都是用osal_snv_read和osal_snv_write写的吗?
数据手册上说CC2540有2048个字节大小,那么osal 的 NV ID号最大可以定义多大?一条NV ID可以存几个字节?
谢谢!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
最长255个字节。
已经使用的ID在bcomdef.h中可以找到,要处理自己的接着下面ID写。
// Device NV Items - Range 0 - 0x1F
#define BLE_NVID_IRK 0x02 //!< The Device's IRK
#define BLE_NVID_CSRK 0x03 //!< The Device's CSRK
#define BLE_NVID_SIGNCOUNTER 0x04 //!< The Device's Sign Counter
// Bonding NV Items - Range 0x20 - 0x5F - This allows for 10 bondings
#define BLE_NVID_GAP_BOND_START 0x20 //!< Start of the GAP Bond Manager's NV IDs
#define BLE_NVID_GAP_BOND_END 0x5f //!< End of the GAP Bond Manager's NV IDs Range
// GATT Configuration NV Items - Range 0x70 - 0x79 - This must match the number of Bonding entries
#define BLE_NVID_GATT_CFG_START 0x70 //!< Start of the GATT Configuration NV IDs
#define BLE_NVID_GATT_CFG_END 0x79 //!< End of the GATT Configuration NV IDs
/** @} End BLE_NV_IDS */
注意下面的表述,也就是说2K,1K存数据,另1K是做备份。
The main reason for SNV is that it's only possible to erase a page, and not a small area of flash. As you re-write a SNV data item, the SNV will create a new space for it and write it. The old space will be marked as invalid, and will become free again when that page is erased. There is only one active page and then a mirror page where the valid items are copied to when the page gets full. I think the max size for everything in SNV is 1K (minus about 250K for bonding info).