# vl53l0x

VL53L0X Time-of-Flight ranging sensor library.

Author | Rob Jansen, Copyright © 2025..2025, all rights reserved.
Adapted-by |
Compiler | 2.5r9

Description

    Libray for the VL53L0X Time-of-Flight ranging sensor. It is controlled
                 using the IIC interface at a maximum speed of 400 kHz.

Sources

    Based on the vl53l0x-arduino: https://github.com/pololu/vl53l0x-arduino
             Datasheet STMicroelectronics  VL53L0X DS11555 - Rev 6

Notes

    The main program must initialize the used - default - IIC interface
             with a maximum speed of 400 kHz and with a I2C_HARDWARE_TIMEOUT
             defined.

Dependencies

No dependency found

## Summary

### Global variables/contants

- `const byte _VL53L0X_GLOBAL_CONFIG_REF_EN_START_SELECT = 0xB6`
- `const byte _VL53L0X_MSRC_CONFIG_TIMEOUT_MACROP = 0x46`
- `const byte VL53L0X_IIC_DEFAULT_ADDRESS = 0x52`
- `const byte _VL53L0X_PRE_RANGE_CONFIG_SIGMA_THRESH_LO = 0x62`
- `const byte _VL53L0X_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI = 0x51`
- `const byte _VL53L0X_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV = 0x89`
- `const byte _VL53L0X_ALGO_PHASECAL_CONFIG_TIMEOUT = 0x30`
- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_5 = 0xB5`
- `const byte _VL53L0X_ALGO_PHASECAL_LIM = 0x30`
- `const byte _VL53L0X_RESULT_CORE_RANGING_TOTAL_EVENTS_REF = 0xD4`
- `const byte _VL53L0X_FINAL_RANGE_CONFIG_VCSEL_PERIOD = 0x70`
- `const byte _VL53L0X_SOFT_RESET_GO2_SOFT_RESET_N = 0xBF`
- `var byte _vl53l0x_iic_address = VL53L0X_IIC_DEFAULT_ADDRESS`
- `const byte _VL53L0X_GPIO_HV_MUX_ACTIVE_HIGH = 0x84`
- `const byte _VL53L0X_TUNING_SETTINGS[] =`
- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_0 = 0xB0`
- `const byte _VL53L0X_SYSTEM_INTERRUPT_CLEAR = 0x0B`
- `const byte _VL53L0X_PRE_RANGE_CONFIG_VALID_PHASE_LOW = 0x56`
- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_3 = 0xB3`
- `const byte _VL53L0X_ALGO_PART_TO_PART_RANGE_OFFSET_MM = 0x28`
- `const byte _VL53L0X_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO = 0x72`
- `const byte _VL53L0X_MSRC_CONFIG_CONTROL = 0x60`
- `const byte _VL53L0X_RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN = 0xBC`
- `const byte _VL53L0X_CROSSTALK_COMPENSATION_PEAK_RATE_MCPS = 0x20`
- `const byte _VL53L0X_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD = 0x4E`
- `const byte _VL53L0X_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH = 0x48`
- `const byte _VL53L0X_PRE_RANGE_CONFIG_VCSEL_PERIOD = 0x50`
- `const byte _VL53L0X_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT = 0x44`
- `const byte _VL53L0X_RESULT_PEAK_SIGNAL_RATE_REF = 0xB6`
- `const byte _VL53L0X_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI = 0x71`
- `const byte _VL53L0X_SYSTEM_THRESH_HIGH = 0x0C`
- `const byte _VL53L0X_SYSTEM_SEQUENCE_CONFIG = 0x01`
- `const byte _VL53L0X_SYSTEM_THRESH_LOW = 0x0E`
- `const byte _VL53L0X_I2C_SLAVE_DEVICE_ADDRESS = 0x8A`
- `const byte VL53L0X_VCSEL_PERIOD_FINAL_RANGE = 1`
- `const byte _VL53L0X_HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT = 0x33`
- `const byte _VL53L0X_MODULE_ID = 0xEE`
- `const byte _VL53L0X_SYSTEM_INTERMEASUREMENT_PERIOD = 0x04`
- `const byte _VL53L0X_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT = 0x64`
- `const byte _VL53L0X_POWER_MANAGEMENT_GO1_POWER_FORCE = 0x80`
- `var bit _vl53l0x_did_timeout`
- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_4 = 0xB4`
- `const byte _VL53L0X_GLOBAL_CONFIG_VCSEL_WIDTH = 0x32`
- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_2 = 0xB2`
- `const byte _VL53L0X_RESULT_RANGE_STATUS = 0x14`
- `var dword _vl53l0x_measurement_timing_budget_us`
- `const byte _VL53L0X_HISTOGRAM_CONFIG_READOUT_CTRL = 0x55`
- `var byte _vl53l0x_reference_spad_map[6]`
- `const byte _VL53L0X_PRE_RANGE_CONFIG_VALID_PHASE_HIGH = 0x57`
- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_1 = 0xB1`
- `const byte _VL53L0X_RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF = 0xD0`
- `const dword _VL53L0X_MM_TO_MIL = 3_937_008`
- `const word _VL53L0X_DEFAULT_RESPONSE_TIMEOUT = 250; 250 ms timeout.`
- `const byte _VL53L0X_IDENTIFICATION_MODEL_ID = 0xC0`
- `const byte _VL53L0X_OSC_CALIBRATE_VAL = 0xF8`
- `const byte VL53L0X_VCSEL_PERIOD_PRE_RANGE = 0`
- `const byte _VL53L0X_SYSRANGE_START = 0x00`
- `const byte _VL53L0X_SYSTEM_RANGE_CONFIG = 0x09`
- `const byte _VL53L0X_FINAL_RANGE_CONFIG_VALID_PHASE_LOW = 0x47`
- `var word _vl53l0x_response_timeout`
- `const byte _VL53L0X_PRE_RANGE_CONFIG_SIGMA_THRESH_HI = 0x61`
- `const byte _VL53L0X_SYSTEM_INTERRUPT_CONFIG_GPIO = 0x0A`
- `var _vl53l0x_sequence_step_timeouts _vl53l0x_timeouts`
- `const byte _VL53L0X_PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO = 0x52`
- `const byte _VL53L0X_FINAL_RANGE_CONFIG_MIN_SNR = 0x67`
- `var _vl53l0x_sequence_step_enables _vl53l0x_enables`
- `const byte _VL53L0X_SYSTEM_HISTOGRAM_BIN = 0x81`
- `const byte _VL53L0X_IDENTIFICATION_REVISION_ID = 0xC2`
- `const byte _VL53L0X_RESULT_INTERRUPT_STATUS = 0x13`
- `const byte _VL53L0X_DYNAMIC_SPAD_REF_EN_START_OFFSET = 0x4F`
- `var byte _vl53l0x_stop_variable`
- `const byte _VL53L0X_PRE_RANGE_CONFIG_MIN_SNR = 0x27`
- `const byte _VL53L0X_RESULT_CORE_RANGING_TOTAL_EVENTS_RTN = 0xC0`

### Procedures

- `vl53l0x_set_timeout(word in timeout)`
- `vl53l0x_start_continuous(dword in period_ms)`
- `vl53l0x_stop_continuous()`
- `vl53l0x_set_iic_address(byte in address)`

Private

- `_vl53l0x_write_spad_map()`
- `_vl53l0x_write_data_byte(byte in register, byte in data)`
- `_vl53l0x_write_data_dword(byte in register, dword in data)`
- `_vl53l0x_write_data_word(byte in register, word in data)`
- `_vl53l0x_get_sequence_step_enables()`
- `_vl53l0x_read_spad_map()`
- `_vl53l0x_get_sequence_step_timeouts()`

### Functions

- `vl53l0x_get_iic_address() return byte`
- `vl53l0x_get_signal_rate_limit() return word`
- `vl53l0x_get_timeout() return word`
- `vl53l0x_set_vcsel_pulse_period(byte in type, byte in period_pclks) return bit`
- `vl53l0x_get_measurement_timing_budget() return dword`
- `vl53l0x_set_measurement_timing_budget(dword in budget_us) return bit`
- `vl53l0x_read_range_single_mil() return word`
- `vl53l0x_timeout_occured() return bit`
- `vl53l0x_init() return bit`
- `vl53l0x_read_range_continuous_millimeters() return word`
- `vl53l0x_valid_module() return bit`
- `vl53l0x_read_range_single_millimeters() return word`
- `vl53l0x_get_vcsel_pulse_period(byte in type) return byte`
- `vl53l0x_set_signal_rate_limit(word in rate_limit) return bit`
- `vl53l0x_read_range_continuous_mil() return word`

Private

- `_vl53l0x_encode_vcsel_period(byte in period_pclks) return byte`
- `_vl53l0x_decode_timeout(word in reg_val) return word`
- `_vl53l0x_perform_single_ref_calibration(byte in vhv_init_byte) return bit`
- `_vl53l0x_read_data_word(byte in register) return word`
- `_vl53l0x_calc_period(byte in vcsel_period_pclks) return dword`
- `_vl53l0x_read_data_byte(byte in register) return byte`
- `_vl53l0x_encode_timeout(dword in timeout_mclks) return word`
- `_vl53l0x_read_data_dword(byte in register) return dword`
- `_vl53l0x_decode_vcsel_period(byte in register_value) return byte`

## API details

### Global variables/contants

- `const byte _VL53L0X_GLOBAL_CONFIG_REF_EN_START_SELECT = 0xB6`

  No documentation found

- `const byte _VL53L0X_MSRC_CONFIG_TIMEOUT_MACROP = 0x46`

  No documentation found

- `const byte VL53L0X_IIC_DEFAULT_ADDRESS = 0x52`

       PUBLIC CONSTANTS DEFS --------------------------------

      Default IIC address of the VL53L0X, LSB is read/write bit. This address is
      used by the VL53L0X module after power up.

- `const byte _VL53L0X_PRE_RANGE_CONFIG_SIGMA_THRESH_LO = 0x62`

  No documentation found

- `const byte _VL53L0X_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI = 0x51`

  No documentation found

- `const byte _VL53L0X_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV = 0x89`

  No documentation found

- `const byte _VL53L0X_ALGO_PHASECAL_CONFIG_TIMEOUT = 0x30`

  No documentation found

- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_5 = 0xB5`

  No documentation found

- `const byte _VL53L0X_ALGO_PHASECAL_LIM = 0x30`

  No documentation found

- `const byte _VL53L0X_RESULT_CORE_RANGING_TOTAL_EVENTS_REF = 0xD4`

  No documentation found

- `const byte _VL53L0X_FINAL_RANGE_CONFIG_VCSEL_PERIOD = 0x70`

  No documentation found

- `const byte _VL53L0X_SOFT_RESET_GO2_SOFT_RESET_N = 0xBF`

  No documentation found

- `var byte _vl53l0x_iic_address = VL53L0X_IIC_DEFAULT_ADDRESS`

  No documentation found

- `const byte _VL53L0X_GPIO_HV_MUX_ACTIVE_HIGH = 0x84`

  No documentation found

- `const byte _VL53L0X_TUNING_SETTINGS[] =`

      Default tuning settings used at initialization.
      Format is: Register, Data, Register, Data, etc...

- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_0 = 0xB0`

  No documentation found

- `const byte _VL53L0X_SYSTEM_INTERRUPT_CLEAR = 0x0B`

  No documentation found

- `const byte _VL53L0X_PRE_RANGE_CONFIG_VALID_PHASE_LOW = 0x56`

  No documentation found

- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_3 = 0xB3`

  No documentation found

- `const byte _VL53L0X_ALGO_PART_TO_PART_RANGE_OFFSET_MM = 0x28`

  No documentation found

- `const byte _VL53L0X_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO = 0x72`

  No documentation found

- `const byte _VL53L0X_MSRC_CONFIG_CONTROL = 0x60`

  No documentation found

- `const byte _VL53L0X_RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN = 0xBC`

  No documentation found

- `const byte _VL53L0X_CROSSTALK_COMPENSATION_PEAK_RATE_MCPS = 0x20`

  No documentation found

- `const byte _VL53L0X_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD = 0x4E`

  No documentation found

- `const byte _VL53L0X_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH = 0x48`

  No documentation found

- `const byte _VL53L0X_PRE_RANGE_CONFIG_VCSEL_PERIOD = 0x50`

  No documentation found

- `const byte _VL53L0X_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT = 0x44`

  No documentation found

- `const byte _VL53L0X_RESULT_PEAK_SIGNAL_RATE_REF = 0xB6`

  No documentation found

- `const byte _VL53L0X_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI = 0x71`

  No documentation found

- `const byte _VL53L0X_SYSTEM_THRESH_HIGH = 0x0C`

  No documentation found

- `const byte _VL53L0X_SYSTEM_SEQUENCE_CONFIG = 0x01`

  No documentation found

- `const byte _VL53L0X_SYSTEM_THRESH_LOW = 0x0E`

  No documentation found

- `const byte _VL53L0X_I2C_SLAVE_DEVICE_ADDRESS = 0x8A`

  No documentation found

- `const byte VL53L0X_VCSEL_PERIOD_FINAL_RANGE = 1`

  No documentation found

- `const byte _VL53L0X_HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT = 0x33`

  No documentation found

- `const byte _VL53L0X_MODULE_ID = 0xEE`

      Module ID can be found at register _VL53L0X_IDENTIFICATION_MODEL_ID.

- `const byte _VL53L0X_SYSTEM_INTERMEASUREMENT_PERIOD = 0x04`

  No documentation found

- `const byte _VL53L0X_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT = 0x64`

  No documentation found

- `const byte _VL53L0X_POWER_MANAGEMENT_GO1_POWER_FORCE = 0x80`

  No documentation found

- `var bit _vl53l0x_did_timeout`

      Keep track of occurence of timeout.

- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_4 = 0xB4`

  No documentation found

- `const byte _VL53L0X_GLOBAL_CONFIG_VCSEL_WIDTH = 0x32`

  No documentation found

- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_2 = 0xB2`

  No documentation found

- `const byte _VL53L0X_RESULT_RANGE_STATUS = 0x14`

  No documentation found

- `var dword _vl53l0x_measurement_timing_budget_us`

      Measurement timing budget.

- `const byte _VL53L0X_HISTOGRAM_CONFIG_READOUT_CTRL = 0x55`

  No documentation found

- `var byte _vl53l0x_reference_spad_map[6]`

      Buffer for holding the SPAD map.

- `const byte _VL53L0X_PRE_RANGE_CONFIG_VALID_PHASE_HIGH = 0x57`

  No documentation found

- `const byte _VL53L0X_GLOBAL_CONFIG_SPAD_ENABLES_REF_1 = 0xB1`

  No documentation found

- `const byte _VL53L0X_RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF = 0xD0`

  No documentation found

- `const dword _VL53L0X_MM_TO_MIL = 3_937_008`

      Conversion from mm to mil

- `const word _VL53L0X_DEFAULT_RESPONSE_TIMEOUT = 250; 250 ms timeout.`

      Response timeout value in steps of 1 ms. The maximum timeout depends on
      some of the parameters given, e.g. when using vl53l0x_start_continuous().
      So the user can change the value.

- `const byte _VL53L0X_IDENTIFICATION_MODEL_ID = 0xC0`

  No documentation found

- `const byte _VL53L0X_OSC_CALIBRATE_VAL = 0xF8`

  No documentation found

- `const byte VL53L0X_VCSEL_PERIOD_PRE_RANGE = 0`

      Enumeration used.

- `const byte _VL53L0X_SYSRANGE_START = 0x00`

      Register addresses from API vl53l0x_device.h (ordered as listed there).

- `const byte _VL53L0X_SYSTEM_RANGE_CONFIG = 0x09`

  No documentation found

- `const byte _VL53L0X_FINAL_RANGE_CONFIG_VALID_PHASE_LOW = 0x47`

  No documentation found

- `var word _vl53l0x_response_timeout`

      Timeout value. Can be changed by the user. Value is in steps of 1 ms.

- `const byte _VL53L0X_PRE_RANGE_CONFIG_SIGMA_THRESH_HI = 0x61`

  No documentation found

- `const byte _VL53L0X_SYSTEM_INTERRUPT_CONFIG_GPIO = 0x0A`

  No documentation found

- `var _vl53l0x_sequence_step_timeouts _vl53l0x_timeouts`

  No documentation found

- `const byte _VL53L0X_PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO = 0x52`

  No documentation found

- `const byte _VL53L0X_FINAL_RANGE_CONFIG_MIN_SNR = 0x67`

  No documentation found

- `var _vl53l0x_sequence_step_enables _vl53l0x_enables`

       Private variables -----------------------------------

- `const byte _VL53L0X_SYSTEM_HISTOGRAM_BIN = 0x81`

  No documentation found

- `const byte _VL53L0X_IDENTIFICATION_REVISION_ID = 0xC2`

  No documentation found

- `const byte _VL53L0X_RESULT_INTERRUPT_STATUS = 0x13`

  No documentation found

- `const byte _VL53L0X_DYNAMIC_SPAD_REF_EN_START_OFFSET = 0x4F`

  No documentation found

- `var byte _vl53l0x_stop_variable`

      Variable read by init and used when starting measurement; is StopVariable
      field of VL53L0X_DevData_t structure in API.

- `const byte _VL53L0X_PRE_RANGE_CONFIG_MIN_SNR = 0x27`

  No documentation found

- `const byte _VL53L0X_RESULT_CORE_RANGING_TOTAL_EVENTS_RTN = 0xC0`

  No documentation found

### Procedures

- `vl53l0x_set_timeout(word in timeout)`

      Set the response timeout. The response of the VL53L0X depends on the settings
      that are used. The timeout given is in ms. Timeout must be > 0 and < 10_000.
      Default after initialization is 250 ms.

- `vl53l0x_start_continuous(dword in period_ms)`

      Start continuous ranging measurements. If period_ms (optional) is 0 or not
      given, continuous back-to-back mode is used (the sensor takes measurements as
      often as possible); otherwise, continuous timed mode is used, with the given
      inter-measurement period in milliseconds determining how often the sensor
      takes a measurement. Based on VL53L0X_StartMeasurement().

- `vl53l0x_stop_continuous()`

      Stop continuous measurements. Based on VL53L0X_StopMeasurement().

- `vl53l0x_set_iic_address(byte in address)`

      Set the IIC address of the VL53L0X to the given address.
      The default after power up is: VL53L0X_IIC_DEFAULT_ADDRESS

Private

- `_vl53l0x_write_spad_map()`

      Write the SPAD map to the VL53L0X via the IIC interface.
      A separate procedure was created since we need to fill the global spad map.

- `_vl53l0x_write_data_byte(byte in register, byte in data)`

      Write a byte to the given register of the VL53L0X via the IIC interface.

- `_vl53l0x_write_data_dword(byte in register, dword in data)`

      Write a dword to the given register of the VL53L0X via the IIC interface.

- `_vl53l0x_write_data_word(byte in register, word in data)`

      Write a word to the given register of the VL53L0X via the IIC interface.

- `_vl53l0x_get_sequence_step_enables()`

      Get sequence step enables. Based on VL53L0X_GetSequenceStepEnables()
      Data is stord in global variable '_vl53l0x_enables'.

- `_vl53l0x_read_spad_map()`

      Read the SPAD map of the VL53L0X via the IIC interface.
      A separate procedure was created since we need to fill the global spad map.

- `_vl53l0x_get_sequence_step_timeouts()`

      Get sequence step timeouts. Based on get_sequence_step_timeout(), but gets
      all timeouts instead of just the requested one, and also stores intermediate
      values.
      Data is stored in global variable '_vl53l0x_timeouts' and uses global
      variable '_vl53l0x_enables'.

### Functions

- `vl53l0x_get_iic_address() return byte`

      Get the IIC address of the VL53L0X module.

- `vl53l0x_get_signal_rate_limit() return word`

      Get the return signal rate limit check value in 100 * MCPS
      The rate limit is returned in 100 * MCPS. Reason for using 100 * MCPS is
      that we do not need to use float but instead use word.

- `vl53l0x_get_timeout() return word`

      Get the current response timeout in ms.

- `vl53l0x_set_vcsel_pulse_period(byte in type, byte in period_pclks) return bit`

      Set the VCSEL (vertical cavity surface emitting laser) pulse period for the
      given period type (pre-range or final range) to the given value in PCLKs.
      Longer periods seem to increase the potential range of the sensor.
      Valid values of period_pcklks are (even numbers only):
      ) VL53L0X_VCSEL_PERIOD_PRE_RANGE:  12 to 18 (initialized default: 14)
      ) VL53L0X_VCSEL_PERIOD_FINAL_RANGE: 8 to 14 (initialized default: 10)
      Based on VL53L0X_set_vcsel_pulse_period().
      Returns TRUE when succesful.

- `vl53l0x_get_measurement_timing_budget() return dword`

      Get the measurement timing budget in microseconds. Based on
      VL53L0X_get_measurement_timing_budget_micro_seconds().

- `vl53l0x_set_measurement_timing_budget(dword in budget_us) return bit`

      Set the measurement timing budget in microseconds, which is the time allowed
      for one measurement; the ST API and this library take care of splitting the
      timing budget among the sub-steps in the ranging sequence. A longer timing
      budget allows for more accurate measurements. Increasing the budget by a
      factor of N decreases the range measurement standard deviation by a factor
      of sqrt(N). Defaults to about 33 milliseconds; the minimum is 20 ms.
      based on VL53L0X_set_measurement_timing_budget_micro_seconds()
      Returns TRUE when succesfull.

- `vl53l0x_read_range_single_mil() return word`

      Performs a single-shot range measurement and returns the reading in mil.
      Calls vl53l0x_read_range_single_millimeters() and converts it to mil.

- `vl53l0x_timeout_occured() return bit`

      Returns TRUE if a timeout occured in one of the read functions or in case of
      timeout on the IIC bus if the IIC timeout is defined. Value is cleared after
      a call to this function.

- `vl53l0x_init() return bit`

      Initialize sensor using sequence based on VL53L0X_DataInit(),
      VL53L0X_StaticInit(), and VL53L0X_PerformRefCalibration().
      This function does not perform reference SPAD calibration
      (VL53L0X_PerformRefSpadManagement()), since the API user manual says that it
      is performed by ST on the bare modules. It seems like that should work well
      enough unless a cover glass is added. We use the 2V8 mode since at power up
      the module is in 1V8 mode. At initialization the module ID is checked.
      Returns TRUE if initialization was succesful.

- `vl53l0x_read_range_continuous_millimeters() return word`

      Returns a range reading in millimeters when continuous mode is active
      (readRangeSingleMillimeters() also calls this function after starting a
      single-shot range measurement).

- `vl53l0x_valid_module() return bit`

      Check presence of correct module. Returns TRUE when valid.

- `vl53l0x_read_range_single_millimeters() return word`

      Performs a single-shot range measurement and returns the reading in
      millimeters. Based on VL53L0X_PerformSingleRangingMeasurement().

- `vl53l0x_get_vcsel_pulse_period(byte in type) return byte`

      Get the VCSEL pulse period in PCLKs for the given period type. Based on
      VL53L0X_get_vcsel_pulse_period().

- `vl53l0x_set_signal_rate_limit(word in rate_limit) return bit`

      Set the return signal rate limit check value in units of MCPS (million counts
      per second). "This represents the amplitude of the signal reflected from the
      target and detected by the device"; setting this limit presumably determines
      the minimum measurement necessary for the sensor to report a valid reading.
      Setting a lower limit increases the potential range of the sensor but also
      seems to increase the likelihood of getting an inaccurate reading because of
      unwanted reflections from objects other than the intended target.
      The rate limit is given in 100 * MCPS and must be < 51_200. Reason for
      using 100 * MCPS is that we do not need to use float but instead use word.
      Defaults to 25 (= 0.25 MCPS) as initialized by the ST API and this library.
      Returns TRUE when succesful.

- `vl53l0x_read_range_continuous_mil() return word`

      Returns a range reading in mil when continuous mode is active. Calls
      vl53l0x_read_range_continuous_millimeters() and converts it to mils.

Private

- `_vl53l0x_encode_vcsel_period(byte in period_pclks) return byte`

      Encode VCSEL pulse period register value from period in PCLKs. Based on
      VL53L0X_encode_vcsel_period().

- `_vl53l0x_decode_timeout(word in reg_val) return word`

      Decode sequence step timeout in MCLKs from register value. Based on
      VL53L0X_decode_timeout()
      Note: the original function returned a dword, but the return value is
      always stored in a word.

- `_vl53l0x_perform_single_ref_calibration(byte in vhv_init_byte) return bit`

      based on VL53L0X_perform_single_ref_calibration()

- `_vl53l0x_read_data_word(byte in register) return word`

      Read a word from the given register of the VL53L0X via the IIC interface.

- `_vl53l0x_calc_period(byte in vcsel_period_pclks) return dword`

      Calculate period in *nanoseconds* from VCSEL period in PCLKs, based on
      VL53L0X_calc_macro_period_ps().
      PLL_period_ps = 1655; macro_period_vclks = 2304

- `_vl53l0x_read_data_byte(byte in register) return byte`

      Read a byte from the given register of the VL53L0X via the IIC interface.

- `_vl53l0x_encode_timeout(dword in timeout_mclks) return word`

      Encode sequence step timeout register value from timeout in MCLKs.
      based on VL53L0X_encode_timeout().

- `_vl53l0x_read_data_dword(byte in register) return dword`

      Read a dword from the given register of the VL53L0X via the IIC interface.

- `_vl53l0x_decode_vcsel_period(byte in register_value) return byte`

      Decode VCSEL (vertical cavity surface emitting laser) pulse period in PCLKs
      from register value. Based on VL53L0X_decode_vcsel_period()

## Related samples

Here are the list of samples which use this library:

16f13115 | 16f13115_vl53l0x_continuous.jal
16f1825 | 16f1825_vl53l0x_single.jal
16f1825 | 16f1825_vl53l0x_continuous.jal