Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
vl53l1_zone_presets.c
00001 00002 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause 00003 /****************************************************************************** 00004 * Copyright (c) 2020, STMicroelectronics - All Rights Reserved 00005 00006 This file is part of VL53L1 and is dual licensed, 00007 either GPL-2.0+ 00008 or 'BSD 3-clause "New" or "Revised" License' , at your option. 00009 ****************************************************************************** 00010 */ 00011 00012 00013 00014 00015 #include "vl53l1_ll_def.h" 00016 #include "vl53l1_ll_device.h" 00017 #include "vl53l1_platform_log.h" 00018 #include "vl53l1_zone_presets.h" 00019 00020 00021 #define LOG_FUNCTION_START(fmt, ...) \ 00022 _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__) 00023 #define LOG_FUNCTION_END(status, ...) \ 00024 _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__) 00025 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \ 00026 _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE,\ 00027 status, fmt, ##__VA_ARGS__) 00028 00029 00030 VL53L1_Error VL53L1_init_zone_config_structure( 00031 uint8_t x_off, 00032 uint8_t x_inc, 00033 uint8_t x_zones, 00034 uint8_t y_off, 00035 uint8_t y_inc, 00036 uint8_t y_zones, 00037 uint8_t width, 00038 uint8_t height, 00039 VL53L1_zone_config_t *pdata) 00040 { 00041 00042 00043 VL53L1_Error status = VL53L1_ERROR_NONE; 00044 00045 uint8_t x = 0; 00046 uint8_t y = 0; 00047 uint16_t i = 0; 00048 00049 LOG_FUNCTION_START(""); 00050 00051 pdata->max_zones = VL53L1_MAX_USER_ZONES; 00052 00053 i = 0; 00054 00055 for (x = 0 ; x < x_zones ; x++) { 00056 for (y = 0 ; y < y_zones ; y++) { 00057 00058 if (i < VL53L1_MAX_USER_ZONES) { 00059 00060 pdata->active_zones = (uint8_t)i; 00061 pdata->user_zones[i].height = height; 00062 pdata->user_zones[i].width = width; 00063 pdata->user_zones[i].x_centre = 00064 x_off + (x * x_inc); 00065 pdata->user_zones[i].y_centre = 00066 y_off + (y * y_inc); 00067 } 00068 00069 i++; 00070 } 00071 } 00072 00073 status = VL53L1_init_zone_config_histogram_bins(pdata); 00074 00075 00076 LOG_FUNCTION_END(status); 00077 00078 return status; 00079 } 00080 00081 00082 VL53L1_Error VL53L1_zone_preset_xtalk_planar( 00083 VL53L1_general_config_t *pgeneral, 00084 VL53L1_zone_config_t *pzone_cfg) 00085 { 00086 00087 00088 VL53L1_Error status = VL53L1_ERROR_NONE; 00089 00090 LOG_FUNCTION_START(""); 00091 00092 00093 pgeneral->global_config__stream_divider = 0x05; 00094 00095 00096 pzone_cfg->active_zones = 0x04; 00097 00098 pzone_cfg->user_zones[0].height = 15; 00099 pzone_cfg->user_zones[0].width = 7; 00100 pzone_cfg->user_zones[0].x_centre = 4; 00101 pzone_cfg->user_zones[0].y_centre = 8; 00102 00103 pzone_cfg->user_zones[1].height = 15; 00104 pzone_cfg->user_zones[1].width = 7; 00105 pzone_cfg->user_zones[1].x_centre = 12; 00106 pzone_cfg->user_zones[1].y_centre = 8; 00107 00108 pzone_cfg->user_zones[2].height = 7; 00109 pzone_cfg->user_zones[2].width = 15; 00110 pzone_cfg->user_zones[2].x_centre = 8; 00111 pzone_cfg->user_zones[2].y_centre = 4; 00112 00113 pzone_cfg->user_zones[3].height = 7; 00114 pzone_cfg->user_zones[3].width = 15; 00115 pzone_cfg->user_zones[3].x_centre = 8; 00116 pzone_cfg->user_zones[3].y_centre = 12; 00117 00118 00119 00120 pzone_cfg->user_zones[4].height = 15; 00121 pzone_cfg->user_zones[4].width = 15; 00122 pzone_cfg->user_zones[4].x_centre = 8; 00123 pzone_cfg->user_zones[4].y_centre = 8; 00124 00125 status = VL53L1_init_zone_config_histogram_bins(pzone_cfg); 00126 00127 00128 LOG_FUNCTION_END(status); 00129 00130 return status; 00131 } 00132 00133 00134 VL53L1_Error VL53L1_init_zone_config_histogram_bins( 00135 VL53L1_zone_config_t *pdata) 00136 { 00137 00138 00139 VL53L1_Error status = VL53L1_ERROR_NONE; 00140 00141 uint8_t i; 00142 00143 LOG_FUNCTION_START(""); 00144 00145 for (i = 0; i < pdata->max_zones; i++) 00146 pdata->bin_config[i] = VL53L1_ZONECONFIG_BINCONFIG__LOWAMB; 00147 00148 LOG_FUNCTION_END(status); 00149 00150 return status; 00151 } 00152
Generated on Thu Jul 14 2022 10:20:22 by
 1.7.2
 1.7.2