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
Diff: VL53L0X.cpp
- Revision:
- 2:d07edeaff6f1
- Parent:
- 1:834986cdde0a
- Child:
- 3:e9269ff624ed
--- a/VL53L0X.cpp Wed Oct 04 13:21:38 2017 +0000
+++ b/VL53L0X.cpp Fri Oct 13 15:31:04 2017 +0000
@@ -438,9 +438,9 @@
offset_calibration_data_micro_meter = c_max_offset_micro_meter;
} else {
if (offset_calibration_data_micro_meter < c_min_offset_micro_meter) {
- offset_calibration_data_micro_meter = c_min_offset_micro_meter;
- }
- }
+ offset_calibration_data_micro_meter = c_min_offset_micro_meter;
+ }
+ }
/* The offset register is 10.2 format and units are mm
* therefore conversion is applied by a division of
@@ -2077,7 +2077,7 @@
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_perform_phase_calibration(
dev, p_phase_cal, get_data_enable, 0);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
@@ -2152,7 +2152,7 @@
quadrant = spad_index >> 6;
if (refArrayQuadrants[quadrant] == REF_ARRAY_SPAD_0) {
is_aperture = 0;
- }
+ }
return is_aperture;
}
@@ -3299,7 +3299,7 @@
status = VL53L0X_get_limit_check_enable(dev,
VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE,
&sigma_limit_check_enable);
- }
+ }
if ((sigma_limit_check_enable != 0) && (status == VL53L0X_ERROR_NONE)) {
/*
@@ -3375,11 +3375,11 @@
* EffectiveSpadRtnCount has a format 8.8
* If (Return signal rate < (1.5 x Xtalk x number of Spads)) : FAIL
*/
- if (status == VL53L0X_ERROR_NONE){
+ if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_get_limit_check_enable(dev,
VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD,
&range_ignore_threshold_limit_check_enable);
- }
+ }
if ((range_ignore_threshold_limit_check_enable != 0) &&
(status == VL53L0X_ERROR_NONE)) {
@@ -3702,11 +3702,11 @@
status = VL53L0X_read_word(dev,
VL53L0X_REG_RESULT_PEAK_SIGNAL_RATE_REF,
p_ref_signal_rate);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev, 0xFF, 0x00);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
/* restore the previous Sequence Config */
@@ -3790,7 +3790,7 @@
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev,
VL53L0X_REG_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD, 0x2C);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev, 0xFF, 0x00);
@@ -3800,18 +3800,18 @@
status = VL53L0X_write_byte(dev,
VL53L0X_REG_GLOBAL_CONFIG_REF_EN_START_SELECT,
start_select);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev,
VL53L0X_REG_POWER_MANAGEMENT_GO1_POWER_FORCE, 0);
- }
+ }
/* Perform ref calibration */
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_perform_ref_calibration(dev, &vhv_settings,
&phase_cal, 0);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
/* Enable Minimum NON-APERTURE Spads */
@@ -4016,26 +4016,26 @@
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev,
VL53L0X_REG_DYNAMIC_SPAD_REF_EN_START_OFFSET, 0x00);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev,
VL53L0X_REG_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD, 0x2C);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev, 0xFF, 0x00);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_write_byte(dev,
VL53L0X_REG_GLOBAL_CONFIG_REF_EN_START_SELECT,
start_select);
- }
+ }
for (index = 0; index < spad_array_size; index++) {
dev->Data.SpadData.RefSpadEnables[index] = 0;
- }
+ }
if (is_aperture_spads) {
/* Increment to the first APERTURE spad */
@@ -4138,78 +4138,78 @@
VL53L0X_REG_GPIO_HV_MUX_ACTIVE_HIGH, data);
} else {
- if (device_mode == VL53L0X_DEVICEMODE_GPIO_OSC) {
-
- status |= VL53L0X_write_byte(dev, 0xff, 0x01);
- status |= VL53L0X_write_byte(dev, 0x00, 0x00);
-
- status |= VL53L0X_write_byte(dev, 0xff, 0x00);
- status |= VL53L0X_write_byte(dev, 0x80, 0x01);
- status |= VL53L0X_write_byte(dev, 0x85, 0x02);
-
- status |= VL53L0X_write_byte(dev, 0xff, 0x04);
- status |= VL53L0X_write_byte(dev, 0xcd, 0x00);
- status |= VL53L0X_write_byte(dev, 0xcc, 0x11);
-
- status |= VL53L0X_write_byte(dev, 0xff, 0x07);
- status |= VL53L0X_write_byte(dev, 0xbe, 0x00);
-
- status |= VL53L0X_write_byte(dev, 0xff, 0x06);
- status |= VL53L0X_write_byte(dev, 0xcc, 0x09);
-
- status |= VL53L0X_write_byte(dev, 0xff, 0x00);
- status |= VL53L0X_write_byte(dev, 0xff, 0x01);
- status |= VL53L0X_write_byte(dev, 0x00, 0x00);
-
- } else {
-
- if (status == VL53L0X_ERROR_NONE) {
- switch (functionality) {
- case VL53L0X_GPIOFUNCTIONALITY_OFF:
- data = 0x00;
- break;
- case VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW:
- data = 0x01;
- break;
- case VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH:
- data = 0x02;
- break;
- case VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT:
- data = 0x03;
- break;
- case VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY:
- data = 0x04;
- break;
- default:
- status =
- VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED;
- }
- }
-
- if (status == VL53L0X_ERROR_NONE) {
- status = VL53L0X_write_byte(dev,
- VL53L0X_REG_SYSTEM_INTERRUPT_CONFIG_GPIO, data);
- }
-
- if (status == VL53L0X_ERROR_NONE) {
- if (polarity == VL53L0X_INTERRUPTPOLARITY_LOW) {
- data = 0;
- } else {
- data = (uint8_t)(1 << 4);
- }
- status = VL53L0X_update_byte(dev,
- VL53L0X_REG_GPIO_HV_MUX_ACTIVE_HIGH, 0xEF, data);
- }
-
- if (status == VL53L0X_ERROR_NONE) {
- VL53L0X_SETDEVICESPECIFICPARAMETER(dev,
- Pin0GpioFunctionality, functionality);
- }
-
- if (status == VL53L0X_ERROR_NONE) {
- status = VL53L0X_clear_interrupt_mask(dev, 0);
- }
- }
+ if (device_mode == VL53L0X_DEVICEMODE_GPIO_OSC) {
+
+ status |= VL53L0X_write_byte(dev, 0xff, 0x01);
+ status |= VL53L0X_write_byte(dev, 0x00, 0x00);
+
+ status |= VL53L0X_write_byte(dev, 0xff, 0x00);
+ status |= VL53L0X_write_byte(dev, 0x80, 0x01);
+ status |= VL53L0X_write_byte(dev, 0x85, 0x02);
+
+ status |= VL53L0X_write_byte(dev, 0xff, 0x04);
+ status |= VL53L0X_write_byte(dev, 0xcd, 0x00);
+ status |= VL53L0X_write_byte(dev, 0xcc, 0x11);
+
+ status |= VL53L0X_write_byte(dev, 0xff, 0x07);
+ status |= VL53L0X_write_byte(dev, 0xbe, 0x00);
+
+ status |= VL53L0X_write_byte(dev, 0xff, 0x06);
+ status |= VL53L0X_write_byte(dev, 0xcc, 0x09);
+
+ status |= VL53L0X_write_byte(dev, 0xff, 0x00);
+ status |= VL53L0X_write_byte(dev, 0xff, 0x01);
+ status |= VL53L0X_write_byte(dev, 0x00, 0x00);
+
+ } else {
+
+ if (status == VL53L0X_ERROR_NONE) {
+ switch (functionality) {
+ case VL53L0X_GPIOFUNCTIONALITY_OFF:
+ data = 0x00;
+ break;
+ case VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW:
+ data = 0x01;
+ break;
+ case VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH:
+ data = 0x02;
+ break;
+ case VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT:
+ data = 0x03;
+ break;
+ case VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY:
+ data = 0x04;
+ break;
+ default:
+ status =
+ VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED;
+ }
+ }
+
+ if (status == VL53L0X_ERROR_NONE) {
+ status = VL53L0X_write_byte(dev,
+ VL53L0X_REG_SYSTEM_INTERRUPT_CONFIG_GPIO, data);
+ }
+
+ if (status == VL53L0X_ERROR_NONE) {
+ if (polarity == VL53L0X_INTERRUPTPOLARITY_LOW) {
+ data = 0;
+ } else {
+ data = (uint8_t)(1 << 4);
+ }
+ status = VL53L0X_update_byte(dev,
+ VL53L0X_REG_GPIO_HV_MUX_ACTIVE_HIGH, 0xEF, data);
+ }
+
+ if (status == VL53L0X_ERROR_NONE) {
+ VL53L0X_SETDEVICESPECIFICPARAMETER(dev,
+ Pin0GpioFunctionality, functionality);
+ }
+
+ if (status == VL53L0X_ERROR_NONE) {
+ status = VL53L0X_clear_interrupt_mask(dev, 0);
+ }
+ }
}
LOG_FUNCTION_END(status);
return status;
@@ -4865,12 +4865,12 @@
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_set_sequence_step_enable(dev,
VL53L0X_SEQUENCESTEP_TCC, 0);
- }
+ }
if (status == VL53L0X_ERROR_NONE) {
status = VL53L0X_set_sequence_step_enable(dev,
VL53L0X_SEQUENCESTEP_MSRC, 0);
- }
+ }
/* Set PAL State to standby */
if (status == VL53L0X_ERROR_NONE) {