HI ,ALL
i need to take use of the pstorage module.
i can read the data after reset,but i do not know the reason.
-
the write function is added in the on_write function in ble_nus.c and not list here
-
the project is the ' \examples\ble_peripheral\ble_app_uart '
-
Following is my source code. //my read function
void ReadPstorage(void){
printf("\r\nread flash: ");
my_flag = 0;
pstorage_handle_t dest_block_id;
uint8_t buff[8];
//因为只注册了一个 flash 块,所以其实这个函数可以不调用的。
pstorage_block_identifier_get(&block_id,0,&dest_block_id);
printf("&block_id : %p\r\n",&dest_block_id);
printf("buff : %p\r\n",buff);
pstorage_load(buff, &dest_block_id, 8, 0);
for(int i = 0; i< 8; i++)
{
printf("%d ",buff[i]);
}
}
//my main function
int main(void) {
uint32_t err_code;
bool erase_bonds;
uint8_t start_string[] = START_STRING;
pstorage_module_param_t module_param;
module_param.block_count = 1;
module_param.block_size = 16;
module_param.cb = my_cb;
pstorage_init();
pstorage_register(&module_param, &block_id);
// Initialize.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
uart_init();
buttons_leds_init(&erase_bonds);
ble_stack_init();
gap_params_init();
services_init();
advertising_init();
conn_params_init();
printf("%s",start_string);
ReadPstorage();
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
// Enter main loop.
for (;;)
{
power_manage();
if(my_flag == 1)
{
ReadPstorage();
}
}
}