|
本帖最后由 cyneer 于 2017-12-8 00:34 编辑
这是随便写的一个dome,之前用ble_flash_word_write把数据写入,返回成功,之后读取一直失败,ble_flash_page_read的第三个参数,到底是填1,还是填4,我看它自己的库也没有用到这个参数的内容,复上图以及库函数:
uint32_t ble_flash_page_read(uint8_t page_num, uint32_t * p_out_array, uint8_t * p_word_count)
{
int byte_count;
uint32_t * p_page;
uint32_t * p_curr_addr;
uint32_t flash_header;
uint32_t calc_header;
uint16_t calc_crc;
uint32_t tmp;
p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num);
p_curr_addr = p_page;
// Check if block is valid
flash_header = *p_curr_addr;
tmp = flash_header & 0xFFFF0000;
if (tmp != BLE_FLASH_MAGIC_NUMBER)
{
*p_word_count = 0;
return NRF_ERROR_NOT_FOUND;
}
p_curr_addr++;
// Read number of elements
*p_word_count = (uint8_t)(*(p_curr_addr));
p_curr_addr++;
// Read data
byte_count = (*p_word_count) * sizeof(uint32_t);
memcpy(p_out_array, p_curr_addr, byte_count);
// Check CRC
calc_crc = ble_flash_crc16_compute((uint8_t *)p_out_array,
(*p_word_count) * sizeof(uint32_t),
NULL);
calc_header = BLE_FLASH_MAGIC_NUMBER | (uint32_t)calc_crc;
if (calc_header != flash_header)
{
return NRF_ERROR_NOT_FOUND;
}
return NRF_SUCCESS;
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|