vl53l1_api_debug.c 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. /*
  2. * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
  3. *
  4. * This file is part of VL53L1 Core and is dual licensed,
  5. * either 'STMicroelectronics
  6. * Proprietary license'
  7. * or 'BSD 3-clause "New" or "Revised" License' , at your option.
  8. *
  9. ********************************************************************************
  10. *
  11. * 'STMicroelectronics Proprietary license'
  12. *
  13. ********************************************************************************
  14. *
  15. * License terms: STMicroelectronics Proprietary in accordance with licensing
  16. * terms at www.st.com/sla0081
  17. *
  18. * STMicroelectronics confidential
  19. * Reproduction and Communication of this document is strictly prohibited unless
  20. * specifically authorized in writing by STMicroelectronics.
  21. *
  22. *
  23. ********************************************************************************
  24. *
  25. * Alternatively, VL53L1 Core may be distributed under the terms of
  26. * 'BSD 3-clause "New" or "Revised" License', in which case the following
  27. * provisions apply instead of the ones mentioned above :
  28. *
  29. ********************************************************************************
  30. *
  31. * License terms: BSD 3-clause "New" or "Revised" License.
  32. *
  33. * Redistribution and use in source and binary forms, with or without
  34. * modification, are permitted provided that the following conditions are met:
  35. *
  36. * 1. Redistributions of source code must retain the above copyright notice, this
  37. * list of conditions and the following disclaimer.
  38. *
  39. * 2. Redistributions in binary form must reproduce the above copyright notice,
  40. * this list of conditions and the following disclaimer in the documentation
  41. * and/or other materials provided with the distribution.
  42. *
  43. * 3. Neither the name of the copyright holder nor the names of its contributors
  44. * may be used to endorse or promote products derived from this software
  45. * without specific prior written permission.
  46. *
  47. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  48. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  50. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  51. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  52. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  53. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  54. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  55. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  56. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  57. *
  58. *
  59. ********************************************************************************
  60. *
  61. */
  62. /**
  63. * @file vl53l1_api_debug.c
  64. * @brief EwokPlus25 low level Driver debug function definition
  65. */
  66. #include "vl53l1_ll_def.h"
  67. #include "vl53l1_ll_device.h"
  68. #include "vl53l1_register_structs.h"
  69. #include "vl53l1_core.h"
  70. #include "vl53l1_api_debug.h"
  71. #define LOG_FUNCTION_START(fmt, ...) \
  72. _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
  73. #define LOG_FUNCTION_END(status, ...) \
  74. _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
  75. #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
  76. _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, \
  77. fmt, ##__VA_ARGS__)
  78. #define trace_print(level, ...) \
  79. _LOG_TRACE_PRINT(trace_flags, \
  80. level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
  81. /* Start Patch_AdditionalDebugData_11823 */
  82. VL53L1_Error VL53L1_get_additional_data(
  83. VL53L1_DEV Dev,
  84. VL53L1_additional_data_t *pdata)
  85. {
  86. /*
  87. * Gets the addition debug data
  88. */
  89. VL53L1_Error status = VL53L1_ERROR_NONE;
  90. VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
  91. LOG_FUNCTION_START("");
  92. /* get LL Driver configuration parameters */
  93. pdata->preset_mode = pdev->preset_mode;
  94. pdata->measurement_mode = pdev->measurement_mode;
  95. pdata->phasecal_config_timeout_us = pdev->phasecal_config_timeout_us;
  96. pdata->mm_config_timeout_us = pdev->mm_config_timeout_us;
  97. pdata->range_config_timeout_us = pdev->range_config_timeout_us;
  98. pdata->inter_measurement_period_ms = pdev->inter_measurement_period_ms;
  99. pdata->dss_config__target_total_rate_mcps =
  100. pdev->dss_config__target_total_rate_mcps;
  101. LOG_FUNCTION_END(status);
  102. return status;
  103. }
  104. /* End Patch_AdditionalDebugData_11823 */
  105. #ifdef VL53L1_LOG_ENABLE
  106. void VL53L1_signed_fixed_point_sprintf(
  107. int32_t signed_fp_value,
  108. uint8_t frac_bits,
  109. uint16_t buf_size,
  110. char *pbuffer)
  111. {
  112. /*
  113. * Converts input signed fixed point number into a string
  114. */
  115. uint32_t fp_value = 0;
  116. uint32_t unity_fp_value = 0;
  117. uint32_t sign_bit = 0;
  118. uint32_t int_part = 0;
  119. uint32_t frac_part = 0;
  120. uint32_t dec_points = 0;
  121. uint32_t dec_scaler = 0;
  122. uint32_t dec_part = 0;
  123. uint64_t tmp_long_int = 0;
  124. char fmt[VL53L1_MAX_STRING_LENGTH];
  125. SUPPRESS_UNUSED_WARNING(buf_size);
  126. /* split into integer and fractional values */
  127. sign_bit = signed_fp_value >> 31;
  128. if (sign_bit > 0) {
  129. fp_value = 0x80000000 -
  130. (0x7FFFFFFF & (uint32_t)signed_fp_value);
  131. } else
  132. fp_value = (uint32_t)signed_fp_value;
  133. int_part = fp_value >> frac_bits;
  134. unity_fp_value = 0x01 << frac_bits;
  135. frac_part = fp_value & (unity_fp_value-1);
  136. /* Calculate decimal scale factor and required decimal points
  137. * min number of displayed places is 2
  138. */
  139. dec_points = 2;
  140. dec_scaler = 100;
  141. while (dec_scaler < unity_fp_value) {
  142. dec_points++;
  143. dec_scaler *= 10;
  144. }
  145. /* Build format string */
  146. if (sign_bit > 0)
  147. sprintf(fmt, "-%%u.%%0%uu", dec_points);
  148. else
  149. sprintf(fmt, "%%u.%%0%uu", dec_points);
  150. /* Convert fractional part into a decimal
  151. * need 64-bit head room at this point
  152. */
  153. tmp_long_int = (uint64_t)frac_part * (uint64_t)dec_scaler;
  154. tmp_long_int += (uint64_t)unity_fp_value/2;
  155. tmp_long_int = do_division_u(tmp_long_int, (uint64_t)unity_fp_value);
  156. dec_part = (uint32_t)tmp_long_int;
  157. /* Generate string for fixed point number */
  158. sprintf(
  159. pbuffer,
  160. fmt,
  161. int_part,
  162. dec_part);
  163. }
  164. void VL53L1_print_static_nvm_managed(
  165. VL53L1_static_nvm_managed_t *pdata,
  166. char *pprefix,
  167. uint32_t trace_flags)
  168. {
  169. /**
  170. * Prints out VL53L1_static_nvm_managed_t for debug
  171. */
  172. char fp_text[VL53L1_MAX_STRING_LENGTH];
  173. trace_print(
  174. VL53L1_TRACE_LEVEL_INFO,
  175. "%s%s = 0x%02X\n",
  176. pprefix,
  177. "i2c_slave__device_address",
  178. pdata->i2c_slave__device_address);
  179. trace_print(
  180. VL53L1_TRACE_LEVEL_INFO,
  181. "%s%s = %u\n",
  182. pprefix,
  183. "ana_config__vhv_ref_sel_vddpix",
  184. pdata->ana_config__vhv_ref_sel_vddpix);
  185. trace_print(
  186. VL53L1_TRACE_LEVEL_INFO,
  187. "%s%s = %u\n",
  188. pprefix,
  189. "ana_config__vhv_ref_sel_vquench",
  190. pdata->ana_config__vhv_ref_sel_vquench);
  191. trace_print(
  192. VL53L1_TRACE_LEVEL_INFO,
  193. "%s%s = %u\n",
  194. pprefix,
  195. "ana_config__reg_avdd1v2_sel",
  196. pdata->ana_config__reg_avdd1v2_sel);
  197. trace_print(
  198. VL53L1_TRACE_LEVEL_INFO,
  199. "%s%s = %u\n",
  200. pprefix,
  201. "ana_config__fast_osc__trim",
  202. pdata->ana_config__fast_osc__trim);
  203. VL53L1_signed_fixed_point_sprintf(
  204. (int32_t)pdata->osc_measured__fast_osc__frequency,
  205. 12,
  206. VL53L1_MAX_STRING_LENGTH,
  207. fp_text);
  208. trace_print(
  209. VL53L1_TRACE_LEVEL_INFO,
  210. "%s%s = %s\n",
  211. pprefix,
  212. "osc_measured__fast_osc__frequency",
  213. fp_text);
  214. trace_print(
  215. VL53L1_TRACE_LEVEL_INFO,
  216. "%s%s = %u\n",
  217. pprefix,
  218. "vhv_config__timeout_macrop_loop_bound",
  219. pdata->vhv_config__timeout_macrop_loop_bound);
  220. trace_print(
  221. VL53L1_TRACE_LEVEL_INFO,
  222. "%s%s = %u\n",
  223. pprefix,
  224. "vhv_config__count_thresh",
  225. pdata->vhv_config__count_thresh);
  226. trace_print(
  227. VL53L1_TRACE_LEVEL_INFO,
  228. "%s%s = %u\n",
  229. pprefix,
  230. "vhv_config__offset",
  231. pdata->vhv_config__offset);
  232. trace_print(
  233. VL53L1_TRACE_LEVEL_INFO,
  234. "%s%s = %u\n",
  235. pprefix,
  236. "vhv_config__init",
  237. pdata->vhv_config__init);
  238. }
  239. void VL53L1_print_customer_nvm_managed(
  240. VL53L1_customer_nvm_managed_t *pdata,
  241. char *pprefix,
  242. uint32_t trace_flags)
  243. {
  244. /*
  245. * Prints out VL53L1_customer_nvm_managed_t for debug
  246. */
  247. char fp_text[VL53L1_MAX_STRING_LENGTH];
  248. trace_print(VL53L1_TRACE_LEVEL_INFO,
  249. "%s%s = %u\n",
  250. pprefix,
  251. "global_config__spad_enables_ref_0",
  252. pdata->global_config__spad_enables_ref_0);
  253. trace_print(VL53L1_TRACE_LEVEL_INFO,
  254. "%s%s = %u\n",
  255. pprefix,
  256. "global_config__spad_enables_ref_1",
  257. pdata->global_config__spad_enables_ref_1);
  258. trace_print(VL53L1_TRACE_LEVEL_INFO,
  259. "%s%s = %u\n",
  260. pprefix,
  261. "global_config__spad_enables_ref_2",
  262. pdata->global_config__spad_enables_ref_2);
  263. trace_print(VL53L1_TRACE_LEVEL_INFO,
  264. "%s%s = %u\n",
  265. pprefix,
  266. "global_config__spad_enables_ref_3",
  267. pdata->global_config__spad_enables_ref_3);
  268. trace_print(VL53L1_TRACE_LEVEL_INFO,
  269. "%s%s = %u\n",
  270. pprefix,
  271. "global_config__spad_enables_ref_4",
  272. pdata->global_config__spad_enables_ref_4);
  273. trace_print(VL53L1_TRACE_LEVEL_INFO,
  274. "%s%s = %u\n",
  275. pprefix,
  276. "global_config__spad_enables_ref_5",
  277. pdata->global_config__spad_enables_ref_5);
  278. trace_print(VL53L1_TRACE_LEVEL_INFO,
  279. "%s%s = %u\n",
  280. pprefix,
  281. "global_config__ref_en_start_select",
  282. pdata->global_config__ref_en_start_select);
  283. trace_print(VL53L1_TRACE_LEVEL_INFO,
  284. "%s%s = %u\n",
  285. pprefix,
  286. "ref_spad_man__num_requested_ref_spads",
  287. pdata->ref_spad_man__num_requested_ref_spads);
  288. trace_print(VL53L1_TRACE_LEVEL_INFO,
  289. "%s%s = %u\n",
  290. pprefix,
  291. "ref_spad_man__ref_location",
  292. pdata->ref_spad_man__ref_location);
  293. VL53L1_signed_fixed_point_sprintf(
  294. (int32_t)pdata->algo__crosstalk_compensation_plane_offset_kcps,
  295. 9,
  296. VL53L1_MAX_STRING_LENGTH,
  297. fp_text);
  298. trace_print(VL53L1_TRACE_LEVEL_INFO,
  299. "%s%s = %s\n",
  300. pprefix,
  301. "algo__crosstalk_compensation_plane_offset_kcps",
  302. fp_text);
  303. VL53L1_signed_fixed_point_sprintf(
  304. (int32_t)pdata->algo__crosstalk_compensation_x_plane_gradient_kcps,
  305. 11,
  306. VL53L1_MAX_STRING_LENGTH,
  307. fp_text);
  308. trace_print(VL53L1_TRACE_LEVEL_INFO,
  309. "%s%s = %s\n",
  310. pprefix,
  311. "algo__crosstalk_compensation_x_plane_gradient_kcps",
  312. fp_text);
  313. VL53L1_signed_fixed_point_sprintf(
  314. (int32_t)pdata->algo__crosstalk_compensation_y_plane_gradient_kcps,
  315. 11,
  316. VL53L1_MAX_STRING_LENGTH,
  317. fp_text);
  318. trace_print(VL53L1_TRACE_LEVEL_INFO,
  319. "%s%s = %s\n",
  320. pprefix,
  321. "algo__crosstalk_compensation_y_plane_gradient_kcps",
  322. fp_text);
  323. VL53L1_signed_fixed_point_sprintf(
  324. (int32_t)pdata->ref_spad_char__total_rate_target_mcps,
  325. 7,
  326. VL53L1_MAX_STRING_LENGTH,
  327. fp_text);
  328. trace_print(VL53L1_TRACE_LEVEL_INFO,
  329. "%s%s = %s\n",
  330. pprefix,
  331. "ref_spad_char__total_rate_target_mcps",
  332. fp_text);
  333. VL53L1_signed_fixed_point_sprintf(
  334. (int32_t)pdata->algo__part_to_part_range_offset_mm,
  335. 2,
  336. VL53L1_MAX_STRING_LENGTH,
  337. fp_text);
  338. trace_print(VL53L1_TRACE_LEVEL_INFO,
  339. "%s%s = %s\n",
  340. pprefix,
  341. "algo__part_to_part_range_offset_mm",
  342. fp_text);
  343. trace_print(VL53L1_TRACE_LEVEL_INFO,
  344. "%s%s = %d\n",
  345. pprefix,
  346. "mm_config__inner_offset_mm",
  347. pdata->mm_config__inner_offset_mm);
  348. trace_print(VL53L1_TRACE_LEVEL_INFO,
  349. "%s%s = %d\n",
  350. pprefix,
  351. "mm_config__outer_offset_mm",
  352. pdata->mm_config__outer_offset_mm);
  353. }
  354. void VL53L1_print_nvm_copy_data(
  355. VL53L1_nvm_copy_data_t *pdata,
  356. char *pprefix,
  357. uint32_t trace_flags)
  358. {
  359. /**
  360. * Prints out VL53L1_nvm_copy_data_t for debug
  361. */
  362. trace_print(
  363. VL53L1_TRACE_LEVEL_INFO,
  364. "%s%s = %u\n",
  365. pprefix,
  366. "identification__model_id",
  367. pdata->identification__model_id);
  368. trace_print(
  369. VL53L1_TRACE_LEVEL_INFO,
  370. "%s%s = %u\n",
  371. pprefix,
  372. "identification__module_type",
  373. pdata->identification__module_type);
  374. trace_print(
  375. VL53L1_TRACE_LEVEL_INFO,
  376. "%s%s = %u\n",
  377. pprefix,
  378. "identification__revision_id",
  379. pdata->identification__revision_id);
  380. trace_print(
  381. VL53L1_TRACE_LEVEL_INFO,
  382. "%s%s = %u\n",
  383. pprefix,
  384. "identification__module_id",
  385. pdata->identification__module_id);
  386. trace_print(
  387. VL53L1_TRACE_LEVEL_INFO,
  388. "%s%s = %u\n",
  389. pprefix,
  390. "ana_config__fast_osc__trim_max",
  391. pdata->ana_config__fast_osc__trim_max);
  392. trace_print(
  393. VL53L1_TRACE_LEVEL_INFO,
  394. "%s%s = %u\n",
  395. pprefix,
  396. "ana_config__fast_osc__freq_set",
  397. pdata->ana_config__fast_osc__freq_set);
  398. trace_print(
  399. VL53L1_TRACE_LEVEL_INFO,
  400. "%s%s = %u\n",
  401. pprefix,
  402. "ana_config__vcsel_trim",
  403. pdata->ana_config__vcsel_trim);
  404. trace_print(
  405. VL53L1_TRACE_LEVEL_INFO,
  406. "%s%s = %u\n",
  407. pprefix,
  408. "ana_config__vcsel_selion",
  409. pdata->ana_config__vcsel_selion);
  410. trace_print(
  411. VL53L1_TRACE_LEVEL_INFO,
  412. "%s%s = %u\n",
  413. pprefix,
  414. "ana_config__vcsel_selion_max",
  415. pdata->ana_config__vcsel_selion_max);
  416. trace_print(
  417. VL53L1_TRACE_LEVEL_INFO,
  418. "%s%s = %u\n",
  419. pprefix,
  420. "protected_laser_safety__lock_bit",
  421. pdata->protected_laser_safety__lock_bit);
  422. trace_print(
  423. VL53L1_TRACE_LEVEL_INFO,
  424. "%s%s = %u\n",
  425. pprefix,
  426. "laser_safety__key",
  427. pdata->laser_safety__key);
  428. trace_print(
  429. VL53L1_TRACE_LEVEL_INFO,
  430. "%s%s = %u\n",
  431. pprefix,
  432. "laser_safety__key_ro",
  433. pdata->laser_safety__key_ro);
  434. trace_print(
  435. VL53L1_TRACE_LEVEL_INFO,
  436. "%s%s = %u\n",
  437. pprefix,
  438. "laser_safety__clip",
  439. pdata->laser_safety__clip);
  440. trace_print(
  441. VL53L1_TRACE_LEVEL_INFO,
  442. "%s%s = %u\n",
  443. pprefix,
  444. "laser_safety__mult",
  445. pdata->laser_safety__mult);
  446. trace_print(
  447. VL53L1_TRACE_LEVEL_INFO,
  448. "%s%s = %u\n",
  449. pprefix,
  450. "global_config__spad_enables_rtn_0",
  451. pdata->global_config__spad_enables_rtn_0);
  452. trace_print(
  453. VL53L1_TRACE_LEVEL_INFO,
  454. "%s%s = %u\n",
  455. pprefix,
  456. "global_config__spad_enables_rtn_1",
  457. pdata->global_config__spad_enables_rtn_1);
  458. trace_print(
  459. VL53L1_TRACE_LEVEL_INFO,
  460. "%s%s = %u\n",
  461. pprefix,
  462. "global_config__spad_enables_rtn_2",
  463. pdata->global_config__spad_enables_rtn_2);
  464. trace_print(
  465. VL53L1_TRACE_LEVEL_INFO,
  466. "%s%s = %u\n",
  467. pprefix,
  468. "global_config__spad_enables_rtn_3",
  469. pdata->global_config__spad_enables_rtn_3);
  470. trace_print(
  471. VL53L1_TRACE_LEVEL_INFO,
  472. "%s%s = %u\n",
  473. pprefix,
  474. "global_config__spad_enables_rtn_4",
  475. pdata->global_config__spad_enables_rtn_4);
  476. trace_print(
  477. VL53L1_TRACE_LEVEL_INFO,
  478. "%s%s = %u\n",
  479. pprefix,
  480. "global_config__spad_enables_rtn_5",
  481. pdata->global_config__spad_enables_rtn_5);
  482. trace_print(
  483. VL53L1_TRACE_LEVEL_INFO,
  484. "%s%s = %u\n",
  485. pprefix,
  486. "global_config__spad_enables_rtn_6",
  487. pdata->global_config__spad_enables_rtn_6);
  488. trace_print(
  489. VL53L1_TRACE_LEVEL_INFO,
  490. "%s%s = %u\n",
  491. pprefix,
  492. "global_config__spad_enables_rtn_7",
  493. pdata->global_config__spad_enables_rtn_7);
  494. trace_print(
  495. VL53L1_TRACE_LEVEL_INFO,
  496. "%s%s = %u\n",
  497. pprefix,
  498. "global_config__spad_enables_rtn_8",
  499. pdata->global_config__spad_enables_rtn_8);
  500. trace_print(
  501. VL53L1_TRACE_LEVEL_INFO,
  502. "%s%s = %u\n",
  503. pprefix,
  504. "global_config__spad_enables_rtn_9",
  505. pdata->global_config__spad_enables_rtn_9);
  506. trace_print(
  507. VL53L1_TRACE_LEVEL_INFO,
  508. "%s%s = %u\n",
  509. pprefix,
  510. "global_config__spad_enables_rtn_10",
  511. pdata->global_config__spad_enables_rtn_10);
  512. trace_print(
  513. VL53L1_TRACE_LEVEL_INFO,
  514. "%s%s = %u\n",
  515. pprefix,
  516. "global_config__spad_enables_rtn_11",
  517. pdata->global_config__spad_enables_rtn_11);
  518. trace_print(
  519. VL53L1_TRACE_LEVEL_INFO,
  520. "%s%s = %u\n",
  521. pprefix,
  522. "global_config__spad_enables_rtn_12",
  523. pdata->global_config__spad_enables_rtn_12);
  524. trace_print(
  525. VL53L1_TRACE_LEVEL_INFO,
  526. "%s%s = %u\n",
  527. pprefix,
  528. "global_config__spad_enables_rtn_13",
  529. pdata->global_config__spad_enables_rtn_13);
  530. trace_print(
  531. VL53L1_TRACE_LEVEL_INFO,
  532. "%s%s = %u\n",
  533. pprefix,
  534. "global_config__spad_enables_rtn_14",
  535. pdata->global_config__spad_enables_rtn_14);
  536. trace_print(
  537. VL53L1_TRACE_LEVEL_INFO,
  538. "%s%s = %u\n",
  539. pprefix,
  540. "global_config__spad_enables_rtn_15",
  541. pdata->global_config__spad_enables_rtn_15);
  542. trace_print(
  543. VL53L1_TRACE_LEVEL_INFO,
  544. "%s%s = %u\n",
  545. pprefix,
  546. "global_config__spad_enables_rtn_16",
  547. pdata->global_config__spad_enables_rtn_16);
  548. trace_print(
  549. VL53L1_TRACE_LEVEL_INFO,
  550. "%s%s = %u\n",
  551. pprefix,
  552. "global_config__spad_enables_rtn_17",
  553. pdata->global_config__spad_enables_rtn_17);
  554. trace_print(
  555. VL53L1_TRACE_LEVEL_INFO,
  556. "%s%s = %u\n",
  557. pprefix,
  558. "global_config__spad_enables_rtn_18",
  559. pdata->global_config__spad_enables_rtn_18);
  560. trace_print(
  561. VL53L1_TRACE_LEVEL_INFO,
  562. "%s%s = %u\n",
  563. pprefix,
  564. "global_config__spad_enables_rtn_19",
  565. pdata->global_config__spad_enables_rtn_19);
  566. trace_print(
  567. VL53L1_TRACE_LEVEL_INFO,
  568. "%s%s = %u\n",
  569. pprefix,
  570. "global_config__spad_enables_rtn_20",
  571. pdata->global_config__spad_enables_rtn_20);
  572. trace_print(
  573. VL53L1_TRACE_LEVEL_INFO,
  574. "%s%s = %u\n",
  575. pprefix,
  576. "global_config__spad_enables_rtn_21",
  577. pdata->global_config__spad_enables_rtn_21);
  578. trace_print(
  579. VL53L1_TRACE_LEVEL_INFO,
  580. "%s%s = %u\n",
  581. pprefix,
  582. "global_config__spad_enables_rtn_22",
  583. pdata->global_config__spad_enables_rtn_22);
  584. trace_print(
  585. VL53L1_TRACE_LEVEL_INFO,
  586. "%s%s = %u\n",
  587. pprefix,
  588. "global_config__spad_enables_rtn_23",
  589. pdata->global_config__spad_enables_rtn_23);
  590. trace_print(
  591. VL53L1_TRACE_LEVEL_INFO,
  592. "%s%s = %u\n",
  593. pprefix,
  594. "global_config__spad_enables_rtn_24",
  595. pdata->global_config__spad_enables_rtn_24);
  596. trace_print(
  597. VL53L1_TRACE_LEVEL_INFO,
  598. "%s%s = %u\n",
  599. pprefix,
  600. "global_config__spad_enables_rtn_25",
  601. pdata->global_config__spad_enables_rtn_25);
  602. trace_print(
  603. VL53L1_TRACE_LEVEL_INFO,
  604. "%s%s = %u\n",
  605. pprefix,
  606. "global_config__spad_enables_rtn_26",
  607. pdata->global_config__spad_enables_rtn_26);
  608. trace_print(
  609. VL53L1_TRACE_LEVEL_INFO,
  610. "%s%s = %u\n",
  611. pprefix,
  612. "global_config__spad_enables_rtn_27",
  613. pdata->global_config__spad_enables_rtn_27);
  614. trace_print(
  615. VL53L1_TRACE_LEVEL_INFO,
  616. "%s%s = %u\n",
  617. pprefix,
  618. "global_config__spad_enables_rtn_28",
  619. pdata->global_config__spad_enables_rtn_28);
  620. trace_print(
  621. VL53L1_TRACE_LEVEL_INFO,
  622. "%s%s = %u\n",
  623. pprefix,
  624. "global_config__spad_enables_rtn_29",
  625. pdata->global_config__spad_enables_rtn_29);
  626. trace_print(
  627. VL53L1_TRACE_LEVEL_INFO,
  628. "%s%s = %u\n",
  629. pprefix,
  630. "global_config__spad_enables_rtn_30",
  631. pdata->global_config__spad_enables_rtn_30);
  632. trace_print(
  633. VL53L1_TRACE_LEVEL_INFO,
  634. "%s%s = %u\n",
  635. pprefix,
  636. "global_config__spad_enables_rtn_31",
  637. pdata->global_config__spad_enables_rtn_31);
  638. trace_print(
  639. VL53L1_TRACE_LEVEL_INFO,
  640. "%s%s = %u\n",
  641. pprefix,
  642. "roi_config__mode_roi_centre_spad",
  643. pdata->roi_config__mode_roi_centre_spad);
  644. trace_print(
  645. VL53L1_TRACE_LEVEL_INFO,
  646. "%s%s = 0x%02X\n",
  647. pprefix,
  648. "roi_config__mode_roi_xy_size",
  649. pdata->roi_config__mode_roi_xy_size);
  650. }
  651. void VL53L1_print_range_data(
  652. VL53L1_range_data_t *pdata,
  653. char *pprefix,
  654. uint32_t trace_flags)
  655. {
  656. /*
  657. * Prints out the range data structure for debug
  658. */
  659. char fp_text[VL53L1_MAX_STRING_LENGTH];
  660. trace_print(
  661. VL53L1_TRACE_LEVEL_INFO,
  662. "%s%s = %u\n",
  663. pprefix,
  664. "range_id",
  665. pdata->range_id);
  666. trace_print(
  667. VL53L1_TRACE_LEVEL_INFO,
  668. "%s%s = %u\n",
  669. pprefix,
  670. "time_stamp",
  671. pdata->time_stamp);
  672. VL53L1_signed_fixed_point_sprintf(
  673. (int32_t)pdata->width,
  674. 4, VL53L1_MAX_STRING_LENGTH, fp_text);
  675. trace_print(
  676. VL53L1_TRACE_LEVEL_INFO,
  677. "%s%s = %s\n",
  678. pprefix,
  679. "width",
  680. fp_text);
  681. trace_print(
  682. VL53L1_TRACE_LEVEL_INFO,
  683. "%s%s = %u\n",
  684. pprefix,
  685. "woi",
  686. pdata->woi);
  687. /* Fast Oscillator Frequency */
  688. VL53L1_signed_fixed_point_sprintf(
  689. (int32_t)pdata->fast_osc_frequency,
  690. 12, VL53L1_MAX_STRING_LENGTH, fp_text);
  691. trace_print(
  692. VL53L1_TRACE_LEVEL_INFO,
  693. "%s%s = %s\n",
  694. pprefix,
  695. "fast_osc_frequency",
  696. fp_text);
  697. /* Zero Distance Phase */
  698. VL53L1_signed_fixed_point_sprintf(
  699. (int32_t)pdata->zero_distance_phase,
  700. 11, VL53L1_MAX_STRING_LENGTH, fp_text);
  701. trace_print(
  702. VL53L1_TRACE_LEVEL_INFO,
  703. "%s%s = %s\n",
  704. pprefix,
  705. "zero_distance_phase",
  706. fp_text);
  707. /* Actual effective SPAD count */
  708. VL53L1_signed_fixed_point_sprintf(
  709. (int32_t)pdata->actual_effective_spads,
  710. 8, VL53L1_MAX_STRING_LENGTH, fp_text);
  711. trace_print(
  712. VL53L1_TRACE_LEVEL_INFO,
  713. "%s%s = %s\n",
  714. pprefix,
  715. "actual_effective_spad",
  716. fp_text);
  717. trace_print(VL53L1_TRACE_LEVEL_INFO,
  718. "%s%s = %u\n",
  719. pprefix,
  720. "total_periods_elapsed",
  721. pdata->total_periods_elapsed);
  722. trace_print(
  723. VL53L1_TRACE_LEVEL_INFO,
  724. "%s%s = %u\n",
  725. pprefix,
  726. "peak_duration_us",
  727. pdata->peak_duration_us);
  728. trace_print(
  729. VL53L1_TRACE_LEVEL_INFO,
  730. "%s%s = %u\n",
  731. pprefix,
  732. "woi_duration_us",
  733. pdata->woi_duration_us);
  734. trace_print(
  735. VL53L1_TRACE_LEVEL_INFO,
  736. "%s%s = %d\n",
  737. pprefix,
  738. "ambient_window_events",
  739. pdata->ambient_window_events);
  740. trace_print(
  741. VL53L1_TRACE_LEVEL_INFO,
  742. "%s%s = %d\n",
  743. pprefix,
  744. "ranging_total_events",
  745. pdata->ranging_total_events);
  746. trace_print(
  747. VL53L1_TRACE_LEVEL_INFO,
  748. "%s%s = %d\n",
  749. pprefix,
  750. "signal_total_events",
  751. pdata->signal_total_events);
  752. /* Rates */
  753. VL53L1_signed_fixed_point_sprintf(
  754. (int32_t)pdata->peak_signal_count_rate_mcps,
  755. 7, VL53L1_MAX_STRING_LENGTH, fp_text);
  756. trace_print(
  757. VL53L1_TRACE_LEVEL_INFO,
  758. "%s%s = %s\n",
  759. pprefix,
  760. "peak_signal_count_rate_mcps",
  761. fp_text);
  762. VL53L1_signed_fixed_point_sprintf(
  763. (int32_t)pdata->avg_signal_count_rate_mcps,
  764. 7, VL53L1_MAX_STRING_LENGTH, fp_text);
  765. trace_print(
  766. VL53L1_TRACE_LEVEL_INFO,
  767. "%s%s = %s\n",
  768. pprefix,
  769. "avg_signal_count_rate_mcps",
  770. fp_text);
  771. VL53L1_signed_fixed_point_sprintf(
  772. (int32_t)pdata->ambient_count_rate_mcps,
  773. 7, VL53L1_MAX_STRING_LENGTH, fp_text);
  774. trace_print(
  775. VL53L1_TRACE_LEVEL_INFO,
  776. "%s%s = %s\n",
  777. pprefix,
  778. "ambient_count_rate_mcps",
  779. fp_text);
  780. VL53L1_signed_fixed_point_sprintf(
  781. (int32_t)pdata->total_rate_per_spad_mcps,
  782. 13, VL53L1_MAX_STRING_LENGTH, fp_text);
  783. trace_print(
  784. VL53L1_TRACE_LEVEL_INFO,
  785. "%s%s = %s\n",
  786. pprefix,
  787. "total_rate_per_spad_mcps",
  788. fp_text);
  789. VL53L1_signed_fixed_point_sprintf(
  790. (int32_t)pdata->peak_rate_per_spad_kcps,
  791. 11, VL53L1_MAX_STRING_LENGTH, fp_text);
  792. trace_print(
  793. VL53L1_TRACE_LEVEL_INFO,
  794. "%s%s = %s\n",
  795. pprefix,
  796. "peak_rate_per_spad_kcps",
  797. fp_text);
  798. /* Sigma */
  799. VL53L1_signed_fixed_point_sprintf(
  800. (int32_t)pdata->sigma_mm,
  801. 2, VL53L1_MAX_STRING_LENGTH, fp_text);
  802. trace_print(
  803. VL53L1_TRACE_LEVEL_INFO,
  804. "%s%s = %s\n",
  805. pprefix,
  806. "sigma_mm",
  807. fp_text);
  808. /* Phase */
  809. VL53L1_signed_fixed_point_sprintf(
  810. (int32_t)pdata->median_phase,
  811. 11, VL53L1_MAX_STRING_LENGTH, fp_text);
  812. trace_print(
  813. VL53L1_TRACE_LEVEL_INFO,
  814. "%s%s = %s\n",
  815. pprefix,
  816. "median_phase",
  817. fp_text);
  818. /* Offset Corrected Range */
  819. trace_print(
  820. VL53L1_TRACE_LEVEL_INFO,
  821. "%s%s = %d\n",
  822. pprefix,
  823. "median_range_mm",
  824. pdata->median_range_mm);
  825. trace_print(
  826. VL53L1_TRACE_LEVEL_INFO,
  827. "%s%s = %u\n",
  828. pprefix,
  829. "range_status",
  830. pdata->range_status);
  831. }
  832. void VL53L1_print_range_results(
  833. VL53L1_range_results_t *pdata,
  834. char *pprefix,
  835. uint32_t trace_flags)
  836. {
  837. /*
  838. * Prints out the range results data structure for debug
  839. */
  840. trace_print(
  841. VL53L1_TRACE_LEVEL_INFO,
  842. "%s%s = %u\n",
  843. pprefix,
  844. "cfg_device_state",
  845. pdata->cfg_device_state);
  846. trace_print(
  847. VL53L1_TRACE_LEVEL_INFO,
  848. "%s%s = %u\n",
  849. pprefix,
  850. "rd_device_state",
  851. pdata->rd_device_state);
  852. trace_print(
  853. VL53L1_TRACE_LEVEL_INFO,
  854. "%s%s = %u\n",
  855. pprefix,
  856. "stream_count",
  857. pdata->stream_count);
  858. trace_print(
  859. VL53L1_TRACE_LEVEL_INFO,
  860. "%s%s = %u\n",
  861. pprefix,
  862. "device_status",
  863. pdata->device_status);
  864. }
  865. void VL53L1_print_offset_range_results(
  866. VL53L1_offset_range_results_t *pdata,
  867. char *pprefix,
  868. uint32_t trace_flags)
  869. {
  870. /*
  871. * Prints out the offset range results data structure for debug
  872. */
  873. char pre_text[VL53L1_MAX_STRING_LENGTH];
  874. char *ppre_text = &(pre_text[0]);
  875. uint8_t i = 0;
  876. trace_print(
  877. VL53L1_TRACE_LEVEL_INFO,
  878. "%s%s = %u\n",
  879. pprefix,
  880. "cal_distance_mm",
  881. pdata->cal_distance_mm);
  882. trace_print(
  883. VL53L1_TRACE_LEVEL_INFO,
  884. "%s%s = %u\n",
  885. pprefix,
  886. "cal_status",
  887. pdata->cal_status);
  888. trace_print(
  889. VL53L1_TRACE_LEVEL_INFO,
  890. "%s%s = %u\n",
  891. pprefix,
  892. "cal_report",
  893. pdata->cal_report);
  894. trace_print(
  895. VL53L1_TRACE_LEVEL_INFO,
  896. "%s%s = %u\n",
  897. pprefix,
  898. "max_results",
  899. pdata->max_results);
  900. trace_print(
  901. VL53L1_TRACE_LEVEL_INFO,
  902. "%s%s = %u\n",
  903. pprefix,
  904. "active_results",
  905. pdata->active_results);
  906. for (i = 0 ; i < pdata->active_results ; i++) {
  907. sprintf(ppre_text, "%sdata[%u].", pprefix, i);
  908. VL53L1_print_offset_range_data(
  909. &(pdata->data[i]),
  910. ppre_text, trace_flags);
  911. }
  912. }
  913. void VL53L1_print_offset_range_data(
  914. VL53L1_offset_range_data_t *pdata,
  915. char *pprefix,
  916. uint32_t trace_flags)
  917. {
  918. /*
  919. * Prints out the xtalk range (ROI) data structure for debug
  920. */
  921. char fp_text[VL53L1_MAX_STRING_LENGTH];
  922. trace_print(
  923. VL53L1_TRACE_LEVEL_INFO,
  924. "%s%s = %u\n",
  925. pprefix,
  926. "preset_mode",
  927. pdata->preset_mode);
  928. trace_print(
  929. VL53L1_TRACE_LEVEL_INFO,
  930. "%s%s = %u\n",
  931. pprefix,
  932. "dss_config__roi_mode_control",
  933. pdata->dss_config__roi_mode_control);
  934. VL53L1_signed_fixed_point_sprintf(
  935. (int32_t)pdata->dss_config__manual_effective_spads_select,
  936. 8,
  937. VL53L1_MAX_STRING_LENGTH,
  938. fp_text);
  939. trace_print(
  940. VL53L1_TRACE_LEVEL_INFO,
  941. "%s%s = %s\n",
  942. pprefix,
  943. "dss_config__manual_effective_spads_select",
  944. fp_text);
  945. trace_print(
  946. VL53L1_TRACE_LEVEL_INFO,
  947. "%s%s = %u\n",
  948. pprefix,
  949. "no_of_samples",
  950. pdata->no_of_samples);
  951. VL53L1_signed_fixed_point_sprintf(
  952. (int32_t)pdata->effective_spads,
  953. 8,
  954. VL53L1_MAX_STRING_LENGTH,
  955. fp_text);
  956. trace_print(
  957. VL53L1_TRACE_LEVEL_INFO,
  958. "%s%s = %s\n",
  959. pprefix,
  960. "effective_spads",
  961. fp_text);
  962. VL53L1_signed_fixed_point_sprintf(
  963. (int32_t)pdata->peak_rate_mcps,
  964. 7,
  965. VL53L1_MAX_STRING_LENGTH,
  966. fp_text);
  967. trace_print(
  968. VL53L1_TRACE_LEVEL_INFO,
  969. "%s%s = %s\n",
  970. pprefix,
  971. "peak_rate_mcps",
  972. fp_text);
  973. VL53L1_signed_fixed_point_sprintf(
  974. (int32_t)pdata->sigma_mm,
  975. 2,
  976. VL53L1_MAX_STRING_LENGTH,
  977. fp_text);
  978. trace_print(
  979. VL53L1_TRACE_LEVEL_INFO,
  980. "%s%s = %s\n",
  981. pprefix,
  982. "sigma_mm",
  983. fp_text);
  984. trace_print(
  985. VL53L1_TRACE_LEVEL_INFO,
  986. "%s%s = %d\n",
  987. pprefix,
  988. "median_range_mm",
  989. pdata->median_range_mm);
  990. trace_print(
  991. VL53L1_TRACE_LEVEL_INFO,
  992. "%s%s = %d\n",
  993. pprefix,
  994. "range_mm_offset",
  995. pdata->range_mm_offset);
  996. }
  997. void VL53L1_print_additional_offset_cal_data(
  998. VL53L1_additional_offset_cal_data_t *pdata,
  999. char *pprefix,
  1000. uint32_t trace_flags)
  1001. {
  1002. /*
  1003. * Prints out the xtalk range (ROI) data structure for debug
  1004. */
  1005. char fp_text[VL53L1_MAX_STRING_LENGTH];
  1006. VL53L1_signed_fixed_point_sprintf(
  1007. (int32_t)pdata->result__mm_inner_actual_effective_spads,
  1008. 8,
  1009. VL53L1_MAX_STRING_LENGTH,
  1010. fp_text);
  1011. trace_print(
  1012. VL53L1_TRACE_LEVEL_INFO,
  1013. "%s%s = %s\n",
  1014. pprefix,
  1015. "result__mm_inner_actual_effective_spads",
  1016. fp_text);
  1017. VL53L1_signed_fixed_point_sprintf(
  1018. (int32_t)pdata->result__mm_outer_actual_effective_spads,
  1019. 8,
  1020. VL53L1_MAX_STRING_LENGTH,
  1021. fp_text);
  1022. trace_print(
  1023. VL53L1_TRACE_LEVEL_INFO,
  1024. "%s%s = %s\n",
  1025. pprefix,
  1026. "result__mm_outer_actual_effective_spads",
  1027. fp_text);
  1028. VL53L1_signed_fixed_point_sprintf(
  1029. (int32_t)pdata->result__mm_inner_peak_signal_count_rtn_mcps,
  1030. 7,
  1031. VL53L1_MAX_STRING_LENGTH,
  1032. fp_text);
  1033. trace_print(
  1034. VL53L1_TRACE_LEVEL_INFO,
  1035. "%s%s = %s\n",
  1036. pprefix,
  1037. "result__mm_inner_peak_signal_count_rtn_mcps",
  1038. fp_text);
  1039. VL53L1_signed_fixed_point_sprintf(
  1040. (int32_t)pdata->result__mm_outer_peak_signal_count_rtn_mcps,
  1041. 7,
  1042. VL53L1_MAX_STRING_LENGTH,
  1043. fp_text);
  1044. trace_print(
  1045. VL53L1_TRACE_LEVEL_INFO,
  1046. "%s%s = %s\n",
  1047. pprefix,
  1048. "result__mm_outer_peak_signal_count_rtn_mcps",
  1049. fp_text);
  1050. }
  1051. void VL53L1_print_cal_peak_rate_map(
  1052. VL53L1_cal_peak_rate_map_t *pdata,
  1053. char *pprefix,
  1054. uint32_t trace_flags)
  1055. {
  1056. /*
  1057. * Prints out peak rate map structure for debug
  1058. */
  1059. char fp_text[VL53L1_MAX_STRING_LENGTH];
  1060. char pre_text[VL53L1_MAX_STRING_LENGTH];
  1061. char *ppre_text = &(pre_text[0]);
  1062. uint8_t i = 0;
  1063. uint8_t x = 0;
  1064. uint8_t y = 0;
  1065. VL53L1_signed_fixed_point_sprintf(
  1066. (int32_t)pdata->cal_distance_mm,
  1067. 2,
  1068. VL53L1_MAX_STRING_LENGTH,
  1069. fp_text);
  1070. trace_print(
  1071. VL53L1_TRACE_LEVEL_INFO,
  1072. "%s%s = %s\n",
  1073. pprefix,
  1074. "cal_distance_mm",
  1075. fp_text);
  1076. trace_print(
  1077. VL53L1_TRACE_LEVEL_INFO,
  1078. "%s%s = %u\n",
  1079. pprefix,
  1080. "max_samples",
  1081. pdata->max_samples);
  1082. trace_print(
  1083. VL53L1_TRACE_LEVEL_INFO,
  1084. "%s%s = %u\n",
  1085. pprefix,
  1086. "width",
  1087. pdata->width);
  1088. trace_print(
  1089. VL53L1_TRACE_LEVEL_INFO,
  1090. "%s%s = %u\n",
  1091. pprefix,
  1092. "height",
  1093. pdata->height);
  1094. i = 0;
  1095. for (y = 0 ; y < pdata->height ; y++) {
  1096. for (x = 0 ; x < pdata->width ; x++) {
  1097. sprintf(ppre_text, "%speak_rate_mcps[%u]", pprefix, i);
  1098. VL53L1_signed_fixed_point_sprintf(
  1099. (int32_t)pdata->peak_rate_mcps[i],
  1100. 7,
  1101. VL53L1_MAX_STRING_LENGTH,
  1102. fp_text);
  1103. trace_print(
  1104. VL53L1_TRACE_LEVEL_INFO,
  1105. "%s = %s\n",
  1106. ppre_text,
  1107. fp_text);
  1108. i++;
  1109. }
  1110. }
  1111. }
  1112. void VL53L1_print_additional_data(
  1113. VL53L1_additional_data_t *pdata,
  1114. char *pprefix,
  1115. uint32_t trace_flags)
  1116. {
  1117. /*
  1118. * Prints out the Additional data structure for debug
  1119. */
  1120. char fp_text[VL53L1_MAX_STRING_LENGTH];
  1121. trace_print(
  1122. VL53L1_TRACE_LEVEL_INFO,
  1123. "%s%s = %u\n",
  1124. pprefix,
  1125. "preset_mode",
  1126. pdata->preset_mode);
  1127. trace_print(
  1128. VL53L1_TRACE_LEVEL_INFO,
  1129. "%s%s = %u\n",
  1130. pprefix,
  1131. "measurement_mode",
  1132. pdata->measurement_mode);
  1133. trace_print(
  1134. VL53L1_TRACE_LEVEL_INFO,
  1135. "%s%s = %u\n",
  1136. pprefix,
  1137. "phasecal_config_timeout_us",
  1138. pdata->phasecal_config_timeout_us);
  1139. trace_print(
  1140. VL53L1_TRACE_LEVEL_INFO,
  1141. "%s%s = %u\n",
  1142. pprefix,
  1143. "mm_config_timeout_us",
  1144. pdata->mm_config_timeout_us);
  1145. trace_print(
  1146. VL53L1_TRACE_LEVEL_INFO,
  1147. "%s%s = %u\n",
  1148. pprefix,
  1149. "range_config_timeout_us",
  1150. pdata->range_config_timeout_us);
  1151. trace_print(
  1152. VL53L1_TRACE_LEVEL_INFO,
  1153. "%s%s = %u\n",
  1154. pprefix,
  1155. "inter_measurement_period_ms",
  1156. pdata->inter_measurement_period_ms);
  1157. VL53L1_signed_fixed_point_sprintf(
  1158. (int32_t)pdata->dss_config__target_total_rate_mcps,
  1159. 7,
  1160. VL53L1_MAX_STRING_LENGTH,
  1161. fp_text);
  1162. trace_print(
  1163. VL53L1_TRACE_LEVEL_INFO,
  1164. "%s%s = %s\n",
  1165. pprefix,
  1166. "dss_config__target_total_rate_mcps",
  1167. fp_text);
  1168. }
  1169. void VL53L1_print_gain_calibration_data(
  1170. VL53L1_gain_calibration_data_t *pdata,
  1171. char *pprefix,
  1172. uint32_t trace_flags)
  1173. {
  1174. /*
  1175. * Prints out the LL Driver state data for debug
  1176. */
  1177. char fp_text[VL53L1_MAX_STRING_LENGTH];
  1178. VL53L1_signed_fixed_point_sprintf(
  1179. (int32_t)pdata->standard_ranging_gain_factor,
  1180. 11,
  1181. VL53L1_MAX_STRING_LENGTH,
  1182. fp_text);
  1183. trace_print(
  1184. VL53L1_TRACE_LEVEL_INFO,
  1185. "%s%s = %s\n",
  1186. pprefix,
  1187. "standard_ranging_gain_factor",
  1188. fp_text);
  1189. }
  1190. void VL53L1_print_xtalk_config(
  1191. VL53L1_xtalk_config_t *pdata,
  1192. char *pprefix,
  1193. uint32_t trace_flags)
  1194. {
  1195. /*
  1196. * Prints out the xtalk config data structure for debug
  1197. */
  1198. char fp_text[VL53L1_MAX_STRING_LENGTH];
  1199. VL53L1_signed_fixed_point_sprintf(
  1200. (int32_t)pdata->algo__crosstalk_compensation_plane_offset_kcps,
  1201. 9,
  1202. VL53L1_MAX_STRING_LENGTH,
  1203. fp_text);
  1204. trace_print(
  1205. VL53L1_TRACE_LEVEL_INFO,
  1206. "%s%s = %s\n",
  1207. pprefix,
  1208. "algo__crosstalk_compensation_plane_offset_kcps",
  1209. fp_text);
  1210. VL53L1_signed_fixed_point_sprintf(
  1211. (int32_t)pdata->algo__crosstalk_compensation_x_plane_gradient_kcps,
  1212. 11,
  1213. VL53L1_MAX_STRING_LENGTH,
  1214. fp_text);
  1215. trace_print(
  1216. VL53L1_TRACE_LEVEL_INFO,
  1217. "%s%s = %s\n",
  1218. pprefix,
  1219. "algo__crosstalk_compensation_x_plane_gradient_kcps",
  1220. fp_text);
  1221. VL53L1_signed_fixed_point_sprintf(
  1222. (int32_t)pdata->algo__crosstalk_compensation_y_plane_gradient_kcps,
  1223. 11,
  1224. VL53L1_MAX_STRING_LENGTH,
  1225. fp_text);
  1226. trace_print(
  1227. VL53L1_TRACE_LEVEL_INFO,
  1228. "%s%s = %s\n",
  1229. pprefix,
  1230. "algo__crosstalk_compensation_y_plane_gradient_kcps",
  1231. fp_text);
  1232. trace_print(
  1233. VL53L1_TRACE_LEVEL_INFO,
  1234. "%s%s = %u\n",
  1235. pprefix,
  1236. "global_crosstalk_compensation_enable",
  1237. pdata->global_crosstalk_compensation_enable);
  1238. VL53L1_signed_fixed_point_sprintf(
  1239. (int32_t)pdata->lite_mode_crosstalk_margin_kcps,
  1240. 9,
  1241. VL53L1_MAX_STRING_LENGTH,
  1242. fp_text);
  1243. trace_print(
  1244. VL53L1_TRACE_LEVEL_INFO,
  1245. "%s%s = %s\n",
  1246. pprefix,
  1247. "lite_mode_crosstalk_margin_kcps",
  1248. fp_text);
  1249. VL53L1_signed_fixed_point_sprintf(
  1250. (int32_t)pdata->crosstalk_range_ignore_threshold_mult,
  1251. 5,
  1252. VL53L1_MAX_STRING_LENGTH,
  1253. fp_text);
  1254. trace_print(
  1255. VL53L1_TRACE_LEVEL_INFO,
  1256. "%s%s = %s\n",
  1257. pprefix,
  1258. "crosstalk_range_ignore_threshold_mult",
  1259. fp_text);
  1260. VL53L1_signed_fixed_point_sprintf(
  1261. (int32_t)pdata->crosstalk_range_ignore_threshold_rate_mcps,
  1262. 13,
  1263. VL53L1_MAX_STRING_LENGTH,
  1264. fp_text);
  1265. trace_print(
  1266. VL53L1_TRACE_LEVEL_INFO,
  1267. "%s%s = %s\n",
  1268. pprefix,
  1269. "crosstalk_range_ignore_threshold_rate_mcps",
  1270. fp_text);
  1271. }
  1272. void VL53L1_print_optical_centre(
  1273. VL53L1_optical_centre_t *pdata,
  1274. char *pprefix,
  1275. uint32_t trace_flags)
  1276. {
  1277. /* Prints out the optical centre data structure for debug
  1278. */
  1279. char fp_text[VL53L1_MAX_STRING_LENGTH];
  1280. VL53L1_signed_fixed_point_sprintf(
  1281. (int32_t)pdata->x_centre,
  1282. 4,
  1283. VL53L1_MAX_STRING_LENGTH,
  1284. fp_text);
  1285. trace_print(
  1286. VL53L1_TRACE_LEVEL_INFO,
  1287. "%s%s = %s\n",
  1288. pprefix,
  1289. "x_centre",
  1290. fp_text);
  1291. VL53L1_signed_fixed_point_sprintf(
  1292. (int32_t)pdata->y_centre,
  1293. 4,
  1294. VL53L1_MAX_STRING_LENGTH,
  1295. fp_text);
  1296. trace_print(
  1297. VL53L1_TRACE_LEVEL_INFO,
  1298. "%s%s = %s\n",
  1299. pprefix,
  1300. "y_centre",
  1301. fp_text);
  1302. }
  1303. void VL53L1_print_user_zone(
  1304. VL53L1_user_zone_t *pdata,
  1305. char *pprefix,
  1306. uint32_t trace_flags)
  1307. {
  1308. /* Prints out the zone (ROI) data structure for debug
  1309. */
  1310. trace_print(
  1311. VL53L1_TRACE_LEVEL_INFO,
  1312. "%s%s = %u\n",
  1313. pprefix,
  1314. "x_centre",
  1315. pdata->x_centre);
  1316. trace_print(
  1317. VL53L1_TRACE_LEVEL_INFO,
  1318. "%s%s = %u\n",
  1319. pprefix,
  1320. "y_centre",
  1321. pdata->y_centre);
  1322. trace_print(
  1323. VL53L1_TRACE_LEVEL_INFO,
  1324. "%s%s = %u\n",
  1325. pprefix,
  1326. "width",
  1327. pdata->width);
  1328. trace_print(VL53L1_TRACE_LEVEL_INFO,
  1329. "%s%s = %u\n",
  1330. pprefix,
  1331. "height",
  1332. pdata->height);
  1333. }
  1334. void VL53L1_print_spad_rate_data(
  1335. VL53L1_spad_rate_data_t *pspad_rates,
  1336. char *pprefix,
  1337. uint32_t trace_flags)
  1338. {
  1339. /**
  1340. * Print per SPAD rates generated by SSC
  1341. */
  1342. uint16_t spad_no = 0;
  1343. uint8_t row = 0;
  1344. uint8_t col = 0;
  1345. char fp_text[VL53L1_MAX_STRING_LENGTH];
  1346. trace_print(
  1347. VL53L1_TRACE_LEVEL_INFO,
  1348. "%s%8s,%4s,%4s, %s\n",
  1349. pprefix,
  1350. "spad_no",
  1351. "row",
  1352. "col",
  1353. "peak_rate_mcps");
  1354. for (spad_no = 0 ; spad_no < pspad_rates->no_of_values ; spad_no++) {
  1355. /* generate row / col location from SPAD number */
  1356. VL53L1_decode_row_col(
  1357. (uint8_t)spad_no,
  1358. &row,
  1359. &col);
  1360. /* Convert fixed point rate value to string */
  1361. VL53L1_signed_fixed_point_sprintf(
  1362. (int32_t)pspad_rates->rate_data[spad_no],
  1363. pspad_rates->fractional_bits,
  1364. VL53L1_MAX_STRING_LENGTH,
  1365. fp_text);
  1366. /* Print data */
  1367. trace_print(
  1368. VL53L1_TRACE_LEVEL_INFO,
  1369. "%s%8u,%4u,%4u, %s\n",
  1370. pprefix,
  1371. spad_no,
  1372. row,
  1373. col,
  1374. fp_text);
  1375. }
  1376. }
  1377. void VL53L1_print_spad_rate_map(
  1378. VL53L1_spad_rate_data_t *pspad_rates,
  1379. char *pprefix,
  1380. uint32_t trace_flags)
  1381. {
  1382. /**
  1383. * Print per SPAD rates generated by SSC as a map
  1384. */
  1385. uint8_t spad_no = 0;
  1386. uint8_t row = 0;
  1387. uint8_t col = 0;
  1388. char fp_text[VL53L1_MAX_STRING_LENGTH];
  1389. /* Print column headers */
  1390. trace_print(
  1391. VL53L1_TRACE_LEVEL_INFO,
  1392. "%s%4s",
  1393. pprefix,
  1394. " ");
  1395. for (col = 0 ; col < VL53L1_SPAD_ARRAY_WIDTH ; col++)
  1396. trace_print(
  1397. VL53L1_TRACE_LEVEL_INFO,
  1398. ",%8u",
  1399. col);
  1400. trace_print(
  1401. VL53L1_TRACE_LEVEL_INFO,
  1402. "\n");
  1403. /* Print rate data */
  1404. for (row = 0 ; row < VL53L1_SPAD_ARRAY_HEIGHT ; row++) {
  1405. trace_print(
  1406. VL53L1_TRACE_LEVEL_INFO,
  1407. "%s%4u",
  1408. pprefix,
  1409. row);
  1410. for (col = 0 ; col < VL53L1_SPAD_ARRAY_HEIGHT ; col++) {
  1411. /* generate SPAD number from (row, col) location */
  1412. VL53L1_encode_row_col(
  1413. row,
  1414. col,
  1415. &spad_no);
  1416. /* Convert fixed point rate value to string */
  1417. VL53L1_signed_fixed_point_sprintf(
  1418. (int32_t)pspad_rates->rate_data[spad_no],
  1419. pspad_rates->fractional_bits,
  1420. VL53L1_MAX_STRING_LENGTH,
  1421. fp_text);
  1422. /* Print data */
  1423. trace_print(
  1424. VL53L1_TRACE_LEVEL_INFO,
  1425. ",%8s",
  1426. fp_text);
  1427. }
  1428. trace_print(
  1429. VL53L1_TRACE_LEVEL_INFO,
  1430. "\n");
  1431. }
  1432. }
  1433. #endif /* VL53L1_LOG_ENABLE */