Condensed Version of Public VL53L0X
Diff: VL53L0X.cpp
- Revision:
- 8:abea9638127a
- Parent:
- 7:41cbc431e1f4
- Child:
- 10:cd251e0fc2fd
--- a/VL53L0X.cpp Sun Mar 24 18:18:54 2019 +0000 +++ b/VL53L0X.cpp Sun Mar 24 18:36:37 2019 +0000 @@ -65,12 +65,18 @@ // is used to replace: // #define PALDevDataSet(field, data) (Dev->field)=(data) - - /* Includes */ #include <stdlib.h> #include "VL53L0X.h" +#define REF_ARRAY_SPAD_0 0 +#define REF_ARRAY_SPAD_5 5 +#define REF_ARRAY_SPAD_10 10 + +uint32_t refArrayQuadrants[4] = {REF_ARRAY_SPAD_10,REF_ARRAY_SPAD_5, + REF_ARRAY_SPAD_0,REF_ARRAY_SPAD_5 }; + + VL53L0X_Error VL53L0X::VL53L0X_device_read_strobe() { VL53L0X_Error status = VL53L0X_ERROR_NONE; @@ -153,7 +159,7 @@ status |= VL53L0X_device_read_strobe(); status |= VL53L0X_read_dword(0x90,&tmp_dword); - reference_spad_count = (uint8_t)((tmp_dword >> 8) & 0x07f); + reference_spad_count = (uint8_t)((tmp_dword >> 8) & 0x7f); reference_spad_type = (uint8_t)((tmp_dword >> 15) & 0x01); status |= VL53L0X_write_byte(0x94,0x24); @@ -161,22 +167,17 @@ status |= VL53L0X_read_dword(0x90,&tmp_dword); - nvm_ref_good_spad_map[0] = (uint8_t)((tmp_dword >> 24) - & 0xff); - nvm_ref_good_spad_map[1] = (uint8_t)((tmp_dword >> 16) - & 0xff); - nvm_ref_good_spad_map[2] = (uint8_t)((tmp_dword >> 8) - & 0xff); + nvm_ref_good_spad_map[0] = (uint8_t)((tmp_dword >> 24)& 0xff); + nvm_ref_good_spad_map[1] = (uint8_t)((tmp_dword >> 16)& 0xff); + nvm_ref_good_spad_map[2] = (uint8_t)((tmp_dword >> 8)& 0xff); nvm_ref_good_spad_map[3] = (uint8_t)(tmp_dword & 0xff); status |= VL53L0X_write_byte(0x94,0x25); status |= VL53L0X_device_read_strobe(); status |= VL53L0X_read_dword(0x90,&tmp_dword); - nvm_ref_good_spad_map[4] = (uint8_t)((tmp_dword >> 24) - & 0xff); - nvm_ref_good_spad_map[5] = (uint8_t)((tmp_dword >> 16) - & 0xff); + nvm_ref_good_spad_map[4] = (uint8_t)((tmp_dword >> 24)& 0xff); + nvm_ref_good_spad_map[5] = (uint8_t)((tmp_dword >> 16)& 0xff); } if (((option & 2) == 2) && @@ -197,7 +198,7 @@ product_id[0] = (char)((tmp_dword >> 25) & 0x07f); product_id[1] = (char)((tmp_dword >> 18) & 0x07f); product_id[2] = (char)((tmp_dword >> 11) & 0x07f); - product_id[3] = (char)((tmp_dword >> 4) & 0x07f); + product_id[3] = (char)((tmp_dword >> 4) & 0x07f); byte = (uint8_t)((tmp_dword & 0x00f) << 3); @@ -301,8 +302,7 @@ if (((option & 1) == 1) && ((read_data_from_device_done & 1) == 0)) { _device->DeviceSpecificParameters.ReferenceSpadCount=reference_spad_count; - _device->DeviceSpecificParameters.ReferenceSpadType=reference_spad_type; - + _device->DeviceSpecificParameters.ReferenceSpadType =reference_spad_type; for (i = 0; i < VL53L0X_REF_SPAD_BUFFER_SIZE; i++) { _device->SpadData.RefGoodSpadMap[i] = nvm_ref_good_spad_map[i]; @@ -312,9 +312,7 @@ if (((option & 2) == 2) && ((read_data_from_device_done & 2) == 0)) { _device->DeviceSpecificParameters.ModuleId = module_id; - _device->DeviceSpecificParameters.Revision = revision; - product_id_tmp = _device->DeviceSpecificParameters.ProductId; strcpy(product_id_tmp,product_id); @@ -323,12 +321,9 @@ if (((option & 4) == 4) && ((read_data_from_device_done & 4) == 0)) { _device->DeviceSpecificParameters.PartUIDUpper = part_uid_upper; - _device->DeviceSpecificParameters.PartUIDLower = part_uid_lower; - signal_rate_meas_fixed400_mm_fix = VL53L0X_FIXPOINT97TOFIXPOINT1616(signal_rate_meas_fixed1104_400_mm); - _device->DeviceSpecificParameters.SignalRateMeasFixed400mm = signal_rate_meas_fixed400_mm_fix; _device->DeviceSpecificParameters.SignalRateMeasFixed400mm = signal_rate_meas_fixed400_mm_fix; @@ -337,11 +332,9 @@ offset_fixed1104_mm = dist_meas_fixed1104_400_mm - dist_meas_tgt_fixed1104_mm; - offset_micro_meters = (offset_fixed1104_mm - * 1000) >> 4; + offset_micro_meters = (offset_fixed1104_mm * 1000) >> 4; offset_micro_meters *= -1; } - _device->Part2PartOffsetAdjustmentNVMMicroMeter = offset_micro_meters; } byte = (uint8_t)(read_data_from_device_done | option);