Hi,
I’ trying to save some user configuration data on the NRF51822 Flash using pstorage module.
Below is the code that I wrote, the code runs on the board with no error and all the functions return 0 but the problem is that the pstorage call back function won’t call and the program never enter the call back function.
I put a break point inside the call back function and verify that.
Please give me some suggestions.
pstorage_handle_t pstorage_handle;
pstorage_module_param_t pstorage_param;
pstorage_handle_t block_handle;
static void example_cb_handler(pstorage_handle_t * handle,
uint8_t op_code,
uint32_t result,
uint8_t * p_data,
uint32_t data_len)
{
switch(op_code)
{
case PSTORAGE_LOAD_OP_CODE:
if (result == NRF_SUCCESS)
{
// Store operation successful.
}
else
{
// Store operation failed.
}
// Source memory can now be reused or freed.
break;
case PSTORAGE_UPDATE_OP_CODE:
if (result == NRF_SUCCESS)
{
// Update operation successful.
}
else
{
// Update operation failed.
}
break;
case PSTORAGE_CLEAR_OP_CODE:
if (result == NRF_SUCCESS)
{
// Clear operation successful.
}
else
{
// Clear operation failed.
}
break;
case PSTORAGE_STORE_OP_CODE:
if (result == NRF_SUCCESS)
{
// Clear operation successful.
oeration_done = 1;
}
else
{
// Clear operation failed.
}
break;
}
}
int main(void){
uint32_t err_code;
err_code = pstorage_init();
APP_ERROR_CHECK(err_code);
pstorage_param.block_size = PSTORAGE_MIN_BLOCK_SIZE;
pstorage_param.block_count = 10;
pstorage_param.cb = example_cb_handler;
err_code = pstorage_register(&pstorage_param, &pstorage_handle);
APP_ERROR_CHECK(err_code);
// Request to get identifier for 1st block.
err_code = pstorage_block_identifier_get(&pstorage_handle, 1, &block_handle);
APP_ERROR_CHECK(err_code);
err_code = pstorage_clear(&pstorage_handle,16);
APP_ERROR_CHECK(err_code);
while(true);}
I’m using SDK 6.1.0 and softdevice s110 7.1.0, softdevice is programmed into the chip but i'm not using it right now.