2020-11-20 08:57 AM
Hi everyone,
I try to implement range measurement using the VL53L3CX sensor with the VL53L3CX_API_1.1.4. I can get distance measurement and talk with the sensor properly using the basic patent :
Status = VL53LX_WaitDeviceBooted(Dev);
Status = VL53LX_DataInit(Dev);
Status = VL53LX_StartMeasurement(Dev);
for(;;)
{
Status = VL53LX_WaitMeasurementDataReady(Dev);
Status = VL53LX_GetMultiRangingData(Dev, pMultiRangingData);
printf("d= %5dmm",pMultiRangingData->RangeData[j].RangeMilliMeter);
}
The issue is : I have FLASH memory overflowed with .data and user data when it comes to add my applicaction! (by 17kB!!) :fearful_face:
I don't need to detect more than 1 object, and I don't need precision nor any calculation feature but the ones strictly needed to have distance. Is there any functions or c files I could get rid of?
I tried to mess around with the API but there are quite a lot of things! I took a look at the VL53LX_DataInit() for instance. It calls VL53LX_data_init() :
VL53LX_Error VL53LX_data_init(
VL53LX_DEV Dev,
uint8_t read_p2p_data)
{
VL53LX_Error status = VL53LX_ERROR_NONE;
VL53LX_LLDriverData_t *pdev =
VL53LXDevStructGetLLDriverHandle(Dev);
VL53LX_LLDriverResults_t *pres =
VL53LXDevStructGetLLResultsHandle(Dev);
VL53LX_zone_objects_t *pobjects;
uint8_t i = 0;
LOG_FUNCTION_START("");
VL53LX_init_ll_driver_state(
Dev,
VL53LX_DEVICESTATE_UNKNOWN);
pres->range_results.max_results = VL53LX_MAX_RANGE_RESULTS;
pres->range_results.active_results = 0;
pres->zone_results.max_zones = VL53LX_MAX_USER_ZONES;
pres->zone_results.active_zones = 0;
for (i = 0; i < VL53LX_MAX_USER_ZONES; i++) {
pobjects = &(pres->zone_results.VL53LX_p_003[i]);
pobjects->xmonitor.VL53LX_p_016 = 0;
pobjects->xmonitor.VL53LX_p_017 = 0;
pobjects->xmonitor.VL53LX_p_011 = 0;
pobjects->xmonitor.range_status =
VL53LX_DEVICEERROR_NOUPDATE;
}
pres->zone_hists.max_zones = VL53LX_MAX_USER_ZONES;
pres->zone_hists.active_zones = 0;
pres->zone_cal.max_zones = VL53LX_MAX_USER_ZONES;
pres->zone_cal.active_zones = 0;
for (i = 0; i < VL53LX_MAX_USER_ZONES; i++) {
pres->zone_cal.VL53LX_p_003[i].no_of_samples = 0;
pres->zone_cal.VL53LX_p_003[i].effective_spads = 0;
pres->zone_cal.VL53LX_p_003[i].peak_rate_mcps = 0;
pres->zone_cal.VL53LX_p_003[i].median_range_mm = 0;
pres->zone_cal.VL53LX_p_003[i].range_mm_offset = 0;
}
pdev->wait_method = VL53LX_WAIT_METHOD_BLOCKING;
pdev->preset_mode = VL53LX_DEVICEPRESETMODE_STANDARD_RANGING;
pdev->zone_preset = VL53LX_DEVICEZONEPRESET_NONE;
pdev->measurement_mode = VL53LX_DEVICEMEASUREMENTMODE_STOP;
pdev->offset_calibration_mode =
VL53LX_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD;
pdev->offset_correction_mode =
VL53LX_OFFSETCORRECTIONMODE__MM1_MM2_OFFSETS;
pdev->dmax_mode =
VL53LX_DEVICEDMAXMODE__FMT_CAL_DATA;
pdev->phasecal_config_timeout_us = 1000;
pdev->mm_config_timeout_us = 2000;
pdev->range_config_timeout_us = 13000;
pdev->inter_measurement_period_ms = 100;
pdev->dss_config__target_total_rate_mcps = 0x0A00;
pdev->debug_mode = 0x00;
pdev->offset_results.max_results = VL53LX_MAX_OFFSET_RANGE_RESULTS;
pdev->offset_results.active_results = 0;
pdev->gain_cal.standard_ranging_gain_factor =
VL53LX_TUNINGPARM_LITE_RANGING_GAIN_FACTOR_DEFAULT;
pdev->gain_cal.histogram_ranging_gain_factor =
VL53LX_TUNINGPARM_HIST_GAIN_FACTOR_DEFAULT;
VL53LX_init_version(Dev);
memset(pdev->multi_bins_rec, 0, sizeof(pdev->multi_bins_rec));
pdev->bin_rec_pos = 0;
pdev->pos_before_next_recom = 0;
if (read_p2p_data > 0 && status == VL53LX_ERROR_NONE)
status = VL53LX_read_p2p_data(Dev);
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_refspadchar_config_struct(
&(pdev->refspadchar));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_ssc_config_struct(
&(pdev->ssc_cfg));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_xtalk_config_struct(
&(pdev->customer),
&(pdev->xtalk_cfg));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_xtalk_extract_config_struct(
&(pdev->xtalk_extract_cfg));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_offset_cal_config_struct(
&(pdev->offsetcal_cfg));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_zone_cal_config_struct(
&(pdev->zonecal_cfg));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_hist_post_process_config_struct(
pdev->xtalk_cfg.global_crosstalk_compensation_enable,
&(pdev->histpostprocess));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_hist_gen3_dmax_config_struct(
&(pdev->dmax_cfg));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_init_tuning_parm_storage_struct(
&(pdev->tuning_parms));
if (status == VL53LX_ERROR_NONE)
status = VL53LX_set_preset_mode(
Dev,
pdev->preset_mode,
pdev->dss_config__target_total_rate_mcps,
pdev->phasecal_config_timeout_us,
pdev->mm_config_timeout_us,
pdev->range_config_timeout_us,
pdev->inter_measurement_period_ms);
VL53LX_init_histogram_bin_data_struct(
0,
VL53LX_HISTOGRAM_BUFFER_SIZE,
&(pdev->hist_data));
VL53LX_init_histogram_bin_data_struct(
0,
VL53LX_HISTOGRAM_BUFFER_SIZE,
&(pdev->hist_xtalk));
VL53LX_init_xtalk_bin_data_struct(
0,
VL53LX_XTALK_HISTO_BINS,
&(pdev->xtalk_shapes.xtalk_shape));
VL53LX_xtalk_cal_data_init(
Dev
);
VL53LX_dynamic_xtalk_correction_data_init(
Dev
);
VL53LX_low_power_auto_data_init(
Dev
);
#ifdef VL53LX_LOG_ENABLE
VL53LX_print_static_nvm_managed(
&(pdev->stat_nvm),
"data_init():pdev->lldata.stat_nvm.",
VL53LX_TRACE_MODULE_DATA_INIT);
VL53LX_print_customer_nvm_managed(
&(pdev->customer),
"data_init():pdev->lldata.customer.",
VL53LX_TRACE_MODULE_DATA_INIT);
VL53LX_print_nvm_copy_data(
&(pdev->nvm_copy_data),
"data_init():pdev->lldata.nvm_copy_data.",
VL53LX_TRACE_MODULE_DATA_INIT);
VL53LX_print_dmax_calibration_data(
&(pdev->fmt_dmax_cal),
"data_init():pdev->lldata.fmt_dmax_cal.",
VL53LX_TRACE_MODULE_DATA_INIT);
VL53LX_print_dmax_calibration_data(
&(pdev->cust_dmax_cal),
"data_init():pdev->lldata.cust_dmax_cal.",
VL53LX_TRACE_MODULE_DATA_INIT);
VL53LX_print_additional_offset_cal_data(
&(pdev->add_off_cal_data),
"data_init():pdev->lldata.add_off_cal_data.",
VL53LX_TRACE_MODULE_DATA_INIT);
VL53LX_print_user_zone(
&(pdev->mm_roi),
"data_init():pdev->lldata.mm_roi.",
VL53LX_TRACE_MODULE_DATA_INIT);
VL53LX_print_optical_centre(
&(pdev->optical_centre),
"data_init():pdev->lldata.optical_centre.",
VL53LX_TRACE_MODULE_DATA_INIT);
VL53LX_print_cal_peak_rate_map(
&(pdev->cal_peak_rate_map),
"data_init():pdev->lldata.cal_peak_rate_map.",
VL53LX_TRACE_MODULE_DATA_INIT);
#endif
LOG_FUNCTION_END(status);
return status;
}
Do we need to set ALL the data in this function? Don't the VL53LCX have any default parameters which could avoid to call all these sub-functions? This is juste an example.
In the case I have to bypass some functions, I am not afraid to get through the entire API to delete/comment all occurences of these functions.
Any suggestion is appreciated, thank you in advance for your help! :beaming_face_with_smiling_eyes:
2020-11-25 10:16 AM
there is some build in functionality
for logging and error decoding that's normally only used for debug and test.
I don't know if you can get rid of that by some compiler flags or defines
have a look at
api/src/vl53l0x_api_strings.c
api/platform/vl53l0x_platform_log.c
and it's header files
ju
2021-01-26 07:49 PM
I wish vl53l3cx can come out a reduced size API like VL53L1X did -- VL53L1X ULD API (Ultra Lite Driver API).
That will be great.
sam