I can't get callback when I call second pstorage clear function.

Hi,

    I want use 3 block flash. each size is 16bytes. My code as below

int main(void)
{
    check_ant_gpio_mode();
  
    if(factory_dm_mode == 1)
    {
        power_check();
        sense_gpio_init();
        control_uart_init();
    
        adc_configure();
    
        //Peer manager init,then we can connect BLE
        peer_manager_init(true);
        
        utils_setup();
        softdevice_setup();
  
        factory_control_dynamometer();
    }
}

void factory_control_dynamometer()
{
    uint32_t err_code;
    static uint16_t omega = 0;  // angular velocity to be set, unit is rpm
    
    while(1)
    {
        if(start_test == 0)
        {
            start_test = 1;
            
            pstorage_data_init();
            pstorage_torque_0_clear();
            pstorage_torque_w_clear();
            pstorage_torque_i_clear();
        }
    }
}

static void example_cb_handler(pstorage_handle_t  *handle,
			       uint8_t            op_code,
                               uint32_t           result,
                               uint8_t            *p_data,
                               uint32_t           data_len)
{   
    if(handle->block_id == pstorage_torque_0_wait_handle) 
    { 
        pstorage_torque_0_wait_flag = 0; 
    } 
    else if(handle->block_id == pstorage_torque_w_wait_handle) 
    { 
        pstorage_torque_w_wait_flag = 0; 
    } 
    else if(handle->block_id == pstorage_torque_i_wait_handle) 
    { 
        pstorage_torque_i_wait_flag = 0; 
    } 
}

static void pstorage_data_init(void)
{
    uint32_t retval;
    
    //1. torque_0 array: 16x4 => 2 x 18 x 2bytes + 2 bytes header => 74 Bytes
    //2. torque_w array: 2x2 => 2 x 2 x 2bytes + 2bytes contact + 2 bytes header => 12 Bytes 
    //3. torque_i array: 2x2 => 2 x 11 x 2bytes + 2bytes contact + 2 bytes header => 48 Bytes 
			     
    param.block_size  = 16;           
    param.block_count = 3;                  
    param.cb          = example_cb_handler; 
			
    retval = pstorage_register(&param, &pstorage_handle);
    pstorage_block_identifier_get(&pstorage_handle, 0, &block_torque_0_handle);
    pstorage_torque_0_wait_handle = block_torque_0_handle.block_id;
    
    pstorage_block_identifier_get(&pstorage_handle, 1, &block_torque_w_handle);
    pstorage_torque_w_wait_handle = block_torque_w_handle.block_id;
    
    pstorage_block_identifier_get(&pstorage_handle, 2, &block_torque_i_handle);
    pstorage_torque_i_wait_handle = block_torque_i_handle.block_id;
}

static void pstorage_torque_0_clear(void)
{
    uint32_t retval;

    pstorage_torque_0_wait_flag = 1;                              
    retval = pstorage_clear(&block_torque_0_handle, 16);                       				
    while(pstorage_torque_0_wait_flag) 
    {
        //nrf_delay_ms(10);
    }              		

}

static void pstorage_torque_w_clear(void)
{
    uint32_t retval;

    pstorage_torque_w_wait_flag = 1;                              
    retval = pstorage_clear(&block_torque_w_handle, 16);                       				
    while(pstorage_torque_w_wait_flag) 
    {
        //nrf_delay_ms(10);
    }              		

}

static void pstorage_torque_i_clear(void)
{
    uint32_t retval;

    pstorage_torque_i_wait_flag = 1;                              
    retval = pstorage_clear(&block_torque_i_handle, 16);                       				
    while(pstorage_torque_i_wait_flag) 
    {
        //nrf_delay_ms(10);
    }              		

}

When I call pstorage_torque_0_clear(). I can get flag change from callback function.

but then call pstorage_torque_1_clear(). I can not get flag change from callback function.

I think the callback function did not enter this. Why?

    

Parents Reply Children
No Data
Related