Hi:
I use nRF5_SDK_15.0.0_a53641a\examples\ble_peripheral\ble_app_buttonless_dfu.
I want to add flash operation.
The code is as follows.
mian()
{
...............
..............
#if FLASH_ENABLED
uint8_t i;
uint32_t uc[6];
uint32_t rc;
static uint32_t pages_to_erase = 1;
nrf_fstorage_api_t * p_fs_api;
p_fs_api = &nrf_fstorage_sd;
rc = nrf_fstorage_init(&fstorage, p_fs_api, NULL);
APP_ERROR_CHECK(rc);
rc = nrf_fstorage_erase(
&fstorage, /* The instance to use. */
0x51000, /* The address of the flash pages to erase. */
pages_to_erase, /* The number of pages to erase. */
NULL /* Optional parameter, backend-dependent. */
);
if (rc == NRF_SUCCESS)
{
NRF_LOG_INFO("nrf_fstorage_erase success.");
}
else
{
NRF_LOG_INFO("nrf_fstorage_erase error.");
}
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");
for(i=0;i<6;i++)
{
uc[i]=(uint32_t)m_password[i];
}
rc = nrf_fstorage_write(&fstorage, 0x51200, uc, sizeof(uc), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");
for(i=0;i<6;i++)
{
uc[i]=0x0000;
}
rc = nrf_fstorage_read(&fstorage, 0x51200, uc,6*4);
APP_ERROR_CHECK(rc);
for(i=0;i<6;i++)
{
NRF_LOG_INFO("%d",(uint8_t)uc[i]);
}
#endif
...................
...................
}
void wait_for_flash_ready(nrf_fstorage_t const * p_fstorage)
{
/* While fstorage is busy, sleep and wait for an event. */
while (nrf_fstorage_is_busy(p_fstorage))
{
power_manage();
}
}
But stayed at wait_for_flash_ready() all the time.(I refer to nRF5_SDK_15.0.0_a53641a\examples\peripheral\flash_fstorage.I don't know where there is difference.)