Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vl53l0x: Perform 'abs' operation before scaling and dividing mcps dif… #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sensor/vl53l0x/api/core/src/vl53l0x_api_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1861,8 +1861,8 @@ VL53L0X_Error VL53L0X_calc_sigma_estimate(VL53L0X_DEV Dev,
* 500 is added to ensure rounding when integer division
* truncates.
*/
diff1_mcps = (((peakSignalRate_kcps << 16) -
2 * xTalkCompRate_kcps) + 500)/1000;
diff1_mcps = abs((int32_t) ((((peakSignalRate_kcps << 16) -
2 * xTalkCompRate_kcps) + 500)/1000));

/* vcselRate + xtalkCompRate */
diff2_mcps = ((peakSignalRate_kcps << 16) + 500)/1000;
Expand All @@ -1872,7 +1872,7 @@ VL53L0X_Error VL53L0X_calc_sigma_estimate(VL53L0X_DEV Dev,
diff1_mcps <<= 8;

/* FixPoint0824/FixPoint1616 = FixPoint2408 */
xTalkCorrection = abs(diff1_mcps/diff2_mcps);
xTalkCorrection = diff1_mcps/diff2_mcps;

/* FixPoint2408 << 8 = FixPoint1616 */
xTalkCorrection <<= 8;
Expand Down