From 11003a1eab2bc4bd38ec6c6e1b4096ddb1aed20f Mon Sep 17 00:00:00 2001 From: Adam Prochazka Date: Sun, 16 Apr 2023 23:22:34 +0200 Subject: [PATCH] Add distance sensor, README update in next commit --- Firmware/CMakeLists.txt | 5 - Firmware/Core/Inc/VL53L1X_api.h | 393 ++++++++ Firmware/Core/Inc/VL53L1X_calibration.h | 93 ++ Firmware/Core/Inc/main.h | 10 +- Firmware/Core/Inc/mxconstants.h | 68 ++ Firmware/Core/Inc/stm32xxx_hal.h | 73 ++ Firmware/Core/Inc/vl53l1_error_codes.h | 253 ++++++ Firmware/Core/Inc/vl53l1_platform.h | 91 ++ Firmware/Core/Inc/vl53l1_platform_log.h | 223 +++++ .../Core/Inc/vl53l1_platform_user_config.h | 84 ++ Firmware/Core/Inc/vl53l1_platform_user_data.h | 66 ++ .../Core/Inc/vl53l1_platform_user_defines.h | 95 ++ Firmware/Core/Inc/vl53l1_types.h | 114 +++ Firmware/Core/Src/VL53L1X_api.c | 855 ++++++++++++++++++ Firmware/Core/Src/VL53L1X_calibration.c | 138 +++ Firmware/Core/Src/main.c | 67 +- Firmware/Core/Src/syscalls.c | 78 ++ Firmware/Core/Src/vl53l1_platform.c | 458 ++++++++++ Receiver/Displayer.o | Bin 12776 -> 0 bytes Receiver/Receiver.cpp | 53 +- Receiver/Receiver.hpp | 6 +- Receiver/Receiver.o | Bin 20856 -> 0 bytes Receiver/main | Bin 38920 -> 0 bytes Receiver/main.o | Bin 15200 -> 0 bytes 24 files changed, 3208 insertions(+), 15 deletions(-) create mode 100644 Firmware/Core/Inc/VL53L1X_api.h create mode 100644 Firmware/Core/Inc/VL53L1X_calibration.h create mode 100644 Firmware/Core/Inc/mxconstants.h create mode 100644 Firmware/Core/Inc/stm32xxx_hal.h create mode 100644 Firmware/Core/Inc/vl53l1_error_codes.h create mode 100644 Firmware/Core/Inc/vl53l1_platform.h create mode 100644 Firmware/Core/Inc/vl53l1_platform_log.h create mode 100644 Firmware/Core/Inc/vl53l1_platform_user_config.h create mode 100644 Firmware/Core/Inc/vl53l1_platform_user_data.h create mode 100644 Firmware/Core/Inc/vl53l1_platform_user_defines.h create mode 100644 Firmware/Core/Inc/vl53l1_types.h create mode 100644 Firmware/Core/Src/VL53L1X_api.c create mode 100644 Firmware/Core/Src/VL53L1X_calibration.c create mode 100644 Firmware/Core/Src/syscalls.c create mode 100644 Firmware/Core/Src/vl53l1_platform.c delete mode 100644 Receiver/Displayer.o delete mode 100644 Receiver/Receiver.o delete mode 100755 Receiver/main delete mode 100644 Receiver/main.o diff --git a/Firmware/CMakeLists.txt b/Firmware/CMakeLists.txt index 6531502..0874c0d 100644 --- a/Firmware/CMakeLists.txt +++ b/Firmware/CMakeLists.txt @@ -69,11 +69,6 @@ ${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/*.c ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/*.c) -#set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Project) -#file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS -# ${PROJECT_DIR}/*.cpp -# ${PROJECT_DIR}/*.c) - set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Core/Src) file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS ${PROJECT_DIR}/*.cpp diff --git a/Firmware/Core/Inc/VL53L1X_api.h b/Firmware/Core/Inc/VL53L1X_api.h new file mode 100644 index 0000000..fc93e56 --- /dev/null +++ b/Firmware/Core/Inc/VL53L1X_api.h @@ -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 diff --git a/Firmware/Core/Inc/VL53L1X_calibration.h b/Firmware/Core/Inc/VL53L1X_calibration.h new file mode 100644 index 0000000..c057722 --- /dev/null +++ b/Firmware/Core/Inc/VL53L1X_calibration.h @@ -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 diff --git a/Firmware/Core/Inc/main.h b/Firmware/Core/Inc/main.h index a819d7b..2e40a16 100644 --- a/Firmware/Core/Inc/main.h +++ b/Firmware/Core/Inc/main.h @@ -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 diff --git a/Firmware/Core/Inc/mxconstants.h b/Firmware/Core/Inc/mxconstants.h new file mode 100644 index 0000000..581a6af --- /dev/null +++ b/Firmware/Core/Inc/mxconstants.h @@ -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****/ diff --git a/Firmware/Core/Inc/stm32xxx_hal.h b/Firmware/Core/Inc/stm32xxx_hal.h new file mode 100644 index 0000000..5ad504b --- /dev/null +++ b/Firmware/Core/Inc/stm32xxx_hal.h @@ -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****/ diff --git a/Firmware/Core/Inc/vl53l1_error_codes.h b/Firmware/Core/Inc/vl53l1_error_codes.h new file mode 100644 index 0000000..1d58a2f --- /dev/null +++ b/Firmware/Core/Inc/vl53l1_error_codes.h @@ -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_ */ diff --git a/Firmware/Core/Inc/vl53l1_platform.h b/Firmware/Core/Inc/vl53l1_platform.h new file mode 100644 index 0000000..fb4a3d5 --- /dev/null +++ b/Firmware/Core/Inc/vl53l1_platform.h @@ -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 diff --git a/Firmware/Core/Inc/vl53l1_platform_log.h b/Firmware/Core/Inc/vl53l1_platform_log.h new file mode 100644 index 0000000..f304159 --- /dev/null +++ b/Firmware/Core/Inc/vl53l1_platform_log.h @@ -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 + + /** + * @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 %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 %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 %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_ */ diff --git a/Firmware/Core/Inc/vl53l1_platform_user_config.h b/Firmware/Core/Inc/vl53l1_platform_user_config.h new file mode 100644 index 0000000..8ed5a6a --- /dev/null +++ b/Firmware/Core/Inc/vl53l1_platform_user_config.h @@ -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_ */ + diff --git a/Firmware/Core/Inc/vl53l1_platform_user_data.h b/Firmware/Core/Inc/vl53l1_platform_user_data.h new file mode 100644 index 0000000..1bd078e --- /dev/null +++ b/Firmware/Core/Inc/vl53l1_platform_user_data.h @@ -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 diff --git a/Firmware/Core/Inc/vl53l1_platform_user_defines.h b/Firmware/Core/Inc/vl53l1_platform_user_defines.h new file mode 100644 index 0000000..b1a0091 --- /dev/null +++ b/Firmware/Core/Inc/vl53l1_platform_user_defines.h @@ -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_ + diff --git a/Firmware/Core/Inc/vl53l1_types.h b/Firmware/Core/Inc/vl53l1_types.h new file mode 100644 index 0000000..4e4e619 --- /dev/null +++ b/Firmware/Core/Inc/vl53l1_types.h @@ -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 +#include +#include +#include +#include + +#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_ */ diff --git a/Firmware/Core/Src/VL53L1X_api.c b/Firmware/Core/Src/VL53L1X_api.c new file mode 100644 index 0000000..572040d --- /dev/null +++ b/Firmware/Core/Src/VL53L1X_api.c @@ -0,0 +1,855 @@ +/* + 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.c + * @brief Functions implementation + */ + +#include "VL53L1X_api.h" +#include + +#if 0 +uint8_t VL51L1X_NVM_CONFIGURATION[] = { +0x00, /* 0x00 : not user-modifiable */ +0x29, /* 0x01 : 7 bits I2C address (default=0x29), use SetI2CAddress(). Warning: after changing the register value to a new I2C address, the device will only answer to the new address */ +0x00, /* 0x02 : not user-modifiable */ +0x00, /* 0x03 : not user-modifiable */ +0x00, /* 0x04 : not user-modifiable */ +0x00, /* 0x05 : not user-modifiable */ +0x00, /* 0x06 : not user-modifiable */ +0x00, /* 0x07 : not user-modifiable */ +0x00, /* 0x08 : not user-modifiable */ +0x50, /* 0x09 : not user-modifiable */ +0x00, /* 0x0A : not user-modifiable */ +0x00, /* 0x0B : not user-modifiable */ +0x00, /* 0x0C : not user-modifiable */ +0x00, /* 0x0D : not user-modifiable */ +0x0a, /* 0x0E : not user-modifiable */ +0x00, /* 0x0F : not user-modifiable */ +0x00, /* 0x10 : not user-modifiable */ +0x00, /* 0x11 : not user-modifiable */ +0x00, /* 0x12 : not user-modifiable */ +0x00, /* 0x13 : not user-modifiable */ +0x00, /* 0x14 : not user-modifiable */ +0x00, /* 0x15 : not user-modifiable */ +0x00, /* 0x16 : Xtalk calibration value MSB (7.9 format in kcps), use SetXtalk() */ +0x00, /* 0x17 : Xtalk calibration value LSB */ +0x00, /* 0x18 : not user-modifiable */ +0x00, /* 0x19 : not user-modifiable */ +0x00, /* 0x1a : not user-modifiable */ +0x00, /* 0x1b : not user-modifiable */ +0x00, /* 0x1e : Part to Part offset x4 MSB (in mm), use SetOffset() */ +0x50, /* 0x1f : Part to Part offset x4 LSB */ +0x00, /* 0x20 : not user-modifiable */ +0x00, /* 0x21 : not user-modifiable */ +0x00, /* 0x22 : not user-modifiable */ +0x00, /* 0x23 : not user-modifiable */ +} +#endif + +const uint8_t VL51L1X_DEFAULT_CONFIGURATION[] = { +0x00, /* 0x2d : set bit 2 and 5 to 1 for fast plus mode (1MHz I2C), else don't touch */ +0x00, /* 0x2e : bit 0 if I2C pulled up at 1.8V, else set bit 0 to 1 (pull up at AVDD) */ +0x00, /* 0x2f : bit 0 if GPIO pulled up at 1.8V, else set bit 0 to 1 (pull up at AVDD) */ +0x01, /* 0x30 : set bit 4 to 0 for active high interrupt and 1 for active low (bits 3:0 must be 0x1), use SetInterruptPolarity() */ +0x02, /* 0x31 : bit 1 = interrupt depending on the polarity, use CheckForDataReady() */ +0x00, /* 0x32 : not user-modifiable */ +0x02, /* 0x33 : not user-modifiable */ +0x08, /* 0x34 : not user-modifiable */ +0x00, /* 0x35 : not user-modifiable */ +0x08, /* 0x36 : not user-modifiable */ +0x10, /* 0x37 : not user-modifiable */ +0x01, /* 0x38 : not user-modifiable */ +0x01, /* 0x39 : not user-modifiable */ +0x00, /* 0x3a : not user-modifiable */ +0x00, /* 0x3b : not user-modifiable */ +0x00, /* 0x3c : not user-modifiable */ +0x00, /* 0x3d : not user-modifiable */ +0xff, /* 0x3e : not user-modifiable */ +0x00, /* 0x3f : not user-modifiable */ +0x0F, /* 0x40 : not user-modifiable */ +0x00, /* 0x41 : not user-modifiable */ +0x00, /* 0x42 : not user-modifiable */ +0x00, /* 0x43 : not user-modifiable */ +0x00, /* 0x44 : not user-modifiable */ +0x00, /* 0x45 : not user-modifiable */ +0x20, /* 0x46 : interrupt configuration 0->level low detection, 1-> level high, 2-> Out of window, 3->In window, 0x20-> New sample ready , TBC */ +0x0b, /* 0x47 : not user-modifiable */ +0x00, /* 0x48 : not user-modifiable */ +0x00, /* 0x49 : not user-modifiable */ +0x02, /* 0x4a : not user-modifiable */ +0x0a, /* 0x4b : not user-modifiable */ +0x21, /* 0x4c : not user-modifiable */ +0x00, /* 0x4d : not user-modifiable */ +0x00, /* 0x4e : not user-modifiable */ +0x05, /* 0x4f : not user-modifiable */ +0x00, /* 0x50 : not user-modifiable */ +0x00, /* 0x51 : not user-modifiable */ +0x00, /* 0x52 : not user-modifiable */ +0x00, /* 0x53 : not user-modifiable */ +0xc8, /* 0x54 : not user-modifiable */ +0x00, /* 0x55 : not user-modifiable */ +0x00, /* 0x56 : not user-modifiable */ +0x38, /* 0x57 : not user-modifiable */ +0xff, /* 0x58 : not user-modifiable */ +0x01, /* 0x59 : not user-modifiable */ +0x00, /* 0x5a : not user-modifiable */ +0x08, /* 0x5b : not user-modifiable */ +0x00, /* 0x5c : not user-modifiable */ +0x00, /* 0x5d : not user-modifiable */ +0x01, /* 0x5e : not user-modifiable */ +0xcc, /* 0x5f : not user-modifiable */ +0x0f, /* 0x60 : not user-modifiable */ +0x01, /* 0x61 : not user-modifiable */ +0xf1, /* 0x62 : not user-modifiable */ +0x0d, /* 0x63 : not user-modifiable */ +0x01, /* 0x64 : Sigma threshold MSB (mm in 14.2 format for MSB+LSB), use SetSigmaThreshold(), default value 90 mm */ +0x68, /* 0x65 : Sigma threshold LSB */ +0x00, /* 0x66 : Min count Rate MSB (MCPS in 9.7 format for MSB+LSB), use SetSignalThreshold() */ +0x80, /* 0x67 : Min count Rate LSB */ +0x08, /* 0x68 : not user-modifiable */ +0xb8, /* 0x69 : not user-modifiable */ +0x00, /* 0x6a : not user-modifiable */ +0x00, /* 0x6b : not user-modifiable */ +0x00, /* 0x6c : Intermeasurement period MSB, 32 bits register, use SetIntermeasurementInMs() */ +0x00, /* 0x6d : Intermeasurement period */ +0x0f, /* 0x6e : Intermeasurement period */ +0x89, /* 0x6f : Intermeasurement period LSB */ +0x00, /* 0x70 : not user-modifiable */ +0x00, /* 0x71 : not user-modifiable */ +0x00, /* 0x72 : distance threshold high MSB (in mm, MSB+LSB), use SetD:tanceThreshold() */ +0x00, /* 0x73 : distance threshold high LSB */ +0x00, /* 0x74 : distance threshold low MSB ( in mm, MSB+LSB), use SetD:tanceThreshold() */ +0x00, /* 0x75 : distance threshold low LSB */ +0x00, /* 0x76 : not user-modifiable */ +0x01, /* 0x77 : not user-modifiable */ +0x0f, /* 0x78 : not user-modifiable */ +0x0d, /* 0x79 : not user-modifiable */ +0x0e, /* 0x7a : not user-modifiable */ +0x0e, /* 0x7b : not user-modifiable */ +0x00, /* 0x7c : not user-modifiable */ +0x00, /* 0x7d : not user-modifiable */ +0x02, /* 0x7e : not user-modifiable */ +0xc7, /* 0x7f : ROI center, use SetROI() */ +0xff, /* 0x80 : XY ROI (X=Width, Y=Height), use SetROI() */ +0x9B, /* 0x81 : not user-modifiable */ +0x00, /* 0x82 : not user-modifiable */ +0x00, /* 0x83 : not user-modifiable */ +0x00, /* 0x84 : not user-modifiable */ +0x01, /* 0x85 : not user-modifiable */ +0x00, /* 0x86 : clear interrupt, use ClearInterrupt() */ +0x00 /* 0x87 : start ranging, use StartRanging() or StopRanging(), If you want an automatic start after VL53L1X_init() call, put 0x40 in location 0x87 */ +}; + +static const uint8_t status_rtn[24] = { 255, 255, 255, 5, 2, 4, 1, 7, 3, 0, + 255, 255, 9, 13, 255, 255, 255, 255, 10, 6, + 255, 255, 11, 12 +}; + +VL53L1X_ERROR VL53L1X_GetSWVersion(VL53L1X_Version_t *pVersion) +{ + VL53L1X_ERROR Status = 0; + + pVersion->major = VL53L1X_IMPLEMENTATION_VER_MAJOR; + pVersion->minor = VL53L1X_IMPLEMENTATION_VER_MINOR; + pVersion->build = VL53L1X_IMPLEMENTATION_VER_SUB; + pVersion->revision = VL53L1X_IMPLEMENTATION_VER_REVISION; + return Status; +} + +VL53L1X_ERROR VL53L1X_SetI2CAddress(uint16_t dev, uint8_t new_address) +{ + VL53L1X_ERROR status = 0; + + status |= VL53L1_WrByte(dev, VL53L1_I2C_SLAVE__DEVICE_ADDRESS, new_address >> 1); + return status; +} + +VL53L1X_ERROR VL53L1X_SensorInit(uint16_t dev) +{ + VL53L1X_ERROR status = 0; + uint8_t Addr = 0x00, tmp; + + for (Addr = 0x2D; Addr <= 0x87; Addr++){ + status |= VL53L1_WrByte(dev, Addr, VL51L1X_DEFAULT_CONFIGURATION[Addr - 0x2D]); + } + status |= VL53L1X_StartRanging(dev); + tmp = 0; + while(tmp==0){ + status |= VL53L1X_CheckForDataReady(dev, &tmp); + } + status |= VL53L1X_ClearInterrupt(dev); + status |= VL53L1X_StopRanging(dev); + status |= VL53L1_WrByte(dev, VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND, 0x09); /* two bounds VHV */ + status |= VL53L1_WrByte(dev, 0x0B, 0); /* start VHV from the previous temperature */ + return status; +} + +VL53L1X_ERROR VL53L1X_ClearInterrupt(uint16_t dev) +{ + VL53L1X_ERROR status = 0; + + status |= VL53L1_WrByte(dev, SYSTEM__INTERRUPT_CLEAR, 0x01); + return status; +} + +VL53L1X_ERROR VL53L1X_SetInterruptPolarity(uint16_t dev, uint8_t NewPolarity) +{ + uint8_t Temp; + VL53L1X_ERROR status = 0; + + status |= VL53L1_RdByte(dev, GPIO_HV_MUX__CTRL, &Temp); + Temp = Temp & 0xEF; + status |= VL53L1_WrByte(dev, GPIO_HV_MUX__CTRL, Temp | (!(NewPolarity & 1)) << 4); + return status; +} + +VL53L1X_ERROR VL53L1X_GetInterruptPolarity(uint16_t dev, uint8_t *pInterruptPolarity) +{ + uint8_t Temp; + VL53L1X_ERROR status = 0; + + status |= VL53L1_RdByte(dev, GPIO_HV_MUX__CTRL, &Temp); + Temp = Temp & 0x10; + *pInterruptPolarity = !(Temp>>4); + return status; +} + +VL53L1X_ERROR VL53L1X_StartRanging(uint16_t dev) +{ + VL53L1X_ERROR status = 0; + + status |= VL53L1_WrByte(dev, SYSTEM__MODE_START, 0x40); /* Enable VL53L1X */ + return status; +} + +VL53L1X_ERROR VL53L1X_StopRanging(uint16_t dev) +{ + VL53L1X_ERROR status = 0; + + status |= VL53L1_WrByte(dev, SYSTEM__MODE_START, 0x00); /* Disable VL53L1X */ + return status; +} + +VL53L1X_ERROR VL53L1X_CheckForDataReady(uint16_t dev, uint8_t *isDataReady) +{ + uint8_t Temp; + uint8_t IntPol; + VL53L1X_ERROR status = 0; + + status |= VL53L1X_GetInterruptPolarity(dev, &IntPol); + status |= VL53L1_RdByte(dev, GPIO__TIO_HV_STATUS, &Temp); + /* Read in the register to check if a new value is available */ + if (status == 0){ + if ((Temp & 1) == IntPol) + *isDataReady = 1; + else + *isDataReady = 0; + } + return status; +} + +VL53L1X_ERROR VL53L1X_SetTimingBudgetInMs(uint16_t dev, uint16_t TimingBudgetInMs) +{ + uint16_t DM; + VL53L1X_ERROR status=0; + + status |= VL53L1X_GetDistanceMode(dev, &DM); + if (DM == 0) + return 1; + else if (DM == 1) { /* Short DistanceMode */ + switch (TimingBudgetInMs) { + case 15: /* only available in short distance mode */ + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x01D); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x0027); + break; + case 20: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x0051); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x006E); + break; + case 33: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x00D6); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x006E); + break; + case 50: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x1AE); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x01E8); + break; + case 100: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x02E1); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x0388); + break; + case 200: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x03E1); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x0496); + break; + case 500: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x0591); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x05C1); + break; + default: + status = 1; + break; + } + } else { + switch (TimingBudgetInMs) { + case 20: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x001E); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x0022); + break; + case 33: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x0060); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x006E); + break; + case 50: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x00AD); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x00C6); + break; + case 100: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x01CC); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x01EA); + break; + case 200: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x02D9); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x02F8); + break; + case 500: + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, + 0x048F); + VL53L1_WrWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_B_HI, + 0x04A4); + break; + default: + status = 1; + break; + } + } + return status; +} + +VL53L1X_ERROR VL53L1X_GetTimingBudgetInMs(uint16_t dev, uint16_t *pTimingBudget) +{ + uint16_t Temp; + VL53L1X_ERROR status = 0; + + status |= VL53L1_RdWord(dev, RANGE_CONFIG__TIMEOUT_MACROP_A_HI, &Temp); + switch (Temp) { + case 0x001D : + *pTimingBudget = 15; + break; + case 0x0051 : + case 0x001E : + *pTimingBudget = 20; + break; + case 0x00D6 : + case 0x0060 : + *pTimingBudget = 33; + break; + case 0x1AE : + case 0x00AD : + *pTimingBudget = 50; + break; + case 0x02E1 : + case 0x01CC : + *pTimingBudget = 100; + break; + case 0x03E1 : + case 0x02D9 : + *pTimingBudget = 200; + break; + case 0x0591 : + case 0x048F : + *pTimingBudget = 500; + break; + default: + status = 1; + *pTimingBudget = 0; + } + return status; +} + +VL53L1X_ERROR VL53L1X_SetDistanceMode(uint16_t dev, uint16_t DM) +{ + uint16_t TB; + VL53L1X_ERROR status = 0; + + status |= VL53L1X_GetTimingBudgetInMs(dev, &TB); + if (status != 0) + return 1; + switch (DM) { + case 1: + status = VL53L1_WrByte(dev, PHASECAL_CONFIG__TIMEOUT_MACROP, 0x14); + status = VL53L1_WrByte(dev, RANGE_CONFIG__VCSEL_PERIOD_A, 0x07); + status = VL53L1_WrByte(dev, RANGE_CONFIG__VCSEL_PERIOD_B, 0x05); + status = VL53L1_WrByte(dev, RANGE_CONFIG__VALID_PHASE_HIGH, 0x38); + status = VL53L1_WrWord(dev, SD_CONFIG__WOI_SD0, 0x0705); + status = VL53L1_WrWord(dev, SD_CONFIG__INITIAL_PHASE_SD0, 0x0606); + break; + case 2: + status = VL53L1_WrByte(dev, PHASECAL_CONFIG__TIMEOUT_MACROP, 0x0A); + status = VL53L1_WrByte(dev, RANGE_CONFIG__VCSEL_PERIOD_A, 0x0F); + status = VL53L1_WrByte(dev, RANGE_CONFIG__VCSEL_PERIOD_B, 0x0D); + status = VL53L1_WrByte(dev, RANGE_CONFIG__VALID_PHASE_HIGH, 0xB8); + status = VL53L1_WrWord(dev, SD_CONFIG__WOI_SD0, 0x0F0D); + status = VL53L1_WrWord(dev, SD_CONFIG__INITIAL_PHASE_SD0, 0x0E0E); + break; + default: + status = 1; + break; + } + + if (status == 0) + status |= VL53L1X_SetTimingBudgetInMs(dev, TB); + return status; +} + +VL53L1X_ERROR VL53L1X_GetDistanceMode(uint16_t dev, uint16_t *DM) +{ + uint8_t TempDM, status=0; + + status |= VL53L1_RdByte(dev,PHASECAL_CONFIG__TIMEOUT_MACROP, &TempDM); + if (TempDM == 0x14) + *DM=1; + if(TempDM == 0x0A) + *DM=2; + return status; +} + +VL53L1X_ERROR VL53L1X_SetInterMeasurementInMs(uint16_t dev, uint32_t InterMeasMs) +{ + uint16_t ClockPLL; + VL53L1X_ERROR status = 0; + + status |= VL53L1_RdWord(dev, VL53L1_RESULT__OSC_CALIBRATE_VAL, &ClockPLL); + ClockPLL = ClockPLL&0x3FF; + VL53L1_WrDWord(dev, VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD, + (uint32_t)(ClockPLL * InterMeasMs * 1.075)); + return status; + +} + +VL53L1X_ERROR VL53L1X_GetInterMeasurementInMs(uint16_t dev, uint16_t *pIM) +{ + uint16_t ClockPLL; + VL53L1X_ERROR status = 0; + uint32_t tmp; + + status |= VL53L1_RdDWord(dev,VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD, &tmp); + *pIM = (uint16_t)tmp; + status |= VL53L1_RdWord(dev, VL53L1_RESULT__OSC_CALIBRATE_VAL, &ClockPLL); + ClockPLL = ClockPLL&0x3FF; + *pIM= (uint16_t)(*pIM/(ClockPLL*1.065)); + return status; +} + +VL53L1X_ERROR VL53L1X_BootState(uint16_t dev, uint8_t *state) +{ + VL53L1X_ERROR status = 0; + uint8_t tmp = 0; + + status |= VL53L1_RdByte(dev,VL53L1_FIRMWARE__SYSTEM_STATUS, &tmp); + *state = tmp; + return status; +} + +VL53L1X_ERROR VL53L1X_GetSensorId(uint16_t dev, uint16_t *sensorId) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp = 0; + + status |= VL53L1_RdWord(dev, VL53L1_IDENTIFICATION__MODEL_ID, &tmp); + *sensorId = tmp; + return status; +} + +VL53L1X_ERROR VL53L1X_GetDistance(uint16_t dev, uint16_t *distance) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp; + + status |= (VL53L1_RdWord(dev, + VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0, &tmp)); + *distance = tmp; + return status; +} + +VL53L1X_ERROR VL53L1X_GetSignalPerSpad(uint16_t dev, uint16_t *signalRate) +{ + VL53L1X_ERROR status = 0; + uint16_t SpNb=1, signal; + + status |= VL53L1_RdWord(dev, + VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0, &signal); + status |= VL53L1_RdWord(dev, + VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0, &SpNb); + *signalRate = (uint16_t) (200.0*signal/SpNb); + return status; +} + +VL53L1X_ERROR VL53L1X_GetAmbientPerSpad(uint16_t dev, uint16_t *ambPerSp) +{ + VL53L1X_ERROR status = 0; + uint16_t AmbientRate, SpNb = 1; + + status |= VL53L1_RdWord(dev, RESULT__AMBIENT_COUNT_RATE_MCPS_SD, &AmbientRate); + status |= VL53L1_RdWord(dev, VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0, &SpNb); + *ambPerSp=(uint16_t) (200.0 * AmbientRate / SpNb); + return status; +} + +VL53L1X_ERROR VL53L1X_GetSignalRate(uint16_t dev, uint16_t *signal) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp; + + status |= VL53L1_RdWord(dev, + VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0, &tmp); + *signal = tmp*8; + return status; +} + +VL53L1X_ERROR VL53L1X_GetSpadNb(uint16_t dev, uint16_t *spNb) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp; + + status |= VL53L1_RdWord(dev, + VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0, &tmp); + *spNb = tmp >> 8; + return status; +} + +VL53L1X_ERROR VL53L1X_GetAmbientRate(uint16_t dev, uint16_t *ambRate) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp; + + status |= VL53L1_RdWord(dev, RESULT__AMBIENT_COUNT_RATE_MCPS_SD, &tmp); + *ambRate = tmp*8; + return status; +} + +VL53L1X_ERROR VL53L1X_GetRangeStatus(uint16_t dev, uint8_t *rangeStatus) +{ + VL53L1X_ERROR status = 0; + uint8_t RgSt; + + *rangeStatus = 255; + status |= VL53L1_RdByte(dev, VL53L1_RESULT__RANGE_STATUS, &RgSt); + RgSt = RgSt & 0x1F; + if (RgSt < 24) + *rangeStatus = status_rtn[RgSt]; + return status; +} + +VL53L1X_ERROR VL53L1X_GetResult(uint16_t dev, VL53L1X_Result_t *pResult) +{ + VL53L1X_ERROR status = 0; + uint8_t Temp[17]; + uint8_t RgSt = 255; + + status |= VL53L1_ReadMulti(dev, VL53L1_RESULT__RANGE_STATUS, Temp, 17); + RgSt = Temp[0] & 0x1F; + if (RgSt < 24) + RgSt = status_rtn[RgSt]; + pResult->Status = RgSt; + pResult->Ambient = (Temp[7] << 8 | Temp[8]) * 8; + pResult->NumSPADs = Temp[3]; + pResult->SigPerSPAD = (Temp[15] << 8 | Temp[16]) * 8; + pResult->Distance = Temp[13] << 8 | Temp[14]; + + return status; +} + +VL53L1X_ERROR VL53L1X_SetOffset(uint16_t dev, int16_t OffsetValue) +{ + VL53L1X_ERROR status = 0; + int16_t Temp; + + Temp = (OffsetValue*4); + status |= VL53L1_WrWord(dev, ALGO__PART_TO_PART_RANGE_OFFSET_MM, + (uint16_t)Temp); + status |= VL53L1_WrWord(dev, MM_CONFIG__INNER_OFFSET_MM, 0x0); + status |= VL53L1_WrWord(dev, MM_CONFIG__OUTER_OFFSET_MM, 0x0); + return status; +} + +VL53L1X_ERROR VL53L1X_GetOffset(uint16_t dev, int16_t *offset) +{ + VL53L1X_ERROR status = 0; + uint16_t Temp; + + status |= VL53L1_RdWord(dev,ALGO__PART_TO_PART_RANGE_OFFSET_MM, &Temp); + Temp = Temp<<3; + Temp = Temp>>5; + *offset = (int16_t)(Temp); + + if(*offset > 1024) + { + *offset = *offset - 2048; + } + + return status; +} + +VL53L1X_ERROR VL53L1X_SetXtalk(uint16_t dev, uint16_t XtalkValue) +{ +/* XTalkValue in count per second to avoid float type */ + VL53L1X_ERROR status = 0; + + status |= VL53L1_WrWord(dev, + ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS, + 0x0000); + status |= VL53L1_WrWord(dev, ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS, + 0x0000); + status |= VL53L1_WrWord(dev, ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS, + (XtalkValue<<9)/1000); /* * << 9 (7.9 format) and /1000 to convert cps to kpcs */ + return status; +} + +VL53L1X_ERROR VL53L1X_GetXtalk(uint16_t dev, uint16_t *xtalk ) +{ + VL53L1X_ERROR status = 0; + + status |= VL53L1_RdWord(dev,ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS, xtalk); + *xtalk = (uint16_t)((*xtalk*1000)>>9); /* * 1000 to convert kcps to cps and >> 9 (7.9 format) */ + return status; +} + +VL53L1X_ERROR VL53L1X_SetDistanceThreshold(uint16_t dev, uint16_t ThreshLow, + uint16_t ThreshHigh, uint8_t Window, + uint8_t IntOnNoTarget) +{ + VL53L1X_ERROR status = 0; + uint8_t Temp = 0; + + status |= VL53L1_RdByte(dev, SYSTEM__INTERRUPT_CONFIG_GPIO, &Temp); + Temp = Temp & 0x47; + if (IntOnNoTarget == 0) { + status = VL53L1_WrByte(dev, SYSTEM__INTERRUPT_CONFIG_GPIO, + (Temp | (Window & 0x07))); + } else { + status = VL53L1_WrByte(dev, SYSTEM__INTERRUPT_CONFIG_GPIO, + ((Temp | (Window & 0x07)) | 0x40)); + } + status |= VL53L1_WrWord(dev, SYSTEM__THRESH_HIGH, ThreshHigh); + status |= VL53L1_WrWord(dev, SYSTEM__THRESH_LOW, ThreshLow); + return status; +} + +VL53L1X_ERROR VL53L1X_GetDistanceThresholdWindow(uint16_t dev, uint16_t *window) +{ + VL53L1X_ERROR status = 0; + uint8_t tmp; + status |= VL53L1_RdByte(dev,SYSTEM__INTERRUPT_CONFIG_GPIO, &tmp); + *window = (uint16_t)(tmp & 0x7); + return status; +} + +VL53L1X_ERROR VL53L1X_GetDistanceThresholdLow(uint16_t dev, uint16_t *low) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp; + + status |= VL53L1_RdWord(dev,SYSTEM__THRESH_LOW, &tmp); + *low = tmp; + return status; +} + +VL53L1X_ERROR VL53L1X_GetDistanceThresholdHigh(uint16_t dev, uint16_t *high) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp; + + status |= VL53L1_RdWord(dev,SYSTEM__THRESH_HIGH, &tmp); + *high = tmp; + return status; +} + +VL53L1X_ERROR VL53L1X_SetROICenter(uint16_t dev, uint8_t ROICenter) +{ + VL53L1X_ERROR status = 0; + status |= VL53L1_WrByte(dev, ROI_CONFIG__USER_ROI_CENTRE_SPAD, ROICenter); + return status; +} + +VL53L1X_ERROR VL53L1X_GetROICenter(uint16_t dev, uint8_t *ROICenter) +{ + VL53L1X_ERROR status = 0; + uint8_t tmp; + status |= VL53L1_RdByte(dev, ROI_CONFIG__USER_ROI_CENTRE_SPAD, &tmp); + *ROICenter = tmp; + return status; +} + +VL53L1X_ERROR VL53L1X_SetROI(uint16_t dev, uint16_t X, uint16_t Y) +{ + uint8_t OpticalCenter; + VL53L1X_ERROR status = 0; + + status |=VL53L1_RdByte(dev, VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD, &OpticalCenter); + if (X > 16) + X = 16; + if (Y > 16) + Y = 16; + if (X > 10 || Y > 10){ + OpticalCenter = 199; + } + status |= VL53L1_WrByte(dev, ROI_CONFIG__USER_ROI_CENTRE_SPAD, OpticalCenter); + status |= VL53L1_WrByte(dev, ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE, + (Y - 1) << 4 | (X - 1)); + return status; +} + +VL53L1X_ERROR VL53L1X_GetROI_XY(uint16_t dev, uint16_t *ROI_X, uint16_t *ROI_Y) +{ + VL53L1X_ERROR status = 0; + uint8_t tmp; + + status = VL53L1_RdByte(dev,ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE, &tmp); + *ROI_X |= ((uint16_t)tmp & 0x0F) + 1; + *ROI_Y |= (((uint16_t)tmp & 0xF0) >> 4) + 1; + return status; +} + +VL53L1X_ERROR VL53L1X_SetSignalThreshold(uint16_t dev, uint16_t Signal) +{ + VL53L1X_ERROR status = 0; + + status |= VL53L1_WrWord(dev,RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS,Signal>>3); + return status; +} + +VL53L1X_ERROR VL53L1X_GetSignalThreshold(uint16_t dev, uint16_t *signal) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp; + + status |= VL53L1_RdWord(dev, + RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS, &tmp); + *signal = tmp <<3; + return status; +} + +VL53L1X_ERROR VL53L1X_SetSigmaThreshold(uint16_t dev, uint16_t Sigma) +{ + VL53L1X_ERROR status = 0; + + if(Sigma>(0xFFFF>>2)){ + return 1; + } + /* 16 bits register 14.2 format */ + status |= VL53L1_WrWord(dev,RANGE_CONFIG__SIGMA_THRESH,Sigma<<2); + return status; +} + +VL53L1X_ERROR VL53L1X_GetSigmaThreshold(uint16_t dev, uint16_t *sigma) +{ + VL53L1X_ERROR status = 0; + uint16_t tmp; + + status |= VL53L1_RdWord(dev,RANGE_CONFIG__SIGMA_THRESH, &tmp); + *sigma = tmp >> 2; + return status; + +} + +VL53L1X_ERROR VL53L1X_StartTemperatureUpdate(uint16_t dev) +{ + VL53L1X_ERROR status = 0; + uint8_t tmp=0; + + status |= VL53L1_WrByte(dev,VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND,0x81); /* full VHV */ + status |= VL53L1_WrByte(dev,0x0B,0x92); + status |= VL53L1X_StartRanging(dev); + while(tmp==0){ + status |= VL53L1X_CheckForDataReady(dev, &tmp); + } + tmp = 0; + status |= VL53L1X_ClearInterrupt(dev); + status |= VL53L1X_StopRanging(dev); + status |= VL53L1_WrByte(dev, VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND, 0x09); /* two bounds VHV */ + status |= VL53L1_WrByte(dev, 0x0B, 0); /* start VHV from the previous temperature */ + return status; +} diff --git a/Firmware/Core/Src/VL53L1X_calibration.c b/Firmware/Core/Src/VL53L1X_calibration.c new file mode 100644 index 0000000..0c58fb1 --- /dev/null +++ b/Firmware/Core/Src/VL53L1X_calibration.c @@ -0,0 +1,138 @@ +/* +* 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.c + * @brief Calibration functions implementation + */ +#include "VL53L1X_api.h" +#include "VL53L1X_calibration.h" + +#define ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x001E +#define MM_CONFIG__INNER_OFFSET_MM 0x0020 +#define MM_CONFIG__OUTER_OFFSET_MM 0x0022 + +int8_t VL53L1X_CalibrateOffset(uint16_t dev, uint16_t TargetDistInMm, int16_t *offset) +{ + uint8_t i, tmp; + int16_t AverageDistance = 0; + uint16_t distance; + VL53L1X_ERROR status = 0; + + status |= VL53L1_WrWord(dev, ALGO__PART_TO_PART_RANGE_OFFSET_MM, 0x0); + status |= VL53L1_WrWord(dev, MM_CONFIG__INNER_OFFSET_MM, 0x0); + status |= VL53L1_WrWord(dev, MM_CONFIG__OUTER_OFFSET_MM, 0x0); + status |= VL53L1X_StartRanging(dev); /* Enable VL53L1X sensor */ + for (i = 0; i < 50; i++) { + tmp = 0; + while (tmp == 0){ + status |= VL53L1X_CheckForDataReady(dev, &tmp); + } + status |= VL53L1X_GetDistance(dev, &distance); + status |= VL53L1X_ClearInterrupt(dev); + AverageDistance = AverageDistance + distance; + } + status |= VL53L1X_StopRanging(dev); + AverageDistance = AverageDistance / 50; + *offset = TargetDistInMm - AverageDistance; + status |= VL53L1_WrWord(dev, ALGO__PART_TO_PART_RANGE_OFFSET_MM, *offset*4); + return status; +} + +int8_t VL53L1X_CalibrateXtalk(uint16_t dev, uint16_t TargetDistInMm, uint16_t *xtalk) +{ + uint8_t i, tmp; + float AverageSignalRate = 0; + float AverageDistance = 0; + float AverageSpadNb = 0; + uint16_t distance = 0, spadNum; + uint16_t sr; + VL53L1X_ERROR status = 0; + uint32_t calXtalk; + + status |= VL53L1_WrWord(dev, 0x0016,0); + status |= VL53L1X_StartRanging(dev); + for (i = 0; i < 50; i++) { + tmp = 0; + while (tmp == 0){ + status |= VL53L1X_CheckForDataReady(dev, &tmp); + } + status |= VL53L1X_GetSignalRate(dev, &sr); + status |= VL53L1X_GetDistance(dev, &distance); + status |= VL53L1X_ClearInterrupt(dev); + AverageDistance = AverageDistance + distance; + status = VL53L1X_GetSpadNb(dev, &spadNum); + AverageSpadNb = AverageSpadNb + spadNum; + AverageSignalRate = + AverageSignalRate + sr; + } + status |= VL53L1X_StopRanging(dev); + AverageDistance = AverageDistance / 50; + AverageSpadNb = AverageSpadNb / 50; + AverageSignalRate = AverageSignalRate / 50; + /* Calculate Xtalk value */ + calXtalk = (uint16_t)(512*(AverageSignalRate*(1-(AverageDistance/TargetDistInMm)))/AverageSpadNb); + if(calXtalk > 0xffff) + calXtalk = 0xffff; + *xtalk = (uint16_t)((calXtalk*1000)>>9); + status |= VL53L1_WrWord(dev, 0x0016, (uint16_t)calXtalk); + return status; +} diff --git a/Firmware/Core/Src/main.c b/Firmware/Core/Src/main.c index b328bde..8c1fa21 100644 --- a/Firmware/Core/Src/main.c +++ b/Firmware/Core/Src/main.c @@ -40,7 +40,6 @@ /* Private variables ---------------------------------------------------------*/ I2C_HandleTypeDef hi2c1; - SPI_HandleTypeDef hspi1; DMA_HandleTypeDef hdma_spi1_rx; DMA_HandleTypeDef hdma_spi1_tx; @@ -49,6 +48,11 @@ UART_HandleTypeDef huart2; PCD_HandleTypeDef hpcd_USB_FS; +uint16_t dev=0x52; +int status=0; +volatile int IntCount; +#define isInterrupt 1 /* If isInterrupt = 1 then device working in interrupt mode, else device working in polling mode */ + /* USER CODE BEGIN PV */ //DAC_HandleTypeDef hdac1; @@ -82,6 +86,16 @@ static void MX_USB_PCD_Init(void); int main(void) { /* USER CODE BEGIN 1 */ + //uint8_t byteData, sensorState=0; + //uint16_t wordData; + //uint8_t ToFSensor = 1; // 0=Left, 1=Center(default), 2=Right + uint16_t Distance = 0; + uint16_t SignalRate; + uint16_t AmbientRate; + uint16_t SpadNum; + uint8_t RangeStatus; + //uint8_t dataReady; + /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ @@ -109,9 +123,28 @@ int main(void) MX_I2C1_Init(); MX_USB_PCD_Init(); /* USER CODE BEGIN 2 */ + HAL_PWREx_EnableVddUSB(); + HAL_Delay(100); + + //ToFSensor = 1; // Select ToFSensor: 0=Left, 1=Center, 2=Right + + status = VL53L1X_SensorInit(dev); + status = VL53L1X_SetDistanceMode(dev, 2); + status = VL53L1X_SetTimingBudgetInMs(dev, 100); + status = VL53L1X_SetInterMeasurementInMs(dev, 100); + status = VL53L1X_StartRanging(dev); + + HAL_Delay(1000); + + status = VL53L1X_GetRangeStatus(dev, &RangeStatus); + status = VL53L1X_GetDistance(dev, &Distance); + status = VL53L1X_GetSignalRate(dev, &SignalRate); + status = VL53L1X_GetAmbientRate(dev, &AmbientRate); + status = VL53L1X_GetSpadNb(dev, &SpadNum); + status = VL53L1X_ClearInterrupt(dev); + LED_On(); - HAL_PWREx_EnableVddUSB(); HAL_Delay(1); tud_init(BOARD_DEVICE_RHPORT_NUM); @@ -127,6 +160,7 @@ int main(void) uint8_t cdc_buff[CDC_BUFF_SIZE+CDC_FRAME_SIZE]; for(int i = 0; i < (CDC_BUFF_SIZE+CDC_FRAME_SIZE); i++) cdc_buff[i] = 0x00; + //Distance_Sensor_Init(&hi2c1); Cam_Init(&hi2c1, &hspi1); @@ -146,6 +180,10 @@ int main(void) last_sent_idx = 0; //for(int i = 0; i < CDC_BUFF_SIZE; i++) cdc_buff[i] = 0x00; + + VL53L1X_GetDistance(dev, &Distance); + HAL_Delay(2); + VL53L1X_ClearInterrupt(dev); CS_Off(); CS_On(); @@ -155,6 +193,8 @@ int main(void) image_size = Cam_FIFO_length(&hspi1); Cam_Start_Burst_Read(&hspi1); + //getDistance(&hi2c1); + LED_On(); continue; @@ -198,6 +238,29 @@ int main(void) } while(last_sent_idx < buff_stop_idx); + if(buff_stop_idx >= (int)image_size){ + HAL_Delay(100); + tud_task(); + uint8_t distance_buff[12]; + distance_buff[0] = 0xff; + distance_buff[1] = 0xff; + distance_buff[2] = 0xff; + distance_buff[3] = 0x69; + distance_buff[4] = (uint8_t)(Distance >> 8); + distance_buff[5] = (Distance & 0xff); + distance_buff[6] = 0xff; + distance_buff[7] = 0x69; + distance_buff[8] = 0xff; + distance_buff[9] = 0xff; + distance_buff[10] = '\n'; + distance_buff[11] = '\r'; + + tud_cdc_write(&distance_buff[0], 12); + HAL_Delay(1); + tud_cdc_write_flush(); + HAL_Delay(1); + tud_task(); + } /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ diff --git a/Firmware/Core/Src/syscalls.c b/Firmware/Core/Src/syscalls.c new file mode 100644 index 0000000..186e49e --- /dev/null +++ b/Firmware/Core/Src/syscalls.c @@ -0,0 +1,78 @@ + +/* +* This file is create on December 8 2017 from the original syscalls.c to allow using the _write function in AC6 +* +* 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 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 : syscalls.c +** +** Abstract : System Workbench Minimal System calls file +** +** For more information about which c-functions +** need which of these lowlevel functions +** please consult the Newlib libc-manual +** +** Environment : System Workbench for MCU +** +** Distribution: The file is distributed �as is,� without any warranty +** of any kind. +** +** (c)Copyright System Workbench for MCU. +** You may use this file as-is or modify it according to the needs of your +** project. Distribution of this file (unmodified or modified) is not +** permitted. System Workbench for MCU permit registered System Workbench(R) users the +** rights to distribute the assembled, compiled & linked contents of this +** file as part of an application binary file, provided that it is built +** using the System Workbench for MCU toolchain. +** +***************************************************************************** +*/ + +/* +extern int fputc(int ch) __attribute__((weak)); + + +int _write(int file, char *ptr, int len) +{ + int DataIdx; + + for (DataIdx = 0; DataIdx < len; DataIdx++) + { + fputc(*ptr++); + } + return len; +} +*/ + diff --git a/Firmware/Core/Src/vl53l1_platform.c b/Firmware/Core/Src/vl53l1_platform.c new file mode 100644 index 0000000..1fa6d3f --- /dev/null +++ b/Firmware/Core/Src/vl53l1_platform.c @@ -0,0 +1,458 @@ + +/* +* 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 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. +* +*/ + + +#include "vl53l1_platform.h" +#include "vl53l1_platform_log.h" +//#include "vl53l1_api.h" +#include "vl53l1_platform_user_config.h" +#include "stm32xxx_hal.h" +#include "main.h" +#include +#include +#include +#include "vl53l1_error_codes.h" +//#include "X-NUCLEO-53L1A1.h" + + +#define I2C_TIME_OUT_BASE 10 +#define I2C_TIME_OUT_BYTE 1 + +#ifdef VL53L1_LOG_ENABLE +#define trace_print(level, ...) VL53L1_trace_print_module_function(VL53L1_TRACE_MODULE_PLATFORM, level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__) +#define trace_i2c(...) VL53L1_trace_print_module_function(VL53L1_TRACE_MODULE_NONE, VL53L1_TRACE_LEVEL_NONE, VL53L1_TRACE_FUNCTION_I2C, ##__VA_ARGS__) +#endif + +#ifndef HAL_I2C_MODULE_ENABLED +#warning "HAL I2C module must be enable " +#endif + +//#define VL53L0X_pI2cHandle (&hi2c1) + +/* when not customized by application define dummy one */ +#ifndef VL53L1_GetI2cBus +/** This macro can be overloaded by user to enforce i2c sharing in RTOS context + */ +# define VL53L1_GetI2cBus(...) (void)0 +#endif + +#ifndef VL53L1_PutI2cBus +/** This macro can be overloaded by user to enforce i2c sharing in RTOS context + */ +# define VL53L1_PutI2cBus(...) (void)0 +#endif + +uint8_t _I2CBuffer[256]; + +int _I2CWrite(uint16_t Dev, uint8_t *pdata, uint32_t count) { + int status; + //int i2c_time_out = I2C_TIME_OUT_BASE+ count* I2C_TIME_OUT_BYTE; + + status = HAL_I2C_Master_Transmit(&hi2c1, Dev, pdata, count, HAL_MAX_DELAY); + if (status) { + //VL6180x_ErrLog("I2C error 0x%x %d len", dev->I2cAddr, len); + //XNUCLEO6180XA1_I2C1_Init(&hi2c1); + } + return status; +} + +int _I2CRead(uint16_t Dev, uint8_t *pdata, uint32_t count) { + int status; + //int i2c_time_out = I2C_TIME_OUT_BASE+ count* I2C_TIME_OUT_BYTE; + + status = HAL_I2C_Master_Receive(&hi2c1, Dev|1, pdata, count, HAL_MAX_DELAY); + if (status) { + //VL6180x_ErrLog("I2C error 0x%x %d len", dev->I2cAddr, len); + //XNUCLEO6180XA1_I2C1_Init(&hi2c1); + } + return status; +} + +int8_t VL53L1_WriteMulti(uint16_t Dev, uint16_t index, uint8_t *pdata, uint32_t count) { + int status_int; + VL53L1_Error Status = VL53L1_ERROR_NONE; + if (count > sizeof(_I2CBuffer) - 1) { + return VL53L1_ERROR_INVALID_PARAMS; + } + _I2CBuffer[0] = index>>8; + _I2CBuffer[1] = index&0xFF; + memcpy(&_I2CBuffer[2], pdata, count); + VL53L1_GetI2cBus(); + status_int = _I2CWrite(Dev, _I2CBuffer, count + 2); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + } + VL53L1_PutI2cBus(); + return Status; +} + +// the ranging_sensor_comms.dll will take care of the page selection +VL53L1_Error VL53L1_ReadMulti(uint16_t Dev, uint16_t index, uint8_t *pdata, uint32_t count) { + VL53L1_Error Status = VL53L1_ERROR_NONE; + int32_t status_int; + + _I2CBuffer[0] = index>>8; + _I2CBuffer[1] = index&0xFF; + VL53L1_GetI2cBus(); + status_int = _I2CWrite(Dev, _I2CBuffer, 2); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + goto done; + } + status_int = _I2CRead(Dev, pdata, count); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + } +done: + VL53L1_PutI2cBus(); + return Status; +} + +VL53L1_Error VL53L1_WrByte(uint16_t Dev, uint16_t index, uint8_t data) { + VL53L1_Error Status = VL53L1_ERROR_NONE; + int32_t status_int; + + _I2CBuffer[0] = index>>8; + _I2CBuffer[1] = index&0xFF; + _I2CBuffer[2] = data; + + VL53L1_GetI2cBus(); + status_int = _I2CWrite(Dev, _I2CBuffer, 3); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + } + VL53L1_PutI2cBus(); + return Status; +} + +VL53L1_Error VL53L1_WrWord(uint16_t Dev, uint16_t index, uint16_t data) { + VL53L1_Error Status = VL53L1_ERROR_NONE; + int32_t status_int; + + _I2CBuffer[0] = index>>8; + _I2CBuffer[1] = index&0xFF; + _I2CBuffer[2] = data >> 8; + _I2CBuffer[3] = data & 0x00FF; + + VL53L1_GetI2cBus(); + status_int = _I2CWrite(Dev, _I2CBuffer, 4); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + } + VL53L1_PutI2cBus(); + return Status; +} + +VL53L1_Error VL53L1_WrDWord(uint16_t Dev, uint16_t index, uint32_t data) { + VL53L1_Error Status = VL53L1_ERROR_NONE; + int32_t status_int; + _I2CBuffer[0] = index>>8; + _I2CBuffer[1] = index&0xFF; + _I2CBuffer[2] = (data >> 24) & 0xFF; + _I2CBuffer[3] = (data >> 16) & 0xFF; + _I2CBuffer[4] = (data >> 8) & 0xFF; + _I2CBuffer[5] = (data >> 0 ) & 0xFF; + VL53L1_GetI2cBus(); + status_int = _I2CWrite(Dev, _I2CBuffer, 6); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + } + VL53L1_PutI2cBus(); + return Status; +} + +VL53L1_Error VL53L1_UpdateByte(uint16_t Dev, uint16_t index, uint8_t AndData, uint8_t OrData) { + VL53L1_Error Status = VL53L1_ERROR_NONE; + uint8_t data; + + Status = VL53L1_RdByte(Dev, index, &data); + if (Status) { + goto done; + } + data = (data & AndData) | OrData; + Status = VL53L1_WrByte(Dev, index, data); +done: + return Status; +} + +VL53L1_Error VL53L1_RdByte(uint16_t Dev, uint16_t index, uint8_t *data) { + VL53L1_Error Status = VL53L1_ERROR_NONE; + int32_t status_int; + + _I2CBuffer[0] = index>>8; + _I2CBuffer[1] = index&0xFF; + VL53L1_GetI2cBus(); + status_int = _I2CWrite(Dev, _I2CBuffer, 2); + if( status_int ){ + Status = VL53L1_ERROR_CONTROL_INTERFACE; + goto done; + } + status_int = _I2CRead(Dev, data, 1); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + } +done: + VL53L1_PutI2cBus(); + return Status; +} + +int8_t VL53L1_RdWord(uint16_t Dev, uint16_t index, uint16_t *data) { + VL53L1_Error Status = VL53L1_ERROR_NONE; + int32_t status_int; + + _I2CBuffer[0] = index>>8; + _I2CBuffer[1] = index&0xFF; + VL53L1_GetI2cBus(); + status_int = _I2CWrite(Dev, _I2CBuffer, 2); + + if( status_int ){ + Status = VL53L1_ERROR_CONTROL_INTERFACE; + goto done; + } + status_int = _I2CRead(Dev, _I2CBuffer, 2); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + goto done; + } + + *data = ((uint16_t)_I2CBuffer[0]<<8) + (uint16_t)_I2CBuffer[1]; +done: + VL53L1_PutI2cBus(); + return Status; +} + +int8_t VL53L1_RdDWord(uint16_t Dev, uint16_t index, uint32_t *data) { + VL53L1_Error Status = VL53L1_ERROR_NONE; + int32_t status_int; + + _I2CBuffer[0] = index>>8; + _I2CBuffer[1] = index&0xFF; + VL53L1_GetI2cBus(); + status_int = _I2CWrite(Dev, _I2CBuffer, 2); + + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + goto done; + } + status_int = _I2CRead(Dev, _I2CBuffer, 4); + if (status_int != 0) { + Status = VL53L1_ERROR_CONTROL_INTERFACE; + goto done; + } + + *data = ((uint32_t)_I2CBuffer[0]<<24) + ((uint32_t)_I2CBuffer[1]<<16) + ((uint32_t)_I2CBuffer[2]<<8) + (uint32_t)_I2CBuffer[3]; + +done: + VL53L1_PutI2cBus(); + return Status; +} + +VL53L1_Error VL53L1_GetTickCount( + uint32_t *ptick_count_ms) +{ + + /* Returns current tick count in [ms] */ + + VL53L1_Error status = VL53L1_ERROR_NONE; + + //*ptick_count_ms = timeGetTime(); + *ptick_count_ms = 0; + +#ifdef VL53L1_LOG_ENABLE + trace_print( + VL53L1_TRACE_LEVEL_DEBUG, + "VL53L1_GetTickCount() = %5u ms;\n", + *ptick_count_ms); +#endif + + return status; +} + + + + + + + + + + + +#define trace_print(level, ...) \ + _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_PLATFORM, \ + level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__) + +#define trace_i2c(...) \ + _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_NONE, \ + VL53L1_TRACE_LEVEL_NONE, VL53L1_TRACE_FUNCTION_I2C, ##__VA_ARGS__) + + + + + + + + + + + + + + +VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz) +{ + *ptimer_freq_hz = 0; + + trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GetTimerFrequency: Freq : %dHz\n", *ptimer_freq_hz); + return VL53L1_ERROR_NONE; +} + + +VL53L1_Error VL53L1_WaitMs(uint16_t dev, int32_t wait_ms){ + (void)dev; + HAL_Delay(wait_ms); + return VL53L1_ERROR_NONE; +} + +VL53L1_Error VL53L1_WaitUs(uint16_t dev, int32_t wait_us){ + (void)dev; + HAL_Delay(wait_us/1000); + return VL53L1_ERROR_NONE; +} + +VL53L1_Error VL53L1_WaitValueMaskEx( + uint16_t dev, + uint32_t timeout_ms, + uint16_t index, + uint8_t value, + uint8_t mask, + uint32_t poll_delay_ms) +{ + + /* + * Platform implementation of WaitValueMaskEx V2WReg script command + * + * WaitValueMaskEx( + * duration_ms, + * index, + * value, + * mask, + * poll_delay_ms); + */ + + VL53L1_Error status = VL53L1_ERROR_NONE; + uint32_t start_time_ms = 0; + uint32_t current_time_ms = 0; + uint32_t polling_time_ms = 0; + uint8_t byte_value = 0; + uint8_t found = 0; +#ifdef VL53L1_LOG_ENABLE + uint8_t trace_functions = VL53L1_TRACE_FUNCTION_NONE; +#endif + +// char register_name[VL53L1_MAX_STRING_LENGTH]; + + /* look up register name */ +#ifdef PAL_EXTENDED + VL53L1_get_register_name( + index, + register_name); +#else +// VL53L1_COPYSTRING(register_name, ""); +#endif + + /* Output to I2C logger for FMT/DFT */ + + /*trace_i2c("WaitValueMaskEx(%5d, 0x%04X, 0x%02X, 0x%02X, %5d);\n", + timeout_ms, index, value, mask, poll_delay_ms); */ + trace_i2c("WaitValueMaskEx(%5d, %s, 0x%02X, 0x%02X, %5d);\n", + timeout_ms, register_name, value, mask, poll_delay_ms); + + /* calculate time limit in absolute time */ + + VL53L1_GetTickCount(&start_time_ms); + + /* remember current trace functions and temporarily disable + * function logging + */ + +#ifdef VL53L1_LOG_ENABLE + trace_functions = VL53L1_get_trace_functions(); + VL53L1_set_trace_functions(VL53L1_TRACE_FUNCTION_NONE); +#endif + + /* wait until value is found, timeout reached on error occurred */ + + while ((status == VL53L1_ERROR_NONE) && + (polling_time_ms < timeout_ms) && + (found == 0)) { + + if (status == VL53L1_ERROR_NONE) + status = VL53L1_RdByte( + dev, + index, + &byte_value); + + if ((byte_value & mask) == value) + found = 1; + + if (status == VL53L1_ERROR_NONE && + found == 0 && + poll_delay_ms > 0) + status = VL53L1_WaitMs( + dev, + poll_delay_ms); + + /* Update polling time (Compare difference rather than absolute to + negate 32bit wrap around issue) */ + VL53L1_GetTickCount(¤t_time_ms); + polling_time_ms = current_time_ms - start_time_ms; + + } + +#ifdef VL53L1_LOG_ENABLE + /* Restore function logging */ + VL53L1_set_trace_functions(trace_functions); +#endif + + if (found == 0 && status == VL53L1_ERROR_NONE) + status = VL53L1_ERROR_TIME_OUT; + + return status; +} + + + + diff --git a/Receiver/Displayer.o b/Receiver/Displayer.o deleted file mode 100644 index 3b3a079b53a8acaac2ef61d7c62ee6b72e398380..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12776 zcmeHNeQ;dWb-%kS+p^{C%6z1vhIsAD&N|>_SN@1>6VO__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8QU%AKsgN+i_%mf}IM-JMi{nFP z>Hwr>!Ab`?S1@v^Ana{T5zM5_ln5Ru7KH?Ywxf!AEQjqri6Pg5W3D`*2Mc-Bh&IE) zu$cD=cL`KlPy7>(8@FmNrIA9fFcG>Q?0wwOI8~oq_XP!7Pms zgts1gs!&Lc6Ci^Et_R_yoyr9-cXooyouMH-LIV#m;$nDI;_yDGPF}#k{xI)K$e^wc1}MEm z3)(CxM*mS2$CKByb%3FLoXb^u*JhW?XxiXUfqP2SX_vo9@_asJ0lWXWFOc=8`Gxsd zo`1Jt+%CV@L7oGOZKjf4em4}#_}T0~{|A;7#|h(y>!3Y;2LVI>@r{hz4*OM@jF6t z7(cwXVEY``&q778E^eFsGi2XO@|S7 z4BG3DzxUM}fA_Rns_^$ZB&*W`&x`KF%*H0lOql zUm$sv2lF?Pyd7sb#?JzPUBy;?(LwTlW~7w;XZXL#zFqzvlE>dWRkF+fC&<_9KLLv0 z1UZcH!zrERIj&f2Ga=2rOn+4vq;Y_EiMW2+<#F$~pzi_Jj*SKM_qKI_+_4Jbjca#3 R`DZ?FvEc8_D%n28{{etqOUeKM diff --git a/Receiver/Receiver.cpp b/Receiver/Receiver.cpp index 0d36f6d..fd9f861 100644 --- a/Receiver/Receiver.cpp +++ b/Receiver/Receiver.cpp @@ -11,7 +11,7 @@ void Receiver::printHex(unsigned char value) { void Receiver::openStream(){ while(1){ // Open the CDC device file for reading - cdcFile = open("/dev/ttyACM0", O_RDWR | O_NOCTTY); + cdcFile = open("/dev/ttyACM1", O_RDWR | O_NOCTTY); if(cdcFile == -1){ std::cerr << "Failed to open CDC device file" << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(500)); @@ -118,6 +118,49 @@ int Receiver::simulateRead(unsigned char (*character)[CDC_FRAME_SIZE]){ return 0; } +int Receiver::getDistance(){ + uint16_t dist = 0; + int distCorrupted = 1; + unsigned char distanceFrame[12]; + int bytesRead = read(cdcFile, distanceFrame, 12); + if(bytesRead == -1){ + std::cout<<"ERROR IN READ!!! "; + } + std::cout<<"distance: "; + for(int i=0; i<7; i++){ + if(distanceFrame[i] == 0xff && distanceFrame[i+1] == 0x69 && distanceFrame [i+4] == 0xff && distanceFrame[i+5] == 0x69){ + + + + + + dist = (distanceFrame[i+2] << 8 | distanceFrame[i+3]); + + + std::cout << " - " << static_cast(dist) << " - "; + + Receiver::printHex(distanceFrame[i+2]); + std::cout << " "; + Receiver::printHex(distanceFrame[i+3]); + std::cout << std::endl; + + distCorrupted = 0; + + return 0; + } + } + if(distCorrupted) { + std::cout << "Corrupted :( -> "; + for(int i = 0; i<12; i++) { + Receiver::printHex(distanceFrame[i]); + std::cout << " "; + } + std::cout << std::endl; + } + + return 1; +} + int Receiver::fillBuffer(){ unsigned char character[CDC_FRAME_SIZE]; std::vector tempVec{}; @@ -142,6 +185,8 @@ int Receiver::fillBuffer(){ tempVec.insert(tempVec.end(), character, character + i + 2); + Receiver::getDistance(); + //////////// SAVE FRAMES TO FILES /* std::ofstream outfile(std::to_string(debugFileIdx) + ".jpg", std::ios::out | std::ios::binary); @@ -184,15 +229,15 @@ void Receiver::bufferToDisplay(){ currentBufferIndexMutex.unlock(); switch(buffIdx){ case 0: - std::cout << buffer1.size() << std::endl; + //std::cout << buffer1.size() << std::endl; dis->vectorToTexture(&buffer1); break; case 1: - std::cout << buffer2.size() << std::endl; + //std::cout << buffer2.size() << std::endl; dis->vectorToTexture(&buffer2); break; case 2: - std::cout << buffer3.size() << std::endl; + //std::cout << buffer3.size() << std::endl; dis->vectorToTexture(&buffer3); break; default: diff --git a/Receiver/Receiver.hpp b/Receiver/Receiver.hpp index 2165fbb..a43aa7a 100644 --- a/Receiver/Receiver.hpp +++ b/Receiver/Receiver.hpp @@ -58,16 +58,18 @@ class Receiver{ void openStream(); int initSerial(); int readCdcData(unsigned char (*character)[CDC_FRAME_SIZE]); - + void printHex(unsigned char value); int fillBuffer(); + int getDistance(); + void bufferToDisplay(); void initTextures(); int findSequence(unsigned char (*str)[CDC_FRAME_SIZE], unsigned char ch1, unsigned char ch2); int findStart(unsigned char (*str)[CDC_FRAME_SIZE]); int findEnd(unsigned char (*str)[CDC_FRAME_SIZE]); - + int simulateRead(unsigned char (*character)[CDC_FRAME_SIZE]); }; \ No newline at end of file diff --git a/Receiver/Receiver.o b/Receiver/Receiver.o deleted file mode 100644 index 7243a8cd8de1a3de1f4e3557e785e5cf6a78f9de..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20856 zcmeHPe|%KMwZEH$5P|L{ii*V_i$#w@=~(AF%;CU<2)BnkTb(Pi0eNHoc&yLTZd zPg0X0*L5vz{rK!}U!U#Mr?#}dTBR)wLJ3-bptUXb^|fGCND;MC1+B2}d*;sUp4{w8 zeeFN}d^#WR-kI;5Ip@roGiT<`1lRcjjRg*erjkSZl$I?iRMYzOY`#up>$Gz196@^m z%G72Op2;$QBHky-{KxU0j)#(7`;=>NC8)hud6)UkXT7cd%3t}-cf2ir^TpO?-TaF_ z@Op)wTvwte>r3^@BmUYQtC#xCw7>H3qS|Awfxi$F^Ju_)J5c$KZoaXfxCR{Y65SjL zR33BI2&=0_JN0^UZ6o_g?3{-ur29aFl4Pg);JyM{KAMDve<$|n}3rkuJkRpimlhVl~E z&|y&lnQsTo=K{b=g?8vkiO=&&APFE)x!*N(DyisbD=%3zH0&DsGb!bF^^EA|jis(r zh*Mc1sh?GR8Y3CzG+!6S?D)MbjQy|&jXRPPvx6Bx+qzWJ_ufx-OQ(C zpKdN0?E|^wA24?W%(Uopzzmd6lSFIFrwMDkmNA5~LgM6rIU>-}v|w)aPfxBb$51{2 z$%2{R+%AYjv(XVy>Zwmshb)HXFGuH*&Q;1jI(%gCyQufJdRtm`^Bw6@aHnM@fn=4Q zyo?+R&bFxXbur@GSI-P27nUqCcls-jEUMkUdhMd2S6oA1A)~>%7>E*UAYjTmjp_z} zjXKwcz4#57`=la2Lyh4Km@h+fxT1w7FM-1t6GY+i)Y@~waVD6Sj$^E;aq#?XuU0g)VX+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1#g4_mjIA-U!*s{tq!e+zyX1oc<|?qTj~&aQi&P=sBM^ z89lepVTN=2I3__DlHERK61Ur@lF{@2dKo>1{&K+;mx?x=%+@J@1w{>CMM+l05Py{+xb}#O?IoVYnY{l%9JTemTP@ z$fJ1T&*x(q!_Q*$r%9aTazAl1dd_D%qd$-FIfX6`kcbbTFEb==x97!-p8MNn4CnrK z4dcV@zk<tpXMo|{-|l8O_qRtRZuhsJGThDd8DV_5ou6g&+~3|~ z^xXa*mxp9_x#vlo?74`^y_VsePnh9+9B28GXN`)a=LHQBzDk4uR8Iq{KdXcO}I z$xRIB{rY1b{2DecocNbWK`ioTIRB8Xv;dSW}%Y2?(c0rKe>^;mc)Zz0{M6 zRf-tzs~Jvp>RvX)a5bl>*#?GF98l@=3@7>%WW{|97yM=C_SkTB4|;*rmtOR!`^64B zE(P3W!___C{We_P^L>xuq^Ar!8vTPyO7xNTPIbL9J{mS$ z-P?WDhO2wKO*UNJ+tGb5CE`twy0_cSa4C|=w7m=`JNZb)Pq7oJsg|A&95L!zixk&a+{EQE`vs+F-QH2OQGmobmIUn#bA zGNWR|43x|9NVm(p^R-v;O@1zlwe#$c(4Jy9CElLq#9u3aIW_ED|@PSoc0JLUrvAItaQUvl^gpeTAnUI zfq2^6_saJ4twHj`e?PuUk-vCO!@{3EQe4BXfUbz8C z^Gz4pyYcYkm+kH2f3Mt#pN4v#?D{vLKG*oyEU;SLBiqkFkxXLO|2ot=f!pWrFdarC zDSE4vEi0V<9xs>tUG-KAWhatv|`S$rsw3O6)lWcFH+25&j*q0-zcB*O^ z0L4gK_qA!Vy;~8=x6)t1yQO@4`x@E4kBq~Tz5OrHKG*oGe-yGoGM)h*6bn>)Wj{0@ zr#p$;bT<8BUo0C?u^f-RJ#FLdz6(fm(?>DVgSLr9@^~skAy@kijTV)<_f~D}?f(xL CT2xd3 diff --git a/Receiver/main b/Receiver/main deleted file mode 100755 index 665d1e7068b269b22a3d7696208dcce67bc99cfb..0000000000000000000000000000000000000000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zaT3q zT#!v=dHEcagz`BktNmpA?-Jz~34w#+CaQ!3qQj^>Ju4>bm*xKzG_r}5uQ-8Fa9++!Erpc~-L8?eTz;L~9c z1Gm)K*dQMH{Kl5Ggu##4=jey5UqZaZL%}U=qr7}xWI&Xcd{TnMC8XzKNGItg^85Vl zqI|V1D4;AS$!DT4jU8EDJ_mA4ly?ck()gz&%gb(k05o&`@;S<~PR6brpiEPeR;W%bEb*%4w)eeR0}8p{jP`VcS(YPviwX7op>pk zq2YTxi+!r1{@chokj}y1`S_Fi%XZQCbQTps!S7ipFe5!e&S6TjUP+?w2*)a)5RO}A JDPTdB{{u{Fa-0AF diff --git a/Receiver/main.o b/Receiver/main.o deleted file mode 100644 index eaa480d6a477e52210a1c6b7dfa2313aa51e320f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15200 zcmeHNe{fvIeSfEuZ23p-WWcSAAwC-!WDM6kSrRfyv3{NO4quG$Nj5`pp3ishtcy=~ z$K5+yCJdNbb~(#(OeQl)r(}{zAdQnUG)*AEX+fPBRMND#w4IPsVmG$xOBi#FF{RMTD#&egj` zwOeb`!h+XFZOHg#*+k_kS-*_R%jvm-p4Ae&n#vE#`UY8ELuHGsZ=~{CS#PCs6Fp2n z^MCMH`sB6?X#3Z7YiRfEicNI@=oyJk-6$%-q_u{LpKVc%~UFGyN@%XbC9%VyyC?dgaYnC8SsGXpB`xo1mjfbn27$ zlA2?)))IYk>FiJ=@!9y%dr5`$710pRR%V2=cKumVPp5H2TQ6FlA?exk{--a#J|+0n@sL8x zf3}{uW0l`r*hZ?-r_W;IIfiq=pf20X(+InWIkADzu3Y@C-H`3rY0x?s1z~ za)QMwuiAVh7|^V%t3s_cW~1nwo%Q(pXnL0#&Umy*Ps8Ut8bS3dX&F*^Wr3W(ui@); z+G)>DO`E7|c)m`1xNh}d*9oo_e;~M)hxSZ)v`0L|Te1>Gi+=M3jn*2*-!qc-zd8L3 zjP(qU=nuT{1*$1?b)x071lZHH*}t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