mirror of
https://github.com/aprochazka/ProfilometerProbe.git
synced 2025-06-30 17:47:20 +02:00
Add distance sensor, README update in next commit
This commit is contained in:
393
Firmware/Core/Inc/VL53L1X_api.h
Normal file
393
Firmware/Core/Inc/VL53L1X_api.h
Normal file
@ -0,0 +1,393 @@
|
||||
/*
|
||||
* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file : part of VL53L1 Core and : dual licensed,
|
||||
* either 'STMicroelectronics
|
||||
* Proprietary license'
|
||||
* or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* 'STMicroelectronics Proprietary license'
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
* terms at www.st.com/sla0081
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document : strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1x_api.h
|
||||
* @brief Functions definition
|
||||
*/
|
||||
|
||||
#ifndef _API_H_
|
||||
#define _API_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#define VL53L1X_IMPLEMENTATION_VER_MAJOR 3
|
||||
#define VL53L1X_IMPLEMENTATION_VER_MINOR 5
|
||||
#define VL53L1X_IMPLEMENTATION_VER_SUB 2
|
||||
#define VL53L1X_IMPLEMENTATION_VER_REVISION 0000
|
||||
|
||||
typedef int8_t VL53L1X_ERROR;
|
||||
|
||||
#define SOFT_RESET 0x0000
|
||||
#define VL53L1_I2C_SLAVE__DEVICE_ADDRESS 0x0001
|
||||
#define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x0008
|
||||
#define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x0016
|
||||
#define ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x0018
|
||||
#define ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x001A
|
||||
#define ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x001E
|
||||
#define MM_CONFIG__INNER_OFFSET_MM 0x0020
|
||||
#define MM_CONFIG__OUTER_OFFSET_MM 0x0022
|
||||
#define GPIO_HV_MUX__CTRL 0x0030
|
||||
#define GPIO__TIO_HV_STATUS 0x0031
|
||||
#define SYSTEM__INTERRUPT_CONFIG_GPIO 0x0046
|
||||
#define PHASECAL_CONFIG__TIMEOUT_MACROP 0x004B
|
||||
#define RANGE_CONFIG__TIMEOUT_MACROP_A_HI 0x005E
|
||||
#define RANGE_CONFIG__VCSEL_PERIOD_A 0x0060
|
||||
#define RANGE_CONFIG__VCSEL_PERIOD_B 0x0063
|
||||
#define RANGE_CONFIG__TIMEOUT_MACROP_B_HI 0x0061
|
||||
#define RANGE_CONFIG__TIMEOUT_MACROP_B_LO 0x0062
|
||||
#define RANGE_CONFIG__SIGMA_THRESH 0x0064
|
||||
#define RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS 0x0066
|
||||
#define RANGE_CONFIG__VALID_PHASE_HIGH 0x0069
|
||||
#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD 0x006C
|
||||
#define SYSTEM__THRESH_HIGH 0x0072
|
||||
#define SYSTEM__THRESH_LOW 0x0074
|
||||
#define SD_CONFIG__WOI_SD0 0x0078
|
||||
#define SD_CONFIG__INITIAL_PHASE_SD0 0x007A
|
||||
#define ROI_CONFIG__USER_ROI_CENTRE_SPAD 0x007F
|
||||
#define ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE 0x0080
|
||||
#define SYSTEM__SEQUENCE_CONFIG 0x0081
|
||||
#define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD 0x0082
|
||||
#define SYSTEM__INTERRUPT_CLEAR 0x0086
|
||||
#define SYSTEM__MODE_START 0x0087
|
||||
#define VL53L1_RESULT__RANGE_STATUS 0x0089
|
||||
#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 0x008C
|
||||
#define RESULT__AMBIENT_COUNT_RATE_MCPS_SD 0x0090
|
||||
#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0096
|
||||
#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 0x0098
|
||||
#define VL53L1_RESULT__OSC_CALIBRATE_VAL 0x00DE
|
||||
#define VL53L1_FIRMWARE__SYSTEM_STATUS 0x00E5
|
||||
#define VL53L1_IDENTIFICATION__MODEL_ID 0x010F
|
||||
#define VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD 0x013E
|
||||
|
||||
/****************************************
|
||||
* PRIVATE define do not edit
|
||||
****************************************/
|
||||
|
||||
/**
|
||||
* @brief defines SW Version
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t major; /*!< major number */
|
||||
uint8_t minor; /*!< minor number */
|
||||
uint8_t build; /*!< build number */
|
||||
uint32_t revision; /*!< revision number */
|
||||
} VL53L1X_Version_t;
|
||||
|
||||
/**
|
||||
* @brief defines packed reading results type
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t Status; /*!< ResultStatus */
|
||||
uint16_t Distance; /*!< ResultDistance */
|
||||
uint16_t Ambient; /*!< ResultAmbient */
|
||||
uint16_t SigPerSPAD;/*!< ResultSignalPerSPAD */
|
||||
uint16_t NumSPADs; /*!< ResultNumSPADs */
|
||||
} VL53L1X_Result_t;
|
||||
|
||||
/**
|
||||
* @brief This function returns the SW driver version
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSWVersion(VL53L1X_Version_t *pVersion);
|
||||
|
||||
/**
|
||||
* @brief This function sets the sensor I2C address used in case multiple devices application, default address 0x52
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetI2CAddress(uint16_t, uint8_t new_address);
|
||||
|
||||
/**
|
||||
* @brief This function loads the 135 bytes default values to initialize the sensor.
|
||||
* @param dev Device address
|
||||
* @return 0:success, != 0:failed
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SensorInit(uint16_t dev);
|
||||
|
||||
/**
|
||||
* @brief This function clears the interrupt, to be called after a ranging data reading
|
||||
* to arm the interrupt for the next data ready event.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_ClearInterrupt(uint16_t dev);
|
||||
|
||||
/**
|
||||
* @brief This function programs the interrupt polarity\n
|
||||
* 1=active high (default), 0=active low
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetInterruptPolarity(uint16_t dev, uint8_t IntPol);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current interrupt polarity\n
|
||||
* 1=active high (default), 0=active low
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetInterruptPolarity(uint16_t dev, uint8_t *pIntPol);
|
||||
|
||||
/**
|
||||
* @brief This function starts the ranging distance operation\n
|
||||
* The ranging operation is continuous. The clear interrupt has to be done after each get data to allow the interrupt to raise when the next data is ready\n
|
||||
* 1=active high (default), 0=active low, use SetInterruptPolarity() to change the interrupt polarity if required.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_StartRanging(uint16_t dev);
|
||||
|
||||
/**
|
||||
* @brief This function stops the ranging.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_StopRanging(uint16_t dev);
|
||||
|
||||
/**
|
||||
* @brief This function checks if the new ranging data is available by polling the dedicated register.
|
||||
* @param : isDataReady==0 -> not ready; isDataReady==1 -> ready
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_CheckForDataReady(uint16_t dev, uint8_t *isDataReady);
|
||||
|
||||
/**
|
||||
* @brief This function programs the timing budget in ms.
|
||||
* Predefined values = 15, 20, 33, 50, 100(default), 200, 500.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetTimingBudgetInMs(uint16_t dev, uint16_t TimingBudgetInMs);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current timing budget in ms.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetTimingBudgetInMs(uint16_t dev, uint16_t *pTimingBudgetInMs);
|
||||
|
||||
/**
|
||||
* @brief This function programs the distance mode (1=short, 2=long(default)).
|
||||
* Short mode max distance is limited to 1.3 m but better ambient immunity.\n
|
||||
* Long mode can range up to 4 m in the dark with 200 ms timing budget.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetDistanceMode(uint16_t dev, uint16_t DistanceMode);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current distance mode (1=short, 2=long).
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistanceMode(uint16_t dev, uint16_t *pDistanceMode);
|
||||
|
||||
/**
|
||||
* @brief This function programs the Intermeasurement period in ms\n
|
||||
* Intermeasurement period must be >/= timing budget. This condition is not checked by the API,
|
||||
* the customer has the duty to check the condition. Default = 100 ms
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetInterMeasurementInMs(uint16_t dev,
|
||||
uint32_t InterMeasurementInMs);
|
||||
|
||||
/**
|
||||
* @brief This function returns the Intermeasurement period in ms.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetInterMeasurementInMs(uint16_t dev, uint16_t * pIM);
|
||||
|
||||
/**
|
||||
* @brief This function returns the boot state of the device (1:booted, 0:not booted)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_BootState(uint16_t dev, uint8_t *state);
|
||||
|
||||
/**
|
||||
* @brief This function returns the sensor id, sensor Id must be 0xEEAC
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSensorId(uint16_t dev, uint16_t *id);
|
||||
|
||||
/**
|
||||
* @brief This function returns the distance measured by the sensor in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistance(uint16_t dev, uint16_t *distance);
|
||||
|
||||
/**
|
||||
* @brief This function returns the returned signal per SPAD in kcps/SPAD.
|
||||
* With kcps stands for Kilo Count Per Second
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSignalPerSpad(uint16_t dev, uint16_t *signalPerSp);
|
||||
|
||||
/**
|
||||
* @brief This function returns the ambient per SPAD in kcps/SPAD
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetAmbientPerSpad(uint16_t dev, uint16_t *amb);
|
||||
|
||||
/**
|
||||
* @brief This function returns the returned signal in kcps.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSignalRate(uint16_t dev, uint16_t *signalRate);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current number of enabled SPADs
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSpadNb(uint16_t dev, uint16_t *spNb);
|
||||
|
||||
/**
|
||||
* @brief This function returns the ambient rate in kcps
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetAmbientRate(uint16_t dev, uint16_t *ambRate);
|
||||
|
||||
/**
|
||||
* @brief This function returns the ranging status error \n
|
||||
* (0:no error, 1:sigma failed, 2:signal failed, ..., 7:wrap-around)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetRangeStatus(uint16_t dev, uint8_t *rangeStatus);
|
||||
|
||||
/**
|
||||
* @brief This function returns measurements and the range status in a single read access
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetResult(uint16_t dev, VL53L1X_Result_t *pResult);
|
||||
|
||||
/**
|
||||
* @brief This function programs the offset correction in mm
|
||||
* @param OffsetValue:the offset correction value to program in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetOffset(uint16_t dev, int16_t OffsetValue);
|
||||
|
||||
/**
|
||||
* @brief This function returns the programmed offset correction value in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetOffset(uint16_t dev, int16_t *Offset);
|
||||
|
||||
/**
|
||||
* @brief This function programs the xtalk correction value in cps (Count Per Second).\n
|
||||
* This is the number of photons reflected back from the cover glass in cps.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetXtalk(uint16_t dev, uint16_t XtalkValue);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current programmed xtalk correction value in cps
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetXtalk(uint16_t dev, uint16_t *Xtalk);
|
||||
|
||||
/**
|
||||
* @brief This function programs the threshold detection mode\n
|
||||
* Example:\n
|
||||
* VL53L1X_SetDistanceThreshold(dev,100,300,0,1): Below 100 \n
|
||||
* VL53L1X_SetDistanceThreshold(dev,100,300,1,1): Above 300 \n
|
||||
* VL53L1X_SetDistanceThreshold(dev,100,300,2,1): Out of window \n
|
||||
* VL53L1X_SetDistanceThreshold(dev,100,300,3,1): In window \n
|
||||
* @param dev : device address
|
||||
* @param ThreshLow(in mm) : the threshold under which one the device raises an interrupt if Window = 0
|
||||
* @param ThreshHigh(in mm) : the threshold above which one the device raises an interrupt if Window = 1
|
||||
* @param Window detection mode : 0=below, 1=above, 2=out, 3=in
|
||||
* @param IntOnNoTarget = 0 (No longer used - just use 0)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetDistanceThreshold(uint16_t dev, uint16_t ThreshLow,
|
||||
uint16_t ThreshHigh, uint8_t Window,
|
||||
uint8_t IntOnNoTarget);
|
||||
|
||||
/**
|
||||
* @brief This function returns the window detection mode (0=below; 1=above; 2=out; 3=in)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistanceThresholdWindow(uint16_t dev, uint16_t *window);
|
||||
|
||||
/**
|
||||
* @brief This function returns the low threshold in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistanceThresholdLow(uint16_t dev, uint16_t *low);
|
||||
|
||||
/**
|
||||
* @brief This function returns the high threshold in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetDistanceThresholdHigh(uint16_t dev, uint16_t *high);
|
||||
|
||||
/**
|
||||
* @brief This function programs the ROI (Region of Interest)\n
|
||||
* The ROI position is centered, only the ROI size can be reprogrammed.\n
|
||||
* The smallest acceptable ROI size = 4\n
|
||||
* @param X:ROI Width; Y=ROI Height
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetROI(uint16_t dev, uint16_t X, uint16_t Y);
|
||||
|
||||
/**
|
||||
*@brief This function returns width X and height Y
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetROI_XY(uint16_t dev, uint16_t *ROI_X, uint16_t *ROI_Y);
|
||||
|
||||
/**
|
||||
*@brief This function programs the new user ROI center, please to be aware that there is no check in this function.
|
||||
*if the ROI center vs ROI size is out of border the ranging function return error #13
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetROICenter(uint16_t dev, uint8_t ROICenter);
|
||||
|
||||
/**
|
||||
*@brief This function returns the current user ROI center
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetROICenter(uint16_t dev, uint8_t *ROICenter);
|
||||
|
||||
/**
|
||||
* @brief This function programs a new signal threshold in kcps (default=1024 kcps\n
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetSignalThreshold(uint16_t dev, uint16_t signal);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current signal threshold in kcps
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSignalThreshold(uint16_t dev, uint16_t *signal);
|
||||
|
||||
/**
|
||||
* @brief This function programs a new sigma threshold in mm (default=15 mm)
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_SetSigmaThreshold(uint16_t dev, uint16_t sigma);
|
||||
|
||||
/**
|
||||
* @brief This function returns the current sigma threshold in mm
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_GetSigmaThreshold(uint16_t dev, uint16_t *signal);
|
||||
|
||||
/**
|
||||
* @brief This function performs the temperature calibration.
|
||||
* It is recommended to call this function any time the temperature might have changed by more than 8 deg C
|
||||
* without sensor ranging activity for an extended period.
|
||||
*/
|
||||
VL53L1X_ERROR VL53L1X_StartTemperatureUpdate(uint16_t dev);
|
||||
|
||||
#endif
|
93
Firmware/Core/Inc/VL53L1X_calibration.h
Normal file
93
Firmware/Core/Inc/VL53L1X_calibration.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file : part of VL53L1 Core and : dual licensed,
|
||||
* either 'STMicroelectronics
|
||||
* Proprietary license'
|
||||
* or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* 'STMicroelectronics Proprietary license'
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
* terms at www.st.com/sla0081
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document : strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @file vl53l1x_calibration.h
|
||||
* @brief Calibration Functions definition
|
||||
*/
|
||||
|
||||
#ifndef _CALIBRATION_H_
|
||||
#define _CALIBRATION_H_
|
||||
|
||||
/**
|
||||
* @brief This function performs the offset calibration.\n
|
||||
* The function returns the offset value found and programs the offset compensation into the device.
|
||||
* @param TargetDistInMm target distance in mm, ST recommended 100 mm
|
||||
* Target reflectance = grey17%
|
||||
* @return 0:success, !=0: failed
|
||||
* @return offset pointer contains the offset found in mm
|
||||
*/
|
||||
int8_t VL53L1X_CalibrateOffset(uint16_t dev, uint16_t TargetDistInMm, int16_t *offset);
|
||||
|
||||
/**
|
||||
* @brief This function performs the xtalk calibration.\n
|
||||
* The function returns the xtalk value found and programs the xtalk compensation to the device
|
||||
* @param TargetDistInMm target distance in mm\n
|
||||
* The target distance : the distance where the sensor start to "under range"\n
|
||||
* due to the influence of the photons reflected back from the cover glass becoming strong\n
|
||||
* It's also called inflection point\n
|
||||
* Target reflectance = grey 17%
|
||||
* @return 0: success, !=0: failed
|
||||
* @return xtalk pointer contains the xtalk value found in cps (number of photons in count per second)
|
||||
*/
|
||||
int8_t VL53L1X_CalibrateXtalk(uint16_t dev, uint16_t TargetDistInMm, uint16_t *xtalk);
|
||||
|
||||
#endif
|
@ -39,9 +39,11 @@ extern "C" {
|
||||
#include "tusb.h"
|
||||
#include "Cam.h"
|
||||
#include "usb_descriptors.h"
|
||||
#include "VL53L1X_api.h"
|
||||
//#include "Distance.h"
|
||||
|
||||
// #include "portable/st/synopsys/dcd_synopsys.c"
|
||||
// #include "portable/st/synopsys/synopsys_common.h"
|
||||
// #include "portable/st/synopsys/dcd_synopsys.c"
|
||||
// #include "portable/st/synopsys/synopsys_common.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@ -68,6 +70,10 @@ void Error_Handler(void);
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
|
||||
extern I2C_HandleTypeDef hi2c1;
|
||||
|
||||
|
||||
#define MCO_Pin GPIO_PIN_0
|
||||
#define MCO_GPIO_Port GPIOA
|
||||
#define DEBUG_LED_Pin GPIO_PIN_1
|
||||
|
68
Firmware/Core/Inc/mxconstants.h
Normal file
68
Firmware/Core/Inc/mxconstants.h
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : mxconstants.h
|
||||
* Description : This file contains the common defines of the application
|
||||
******************************************************************************
|
||||
*
|
||||
* COPYRIGHT(c) 2015 STMicroelectronics
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
||||
#define B1_Pin GPIO_PIN_13
|
||||
#define B1_GPIO_Port GPIOC
|
||||
#define USART_TX_Pin GPIO_PIN_2
|
||||
#define USART_TX_GPIO_Port GPIOA
|
||||
#define USART_RX_Pin GPIO_PIN_3
|
||||
#define USART_RX_GPIO_Port GPIOA
|
||||
#define LD2_Pin GPIO_PIN_5
|
||||
#define LD2_GPIO_Port GPIOA
|
||||
#define TMS_Pin GPIO_PIN_13
|
||||
#define TMS_GPIO_Port GPIOA
|
||||
#define TCK_Pin GPIO_PIN_14
|
||||
#define TCK_GPIO_Port GPIOA
|
||||
#define SWO_Pin GPIO_PIN_3
|
||||
#define SWO_GPIO_Port GPIOB
|
||||
#define VL53L0_OsDelay() HAL_Delay(1)
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
73
Firmware/Core/Inc/stm32xxx_hal.h
Normal file
73
Firmware/Core/Inc/stm32xxx_hal.h
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32xxx_hal.h
|
||||
* @date 10/03/2015 18:07:07
|
||||
* @brief This file allows to select the right stm32 hal file
|
||||
******************************************************************************
|
||||
*
|
||||
* COPYRIGHT(c) 2015 STMicroelectronics
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32xxx_HAL_H
|
||||
#define __STM32xxx_HAL_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "mxconstants.h"
|
||||
|
||||
#ifdef STM32F401xE
|
||||
#include "stm32f4xx_hal.h"
|
||||
#define MCU_NAME "STM32F401xE"
|
||||
#endif
|
||||
#ifdef STM32L476xx
|
||||
#include "stm32l4xx_hal.h"
|
||||
#define MCU_NAME "STM32L476"
|
||||
#endif
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#if TRACE_UART
|
||||
# define trace_printf uart_printf
|
||||
extern int uart_printf(const char *msg, ...);
|
||||
#else
|
||||
# define trace_printf(...) (void)0
|
||||
# define uart_printf(...) (void)0
|
||||
#endif
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32xxx_HAL_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
253
Firmware/Core/Inc/vl53l1_error_codes.h
Normal file
253
Firmware/Core/Inc/vl53l1_error_codes.h
Normal file
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core and is dual licensed,
|
||||
* either 'STMicroelectronics
|
||||
* Proprietary license'
|
||||
* or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* 'STMicroelectronics Proprietary license'
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
* terms at www.st.com/sla0081
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_error_codes.h
|
||||
*
|
||||
* @brief Error Code definitions for VL53L1 API.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_ERROR_CODES_H_
|
||||
#define _VL53L1_ERROR_CODES_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************
|
||||
* PRIVATE define do not edit
|
||||
****************************************/
|
||||
|
||||
/** @defgroup VL53L1_define_Error_group Error and Warning code returned by API
|
||||
* The following DEFINE are used to identify the PAL ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef int8_t VL53L1_Error;
|
||||
|
||||
#define VL53L1_ERROR_NONE ((VL53L1_Error) 0)
|
||||
#define VL53L1_ERROR_CALIBRATION_WARNING ((VL53L1_Error) - 1)
|
||||
/*!< Warning invalid calibration data may be in used
|
||||
\a VL53L1_InitData()
|
||||
\a VL53L1_GetOffsetCalibrationData
|
||||
\a VL53L1_SetOffsetCalibrationData */
|
||||
#define VL53L1_ERROR_MIN_CLIPPED ((VL53L1_Error) - 2)
|
||||
/*!< Warning parameter passed was clipped to min before to be applied */
|
||||
|
||||
#define VL53L1_ERROR_UNDEFINED ((VL53L1_Error) - 3)
|
||||
/*!< Unqualified error */
|
||||
#define VL53L1_ERROR_INVALID_PARAMS ((VL53L1_Error) - 4)
|
||||
/*!< Parameter passed is invalid or out of range */
|
||||
#define VL53L1_ERROR_NOT_SUPPORTED ((VL53L1_Error) - 5)
|
||||
/*!< Function is not supported in current mode or configuration */
|
||||
#define VL53L1_ERROR_RANGE_ERROR ((VL53L1_Error) - 6)
|
||||
/*!< Device report a ranging error interrupt status */
|
||||
#define VL53L1_ERROR_TIME_OUT ((VL53L1_Error) - 7)
|
||||
/*!< Aborted due to time out */
|
||||
#define VL53L1_ERROR_MODE_NOT_SUPPORTED ((VL53L1_Error) - 8)
|
||||
/*!< Asked mode is not supported by the device */
|
||||
#define VL53L1_ERROR_BUFFER_TOO_SMALL ((VL53L1_Error) - 9)
|
||||
/*!< ... */
|
||||
#define VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL ((VL53L1_Error) - 10)
|
||||
/*!< Supplied buffer is larger than I2C supports */
|
||||
#define VL53L1_ERROR_GPIO_NOT_EXISTING ((VL53L1_Error) - 11)
|
||||
/*!< User tried to setup a non-existing GPIO pin */
|
||||
#define VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L1_Error) - 12)
|
||||
/*!< unsupported GPIO functionality */
|
||||
#define VL53L1_ERROR_CONTROL_INTERFACE ((VL53L1_Error) - 13)
|
||||
/*!< error reported from IO functions */
|
||||
#define VL53L1_ERROR_INVALID_COMMAND ((VL53L1_Error) - 14)
|
||||
/*!< The command is not allowed in the current device state
|
||||
* (power down) */
|
||||
#define VL53L1_ERROR_DIVISION_BY_ZERO ((VL53L1_Error) - 15)
|
||||
/*!< In the function a division by zero occurs */
|
||||
#define VL53L1_ERROR_REF_SPAD_INIT ((VL53L1_Error) - 16)
|
||||
/*!< Error during reference SPAD initialization */
|
||||
#define VL53L1_ERROR_GPH_SYNC_CHECK_FAIL ((VL53L1_Error) - 17)
|
||||
/*!< GPH sync interrupt check fail - API out of sync with device*/
|
||||
#define VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 18)
|
||||
/*!< Stream count check fail - API out of sync with device */
|
||||
#define VL53L1_ERROR_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 19)
|
||||
/*!< GPH ID check fail - API out of sync with device */
|
||||
#define VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 20)
|
||||
/*!< Zone dynamic config stream count check failed - API out of sync */
|
||||
#define VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 21)
|
||||
/*!< Zone dynamic config GPH ID check failed - API out of sync */
|
||||
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL ((VL53L1_Error) - 22)
|
||||
/*!< Thrown when run_xtalk_extraction fn has 0 succesful samples
|
||||
* when using the full array to sample the xtalk. In this case there is
|
||||
* not enough information to generate new Xtalk parm info. The function
|
||||
* will exit and leave the current xtalk parameters unaltered */
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL ((VL53L1_Error) - 23)
|
||||
/*!< Thrown when run_xtalk_extraction fn has found that the
|
||||
* avg sigma estimate of the full array xtalk sample is > than the
|
||||
* maximal limit allowed. In this case the xtalk sample is too noisy for
|
||||
* measurement. The function will exit and leave the current xtalk parameters
|
||||
* unaltered. */
|
||||
|
||||
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 24)
|
||||
/*!< Thrown if there one of stages has no valid offset calibration
|
||||
* samples. A fatal error calibration not valid */
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL ((VL53L1_Error) - 25)
|
||||
/*!< Thrown if there one of stages has zero effective SPADS
|
||||
* Traps the case when MM1 SPADs is zero.
|
||||
* A fatal error calibration not valid */
|
||||
#define VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 26)
|
||||
/*!< Thrown if then some of the zones have no valid samples
|
||||
* A fatal error calibration not valid */
|
||||
|
||||
#define VL53L1_ERROR_TUNING_PARM_KEY_MISMATCH ((VL53L1_Error) - 27)
|
||||
/*!< Thrown if the tuning file key table version does not match with
|
||||
* expected value. The driver expects the key table version to match
|
||||
* the compiled default version number in the define
|
||||
* #VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT
|
||||
* */
|
||||
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS ((VL53L1_Error) - 28)
|
||||
/*!< Thrown if there are less than 5 good SPADs are available. */
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH ((VL53L1_Error) - 29)
|
||||
/*!< Thrown if the final reference rate is greater than
|
||||
the upper reference rate limit - default is 40 Mcps.
|
||||
Implies a minimum Q3 (x10) SPAD (5) selected */
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW ((VL53L1_Error) - 30)
|
||||
/*!< Thrown if the final reference rate is less than
|
||||
the lower reference rate limit - default is 10 Mcps.
|
||||
Implies maximum Q1 (x1) SPADs selected */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES ((VL53L1_Error) - 31)
|
||||
/*!< Thrown if there is less than the requested number of
|
||||
* valid samples. */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 32)
|
||||
/*!< Thrown if the offset calibration range sigma estimate is greater
|
||||
* than 8.0 mm. This is the recommended min value to yield a stable
|
||||
* offset measurement */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 33)
|
||||
/*!< Thrown when VL53L1_run_offset_calibration() peak rate is greater
|
||||
than that 50.0Mcps. This is the recommended max rate to avoid
|
||||
pile-up influencing the offset measurement */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW ((VL53L1_Error) - 34)
|
||||
/*!< Thrown when VL53L1_run_offset_calibration() when one of stages
|
||||
range has less that 5.0 effective SPADS. This is the recommended
|
||||
min value to yield a stable offset */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES ((VL53L1_Error) - 35)
|
||||
/*!< Thrown if one of more of the zones have less than
|
||||
the requested number of valid samples */
|
||||
#define VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 36)
|
||||
/*!< Thrown if one or more zones have sigma estimate value greater
|
||||
* than 8.0 mm. This is the recommended min value to yield a stable
|
||||
* offset measurement */
|
||||
#define VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 37)
|
||||
/*!< Thrown if one of more zones have peak rate higher than
|
||||
that 50.0Mcps. This is the recommended max rate to avoid
|
||||
pile-up influencing the offset measurement */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_XTALK_MISSING_SAMPLES ((VL53L1_Error) - 38)
|
||||
/*!< Thrown to notify that some of the xtalk samples did not yield
|
||||
* valid ranging pulse data while attempting to measure
|
||||
* the xtalk signal in vl53l1_run_xtalk_extract(). This can signify any of
|
||||
* the zones are missing samples, for further debug information the
|
||||
* xtalk_results struct should be referred to. This warning is for
|
||||
* notification only, the xtalk pulse and shape have still been generated
|
||||
*/
|
||||
#define VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT ((VL53L1_Error) - 39)
|
||||
/*!< Thrown to notify that some of teh xtalk samples used for gradient
|
||||
* generation did not yield valid ranging pulse data while attempting to
|
||||
* measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
|
||||
* that any one of the zones 0-3 yielded no successful samples. The
|
||||
* xtalk_results struct should be referred to for further debug info.
|
||||
* This warning is for notification only, the xtalk pulse and shape
|
||||
* have still been generated.
|
||||
*/
|
||||
#define VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT ((VL53L1_Error) - 40)
|
||||
/*!< Thrown to notify that some of the xtalk samples used for gradient
|
||||
* generation did not pass the sigma limit check while attempting to
|
||||
* measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
|
||||
* that any one of the zones 0-3 yielded an avg sigma_mm value > the limit.
|
||||
* The xtalk_results struct should be referred to for further debug info.
|
||||
* This warning is for notification only, the xtalk pulse and shape
|
||||
* have still been generated.
|
||||
*/
|
||||
|
||||
#define VL53L1_ERROR_NOT_IMPLEMENTED ((VL53L1_Error) - 41)
|
||||
/*!< Tells requested functionality has not been implemented yet or
|
||||
* not compatible with the device */
|
||||
#define VL53L1_ERROR_PLATFORM_SPECIFIC_START ((VL53L1_Error) - 60)
|
||||
/*!< Tells the starting code for platform */
|
||||
/** @} VL53L1_define_Error_group */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _VL53L1_ERROR_CODES_H_ */
|
91
Firmware/Core/Inc/vl53l1_platform.h
Normal file
91
Firmware/Core/Inc/vl53l1_platform.h
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file vl53l1_platform.h
|
||||
* @brief Those platform functions are platform dependent and have to be implemented by the user
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_H_
|
||||
#define _VL53L1_PLATFORM_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint32_t dummy;
|
||||
} VL53L1_Dev_t;
|
||||
|
||||
typedef VL53L1_Dev_t *VL53L1_DEV;
|
||||
|
||||
/** @brief VL53L1_WriteMulti() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_WriteMulti(
|
||||
uint16_t dev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata,
|
||||
uint32_t count);
|
||||
/** @brief VL53L1_ReadMulti() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_ReadMulti(
|
||||
uint16_t dev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata,
|
||||
uint32_t count);
|
||||
/** @brief VL53L1_WrByte() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_WrByte(
|
||||
uint16_t dev,
|
||||
uint16_t index,
|
||||
uint8_t data);
|
||||
/** @brief VL53L1_WrWord() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_WrWord(
|
||||
uint16_t dev,
|
||||
uint16_t index,
|
||||
uint16_t data);
|
||||
/** @brief VL53L1_WrDWord() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_WrDWord(
|
||||
uint16_t dev,
|
||||
uint16_t index,
|
||||
uint32_t data);
|
||||
/** @brief VL53L1_RdByte() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_RdByte(
|
||||
uint16_t dev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata);
|
||||
/** @brief VL53L1_RdWord() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_RdWord(
|
||||
uint16_t dev,
|
||||
uint16_t index,
|
||||
uint16_t *pdata);
|
||||
/** @brief VL53L1_RdDWord() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_RdDWord(
|
||||
uint16_t dev,
|
||||
uint16_t index,
|
||||
uint32_t *data);
|
||||
/** @brief VL53L1_WaitMs() definition.\n
|
||||
* To be implemented by the developer
|
||||
*/
|
||||
int8_t VL53L1_WaitMs(
|
||||
uint16_t dev,
|
||||
int32_t wait_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
223
Firmware/Core/Inc/vl53l1_platform_log.h
Normal file
223
Firmware/Core/Inc/vl53l1_platform_log.h
Normal file
@ -0,0 +1,223 @@
|
||||
/*******************************************************************************
|
||||
Copyright (C) 2015, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_log.h
|
||||
*
|
||||
* @brief EwokPlus25 platform logging function definition
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_LOG_H_
|
||||
#define _VL53L1_PLATFORM_LOG_H_
|
||||
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
#include "vl53l1_platform_user_config.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define EWOKPLUS_EXPORTS __declspec(dllexport)
|
||||
#else
|
||||
# define EWOKPLUS_EXPORTS
|
||||
#endif
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
/**
|
||||
* @brief Set the level, output and specific functions for module logging.
|
||||
*
|
||||
*
|
||||
* @param filename - full path of output log file, NULL for print to stdout
|
||||
*
|
||||
* @param modules - Module or None or All to trace
|
||||
* VL53L1_TRACE_MODULE_NONE
|
||||
* VL53L1_TRACE_MODULE_API
|
||||
* VL53L1_TRACE_MODULE_CORE
|
||||
* VL53L1_TRACE_MODULE_TUNING
|
||||
* VL53L1_TRACE_MODULE_CHARACTERISATION
|
||||
* VL53L1_TRACE_MODULE_PLATFORM
|
||||
* VL53L1_TRACE_MODULE_ALL
|
||||
*
|
||||
* @param level - trace level
|
||||
* VL53L1_TRACE_LEVEL_NONE
|
||||
* VL53L1_TRACE_LEVEL_ERRORS
|
||||
* VL53L1_TRACE_LEVEL_WARNING
|
||||
* VL53L1_TRACE_LEVEL_INFO
|
||||
* VL53L1_TRACE_LEVEL_DEBUG
|
||||
* VL53L1_TRACE_LEVEL_ALL
|
||||
* VL53L1_TRACE_LEVEL_IGNORE
|
||||
*
|
||||
* @param functions - function level to trace;
|
||||
* VL53L1_TRACE_FUNCTION_NONE
|
||||
* VL53L1_TRACE_FUNCTION_I2C
|
||||
* VL53L1_TRACE_FUNCTION_ALL
|
||||
*
|
||||
* @return status - always VL53L1_ERROR_NONE
|
||||
*
|
||||
*/
|
||||
|
||||
#define VL53L1_TRACE_LEVEL_NONE 0x00000000
|
||||
#define VL53L1_TRACE_LEVEL_ERRORS 0x00000001
|
||||
#define VL53L1_TRACE_LEVEL_WARNING 0x00000002
|
||||
#define VL53L1_TRACE_LEVEL_INFO 0x00000004
|
||||
#define VL53L1_TRACE_LEVEL_DEBUG 0x00000008
|
||||
#define VL53L1_TRACE_LEVEL_ALL 0x00000010
|
||||
#define VL53L1_TRACE_LEVEL_IGNORE 0x00000020
|
||||
|
||||
#define VL53L1_TRACE_FUNCTION_NONE 0x00000000
|
||||
#define VL53L1_TRACE_FUNCTION_I2C 0x00000001
|
||||
#define VL53L1_TRACE_FUNCTION_ALL 0x7fffffff
|
||||
|
||||
#define VL53L1_TRACE_MODULE_NONE 0x00000000
|
||||
#define VL53L1_TRACE_MODULE_API 0x00000001
|
||||
#define VL53L1_TRACE_MODULE_CORE 0x00000002
|
||||
#define VL53L1_TRACE_MODULE_PROTECTED 0x00000004
|
||||
#define VL53L1_TRACE_MODULE_HISTOGRAM 0x00000008
|
||||
#define VL53L1_TRACE_MODULE_REGISTERS 0x00000010
|
||||
#define VL53L1_TRACE_MODULE_PLATFORM 0x00000020
|
||||
#define VL53L1_TRACE_MODULE_NVM 0x00000040
|
||||
#define VL53L1_TRACE_MODULE_CALIBRATION_DATA 0x00000080
|
||||
#define VL53L1_TRACE_MODULE_NVM_DATA 0x00000100
|
||||
#define VL53L1_TRACE_MODULE_HISTOGRAM_DATA 0x00000200
|
||||
#define VL53L1_TRACE_MODULE_RANGE_RESULTS_DATA 0x00000400
|
||||
#define VL53L1_TRACE_MODULE_XTALK_DATA 0x00000800
|
||||
#define VL53L1_TRACE_MODULE_OFFSET_DATA 0x00001000
|
||||
#define VL53L1_TRACE_MODULE_DATA_INIT 0x00002000
|
||||
#define VL53L1_TRACE_MODULE_REF_SPAD_CHAR 0x00004000
|
||||
#define VL53L1_TRACE_MODULE_SPAD_RATE_MAP 0x00008000
|
||||
#ifdef PAL_EXTENDED
|
||||
#define VL53L1_TRACE_MODULE_SPAD 0x01000000
|
||||
#define VL53L1_TRACE_MODULE_FMT 0x02000000
|
||||
#define VL53L1_TRACE_MODULE_UTILS 0x04000000
|
||||
#define VL53L1_TRACE_MODULE_BENCH_FUNCS 0x08000000
|
||||
#endif
|
||||
#define VL53L1_TRACE_MODULE_CUSTOMER_API 0x40000000
|
||||
#define VL53L1_TRACE_MODULE_ALL 0x7fffffff
|
||||
|
||||
|
||||
extern uint32_t _trace_level;
|
||||
|
||||
/*
|
||||
* NOTE: dynamically exported if we enable logging.
|
||||
* this way, Python interfaces can access this function, but we don't
|
||||
* need to include it in the .def files.
|
||||
*/
|
||||
EWOKPLUS_EXPORTS int8_t VL53L1_trace_config(
|
||||
char *filename,
|
||||
uint32_t modules,
|
||||
uint32_t level,
|
||||
uint32_t functions);
|
||||
|
||||
/**
|
||||
* @brief Print trace module function.
|
||||
*
|
||||
* @param module - ??
|
||||
* @param level - ??
|
||||
* @param function - ??
|
||||
* @param format - ??
|
||||
*
|
||||
*/
|
||||
|
||||
EWOKPLUS_EXPORTS void VL53L1_trace_print_module_function(
|
||||
uint32_t module,
|
||||
uint32_t level,
|
||||
uint32_t function,
|
||||
const char *format, ...);
|
||||
|
||||
/**
|
||||
* @brief Get global _trace_functions parameter
|
||||
*
|
||||
* @return _trace_functions
|
||||
*/
|
||||
|
||||
uint32_t VL53L1_get_trace_functions(void);
|
||||
|
||||
/**
|
||||
* @brief Set global _trace_functions parameter
|
||||
*
|
||||
* @param[in] function : new function code
|
||||
*/
|
||||
|
||||
void VL53L1_set_trace_functions(uint32_t function);
|
||||
|
||||
|
||||
/*
|
||||
* @brief Returns the current system tick count in [ms]
|
||||
*
|
||||
* @return time_ms : current time in [ms]
|
||||
*
|
||||
*/
|
||||
|
||||
uint32_t VL53L1_clock(void);
|
||||
|
||||
#define LOG_GET_TIME() \
|
||||
((int)VL53L1_clock())
|
||||
|
||||
#define _LOG_TRACE_PRINT(module, level, function, ...) \
|
||||
VL53L1_trace_print_module_function(module, level, function, ##__VA_ARGS__);
|
||||
|
||||
#define _LOG_FUNCTION_START(module, fmt, ...) \
|
||||
VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__);
|
||||
|
||||
#define _LOG_FUNCTION_END(module, status, ...)\
|
||||
VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <END> %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__)
|
||||
|
||||
#define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\
|
||||
VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <END> %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__)
|
||||
|
||||
#define _LOG_GET_TRACE_FUNCTIONS()\
|
||||
VL53L1_get_trace_functions()
|
||||
|
||||
#define _LOG_SET_TRACE_FUNCTIONS(functions)\
|
||||
VL53L1_set_trace_functions(functions)
|
||||
|
||||
#define _LOG_STRING_BUFFER(x) char x[VL53L1_MAX_STRING_LENGTH]
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* VL53L1_LOG_ENABLE - no logging */
|
||||
|
||||
#define _LOG_TRACE_PRINT(module, level, function, ...)
|
||||
#define _LOG_FUNCTION_START(module, fmt, ...)
|
||||
#define _LOG_FUNCTION_END(module, status, ...)
|
||||
#define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)
|
||||
#define _LOG_GET_TRACE_FUNCTIONS() 0
|
||||
#define _LOG_SET_TRACE_FUNCTIONS(functions)
|
||||
#define _LOG_STRING_BUFFER(x)
|
||||
|
||||
#endif /* VL53L1_LOG_ENABLE */
|
||||
|
||||
#endif /* _VL53L1_PLATFORM_LOG_H_ */
|
84
Firmware/Core/Inc/vl53l1_platform_user_config.h
Normal file
84
Firmware/Core/Inc/vl53l1_platform_user_config.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*******************************************************************************
|
||||
Copyright (C) 2015, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_user_config.h
|
||||
*
|
||||
* @brief EwokPlus compile time user modifiable configuration
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_USER_CONFIG_H_
|
||||
#define _VL53L1_PLATFORM_USER_CONFIG_H_
|
||||
|
||||
#define VL53L1_BYTES_PER_WORD 2
|
||||
#define VL53L1_BYTES_PER_DWORD 4
|
||||
|
||||
/* Define polling delays */
|
||||
#define VL53L1_BOOT_COMPLETION_POLLING_TIMEOUT_MS 500
|
||||
#define VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS 2000
|
||||
#define VL53L1_TEST_COMPLETION_POLLING_TIMEOUT_MS 60000
|
||||
|
||||
#define VL53L1_POLLING_DELAY_MS 1
|
||||
|
||||
/* Define LLD TuningParms Page Base Address
|
||||
* - Part of Patch_AddedTuningParms_11761
|
||||
*/
|
||||
#define VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS 0x8000
|
||||
#define VL53L1_TUNINGPARM_PRIVATE_PAGE_BASE_ADDRESS 0xC000
|
||||
|
||||
#define VL53L1_GAIN_FACTOR__STANDARD_DEFAULT 0x0800
|
||||
/*!< Default standard ranging gain correction factor
|
||||
1.11 format. 1.0 = 0x0800, 0.980 = 0x07D7 */
|
||||
|
||||
#define VL53L1_OFFSET_CAL_MIN_EFFECTIVE_SPADS 0x0500
|
||||
/*!< Lower Limit for the MM1 effective SPAD count during offset
|
||||
calibration Format 8.8 0x0500 -> 5.0 effective SPADs */
|
||||
|
||||
#define VL53L1_OFFSET_CAL_MAX_PRE_PEAK_RATE_MCPS 0x1900
|
||||
/*!< Max Limit for the pre range peak rate during offset
|
||||
calibration Format 9.7 0x1900 -> 50.0 Mcps.
|
||||
If larger then in pile up */
|
||||
|
||||
#define VL53L1_OFFSET_CAL_MAX_SIGMA_MM 0x0040
|
||||
/*!< Max sigma estimate limit during offset calibration
|
||||
Check applies to pre-range, mm1 and mm2 ranges
|
||||
Format 14.2 0x0040 -> 16.0mm. */
|
||||
|
||||
#define VL53L1_MAX_USER_ZONES 169
|
||||
/*!< Max number of user Zones - maximal limitation from
|
||||
FW stream divide - value of 254 */
|
||||
|
||||
#define VL53L1_MAX_RANGE_RESULTS 2
|
||||
/*!< Allocates storage for return and reference restults */
|
||||
|
||||
|
||||
#define VL53L1_MAX_STRING_LENGTH 512
|
||||
|
||||
#endif /* _VL53L1_PLATFORM_USER_CONFIG_H_ */
|
||||
|
66
Firmware/Core/Inc/vl53l1_platform_user_data.h
Normal file
66
Firmware/Core/Inc/vl53l1_platform_user_data.h
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
/*
|
||||
* This file is part of VL53L1 Platform
|
||||
*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFIT S; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_USER_DATA_H_
|
||||
#define _VL53L1_PLATFORM_USER_DATA_H_
|
||||
#include "stm32xxx_hal.h"
|
||||
//#include "vl53l1_def.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
||||
VL53L1_DevData_t Data;
|
||||
|
||||
uint8_t I2cDevAddr;
|
||||
uint8_t comms_type;
|
||||
uint16_t comms_speed_khz;
|
||||
uint32_t new_data_ready_poll_duration_ms;
|
||||
I2C_HandleTypeDef *I2cHandle;
|
||||
|
||||
} VL53L1_Dev_t;
|
||||
|
||||
typedef VL53L1_Dev_t *VL53L1_DEV;
|
||||
|
||||
#define VL53L1DevDataGet(Dev, field) (Dev->Data.field)
|
||||
#define VL53L1DevDataSet(Dev, field, VL53L1_PRM_00005) ((Dev->Data.field) = (VL53L1_PRM_00005))
|
||||
#define VL53L1DevStructGetLLDriverHandle(Dev) (&Dev->Data.LLData)
|
||||
#define VL53L1DevStructGetLLResultsHandle(Dev) (&Dev->Data.llresults)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
95
Firmware/Core/Inc/vl53l1_platform_user_defines.h
Normal file
95
Firmware/Core/Inc/vl53l1_platform_user_defines.h
Normal file
@ -0,0 +1,95 @@
|
||||
/*******************************************************************************
|
||||
Copyright (C) 2016, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_USER_DEFINES_H_
|
||||
#define _VL53L1_PLATFORM_USER_DEFINES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_user_defines.h
|
||||
*
|
||||
* @brief All end user OS/platform/application definitions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @def do_division_u
|
||||
* @brief customer supplied division operation - 64-bit unsigned
|
||||
*
|
||||
* @param dividend unsigned 64-bit numerator
|
||||
* @param divisor unsigned 64-bit denominator
|
||||
*/
|
||||
#define do_division_u(dividend, divisor) (dividend / divisor)
|
||||
|
||||
|
||||
/**
|
||||
* @def do_division_s
|
||||
* @brief customer supplied division operation - 64-bit signed
|
||||
*
|
||||
* @param dividend signed 64-bit numerator
|
||||
* @param divisor signed 64-bit denominator
|
||||
*/
|
||||
#define do_division_s(dividend, divisor) (dividend / divisor)
|
||||
|
||||
|
||||
/**
|
||||
* @def WARN_OVERRIDE_STATUS
|
||||
* @brief customer supplied macro to optionally output info when a specific
|
||||
error has been overridden with success within the EwokPlus driver
|
||||
*
|
||||
* @param __X__ the macro which enabled the suppression
|
||||
*/
|
||||
#define WARN_OVERRIDE_STATUS(__X__)\
|
||||
trace_print (VL53L1_TRACE_LEVEL_WARNING, #__X__);
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define DISABLE_WARNINGS() { \
|
||||
__pragma (warning (push)); \
|
||||
__pragma (warning (disable:4127)); \
|
||||
}
|
||||
#define ENABLE_WARNINGS() { \
|
||||
__pragma (warning (pop)); \
|
||||
}
|
||||
#else
|
||||
#define DISABLE_WARNINGS()
|
||||
#define ENABLE_WARNINGS()
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _VL53L1_PLATFORM_USER_DEFINES_H_
|
||||
|
114
Firmware/Core/Inc/vl53l1_types.h
Normal file
114
Firmware/Core/Inc/vl53l1_types.h
Normal file
@ -0,0 +1,114 @@
|
||||
/*******************************************************************************
|
||||
Copyright (C) 2015, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
********************************************************************************/
|
||||
/**
|
||||
* @file vl53l1_types.h
|
||||
* @brief VL53L1 types definition
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_TYPES_H_
|
||||
#define _VL53L1_TYPES_H_
|
||||
|
||||
/** @defgroup porting_type Basic type definition
|
||||
* @ingroup api_platform
|
||||
*
|
||||
* @brief file vl53l1_types.h files hold basic type definition that may requires porting
|
||||
*
|
||||
* contains type that must be defined for the platform\n
|
||||
* when target platform and compiler provide stdint.h and stddef.h it is enough to include it.\n
|
||||
* If stdint.h is not available review and adapt all signed and unsigned 8/16/32 bits basic types. \n
|
||||
* If stddef.h is not available review and adapt NULL definition .
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef NULL
|
||||
#error "Error NULL definition should be done. Please add required include "
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(STDINT_H) && !defined(_STDINT_H) && !defined(_GCC_STDINT_H) && !defined(__STDINT_DECLS) && !defined(_GCC_WRAP_STDINT_H) && !defined(_STDINT)
|
||||
|
||||
#pragma message("Please review type definition of STDINT define for your platform and add to list above ")
|
||||
|
||||
/*
|
||||
* target platform do not provide stdint or use a different #define than above
|
||||
* to avoid seeing the message below addapt the #define list above or implement
|
||||
* all type and delete these pragma
|
||||
*/
|
||||
|
||||
/** \ingroup VL53L1_portingType_group
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
|
||||
/** @brief Typedef defining 32 bit unsigned int type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
/** @brief Typedef defining 32 bit int type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef int int32_t;
|
||||
|
||||
/** @brief Typedef defining 16 bit unsigned short type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef unsigned short uint16_t;
|
||||
|
||||
/** @brief Typedef defining 16 bit short type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef short int16_t;
|
||||
|
||||
/** @brief Typedef defining 8 bit unsigned char type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
/** @brief Typedef defining 8 bit char type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef signed char int8_t;
|
||||
|
||||
/** @} */
|
||||
#endif /* _STDINT_H */
|
||||
|
||||
|
||||
/** use where fractional values are expected
|
||||
*
|
||||
* Given a floating point value f it's .16 bit point is (int)(f*(1<<16))*/
|
||||
typedef uint32_t FixPoint1616_t;
|
||||
|
||||
#endif /* VL53L1_TYPES_H_ */
|
Reference in New Issue
Block a user