Initial release.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: X_NUCLEO_53L1A1_mbed X_NUCLEO_53L1A1_mbed VL53L1X_Ranging_With_Standalone_Satellite_MbedOS X_NUCLEO_53L1A1
Revision 3:e9269ff624ed, committed 2017-10-13
- Comitter:
- Davidroid
- Date:
- Fri Oct 13 22:03:48 2017 +0000
- Parent:
- 2:d07edeaff6f1
- Child:
- 4:d25c4fa216af
- Commit message:
- Astyle formatting.
Changed in this revision
| VL53L0X.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/VL53L0X.cpp Fri Oct 13 15:31:04 2017 +0000
+++ b/VL53L0X.cpp Fri Oct 13 22:03:48 2017 +0000
@@ -616,8 +616,9 @@
status = VL53L0X_read_word(dev,
VL53L0X_REG_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT,
&temp16);
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
temp_fix1616 = VL53L0X_FIXPOINT97TOFIXPOINT1616(temp16);
+ }
enable_zero_value = 1;
@@ -642,8 +643,9 @@
status = VL53L0X_read_word(dev,
VL53L0X_REG_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT,
&temp16);
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
temp_fix1616 = VL53L0X_FIXPOINT97TOFIXPOINT1616(temp16);
+ }
enable_zero_value = 0;
@@ -716,10 +718,11 @@
status = VL53L0X_read_byte(dev, VL53L0X_REG_SYSTEM_SEQUENCE_CONFIG, &data);
if (status == VL53L0X_ERROR_NONE) {
PALDevDataSet(dev, SequenceConfig, data);
- if (data & (0x01 << 7))
+ if (data & (0x01 << 7)) {
*p_wrap_around_check_enable = 0x01;
- else
+ } else {
*p_wrap_around_check_enable = 0x00;
+ }
}
if (status == VL53L0X_ERROR_NONE) {
VL53L0X_SETPARAMETERFIELD(dev, WrapAroundCheckEnable,
@@ -864,8 +867,9 @@
/* Apply specific settings for the requested clock period */
- if (status != VL53L0X_ERROR_NONE)
+ if (status != VL53L0X_ERROR_NONE) {
return status;
+ }
if (vcsel_period_type == VL53L0X_VCSEL_PERIOD_PRE_RANGE) {
@@ -1412,8 +1416,9 @@
&(p_device_parameters->InterMeasurementPeriodMilliSeconds));
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
p_device_parameters->XTalkCompensationEnable = 0;
+ }
if (status == VL53L0X_ERROR_NONE)
status = VL53L0X_get_x_talk_compensation_rate_mega_cps(dev,
@@ -1557,14 +1562,16 @@
#endif
/* Set I2C standard mode */
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev, 0x88, 0x00);
+ }
VL53L0X_SETDEVICESPECIFICPARAMETER(dev, ReadDataFromDeviceDone, 0);
#ifdef USE_IQC_STATION
- if (Status == VL53L0X_ERROR_NONE)
+ if (Status == VL53L0X_ERROR_NONE) {
Status = VL53L0X_apply_offset_adjustment(Dev);
+ }
#endif
/* Default value is 1000 for Linearity Corrective Gain */
@@ -1611,10 +1618,11 @@
/* Enable all check */
for (i = 0; i < VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS; i++) {
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
status |= VL53L0X_set_limit_check_enable(dev, i, 1);
- else
+ } else {
break;
+ }
}
@@ -1671,8 +1679,9 @@
PALDevDataSet(dev, PalState, VL53L0X_STATE_WAIT_STATICINIT);
}
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
VL53L0X_SETDEVICESPECIFICPARAMETER(dev, RefSpadsInitialised, 0);
+ }
LOG_FUNCTION_END(status);
@@ -2023,8 +2032,9 @@
* this will be reset before the end of the function
*/
- if (restore_config)
+ if (restore_config) {
sequence_config = PALDevDataGet(dev, SequenceConfig);
+ }
/* Run PhaseCal */
status = VL53L0X_write_byte(dev, VL53L0X_REG_SYSTEM_SEQUENCE_CONFIG, 0x02);
@@ -2514,8 +2524,9 @@
&& (status == VL53L0X_ERROR_NONE)
&& (loop_nb < VL53L0X_DEFAULT_MAX_LOOP));
- if (loop_nb >= VL53L0X_DEFAULT_MAX_LOOP)
+ if (loop_nb >= VL53L0X_DEFAULT_MAX_LOOP) {
status = VL53L0X_ERROR_TIME_OUT;
+ }
}
@@ -2524,8 +2535,9 @@
/* Back-to-back mode */
/* Check if need to apply interrupt settings */
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_check_and_load_interrupt_settings(dev, 1);
+ }
status = VL53L0X_write_byte(dev,
VL53L0X_REG_SYSRANGE_START,
@@ -2538,8 +2550,9 @@
case VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING:
/* Continuous mode */
/* Check if need to apply interrupt settings */
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_check_and_load_interrupt_settings(dev, 1);
+ }
status = VL53L0X_write_byte(dev,
VL53L0X_REG_SYSRANGE_START,
@@ -2586,8 +2599,9 @@
/* Change PAL State in case of single ranging or single histogram */
if (status == VL53L0X_ERROR_NONE
- && device_mode == VL53L0X_DEVICEMODE_SINGLE_RANGING)
+ && device_mode == VL53L0X_DEVICEMODE_SINGLE_RANGING) {
PALDevDataSet(dev, PalState, VL53L0X_STATE_IDLE);
+ }
LOG_FUNCTION_END(status);
@@ -2708,8 +2722,9 @@
if (num >= res + bit) {
num -= res + bit;
res = (res >> 1) + bit;
- } else
+ } else {
res >>= 1;
+ }
bit >>= 2;
}
@@ -3428,8 +3443,9 @@
}
/* DMAX only relevant during range error */
- if (*p_pal_range_status == 0)
+ if (*p_pal_range_status == 0) {
p_ranging_measurement_data->RangeDMaxMilliMeter = 0;
+ }
/* fill the Limit Check Status */
@@ -3776,8 +3792,9 @@
* Note that there are 6 bytes. Only the first 44 bits will be used to
* represent spads.
*/
- for (index = 0; index < spad_array_size; index++)
+ for (index = 0; index < spad_array_size; index++) {
dev->Data.SpadData.RefSpadEnables[index] = 0;
+ }
status = VL53L0X_write_byte(dev, 0xFF, 0x01);
@@ -4842,8 +4859,9 @@
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_get_fraction_enable(dev, &tempbyte);
- if (status == VL53L0X_ERROR_NONE)
+ if (status == VL53L0X_ERROR_NONE) {
PALDevDataSet(dev, RangeFractionalEnable, tempbyte);
+ }
}
@@ -5067,8 +5085,9 @@
status = VL53L0X_i2c_read(Dev->I2cDevAddr, index, p_data, 1);
- if (status)
+ if (status) {
return -1;
+ }
return 0;
}
@@ -5429,8 +5448,9 @@
}
if (operating_mode == range_continuous_polling) {
- if (Status == VL53L0X_ERROR_NONE)
+ if (Status == VL53L0X_ERROR_NONE) {
Status = VL53L0X_measurement_poll_for_completion(_device);
+ }
if (Status == VL53L0X_ERROR_NONE) {
Status = VL53L0X_get_ranging_measurement_data(_device, p_data);