77 #include "vl53l1_debug.h" 78 #include "vl53l1_register_debug.h" 81 #define LOG_FUNCTION_START(fmt, ...) \ 82 _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__) 83 #define LOG_FUNCTION_END(status, ...) \ 84 _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__) 85 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \ 86 _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, \ 87 status, fmt, ##__VA_ARGS__) 89 #define trace_print(level, ...) \ 90 _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_CORE, \ 91 level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__) 114 pll_period_us = (0x01 << 30) / fast_osc_frequency;
116 #ifdef VL53L1_LOGGING 118 " %-48s : %10u\n",
"pll_period_us",
124 return pll_period_us;
151 duration_us = window_vclks * pll_period_us;
156 duration_us = duration_us >> 12;
159 tmp_long_int = (
uint64_t)duration_us;
165 duration_us = elapsed_mclks * vcsel_parm_pclks;
170 duration_us = duration_us >> 4;
175 tmp_long_int = tmp_long_int * (
uint64_t)duration_us;
180 tmp_long_int = tmp_long_int >> 12;
183 if (tmp_long_int > 0xFFFFFFFF) {
184 tmp_long_int = 0xFFFFFFFF;
187 duration_us = (
uint32_t)tmp_long_int;
211 if (num >= res + bit) {
213 res = (res >> 1) + bit;
249 }
else if (events > 0) {
270 tmp_int = ((tmp_int << frac_bits) + (time_us / 2)) / time_us;
277 tmp_int = tmp_int << 4;
285 if (tmp_int > 0xFFFF) {
294 uint16_t VL53L1_rate_per_spad_maths(
313 tmp_int = (peak_count_rate << 8) << frac_bits;
316 tmp_int = ((peak_count_rate) << frac_bits);
321 if (tmp_int > max_output_value) {
322 tmp_int = max_output_value;
327 return rate_per_spad;
343 int64_t tmp_long_int = 0;
358 tmp_long_int = (int64_t)phase - (int64_t)zero_distance_phase;
368 tmp_long_int = tmp_long_int * (int64_t)pll_period_us;
374 tmp_long_int = tmp_long_int / (0x01 << 9);
391 tmp_long_int = tmp_long_int / (0x01 << 22);
394 range_mm = (
int32_t)tmp_long_int + range_offset_mm;
397 range_mm *= gain_factor;
402 if (fractional_bits == 0)
403 range_mm = range_mm / (0x01 << 2);
404 else if (fractional_bits == 1)
405 range_mm = range_mm / (0x01 << 1);
418 uint8_t vcsel_period_pclks = 0;
420 vcsel_period_pclks = (vcsel_period_reg + 1) << 1;
422 return vcsel_period_pclks;
437 if (spad_number > 127) {
438 *prow = 8 + ((255-spad_number) & 0x07);
439 *pcol = (spad_number-128) >> 3;
441 *prow = spad_number & 0x07;
442 *pcol = (127-spad_number) >> 3;
#define VL53L1_SPAD_TOTAL_COUNT_MAX
#define LOG_FUNCTION_END(status,...)
#define VL53L1_SPAD_TOTAL_COUNT_RES_THRES
#define VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8
LL Driver Device specific defines. To be adapted by implementer for the targeted device.
Type definitions for VL53L1 LL Driver.
int int32_t
Typedef defining 32 bit int type. The developer should modify this to suit the platform being deploye...
#define LOG_FUNCTION_START(fmt,...)
EwokPlus25 core function definitions.
uint32_t VL53L1_calc_pll_period_us(uint16_t fast_osc_frequency)
Calculates the PLL period in [us] from the input fast_osc_frequency.
#define trace_print(level,...)
uint8_t VL53L1_decode_vcsel_period(uint8_t vcsel_period_reg)
Decodes VCSEL period register value into the real period in PLL clocks.
unsigned long long uint64_t
unsigned short uint16_t
Typedef defining 16 bit unsigned short type. The developer should modify this to suit the platform be...
void VL53L1_decode_row_col(uint8_t spad_number, uint8_t *prow, uint8_t *pcol)
Decodes the Byte.Bit coord encoding into an (x,y) coord value.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type. The developer should modify this to suit the platform bein...
unsigned int uint32_t
Typedef defining 32 bit unsigned int type. The developer should modify this to suit the platform bein...