Greatly simplified Architecture, Identical Functions Removed: Platform Interfaces, STP6001 interface
Diff: VL53L0X.h
- Revision:
- 8:2fd7cb217068
- Parent:
- 7:3a1115c2556b
- Child:
- 9:cb4c6d4e5030
--- a/VL53L0X.h Thu Jun 20 12:54:25 2019 +0000 +++ b/VL53L0X.h Thu Jun 20 15:19:03 2019 +0000 @@ -48,10 +48,8 @@ * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT * @param[in] dev_addr device address, 0x29 by default */ - VL53L0X(I2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _dev_i2c(i2c), - _gpio0(pin) - { - I2cDevAddr = dev_addr; + VL53L0X(I2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _gpio0(pin), _dev_i2c(i2c) + { I2cDevAddr = dev_addr; comms_type = 1; // VL53L0X_COMMS_I2C comms_speed_khz = 400; if (pin_gpio1 != NC) { _gpio1Int = new InterruptIn(pin_gpio1); } @@ -61,12 +59,9 @@ /** Destructor */ virtual ~VL53L0X() - { - if (_gpio1Int != NULL) { delete _gpio1Int; } - } + { if (_gpio1Int != NULL) { delete _gpio1Int; } } - /*** Interface Methods ***/ - /*** High level API ***/ + /*** Interface Methods High level API ***/ /** * @brief PowerOn the sensor * @return void @@ -133,18 +128,14 @@ * @return "0" on success */ void enable_interrupt_measure_detection_irq(void) - { - if (_gpio1Int != NULL) { _gpio1Int->enable_irq();} - } + { if (_gpio1Int != NULL) { _gpio1Int->enable_irq();} } /** * @brief Disable interrupt measure IRQ * @return "0" on success */ void disable_interrupt_measure_detection_irq(void) - { - if (_gpio1Int != NULL) { _gpio1Int->disable_irq(); } - } + { if (_gpio1Int != NULL) { _gpio1Int->disable_irq(); } } /** * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready @@ -152,9 +143,7 @@ * @return "0" on success */ void attach_interrupt_measure_detection_irq(void (*fptr)(void)) - { - if (_gpio1Int != NULL) { _gpio1Int->rise(fptr); } - } + { if (_gpio1Int != NULL) { _gpio1Int->rise(fptr); } } /** Wrapper functions */ /** @defgroup api_init Init functions @@ -199,30 +188,11 @@ * @param p_data Pointer to range distance * @return "0" on success */ - virtual int get_distance(uint32_t *p_data) - { - int status = 0; - VL53L0X_RangingMeasurementData_t p_ranging_measurement_data; - - status = start_measurement(range_single_shot_polling, NULL); - if (!status) { - status = get_measurement(range_single_shot_polling, &p_ranging_measurement_data); - } - if (p_ranging_measurement_data.RangeStatus == 0) { - // we have a valid range. - *p_data = p_ranging_measurement_data.RangeMilliMeter; - } else { - *p_data = 0; - status = VL53L0X_ERROR_RANGE_ERROR; - } - stop_measurement(range_single_shot_polling); - return status; - } + int get_distance(uint32_t *p_data); /** @} */ - /** - * @brief Set new device i2c address + /** @brief Set new device i2c address * * After completion the device will answer to the new address programmed. * @@ -249,10 +219,7 @@ int clear_interrupt(uint8_t int_clear) { return VL53L0X_clear_interrupt_mask(int_clear); } - - /** - * - * @brief One time device initialization + /** @brief One time device initialization * * To be called once and only once after device is brought out of reset * (Chip enable) and booted see @a VL53L0X_WaitDeviceBooted() @@ -532,7 +499,6 @@ * * @note This function doesn't Access to the device * - * * @param device_mode New device mode to apply * Valid values are: * VL53L0X_DEVICEMODE_SINGLE_RANGING @@ -558,7 +524,6 @@ * * @note This function doesn't Access to the device * - * * @param p_device_mode Pointer to current apply mode value * Valid values are: * VL53L0X_DEVICEMODE_SINGLE_RANGING @@ -574,8 +539,7 @@ * DeviceMode is not in the * supported list */ - VL53L0X_Error VL53L0X_get_device_mode( - VL53L0X_DeviceModes *p_device_mode); + VL53L0X_Error VL53L0X_get_device_mode(VL53L0X_DeviceModes *p_device_mode); /** * @brief Get current configuration for GPIO pin for a given device @@ -613,7 +577,6 @@ * * @note This function Access to the device * - * * @param pin ID of the GPIO Pin * @param functionality Select Pin functionality. * Refer to ::VL53L0X_GpioFunctionality @@ -647,8 +610,6 @@ * * @note This function Access to the device * - - * * @return VL53L0X_ERROR_NONE Success * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when * DeviceMode programmed with @a VL53L0X_SetDeviceMode is not in the supported @@ -673,7 +634,6 @@ * * @note This function Access to the device * - * * @return VL53L0X_ERROR_NONE Success * @return "Other error code" See ::VL53L0X_Error */ @@ -765,7 +725,6 @@ * * @note This function Access to the device * - * * @param p_interrupt_mask_status Pointer to status variable to update * @return VL53L0X_ERROR_NONE Success * @return "Other error code" See ::VL53L0X_Error @@ -814,52 +773,11 @@ * * @note This function Access to the device * - * * @return VL53L0X_ERROR_NONE Success * @return "Other error code" See ::VL53L0X_Error */ VL53L0X_Error VL53L0X_perform_single_measurement(void); - /** - * @brief Read current status of the error register for the selected device - * - * @note This function Access to the device - * - * - * @param p_device_error_status Pointer to current error code of the device - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_device_error_status( - VL53L0X_DeviceError *p_device_error_status); - - /** - * @brief Human readable error string for a given Error Code - * - * @note This function doesn't access to the device - * - * @param error_code The error code as stored on ::VL53L0X_DeviceError - * @param p_device_error_string The error string corresponding to the ErrorCode - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_device_error_string( - VL53L0X_DeviceError error_code, char *p_device_error_string); - - /** - * @brief Human readable Range Status string for a given RangeStatus - * - * @note This function doesn't access to the device - * - * @param range_status The RangeStatus code as stored on - * @a VL53L0X_RangingMeasurementData_t - * @param p_range_status_string The returned RangeStatus string. - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_range_status_string(uint8_t range_status, - char *p_range_status_string); - VL53L0X_Error VL53L0X_get_total_signal_rate( VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, FixPoint1616_t *p_total_signal_rate_mcps); @@ -878,7 +796,6 @@ * * @note This function Access to the device * - * * @param p_measurement_timing_budget_micro_seconds Max measurement time in * microseconds. * Valid values are: @@ -899,7 +816,6 @@ * * @note This function Access to the device * - * * @param measurement_timing_budget_micro_seconds Max measurement time in * microseconds. * Valid values are: @@ -1249,8 +1165,7 @@ * @return VL53L0X_ERROR_NONE Success * @return "Other error code" See ::VL53L0X_Error */ - VL53L0X_Error VL53L0X_get_device_info( - VL53L0X_DeviceInfo_t *p_VL53L0X_device_info); + VL53L0X_Error VL53L0X_get_device_info( VL53L0X_DeviceInfo_t *p_VL53L0X_device_info); /** * @brief Gets the (on/off) state of all sequence steps. @@ -1321,36 +1236,7 @@ * @return VL53L0X_ERROR_NONE Success * @return "Other error code" See ::VL53L0X_Error */ - VL53L0X_Error VL53L0X_set_range_fraction_enable( - uint8_t enable); - - /** - * @brief Return the VL53L0X PAL Implementation Version - * - * @note This function doesn't access to the device - * - * @param p_version Pointer to current PAL Implementation Version - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_version(VL53L0X_Version_t *p_version); - - /** - * @brief Reads the Product Revision for a for given Device - * This function can be used to distinguish cut1.0 from cut1.1. - * - * @note This function Access to the device - * - * - * @param p_product_revision_major Pointer to Product Revision Major - * for a given Device - * @param p_product_revision_minor Pointer to Product Revision Minor - * for a given Device - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_product_revision( - uint8_t *p_product_revision_major, uint8_t *p_product_revision_minor); + VL53L0X_Error VL53L0X_set_range_fraction_enable(uint8_t enable); /** * @brief Retrieve current device parameters @@ -1368,60 +1254,6 @@ VL53L0X_Error VL53L0X_get_device_parameters( VL53L0X_DeviceParameters_t *p_device_parameters); - /** - * @brief Human readable error string for current PAL error status - * - * @note This function doesn't access to the device - * - * @param pal_error_code The error code as stored on @a VL53L0X_Error - * @param p_pal_error_string The error string corresponding to the - * PalErrorCode - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_pal_error_string(VL53L0X_Error pal_error_code, - char *p_pal_error_string); - - /** - * @brief Return the PAL Specification Version used for the current - * implementation. - * - * @note This function doesn't access to the device - * - * @param p_pal_spec_version Pointer to current PAL Specification Version - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_pal_spec_version( - VL53L0X_Version_t *p_pal_spec_version); - - /** - * @brief Reads the internal state of the PAL for a given Device - * - * @note This function doesn't access to the device - * - * - * @param p_pal_state Pointer to current state of the PAL for a - * given Device - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_pal_state( - VL53L0X_State *p_pal_state); - - /** - * @brief Human readable PAL State string - * - * @note This function doesn't access to the device - * - * @param pal_state_code The State code as stored on @a VL53L0X_State - * @param p_pal_state_string The State string corresponding to the - * PalStateCode - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_pal_state_string(VL53L0X_State pal_state_code, - char *p_pal_state_string); /*** End High level API ***/ public: @@ -1461,25 +1293,21 @@ VL53L0X_Error VL53L0X_load_tuning_settings( uint8_t *p_tuning_setting_buffer); - VL53L0X_Error VL53L0X_get_pal_range_status( - uint8_t device_range_status, - FixPoint1616_t signal_rate, - uint16_t effective_spad_rtn_count, + VL53L0X_Error VL53L0X_get_pal_range_status( uint8_t device_range_status, + FixPoint1616_t signal_rate, uint16_t effective_spad_rtn_count, VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, uint8_t *p_pal_range_status); VL53L0X_Error VL53L0X_calc_sigma_estimate( VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, FixPoint1616_t *p_sigma_estimate, uint32_t *p_dmax_mm); - uint32_t VL53L0X_calc_timeout_mclks( - uint32_t timeout_period_us, + uint32_t VL53L0X_calc_timeout_mclks( uint32_t timeout_period_us, uint8_t vcsel_period_pclks); uint32_t VL53L0X_isqrt(uint32_t num); uint32_t VL53L0X_quadrature_sum(uint32_t a, uint32_t b); VL53L0X_Error VL53L0X_calc_dmax( - FixPoint1616_t total_signal_rate_mcps, FixPoint1616_t total_corr_signal_rate_mcps, FixPoint1616_t pw_mult, @@ -1489,11 +1317,9 @@ uint32_t *pd_max_mm); VL53L0X_Error wrapped_VL53L0X_set_measurement_timing_budget_micro_seconds( uint32_t measurement_timing_budget_micro_seconds); - VL53L0X_Error get_sequence_step_timeout( - VL53L0X_SequenceStepId sequence_step_id, + VL53L0X_Error get_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id, uint32_t *p_time_out_micro_secs); - VL53L0X_Error set_sequence_step_timeout( - VL53L0X_SequenceStepId sequence_step_id, + VL53L0X_Error set_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id, uint32_t timeout_micro_secs); uint16_t VL53L0X_encode_timeout(uint32_t timeout_macro_clks); VL53L0X_Error wrapped_VL53L0X_set_vcsel_pulse_period( @@ -1523,8 +1349,7 @@ VL53L0X_Error VL53L0X_perform_phase_calibration( uint8_t *p_phase_cal, const uint8_t get_data_enable, const uint8_t restore_config); - VL53L0X_Error enable_ref_spads( - uint8_t aperture_spads, + VL53L0X_Error enable_ref_spads(uint8_t aperture_spads, uint8_t good_spad_array[], uint8_t spad_array[], uint32_t size, @@ -1547,8 +1372,7 @@ /* api_strings.h functions */ VL53L0X_Error wrapped_VL53L0X_get_device_info( VL53L0X_DeviceInfo_t *p_VL53L0X_device_info); - VL53L0X_Error VL53L0X_check_part_used( - uint8_t *revision, + VL53L0X_Error VL53L0X_check_part_used(uint8_t *revision, VL53L0X_DeviceInfo_t *p_VL53L0X_device_info); /* Read function of the ID device */ @@ -1619,7 +1443,6 @@ * * Final_reg = (Initial_reg & and_data) |or_data * - * * @param index The register index * @param and_data 8 bit and data * @param or_data 8 bit or data @@ -1648,29 +1471,7 @@ */ VL53L0X_Error VL53L0X_read_multi( uint8_t index, uint8_t *p_data, uint32_t count); - /** - * @brief Writes a buffer towards the I2C peripheral device. - * - * @param p_data pointer to the byte-array data to send - * @param number_of_bytes number of bytes to be written. - * @retval 0 if ok, - * @retval -1 if an I2C error has occured - * @note On some devices if NumByteToWrite is greater - * than one, the RegisterAddr must be masked correctly! - */ - VL53L0X_Error VL53L0X_i2c_write(uint8_t index, uint8_t *p_data, uint16_t number_of_bytes); - /** - * @brief Reads a buffer from the I2C peripheral device. - * - * @param p_data pointer to the byte-array to read data in to - * @param number_of_bytes number of bytes to be read. - * @retval 0 if ok, - * @retval -1 if an I2C error has occured - * @note On some devices if NumByteToWrite is greater - * than one, the RegisterAddr must be masked correctly! - */ - VL53L0X_Error VL53L0X_i2c_read(uint8_t index, uint8_t *p_data, uint16_t number_of_bytes); /** * @brief execute delay in all polling API call @@ -1700,21 +1501,9 @@ uint8_t VL53L0X_encode_vcsel_period(uint8_t vcsel_period_pclks); - VL53L0X_Error wrapped_VL53L0X_get_device_error_string(VL53L0X_DeviceError error_code, - char *p_device_error_string); - VL53L0X_Error wrapped_VL53L0X_get_limit_check_info( uint16_t limit_check_id, char *p_limit_check_string); - VL53L0X_Error wrapped_VL53L0X_get_pal_error_string(VL53L0X_Error pal_error_code, - char *p_pal_error_string); - - VL53L0X_Error wrapped_VL53L0X_get_pal_state_string(VL53L0X_State pal_state_code, - char *p_pal_state_string); - - VL53L0X_Error wrapped_VL53L0X_get_range_status_string(uint8_t range_status, - char *p_range_status_string); - VL53L0X_Error wrapped_VL53L0X_get_ref_calibration( uint8_t *p_vhv_settings, uint8_t *p_phase_cal); @@ -1943,44 +1732,6 @@ uint16_t *p_number_of_limit_check); /** - * @brief Get the number of ROI Zones managed by the Device - * - * @par Function Description - * Get number of ROI Zones managed by the Device - * USER should take care about @a VL53L0X_GetNumberOfROIZones() - * before get data after a perform measurement. - * PAL will fill a NumberOfROIZones times the corresponding data - * structure used in the measurement function. - * - * @note This function doesn't Access to the device - * - * - * @param p_number_of_roi_zones Pointer to the Number of ROI Zones value. - * @return VL53L0X_ERROR_NONE Success - */ - VL53L0X_Error VL53L0X_get_number_of_roi_zones( - uint8_t *p_number_of_roi_zones); - - /** - * @brief Set the number of ROI Zones to be used for a specific Device - * - * @par Function Description - * Set the number of ROI Zones to be used for a specific Device. - * The programmed value should be less than the max number of ROI Zones given - * with @a VL53L0X_GetMaxNumberOfROIZones(). - * This version of API manage only one zone. - * - * - * @param number_of_roi_zones Number of ROI Zones to be used for a - * specific Device. - * @return VL53L0X_ERROR_NONE Success - * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if - * NumberOfROIZones != 1 - */ - VL53L0X_Error VL53L0X_set_number_of_roi_zones( - uint8_t number_of_roi_zones); - - /** * @brief Gets number of sequence steps managed by the API. * * @par Function Description @@ -1989,7 +1740,6 @@ * * @note This function Accesses the device * - * * @param p_number_of_sequence_steps Out parameter reporting the number of * sequence steps. * @return VL53L0X_ERROR_NONE Success @@ -2022,7 +1772,6 @@ * * @note This function Access to the device * - * * @param power_mode The value of the power mode to set. * see ::VL53L0X_PowerModes * Valid values are: @@ -2033,8 +1782,7 @@ * is not in the supported list * @return "Other error code" See ::VL53L0X_Error */ - VL53L0X_Error VL53L0X_set_power_mode( - VL53L0X_PowerModes power_mode); + VL53L0X_Error VL53L0X_set_power_mode(VL53L0X_PowerModes power_mode); /** * @brief Retrieves SPAD configuration @@ -2078,7 +1826,6 @@ VL53L0X_Error VL53L0X_get_sequence_step_enable( VL53L0X_SequenceStepId sequence_step_id, uint8_t *p_sequence_step_enabled); - /** * @brief Gets the timeout of a requested sequence step. * @@ -2087,7 +1834,6 @@ * * @note This function Accesses the device * - * * @param sequence_step_id Sequence step identifier. * @param p_time_out_milli_secs Timeout value. * @return VL53L0X_ERROR_NONE Success @@ -2095,8 +1841,7 @@ * supported. * @return "Other error code" See ::VL53L0X_Error */ - VL53L0X_Error VL53L0X_get_sequence_step_timeout( - VL53L0X_SequenceStepId sequence_step_id, + VL53L0X_Error VL53L0X_get_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id, FixPoint1616_t *p_time_out_milli_secs); /** @@ -2119,72 +1864,6 @@ VL53L0X_SequenceStepId sequence_step_id, FixPoint1616_t time_out_milli_secs); /** - * @brief Get the current SPAD Ambient Damper Factor value - * - * @par Function Description - * This function get the SPAD Ambient Damper Factor value - * - * @note This function Access to the device - * - * - * @param p_spad_ambient_damper_factor Pointer to programmed SPAD Ambient - * Damper Factor value - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_spad_ambient_damper_factor( - uint16_t *p_spad_ambient_damper_factor); - /** - * @brief Set the SPAD Ambient Damper Factor value - * - * @par Function Description - * This function set the SPAD Ambient Damper Factor value - * - * @note This function Access to the device - * - * - * @param spad_ambient_damper_factor SPAD Ambient Damper Factor value - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_set_spad_ambient_damper_factor( - uint16_t spad_ambient_damper_factor); - - /** - * @brief Get the current SPAD Ambient Damper Threshold value - * - * @par Function Description - * This function get the SPAD Ambient Damper Threshold value - * - * @note This function Access to the device - * - * - * @param p_spad_ambient_damper_threshold Pointer to programmed - * SPAD Ambient Damper Threshold value - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_get_spad_ambient_damper_threshold( - uint16_t *p_spad_ambient_damper_threshold); - - /** - * @brief Set the SPAD Ambient Damper Threshold value - * - * @par Function Description - * This function set the SPAD Ambient Damper Threshold value - * - * @note This function Access to the device - * - * - * @param spad_ambient_damper_threshold SPAD Ambient Damper Threshold value - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_set_spad_ambient_damper_threshold( - uint16_t spad_ambient_damper_threshold); - - - /** * @brief Get the tuning settings pointer and the internal external switch * value. * @@ -2231,22 +1910,6 @@ */ /** - * Lock comms interface to serialize all commands to a shared I2C interface for a specific device - * - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_lock_sequence_access(void); - - /** - * Unlock comms interface to serialize all commands to a shared I2C interface for a specific device - * - * @return VL53L0X_ERROR_NONE Success - * @return "Other error code" See ::VL53L0X_Error - */ - VL53L0X_Error VL53L0X_unlock_sequence_access(void); - - /** * @brief Prepare device for operation * @par Function Description * Update device with provided parameters @@ -2266,48 +1929,43 @@ int range_meas_int_continuous_mode(void (*fptr)(void)); - VL53L0X_DeviceInfo_t _device_info; - - /* IO Device */ - I2C *_dev_i2c; /* Digital out pin */ DigitalOut *_gpio0; /* Measure detection IRQ */ InterruptIn *_gpio1Int; - /* Device data */ - VL53L0X_DevData_t Data; /*!< embed ST Ewok Dev data as "Data"*/ + + VL53L0X_DevData_t Data; + VL53L0X_DeviceInfo_t _device_info; + +private: + /* IO Device */ + I2C *_dev_i2c; uint8_t I2cDevAddr; /*!< i2c device address user specific field */ uint8_t comms_type; /*!< Type of comms : VL53L0X_COMMS_I2C or VL53L0X_COMMS_SPI */ uint16_t comms_speed_khz; /*!< Comms speed [kHz] : typically 400kHz for I2C */ -private: - /** @brief Writes a buffer towards the I2C peripheral device. - * @param pBuffer pointer to the byte-array data to send - * @param DeviceAddr specifies the peripheral device slave address. - * @param RegisterAddr specifies the internal address register - * where to start writing to (must be correctly masked). - * @param NumByteToWrite number of bytes to be written. - * @retval 0 if ok, - * @retval -1 if an I2C error has occured, or - * @retval -2 on temporary buffer overflow (i.e. NumByteToWrite was too high) - * @note On some devices if NumByteToWrite is greater - * than one, the RegisterAddr must be masked correctly! - */ - int i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, - uint16_t NumByteToWrite); - - /** @brief Reads a buffer from the I2C peripheral device. - * @param pBuffer pointer to the byte-array to read data in to - * @param DeviceAddr specifies the peripheral device slave address. - * @param RegisterAddr specifies the internal address register - * where to start reading from (must be correctly masked). - * @param NumByteToRead number of bytes to be read. + /** + * @brief Writes a buffer towards the I2C peripheral device. + * + * @param p_data pointer to the byte-array data to send + * @param number_of_bytes number of bytes to be written. * @retval 0 if ok, * @retval -1 if an I2C error has occured * @note On some devices if NumByteToWrite is greater * than one, the RegisterAddr must be masked correctly! */ - int i2c_read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, - uint16_t NumByteToRead); + VL53L0X_Error VL53L0X_i2c_write(uint8_t index, uint8_t *p_data, uint16_t number_of_bytes); + + /** + * @brief Reads a buffer from the I2C peripheral device. + * + * @param p_data pointer to the byte-array to read data in to + * @param number_of_bytes number of bytes to be read. + * @retval 0 if ok, + * @retval -1 if an I2C error has occured + * @note On some devices if NumByteToWrite is greater + * than one, the RegisterAddr must be masked correctly! + */ + VL53L0X_Error VL53L0X_i2c_read(uint8_t index, uint8_t *p_data, uint16_t number_of_bytes); };