This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

what's the safest way to wait for pstorage_store

when I call pstorage_store so store a block of data, sometimes I call just after pstorage_store: the following code

do {
	pstorage_access_status_get(&count);
} while (count);

sometimes I want for a flag while(!flashWriteTerminated); which is set to false on flash callback handler

    static void flash_callback_handler(pstorage_handle_t * p_handle,
        uint8_t             op_code,
        uint32_t            result,
        uint8_t           * p_data,
        uint32_t            data_len)
    {
        switch (op_code) {
        case PSTORAGE_STORE_OP_CODE:
            if (result == NRF_SUCCESS) {
                flashWriteTerminated = true;
            }
            else {
                APP_ERROR_CHECK(result);    // Store operation failed.
            }
            break;
        case PSTORAGE_LOAD_OP_CODE:
            if (result == NRF_SUCCESS) {
    					flashWriteTerminated = true;
            }
            else {
                APP_ERROR_CHECK(result);    // Store operation failed.
            }
            break;
        case PSTORAGE_CLEAR_OP_CODE:
            if (result == NRF_SUCCESS) {
    					flashWriteTerminated = true;
            }
            else {
                APP_ERROR_CHECK(result);    // Store operation failed.
            }
            break;
        case PSTORAGE_UPDATE_OP_CODE:
            if (result == NRF_SUCCESS) {
flashWriteTerminated = true;
            }
            else {
                APP_ERROR_CHECK(result);    // Store operation failed.
            }
            break;
        default:
            break;
        }
    }

what's the effective way to wait for pstorage_store load clear functions to ensure that flash data is successfuly handled

Related