Thundersoft
/
VL6180XA1_for_TT_Mxx
Creating a project about VL6180XA1 for TT_Mxx
VL6180XA1/VL6180X/vl6180x_def.h@3:7a97a01bad5e, 2019-04-26 (annotated)
- Committer:
- ThunderSoft
- Date:
- Fri Apr 26 09:34:53 2019 +0000
- Revision:
- 3:7a97a01bad5e
- Parent:
- 0:293917667c17
"update the mbed-os code to support TT_M4G9"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThunderSoft | 0:293917667c17 | 1 | /******************************************************************************* |
ThunderSoft | 0:293917667c17 | 2 | Copyright © 2014, STMicroelectronics International N.V. |
ThunderSoft | 0:293917667c17 | 3 | All rights reserved. |
ThunderSoft | 0:293917667c17 | 4 | |
ThunderSoft | 0:293917667c17 | 5 | Redistribution and use in source and binary forms, with or without |
ThunderSoft | 0:293917667c17 | 6 | modification, are permitted provided that the following conditions are met: |
ThunderSoft | 0:293917667c17 | 7 | * Redistributions of source code must retain the above copyright |
ThunderSoft | 0:293917667c17 | 8 | notice, this list of conditions and the following disclaimer. |
ThunderSoft | 0:293917667c17 | 9 | * Redistributions in binary form must reproduce the above copyright |
ThunderSoft | 0:293917667c17 | 10 | notice, this list of conditions and the following disclaimer in the |
ThunderSoft | 0:293917667c17 | 11 | documentation and/or other materials provided with the distribution. |
ThunderSoft | 0:293917667c17 | 12 | * Neither the name of STMicroelectronics nor the |
ThunderSoft | 0:293917667c17 | 13 | names of its contributors may be used to endorse or promote products |
ThunderSoft | 0:293917667c17 | 14 | derived from this software without specific prior written permission. |
ThunderSoft | 0:293917667c17 | 15 | |
ThunderSoft | 0:293917667c17 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
ThunderSoft | 0:293917667c17 | 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
ThunderSoft | 0:293917667c17 | 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND |
ThunderSoft | 0:293917667c17 | 19 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. |
ThunderSoft | 0:293917667c17 | 20 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY |
ThunderSoft | 0:293917667c17 | 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
ThunderSoft | 0:293917667c17 | 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
ThunderSoft | 0:293917667c17 | 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ThunderSoft | 0:293917667c17 | 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
ThunderSoft | 0:293917667c17 | 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
ThunderSoft | 0:293917667c17 | 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
ThunderSoft | 0:293917667c17 | 27 | ********************************************************************************/ |
ThunderSoft | 0:293917667c17 | 28 | |
ThunderSoft | 0:293917667c17 | 29 | /* |
ThunderSoft | 0:293917667c17 | 30 | * $Date: 2015-05-13 14:12:05 +0200 (Wed, 13 May 2015) $ |
ThunderSoft | 0:293917667c17 | 31 | * $Revision: 2290 $ |
ThunderSoft | 0:293917667c17 | 32 | */ |
ThunderSoft | 0:293917667c17 | 33 | |
ThunderSoft | 0:293917667c17 | 34 | /** |
ThunderSoft | 0:293917667c17 | 35 | * @file VL6180x_def.h |
ThunderSoft | 0:293917667c17 | 36 | * |
ThunderSoft | 0:293917667c17 | 37 | * @brief Type definitions for vl6180x api. |
ThunderSoft | 0:293917667c17 | 38 | * |
ThunderSoft | 0:293917667c17 | 39 | */ |
ThunderSoft | 0:293917667c17 | 40 | |
ThunderSoft | 0:293917667c17 | 41 | |
ThunderSoft | 0:293917667c17 | 42 | #ifndef _VL6180x_DEF |
ThunderSoft | 0:293917667c17 | 43 | #define _VL6180x_DEF |
ThunderSoft | 0:293917667c17 | 44 | |
ThunderSoft | 0:293917667c17 | 45 | /** API major version */ |
ThunderSoft | 0:293917667c17 | 46 | #define VL6180x_API_REV_MAJOR 3 |
ThunderSoft | 0:293917667c17 | 47 | /** API minor version */ |
ThunderSoft | 0:293917667c17 | 48 | #define VL6180x_API_REV_MINOR 2 |
ThunderSoft | 0:293917667c17 | 49 | /** API sub version */ |
ThunderSoft | 0:293917667c17 | 50 | #define VL6180x_API_REV_SUB 0 |
ThunderSoft | 0:293917667c17 | 51 | |
ThunderSoft | 0:293917667c17 | 52 | #define VL6180X_STR_HELPER(x) #x |
ThunderSoft | 0:293917667c17 | 53 | #define VL6180X_STR(x) VL6180X_STR_HELPER(x) |
ThunderSoft | 0:293917667c17 | 54 | |
ThunderSoft | 0:293917667c17 | 55 | #include "vl6180x_cfg.h" |
ThunderSoft | 0:293917667c17 | 56 | #include "vl6180x_types.h" |
ThunderSoft | 0:293917667c17 | 57 | |
ThunderSoft | 0:293917667c17 | 58 | /* |
ThunderSoft | 0:293917667c17 | 59 | * check configuration macro raise error or warning and suggest a default value |
ThunderSoft | 0:293917667c17 | 60 | */ |
ThunderSoft | 0:293917667c17 | 61 | |
ThunderSoft | 0:293917667c17 | 62 | #ifndef VL6180x_UPSCALE_SUPPORT |
ThunderSoft | 0:293917667c17 | 63 | #error "VL6180x_UPSCALE_SUPPORT not defined" |
ThunderSoft | 0:293917667c17 | 64 | /* TODO you must define value for upscale support in your vl6180x_cfg.h */ |
ThunderSoft | 0:293917667c17 | 65 | #endif |
ThunderSoft | 0:293917667c17 | 66 | |
ThunderSoft | 0:293917667c17 | 67 | #ifndef VL6180x_ALS_SUPPORT |
ThunderSoft | 0:293917667c17 | 68 | #error "VL6180x_ALS_SUPPORT not defined" |
ThunderSoft | 0:293917667c17 | 69 | /* TODO you must define VL6180x_ALS_SUPPORT with a value in your vl6180x_cfg.h set to 0 do disable*/ |
ThunderSoft | 0:293917667c17 | 70 | #endif |
ThunderSoft | 0:293917667c17 | 71 | |
ThunderSoft | 0:293917667c17 | 72 | #ifndef VL6180x_HAVE_DMAX_RANGING |
ThunderSoft | 0:293917667c17 | 73 | #error "VL6180x_HAVE_DMAX_RANGING not defined" |
ThunderSoft | 0:293917667c17 | 74 | /* TODO you may remove or comment these #error and keep the default below or update your vl6180x_cfg.h .h file */ |
ThunderSoft | 0:293917667c17 | 75 | /** |
ThunderSoft | 0:293917667c17 | 76 | * force VL6180x_HAVE_DMAX_RANGING to not supported when not part of cfg file |
ThunderSoft | 0:293917667c17 | 77 | */ |
ThunderSoft | 0:293917667c17 | 78 | #define VL6180x_HAVE_DMAX_RANGING 0 |
ThunderSoft | 0:293917667c17 | 79 | #endif |
ThunderSoft | 0:293917667c17 | 80 | |
ThunderSoft | 0:293917667c17 | 81 | #ifndef VL6180x_EXTENDED_RANGE |
ThunderSoft | 0:293917667c17 | 82 | #define VL6180x_EXTENDED_RANGE 0 |
ThunderSoft | 0:293917667c17 | 83 | #endif |
ThunderSoft | 0:293917667c17 | 84 | |
ThunderSoft | 0:293917667c17 | 85 | #ifndef VL6180x_WRAP_AROUND_FILTER_SUPPORT |
ThunderSoft | 0:293917667c17 | 86 | #error "VL6180x_WRAP_AROUND_FILTER_SUPPORT not defined ?" |
ThunderSoft | 0:293917667c17 | 87 | /* TODO you may remove or comment these #error and keep the default below or update vl6180x_cfg.h file */ |
ThunderSoft | 0:293917667c17 | 88 | /** |
ThunderSoft | 0:293917667c17 | 89 | * force VL6180x_WRAP_AROUND_FILTER_SUPPORT to not supported when not part of cfg file |
ThunderSoft | 0:293917667c17 | 90 | */ |
ThunderSoft | 0:293917667c17 | 91 | #define VL6180x_WRAP_AROUND_FILTER_SUPPORT 0 |
ThunderSoft | 0:293917667c17 | 92 | #endif |
ThunderSoft | 0:293917667c17 | 93 | |
ThunderSoft | 0:293917667c17 | 94 | |
ThunderSoft | 0:293917667c17 | 95 | |
ThunderSoft | 0:293917667c17 | 96 | #ifndef VL6180x_HAVE_MULTI_READ |
ThunderSoft | 0:293917667c17 | 97 | # define VL6180x_HAVE_MULTI_READ 0 |
ThunderSoft | 0:293917667c17 | 98 | #endif |
ThunderSoft | 0:293917667c17 | 99 | |
ThunderSoft | 0:293917667c17 | 100 | /** |
ThunderSoft | 0:293917667c17 | 101 | * Force VL6180x_CACHED_REG to default 0 when not defined |
ThunderSoft | 0:293917667c17 | 102 | */ |
ThunderSoft | 0:293917667c17 | 103 | #ifndef VL6180x_CACHED_REG |
ThunderSoft | 0:293917667c17 | 104 | # define VL6180x_CACHED_REG 0 |
ThunderSoft | 0:293917667c17 | 105 | #else |
ThunderSoft | 0:293917667c17 | 106 | # define VL6180x_FIRST_CACHED_INDEX 0x04D |
ThunderSoft | 0:293917667c17 | 107 | # define VL6180x_LAST_CACHED_INDEX (VL6180x_FIRST_CACHED_INDEX+55) |
ThunderSoft | 0:293917667c17 | 108 | # define VL6180x_CACHED_REG_CNT (VL6180x_LAST_CACHED_INDEX-VL6180x_FIRST_CACHED_INDEX+1) |
ThunderSoft | 0:293917667c17 | 109 | #endif |
ThunderSoft | 0:293917667c17 | 110 | |
ThunderSoft | 0:293917667c17 | 111 | /**************************************** |
ThunderSoft | 0:293917667c17 | 112 | * PRIVATE define do not edit |
ThunderSoft | 0:293917667c17 | 113 | ****************************************/ |
ThunderSoft | 0:293917667c17 | 114 | |
ThunderSoft | 0:293917667c17 | 115 | /** Maximal buffer size ever use in i2c */ |
ThunderSoft | 0:293917667c17 | 116 | #define VL6180x_MAX_I2C_XFER_SIZE 8 /* At present time it 6 byte max but that can change */ |
ThunderSoft | 0:293917667c17 | 117 | |
ThunderSoft | 0:293917667c17 | 118 | #if VL6180x_UPSCALE_SUPPORT < 0 |
ThunderSoft | 0:293917667c17 | 119 | /** |
ThunderSoft | 0:293917667c17 | 120 | * @def VL6180x_HAVE_UPSCALE_DATA |
ThunderSoft | 0:293917667c17 | 121 | * @brief is defined if device data structure has data so when user configurable up-scale is active |
ThunderSoft | 0:293917667c17 | 122 | */ |
ThunderSoft | 0:293917667c17 | 123 | #define VL6180x_HAVE_UPSCALE_DATA /* have data only for user configurable up-scale config */ |
ThunderSoft | 0:293917667c17 | 124 | #endif |
ThunderSoft | 0:293917667c17 | 125 | |
ThunderSoft | 0:293917667c17 | 126 | #if VL6180x_WRAP_AROUND_FILTER_SUPPORT |
ThunderSoft | 0:293917667c17 | 127 | /** |
ThunderSoft | 0:293917667c17 | 128 | * @def VL6180x_HAVE_WRAP_AROUND_DATA |
ThunderSoft | 0:293917667c17 | 129 | * @brief is defined if device data structure has filter data so when active in cfg file |
ThunderSoft | 0:293917667c17 | 130 | */ |
ThunderSoft | 0:293917667c17 | 131 | #define VL6180x_HAVE_WRAP_AROUND_DATA |
ThunderSoft | 0:293917667c17 | 132 | #endif |
ThunderSoft | 0:293917667c17 | 133 | |
ThunderSoft | 0:293917667c17 | 134 | #if VL6180x_ALS_SUPPORT != 0 |
ThunderSoft | 0:293917667c17 | 135 | /** |
ThunderSoft | 0:293917667c17 | 136 | * @def VL6180x_HAVE_ALS_DATA |
ThunderSoft | 0:293917667c17 | 137 | * @brief is defined when als data are include in device data structure so when als suport if configured |
ThunderSoft | 0:293917667c17 | 138 | */ |
ThunderSoft | 0:293917667c17 | 139 | #define VL6180x_HAVE_ALS_DATA |
ThunderSoft | 0:293917667c17 | 140 | #endif |
ThunderSoft | 0:293917667c17 | 141 | |
ThunderSoft | 0:293917667c17 | 142 | |
ThunderSoft | 0:293917667c17 | 143 | #if VL6180x_WRAP_AROUND_FILTER_SUPPORT || VL6180x_HAVE_DMAX_RANGING |
ThunderSoft | 0:293917667c17 | 144 | #define VL6180x_HAVE_RATE_DATA |
ThunderSoft | 0:293917667c17 | 145 | #endif |
ThunderSoft | 0:293917667c17 | 146 | |
ThunderSoft | 0:293917667c17 | 147 | /** Error and warning code returned by API |
ThunderSoft | 0:293917667c17 | 148 | * |
ThunderSoft | 0:293917667c17 | 149 | * negative value are true error mostly fatal\n |
ThunderSoft | 0:293917667c17 | 150 | * positive value are warning most of time it's ok to continue\n |
ThunderSoft | 0:293917667c17 | 151 | */ |
ThunderSoft | 0:293917667c17 | 152 | enum VL6180x_ErrCode_t{ |
ThunderSoft | 0:293917667c17 | 153 | API_NO_ERROR = 0, |
ThunderSoft | 0:293917667c17 | 154 | CALIBRATION_WARNING = 1, /*!< warning invalid calibration data may be in used \a VL6180x_InitData() \a VL6180x_GetOffsetCalibrationData \a VL6180x_SetOffsetCalibrationData*/ |
ThunderSoft | 0:293917667c17 | 155 | MIN_CLIPED = 2, /*!< warning parameter passed was clipped to min before to be applied */ |
ThunderSoft | 0:293917667c17 | 156 | NOT_GUARANTEED = 3, /*!< Correct operation is not guaranteed typically using extended ranging on vl6180x */ |
ThunderSoft | 0:293917667c17 | 157 | |
ThunderSoft | 0:293917667c17 | 158 | API_ERROR = -1, /*!< Unqualified error */ |
ThunderSoft | 0:293917667c17 | 159 | INVALID_PARAMS = -2, /*!< parameter passed is invalid or out of range */ |
ThunderSoft | 0:293917667c17 | 160 | NOT_SUPPORTED = -3, /*!< function is not supported in current mode or configuration */ |
ThunderSoft | 0:293917667c17 | 161 | RANGE_ERROR = -4, /*!< device report a ranging error interrupt status */ |
ThunderSoft | 0:293917667c17 | 162 | TIME_OUT = -5, /*!< aborted due to time out */ |
ThunderSoft | 0:293917667c17 | 163 | }; |
ThunderSoft | 0:293917667c17 | 164 | |
ThunderSoft | 0:293917667c17 | 165 | /** |
ThunderSoft | 0:293917667c17 | 166 | * Filtered result data structure range data is to be used |
ThunderSoft | 0:293917667c17 | 167 | */ |
ThunderSoft | 0:293917667c17 | 168 | typedef struct RangeFilterResult_tag { |
ThunderSoft | 0:293917667c17 | 169 | uint16_t range_mm; /*!< Filtered ranging value */ |
ThunderSoft | 0:293917667c17 | 170 | uint16_t rawRange_mm; /*!< raw range value (scaled) */ |
ThunderSoft | 0:293917667c17 | 171 | uint32_t filterError; /*!< current filter error code */ |
ThunderSoft | 0:293917667c17 | 172 | } RangeFilterResult_t; |
ThunderSoft | 0:293917667c17 | 173 | |
ThunderSoft | 0:293917667c17 | 174 | /** |
ThunderSoft | 0:293917667c17 | 175 | * "small" unsigned data type used in filter |
ThunderSoft | 0:293917667c17 | 176 | * |
ThunderSoft | 0:293917667c17 | 177 | * if data space saving is not a concern it can be change to platform native unsigned int |
ThunderSoft | 0:293917667c17 | 178 | */ |
ThunderSoft | 0:293917667c17 | 179 | typedef uint32_t FilterType1_t; |
ThunderSoft | 0:293917667c17 | 180 | |
ThunderSoft | 0:293917667c17 | 181 | /** |
ThunderSoft | 0:293917667c17 | 182 | * @def FILTER_NBOF_SAMPLES |
ThunderSoft | 0:293917667c17 | 183 | * @brief sample history len used for wrap around filtering |
ThunderSoft | 0:293917667c17 | 184 | */ |
ThunderSoft | 0:293917667c17 | 185 | #define FILTER_NBOF_SAMPLES 10 |
ThunderSoft | 0:293917667c17 | 186 | /** |
ThunderSoft | 0:293917667c17 | 187 | * Wrap around filter internal data |
ThunderSoft | 0:293917667c17 | 188 | */ |
ThunderSoft | 0:293917667c17 | 189 | struct FilterData_t { |
ThunderSoft | 0:293917667c17 | 190 | uint32_t MeasurementIndex; /*!< current measurement index */ |
ThunderSoft | 0:293917667c17 | 191 | uint32_t MeasurementsSinceLastFlush; /*!< Number of measurements done since last time buffer has been flushed */ |
ThunderSoft | 0:293917667c17 | 192 | uint16_t LastTrueRange[FILTER_NBOF_SAMPLES]; /*!< filtered/corrected distance history */ |
ThunderSoft | 0:293917667c17 | 193 | uint32_t LastReturnRates[FILTER_NBOF_SAMPLES]; /*!< Return rate history */ |
ThunderSoft | 0:293917667c17 | 194 | uint16_t StdFilteredReads; /*!< internal use */ |
ThunderSoft | 0:293917667c17 | 195 | FilterType1_t Default_ZeroVal; /*!< internal use */ |
ThunderSoft | 0:293917667c17 | 196 | FilterType1_t Default_VAVGVal; /*!< internal use */ |
ThunderSoft | 0:293917667c17 | 197 | FilterType1_t NoDelay_ZeroVal; /*!< internal use */ |
ThunderSoft | 0:293917667c17 | 198 | FilterType1_t NoDelay_VAVGVal; /*!< internal use */ |
ThunderSoft | 0:293917667c17 | 199 | FilterType1_t Previous_VAVGDiff; /*!< internal use */ |
ThunderSoft | 0:293917667c17 | 200 | uint32_t FilteringOnGoingConsecutiveStates; /*!< internal use */ |
ThunderSoft | 0:293917667c17 | 201 | uint32_t filterError; /*!< current filter error code */ |
ThunderSoft | 0:293917667c17 | 202 | }; |
ThunderSoft | 0:293917667c17 | 203 | |
ThunderSoft | 0:293917667c17 | 204 | #if VL6180x_HAVE_DMAX_RANGING |
ThunderSoft | 0:293917667c17 | 205 | typedef int32_t DMaxFix_t; |
ThunderSoft | 0:293917667c17 | 206 | struct DMaxData_t { |
ThunderSoft | 0:293917667c17 | 207 | uint32_t ambTuningWindowFactor_K; /*!< internal algo tuning (*1000) */ |
ThunderSoft | 0:293917667c17 | 208 | |
ThunderSoft | 0:293917667c17 | 209 | DMaxFix_t retSignalAt400mm; /*!< intermediate dmax computation value caching @a #SYSRANGE_CROSSTALK_COMPENSATION_RATE and private reg 0x02A */ |
ThunderSoft | 0:293917667c17 | 210 | /* int32_t RegB8; */ /*!< register 0xB8 cached to speed reduce i2c traffic for dmax computation */ |
ThunderSoft | 0:293917667c17 | 211 | /* place all word data below to optimize struct packing */ |
ThunderSoft | 0:293917667c17 | 212 | /* int32_t minSignalNeeded; */ /*!< optimized computation intermediate base on register cached value */ |
ThunderSoft | 0:293917667c17 | 213 | int32_t snrLimit_K; /*!< cached and optimized computation intermediate from @a #SYSRANGE_MAX_AMBIENT_LEVEL_MULT */ |
ThunderSoft | 0:293917667c17 | 214 | uint16_t ClipSnrLimit; /*!< Max value for snr limit */ |
ThunderSoft | 0:293917667c17 | 215 | /* place all byte data below to optimize packing */ |
ThunderSoft | 0:293917667c17 | 216 | /* uint8_t MaxConvTime; */ /*!< cached max convergence time @a #SYSRANGE_MAX_CONVERGENCE_TIME*/ |
ThunderSoft | 0:293917667c17 | 217 | }; |
ThunderSoft | 0:293917667c17 | 218 | #endif |
ThunderSoft | 0:293917667c17 | 219 | |
ThunderSoft | 0:293917667c17 | 220 | struct RangeIgnoreData_t { |
ThunderSoft | 0:293917667c17 | 221 | uint16_t ValidHeight; |
ThunderSoft | 0:293917667c17 | 222 | uint16_t IgnoreThreshold; |
ThunderSoft | 0:293917667c17 | 223 | uint8_t Enabled; |
ThunderSoft | 0:293917667c17 | 224 | }; |
ThunderSoft | 0:293917667c17 | 225 | /** |
ThunderSoft | 0:293917667c17 | 226 | * @struct VL6180xDevData_t |
ThunderSoft | 0:293917667c17 | 227 | * |
ThunderSoft | 0:293917667c17 | 228 | * @brief Per VL6180x device St private data structure \n |
ThunderSoft | 0:293917667c17 | 229 | * End user should never access any of these field directly |
ThunderSoft | 0:293917667c17 | 230 | * |
ThunderSoft | 0:293917667c17 | 231 | * These must never access directly but only via VL6180xDev/SetData(dev, field) macro |
ThunderSoft | 0:293917667c17 | 232 | */ |
ThunderSoft | 0:293917667c17 | 233 | struct VL6180xDevData_t { |
ThunderSoft | 0:293917667c17 | 234 | |
ThunderSoft | 0:293917667c17 | 235 | uint32_t Part2PartAmbNVM; /*!< backed up NVM value */ |
ThunderSoft | 0:293917667c17 | 236 | uint32_t XTalkCompRate_KCps; /*! Cached XTlak Compensation Rate */ |
ThunderSoft | 0:293917667c17 | 237 | |
ThunderSoft | 0:293917667c17 | 238 | uint16_t EceFactorM; /*!< Ece Factor M numerator */ |
ThunderSoft | 0:293917667c17 | 239 | uint16_t EceFactorD; /*!< Ece Factor D denominator*/ |
ThunderSoft | 0:293917667c17 | 240 | |
ThunderSoft | 0:293917667c17 | 241 | struct RangeIgnoreData_t RangeIgnore; |
ThunderSoft | 0:293917667c17 | 242 | #ifdef VL6180x_HAVE_ALS_DATA |
ThunderSoft | 0:293917667c17 | 243 | uint16_t IntegrationPeriod; /*!< cached als Integration period avoid slow read from device at each measure */ |
ThunderSoft | 0:293917667c17 | 244 | uint16_t AlsGainCode; /*!< cached Als gain avoid slow read from device at each measure */ |
ThunderSoft | 0:293917667c17 | 245 | uint16_t AlsScaler; /*!< cached Als scaler avoid slow read from device at each measure */ |
ThunderSoft | 0:293917667c17 | 246 | #endif |
ThunderSoft | 0:293917667c17 | 247 | |
ThunderSoft | 0:293917667c17 | 248 | #ifdef VL6180x_HAVE_UPSCALE_DATA |
ThunderSoft | 0:293917667c17 | 249 | uint8_t UpscaleFactor; /*!< up-scaling factor*/ |
ThunderSoft | 0:293917667c17 | 250 | #endif |
ThunderSoft | 0:293917667c17 | 251 | |
ThunderSoft | 0:293917667c17 | 252 | #ifdef VL6180x_HAVE_WRAP_AROUND_DATA |
ThunderSoft | 0:293917667c17 | 253 | uint8_t WrapAroundFilterActive; /*!< Filter on/off */ |
ThunderSoft | 0:293917667c17 | 254 | struct FilterData_t FilterData; /*!< Filter internal data state history ... */ |
ThunderSoft | 0:293917667c17 | 255 | #endif |
ThunderSoft | 0:293917667c17 | 256 | |
ThunderSoft | 0:293917667c17 | 257 | #if VL6180x_CACHED_REG |
ThunderSoft | 0:293917667c17 | 258 | uint8_t CacheFilled; /*!< Set if valid data got fetched use to control when to fill up register cache */ |
ThunderSoft | 0:293917667c17 | 259 | uint8_t CachedRegs[VL6180x_CACHED_REG_CNT]; /*!< Cache register storage */ |
ThunderSoft | 0:293917667c17 | 260 | #endif |
ThunderSoft | 0:293917667c17 | 261 | #if VL6180x_HAVE_DMAX_RANGING |
ThunderSoft | 0:293917667c17 | 262 | struct DMaxData_t DMaxData; |
ThunderSoft | 0:293917667c17 | 263 | uint8_t DMaxEnable; |
ThunderSoft | 0:293917667c17 | 264 | #endif |
ThunderSoft | 0:293917667c17 | 265 | int8_t Part2PartOffsetNVM; /*!< backed up NVM value */ |
ThunderSoft | 0:293917667c17 | 266 | }; |
ThunderSoft | 0:293917667c17 | 267 | |
ThunderSoft | 0:293917667c17 | 268 | |
ThunderSoft | 0:293917667c17 | 269 | /** |
ThunderSoft | 0:293917667c17 | 270 | * @struct VL6180x_RangeData_t |
ThunderSoft | 0:293917667c17 | 271 | * @brief Range and any optional measurement data. |
ThunderSoft | 0:293917667c17 | 272 | */ |
ThunderSoft | 0:293917667c17 | 273 | typedef struct { |
ThunderSoft | 0:293917667c17 | 274 | uint32_t range_mm; /*!< range distance in mm. */ |
ThunderSoft | 0:293917667c17 | 275 | int32_t signalRate_mcps; /*!< signal rate (MCPS)\n these is a 9.7 fix point value, which is effectively a measure of target reflectance.*/ |
ThunderSoft | 0:293917667c17 | 276 | uint32_t errorStatus; /*!< Error status of the current measurement. \n see @a ::RangeError_u @a VL6180x_GetRangeStatusErrString() */ |
ThunderSoft | 0:293917667c17 | 277 | |
ThunderSoft | 0:293917667c17 | 278 | |
ThunderSoft | 0:293917667c17 | 279 | #ifdef VL6180x_HAVE_RATE_DATA |
ThunderSoft | 0:293917667c17 | 280 | uint32_t rtnAmbRate; /*!< Return Ambient rate in KCount per sec related to \a RESULT_RANGE_RETURN_AMB_COUNT */ |
ThunderSoft | 0:293917667c17 | 281 | uint32_t rtnRate; /*!< Return rate in KCount per sec related to \a RESULT_RANGE_RETURN_SIGNAL_COUNT */ |
ThunderSoft | 0:293917667c17 | 282 | uint32_t rtnConvTime; /*!< Return Convergence time \a RESULT_RANGE_RETURN_CONV_TIME */ |
ThunderSoft | 0:293917667c17 | 283 | uint32_t refConvTime; /*!< Reference convergence time \a RESULT_RANGE_REFERENCE_CONV_TIME */ |
ThunderSoft | 0:293917667c17 | 284 | #endif |
ThunderSoft | 0:293917667c17 | 285 | |
ThunderSoft | 0:293917667c17 | 286 | |
ThunderSoft | 0:293917667c17 | 287 | #if VL6180x_HAVE_DMAX_RANGING |
ThunderSoft | 0:293917667c17 | 288 | uint32_t DMax; /*!< DMax when applicable */ |
ThunderSoft | 0:293917667c17 | 289 | #endif |
ThunderSoft | 0:293917667c17 | 290 | |
ThunderSoft | 0:293917667c17 | 291 | #ifdef VL6180x_HAVE_WRAP_AROUND_DATA |
ThunderSoft | 0:293917667c17 | 292 | RangeFilterResult_t FilteredData; /*!< Filter result main range_mm is updated */ |
ThunderSoft | 0:293917667c17 | 293 | #endif |
ThunderSoft | 0:293917667c17 | 294 | }VL6180x_RangeData_t; |
ThunderSoft | 0:293917667c17 | 295 | |
ThunderSoft | 0:293917667c17 | 296 | |
ThunderSoft | 0:293917667c17 | 297 | /** use where fix point 9.7 bit values are expected |
ThunderSoft | 0:293917667c17 | 298 | * |
ThunderSoft | 0:293917667c17 | 299 | * given a floating point value f it's .7 bit point is (int)(f*(1<<7))*/ |
ThunderSoft | 0:293917667c17 | 300 | typedef uint16_t FixPoint97_t; |
ThunderSoft | 0:293917667c17 | 301 | |
ThunderSoft | 0:293917667c17 | 302 | /** lux data type */ |
ThunderSoft | 0:293917667c17 | 303 | typedef uint32_t lux_t; |
ThunderSoft | 0:293917667c17 | 304 | |
ThunderSoft | 0:293917667c17 | 305 | /** |
ThunderSoft | 0:293917667c17 | 306 | * @brief This data type defines als measurement data. |
ThunderSoft | 0:293917667c17 | 307 | */ |
ThunderSoft | 0:293917667c17 | 308 | typedef struct VL6180x_AlsData_st{ |
ThunderSoft | 0:293917667c17 | 309 | lux_t lux; /**< Light measurement (Lux) */ |
ThunderSoft | 0:293917667c17 | 310 | uint32_t errorStatus; /**< Error status of the current measurement. \n |
ThunderSoft | 0:293917667c17 | 311 | * No Error := 0. \n |
ThunderSoft | 0:293917667c17 | 312 | * Refer to product sheets for other error codes. */ |
ThunderSoft | 0:293917667c17 | 313 | }VL6180x_AlsData_t; |
ThunderSoft | 0:293917667c17 | 314 | |
ThunderSoft | 0:293917667c17 | 315 | /** |
ThunderSoft | 0:293917667c17 | 316 | * @brief Range status Error code |
ThunderSoft | 0:293917667c17 | 317 | * |
ThunderSoft | 0:293917667c17 | 318 | * @a VL6180x_GetRangeStatusErrString() if configured ( @a #VL6180x_RANGE_STATUS_ERRSTRING ) |
ThunderSoft | 0:293917667c17 | 319 | * related to register @a #RESULT_RANGE_STATUS and additional post processing |
ThunderSoft | 0:293917667c17 | 320 | */ |
ThunderSoft | 0:293917667c17 | 321 | typedef enum { |
ThunderSoft | 0:293917667c17 | 322 | NoError = 0, /*!< 0 0b0000 NoError */ |
ThunderSoft | 0:293917667c17 | 323 | VCSEL_Continuity_Test, /*!< 1 0b0001 VCSEL_Continuity_Test */ |
ThunderSoft | 0:293917667c17 | 324 | VCSEL_Watchdog_Test, /*!< 2 0b0010 VCSEL_Watchdog_Test */ |
ThunderSoft | 0:293917667c17 | 325 | VCSEL_Watchdog, /*!< 3 0b0011 VCSEL_Watchdog */ |
ThunderSoft | 0:293917667c17 | 326 | PLL1_Lock, /*!< 4 0b0100 PLL1_Lock */ |
ThunderSoft | 0:293917667c17 | 327 | PLL2_Lock, /*!< 5 0b0101 PLL2_Lock */ |
ThunderSoft | 0:293917667c17 | 328 | Early_Convergence_Estimate,/*!< 6 0b0110 Early_Convergence_Estimate */ |
ThunderSoft | 0:293917667c17 | 329 | Max_Convergence, /*!< 7 0b0111 Max_Convergence */ |
ThunderSoft | 0:293917667c17 | 330 | No_Target_Ignore, /*!< 8 0b1000 No_Target_Ignore */ |
ThunderSoft | 0:293917667c17 | 331 | Not_used_9, /*!< 9 0b1001 Not_used */ |
ThunderSoft | 0:293917667c17 | 332 | Not_used_10, /*!< 10 0b1010 Not_used_ */ |
ThunderSoft | 0:293917667c17 | 333 | Max_Signal_To_Noise_Ratio, /*!< 11 0b1011 Max_Signal_To_Noise_Ratio*/ |
ThunderSoft | 0:293917667c17 | 334 | Raw_Ranging_Algo_Underflow,/*!< 12 0b1100 Raw_Ranging_Algo_Underflow*/ |
ThunderSoft | 0:293917667c17 | 335 | Raw_Ranging_Algo_Overflow, /*!< 13 0b1101 Raw_Ranging_Algo_Overflow */ |
ThunderSoft | 0:293917667c17 | 336 | Ranging_Algo_Underflow, /*!< 14 0b1110 Ranging_Algo_Underflow */ |
ThunderSoft | 0:293917667c17 | 337 | Ranging_Algo_Overflow, /*!< 15 0b1111 Ranging_Algo_Overflow */ |
ThunderSoft | 0:293917667c17 | 338 | |
ThunderSoft | 0:293917667c17 | 339 | /* code below are addition for API/software side they are not hardware*/ |
ThunderSoft | 0:293917667c17 | 340 | RangingFiltered =0x10, /*!< 16 0b10000 filtered by post processing*/ |
ThunderSoft | 0:293917667c17 | 341 | DataNotReady = 0x12, /*!< 18 0b10011 New data sample not ready */ |
ThunderSoft | 0:293917667c17 | 342 | |
ThunderSoft | 0:293917667c17 | 343 | } RangeError_u; |
ThunderSoft | 0:293917667c17 | 344 | |
ThunderSoft | 0:293917667c17 | 345 | |
ThunderSoft | 0:293917667c17 | 346 | /** @defgroup device_regdef Device registers & masks definitions |
ThunderSoft | 0:293917667c17 | 347 | * @brief Device registers and masks definitions |
ThunderSoft | 0:293917667c17 | 348 | */ |
ThunderSoft | 0:293917667c17 | 349 | |
ThunderSoft | 0:293917667c17 | 350 | |
ThunderSoft | 0:293917667c17 | 351 | /** @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 352 | * @{*/ |
ThunderSoft | 0:293917667c17 | 353 | |
ThunderSoft | 0:293917667c17 | 354 | /** |
ThunderSoft | 0:293917667c17 | 355 | * The device model ID |
ThunderSoft | 0:293917667c17 | 356 | */ |
ThunderSoft | 0:293917667c17 | 357 | #define IDENTIFICATION_MODEL_ID 0x000 |
ThunderSoft | 0:293917667c17 | 358 | /** |
ThunderSoft | 0:293917667c17 | 359 | * Revision identifier of the Device for major change. |
ThunderSoft | 0:293917667c17 | 360 | */ |
ThunderSoft | 0:293917667c17 | 361 | #define IDENTIFICATION_MODULE_REV_MAJOR 0x003 |
ThunderSoft | 0:293917667c17 | 362 | /** |
ThunderSoft | 0:293917667c17 | 363 | * Revision identifier of the Device for minor change. |
ThunderSoft | 0:293917667c17 | 364 | */ |
ThunderSoft | 0:293917667c17 | 365 | #define IDENTIFICATION_MODULE_REV_MINOR 0x004 |
ThunderSoft | 0:293917667c17 | 366 | |
ThunderSoft | 0:293917667c17 | 367 | |
ThunderSoft | 0:293917667c17 | 368 | /** |
ThunderSoft | 0:293917667c17 | 369 | * @def SYSTEM_MODE_GPIO0 |
ThunderSoft | 0:293917667c17 | 370 | * @brief Configures polarity and select which function gpio 0 serves. |
ThunderSoft | 0:293917667c17 | 371 | * Gpio0 is chip enable at power up ! Be aware of all h/w implication of turning it to output. |
ThunderSoft | 0:293917667c17 | 372 | * Same definition as #SYSTEM_MODE_GPIO1 |
ThunderSoft | 0:293917667c17 | 373 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 374 | */ |
ThunderSoft | 0:293917667c17 | 375 | #define SYSTEM_MODE_GPIO0 0x010 |
ThunderSoft | 0:293917667c17 | 376 | /** |
ThunderSoft | 0:293917667c17 | 377 | * @def SYSTEM_MODE_GPIO1 |
ThunderSoft | 0:293917667c17 | 378 | * @brief Configures polarity and select what als or ranging functionality gpio pin serves. |
ThunderSoft | 0:293917667c17 | 379 | * |
ThunderSoft | 0:293917667c17 | 380 | * Function can be #GPIOx_SELECT_OFF #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT.\n |
ThunderSoft | 0:293917667c17 | 381 | * Same definition apply to register GPIO0 that is used as chip enable at power up. |
ThunderSoft | 0:293917667c17 | 382 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 383 | */ |
ThunderSoft | 0:293917667c17 | 384 | #define SYSTEM_MODE_GPIO1 0x011 |
ThunderSoft | 0:293917667c17 | 385 | /** gpio pad POLARITY mask in #SYSTEM_MODE_GPIO1 (and/or 0) write 1 to set active high polarity (positive edge) */ |
ThunderSoft | 0:293917667c17 | 386 | #define GPIOx_POLARITY_SELECT_MASK 0x20 |
ThunderSoft | 0:293917667c17 | 387 | /** gpio pad Function select shift in #SYSTEM_MODE_GPIO1 or 0 */ |
ThunderSoft | 0:293917667c17 | 388 | #define GPIOx_FUNCTIONALITY_SELECT_SHIFT 1 |
ThunderSoft | 0:293917667c17 | 389 | /** gpio pad Function select mask in #SYSTEM_MODE_GPIO1 or 0 */ |
ThunderSoft | 0:293917667c17 | 390 | #define GPIOx_FUNCTIONALITY_SELECT_MASK (0xF<<GPIOx_FUNCTIONALITY_SELECT_SHIFT) |
ThunderSoft | 0:293917667c17 | 391 | /** select no interrupt in #SYSTEM_MODE_GPIO1 pad is put in Hi-Z*/ |
ThunderSoft | 0:293917667c17 | 392 | #define GPIOx_SELECT_OFF 0x00 |
ThunderSoft | 0:293917667c17 | 393 | /** select gpiox as interrupt output in #SYSTEM_MODE_GPIO1 */ |
ThunderSoft | 0:293917667c17 | 394 | #define GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT 0x08 |
ThunderSoft | 0:293917667c17 | 395 | /** select range as source for interrupt on in #SYSTEM_MODE_GPIO1 */ |
ThunderSoft | 0:293917667c17 | 396 | #define GPIOx_MODE_SELECT_RANGING 0x00 |
ThunderSoft | 0:293917667c17 | 397 | /** select als as source for interrupt on in #SYSTEM_MODE_GPIO1 */ |
ThunderSoft | 0:293917667c17 | 398 | #define GPIOx_MODE_SELECT_ALS 0x01 |
ThunderSoft | 0:293917667c17 | 399 | |
ThunderSoft | 0:293917667c17 | 400 | |
ThunderSoft | 0:293917667c17 | 401 | /** |
ThunderSoft | 0:293917667c17 | 402 | * @def SYSTEM_INTERRUPT_CONFIG_GPIO |
ThunderSoft | 0:293917667c17 | 403 | * |
ThunderSoft | 0:293917667c17 | 404 | * @brief Configure Als and Ranging interrupt reporting |
ThunderSoft | 0:293917667c17 | 405 | * |
ThunderSoft | 0:293917667c17 | 406 | * Possible values for Range and ALS are\n |
ThunderSoft | 0:293917667c17 | 407 | * |
ThunderSoft | 0:293917667c17 | 408 | * #CONFIG_GPIO_INTERRUPT_DISABLED\n |
ThunderSoft | 0:293917667c17 | 409 | * #CONFIG_GPIO_INTERRUPT_LEVEL_LOW\n |
ThunderSoft | 0:293917667c17 | 410 | * #CONFIG_GPIO_INTERRUPT_LEVEL_HIGH\n |
ThunderSoft | 0:293917667c17 | 411 | * #CONFIG_GPIO_INTERRUPT_OUT_OF_WINDOW\n |
ThunderSoft | 0:293917667c17 | 412 | * #CONFIG_GPIO_INTERRUPT_NEW_SAMPLE_READY\n |
ThunderSoft | 0:293917667c17 | 413 | * Apply respective rang/als shift and mask \n |
ThunderSoft | 0:293917667c17 | 414 | * #CONFIG_GPIO_RANGE_SHIFT and full reg mask #CONFIG_GPIO_RANGE_MASK\n |
ThunderSoft | 0:293917667c17 | 415 | * #CONFIG_GPIO_ALS_SHIFT and full reg mask #CONFIG_GPIO_ALS_MASK\n |
ThunderSoft | 0:293917667c17 | 416 | * |
ThunderSoft | 0:293917667c17 | 417 | * \sa GPIO use for interrupt #SYSTEM_MODE_GPIO0 or #SYSTEM_MODE_GPIO1\n |
ThunderSoft | 0:293917667c17 | 418 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 419 | */ |
ThunderSoft | 0:293917667c17 | 420 | #define SYSTEM_INTERRUPT_CONFIG_GPIO 0x014 |
ThunderSoft | 0:293917667c17 | 421 | /** RANGE bits shift in #SYSTEM_INTERRUPT_CONFIG_GPIO */ |
ThunderSoft | 0:293917667c17 | 422 | #define CONFIG_GPIO_RANGE_SHIFT 0 |
ThunderSoft | 0:293917667c17 | 423 | /** RANGE bits mask in #SYSTEM_INTERRUPT_CONFIG_GPIO (unshifted)*/ |
ThunderSoft | 0:293917667c17 | 424 | #define CONFIG_GPIO_RANGE_MASK (0x7<<CONFIG_GPIO_RANGE_SHIFT) |
ThunderSoft | 0:293917667c17 | 425 | /** ALS bits shift in #SYSTEM_INTERRUPT_CONFIG_GPIO */ |
ThunderSoft | 0:293917667c17 | 426 | #define CONFIG_GPIO_ALS_SHIFT 3 |
ThunderSoft | 0:293917667c17 | 427 | /** ALS bits mask in #SYSTEM_INTERRUPT_CONFIG_GPIO (unshifted)*/ |
ThunderSoft | 0:293917667c17 | 428 | #define CONFIG_GPIO_ALS_MASK (0x7<<CONFIG_GPIO_ALS_SHIFT) |
ThunderSoft | 0:293917667c17 | 429 | /** interrupt is disabled */ |
ThunderSoft | 0:293917667c17 | 430 | #define CONFIG_GPIO_INTERRUPT_DISABLED 0x00 |
ThunderSoft | 0:293917667c17 | 431 | /** trigger when value < low threshold */ |
ThunderSoft | 0:293917667c17 | 432 | #define CONFIG_GPIO_INTERRUPT_LEVEL_LOW 0x01 |
ThunderSoft | 0:293917667c17 | 433 | /** trigger when value < low threshold */ |
ThunderSoft | 0:293917667c17 | 434 | #define CONFIG_GPIO_INTERRUPT_LEVEL_HIGH 0x02 |
ThunderSoft | 0:293917667c17 | 435 | /** trigger when outside range defined by high low threshold */ |
ThunderSoft | 0:293917667c17 | 436 | #define CONFIG_GPIO_INTERRUPT_OUT_OF_WINDOW 0x03 |
ThunderSoft | 0:293917667c17 | 437 | /** trigger when new sample are ready */ |
ThunderSoft | 0:293917667c17 | 438 | #define CONFIG_GPIO_INTERRUPT_NEW_SAMPLE_READY 0x04 |
ThunderSoft | 0:293917667c17 | 439 | |
ThunderSoft | 0:293917667c17 | 440 | /** |
ThunderSoft | 0:293917667c17 | 441 | * @def SYSTEM_INTERRUPT_CLEAR |
ThunderSoft | 0:293917667c17 | 442 | * @brief Writing to this register will clear interrupt source |
ThunderSoft | 0:293917667c17 | 443 | * |
ThunderSoft | 0:293917667c17 | 444 | * Use or combination of any #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR |
ThunderSoft | 0:293917667c17 | 445 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 446 | */ |
ThunderSoft | 0:293917667c17 | 447 | #define SYSTEM_INTERRUPT_CLEAR 0x015 |
ThunderSoft | 0:293917667c17 | 448 | /** clear ranging interrupt in write to #SYSTEM_INTERRUPT_CLEAR */ |
ThunderSoft | 0:293917667c17 | 449 | #define INTERRUPT_CLEAR_RANGING 0x01 |
ThunderSoft | 0:293917667c17 | 450 | /** clear als interrupt in write to #SYSTEM_INTERRUPT_CLEAR */ |
ThunderSoft | 0:293917667c17 | 451 | #define INTERRUPT_CLEAR_ALS 0x02 |
ThunderSoft | 0:293917667c17 | 452 | /** clear error interrupt in write to #SYSTEM_INTERRUPT_CLEAR */ |
ThunderSoft | 0:293917667c17 | 453 | #define INTERRUPT_CLEAR_ERROR 0x04 |
ThunderSoft | 0:293917667c17 | 454 | |
ThunderSoft | 0:293917667c17 | 455 | /** After power up or reset this register will start reading 1 when device is ready */ |
ThunderSoft | 0:293917667c17 | 456 | #define SYSTEM_FRESH_OUT_OF_RESET 0x016 |
ThunderSoft | 0:293917667c17 | 457 | |
ThunderSoft | 0:293917667c17 | 458 | /** |
ThunderSoft | 0:293917667c17 | 459 | * @def SYSTEM_GROUPED_PARAMETER_HOLD |
ThunderSoft | 0:293917667c17 | 460 | * @brief Writing 1/0 activate/deactivate safe host update of multiple register in critical group \n |
ThunderSoft | 0:293917667c17 | 461 | * rather use \a VL6180x_SetGroupParamHold() |
ThunderSoft | 0:293917667c17 | 462 | * |
ThunderSoft | 0:293917667c17 | 463 | * The critical register group is made of: \n |
ThunderSoft | 0:293917667c17 | 464 | * #SYSTEM_INTERRUPT_CONFIG_GPIO \n |
ThunderSoft | 0:293917667c17 | 465 | * #SYSRANGE_THRESH_HIGH \n |
ThunderSoft | 0:293917667c17 | 466 | * #SYSRANGE_THRESH_LOW \n |
ThunderSoft | 0:293917667c17 | 467 | * #SYSALS_INTEGRATION_PERIOD \n |
ThunderSoft | 0:293917667c17 | 468 | * #SYSALS_ANALOGUE_GAIN \n |
ThunderSoft | 0:293917667c17 | 469 | * #SYSALS_THRESH_HIGH \n |
ThunderSoft | 0:293917667c17 | 470 | * #SYSALS_THRESH_LOW |
ThunderSoft | 0:293917667c17 | 471 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 472 | */ |
ThunderSoft | 0:293917667c17 | 473 | #define SYSTEM_GROUPED_PARAMETER_HOLD 0x017 |
ThunderSoft | 0:293917667c17 | 474 | |
ThunderSoft | 0:293917667c17 | 475 | |
ThunderSoft | 0:293917667c17 | 476 | /** |
ThunderSoft | 0:293917667c17 | 477 | * @def SYSRANGE_START |
ThunderSoft | 0:293917667c17 | 478 | * @brief Start/stop and set operating range mode |
ThunderSoft | 0:293917667c17 | 479 | * |
ThunderSoft | 0:293917667c17 | 480 | * Write Combination of #MODE_START_STOP and #MODE_CONTINUOUS to select and start desired operation. |
ThunderSoft | 0:293917667c17 | 481 | * |
ThunderSoft | 0:293917667c17 | 482 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 483 | */ |
ThunderSoft | 0:293917667c17 | 484 | #define SYSRANGE_START 0x018 |
ThunderSoft | 0:293917667c17 | 485 | /** mask existing bit in #SYSRANGE_START*/ |
ThunderSoft | 0:293917667c17 | 486 | #define SYSRANGE_START_MODE_MASK 0x03 |
ThunderSoft | 0:293917667c17 | 487 | /** bit 0 in #SYSRANGE_START write 1 toggle state in continuous mode and arm next shot in single shot mode */ |
ThunderSoft | 0:293917667c17 | 488 | #define MODE_START_STOP 0x01 |
ThunderSoft | 0:293917667c17 | 489 | /** bit 1 write 1 in #SYSRANGE_START set continuous operation mode */ |
ThunderSoft | 0:293917667c17 | 490 | #define MODE_CONTINUOUS 0x02 |
ThunderSoft | 0:293917667c17 | 491 | /** bit 1 write 0 in #SYSRANGE_START set single shot mode */ |
ThunderSoft | 0:293917667c17 | 492 | #define MODE_SINGLESHOT 0x00 |
ThunderSoft | 0:293917667c17 | 493 | |
ThunderSoft | 0:293917667c17 | 494 | /** |
ThunderSoft | 0:293917667c17 | 495 | * @def SYSRANGE_THRESH_HIGH |
ThunderSoft | 0:293917667c17 | 496 | * High level range threshold (must be scaled) |
ThunderSoft | 0:293917667c17 | 497 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 498 | */ |
ThunderSoft | 0:293917667c17 | 499 | #define SYSRANGE_THRESH_HIGH 0x019 |
ThunderSoft | 0:293917667c17 | 500 | |
ThunderSoft | 0:293917667c17 | 501 | /** |
ThunderSoft | 0:293917667c17 | 502 | * @def SYSRANGE_THRESH_LOW |
ThunderSoft | 0:293917667c17 | 503 | * Low level range threshold (must be scaled) |
ThunderSoft | 0:293917667c17 | 504 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 505 | */ |
ThunderSoft | 0:293917667c17 | 506 | #define SYSRANGE_THRESH_LOW 0x01A |
ThunderSoft | 0:293917667c17 | 507 | |
ThunderSoft | 0:293917667c17 | 508 | /** |
ThunderSoft | 0:293917667c17 | 509 | * @def SYSRANGE_INTERMEASUREMENT_PERIOD |
ThunderSoft | 0:293917667c17 | 510 | * @brief Continuous mode intermeasurement delay \a VL6180x_RangeSetInterMeasPeriod() |
ThunderSoft | 0:293917667c17 | 511 | * |
ThunderSoft | 0:293917667c17 | 512 | * Time delay between measurements in Ranging continuous mode.\n |
ThunderSoft | 0:293917667c17 | 513 | * Range 0-254 (0 = 10ms).\n Step size = 10ms. |
ThunderSoft | 0:293917667c17 | 514 | * |
ThunderSoft | 0:293917667c17 | 515 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 516 | */ |
ThunderSoft | 0:293917667c17 | 517 | #define SYSRANGE_INTERMEASUREMENT_PERIOD 0x01B |
ThunderSoft | 0:293917667c17 | 518 | |
ThunderSoft | 0:293917667c17 | 519 | /** |
ThunderSoft | 0:293917667c17 | 520 | * @brief Maximum time to run measurement in Ranging modes. |
ThunderSoft | 0:293917667c17 | 521 | * Range 1 - 63 ms (1 code = 1 ms); |
ThunderSoft | 0:293917667c17 | 522 | * |
ThunderSoft | 0:293917667c17 | 523 | * Measurement aborted when limit reached to aid power reduction.\ |
ThunderSoft | 0:293917667c17 | 524 | * For example, 0x01 = 1ms, 0x0a = 10ms.\ |
ThunderSoft | 0:293917667c17 | 525 | * Note: Effective max_convergence_time depends on readout_averaging_sample_period setting. |
ThunderSoft | 0:293917667c17 | 526 | * |
ThunderSoft | 0:293917667c17 | 527 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 528 | */ |
ThunderSoft | 0:293917667c17 | 529 | #define SYSRANGE_MAX_CONVERGENCE_TIME 0x01C |
ThunderSoft | 0:293917667c17 | 530 | /**@brief Cross talk compensation rate |
ThunderSoft | 0:293917667c17 | 531 | * @warning never write register directly use @a VL6180x_SetXTalkCompensationRate() |
ThunderSoft | 0:293917667c17 | 532 | * refer to manual for calibration procedure and computation |
ThunderSoft | 0:293917667c17 | 533 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 534 | */ |
ThunderSoft | 0:293917667c17 | 535 | #define SYSRANGE_CROSSTALK_COMPENSATION_RATE 0x01E |
ThunderSoft | 0:293917667c17 | 536 | /** |
ThunderSoft | 0:293917667c17 | 537 | * @brief Minimum range value in mm to qualify for crosstalk compensation |
ThunderSoft | 0:293917667c17 | 538 | */ |
ThunderSoft | 0:293917667c17 | 539 | #define SYSRANGE_CROSSTALK_VALID_HEIGHT 0x021 |
ThunderSoft | 0:293917667c17 | 540 | #define SYSRANGE_EARLY_CONVERGENCE_ESTIMATE 0x022 |
ThunderSoft | 0:293917667c17 | 541 | #define SYSRANGE_PART_TO_PART_RANGE_OFFSET 0x024 |
ThunderSoft | 0:293917667c17 | 542 | /** |
ThunderSoft | 0:293917667c17 | 543 | * @brief range ignore valid height |
ThunderSoft | 0:293917667c17 | 544 | * @warning do not program directly use @a VL6180x_RangeIgnoreConfigure() and @a VL6180x_RangeIgnoreSetEnable() |
ThunderSoft | 0:293917667c17 | 545 | */ |
ThunderSoft | 0:293917667c17 | 546 | #define SYSRANGE_RANGE_IGNORE_VALID_HEIGHT 0x025 |
ThunderSoft | 0:293917667c17 | 547 | /** |
ThunderSoft | 0:293917667c17 | 548 | * @brief range ignore threshold |
ThunderSoft | 0:293917667c17 | 549 | * @warning do not program directly use @a VL6180x_RangeIgnoreConfigure() and @a VL6180x_RangeIgnoreSetEnable() |
ThunderSoft | 0:293917667c17 | 550 | */ |
ThunderSoft | 0:293917667c17 | 551 | #define SYSRANGE_RANGE_IGNORE_THRESHOLD 0x026 |
ThunderSoft | 0:293917667c17 | 552 | #define SYSRANGE_EMITTER_BLOCK_THRESHOLD 0x028 |
ThunderSoft | 0:293917667c17 | 553 | #define SYSRANGE_MAX_AMBIENT_LEVEL_THRESH 0x02A |
ThunderSoft | 0:293917667c17 | 554 | #define SYSRANGE_MAX_AMBIENT_LEVEL_MULT 0x02C |
ThunderSoft | 0:293917667c17 | 555 | /** @brief various Enable check enable register |
ThunderSoft | 0:293917667c17 | 556 | * @a VL6180x_RangeSetEceState() |
ThunderSoft | 0:293917667c17 | 557 | * @a VL6180x_RangeIgnoreConfigure() and @a VL6180x_RangeIgnoreSetEnable() |
ThunderSoft | 0:293917667c17 | 558 | */ |
ThunderSoft | 0:293917667c17 | 559 | #define SYSRANGE_RANGE_CHECK_ENABLES 0x02D |
ThunderSoft | 0:293917667c17 | 560 | #define RANGE_CHECK_ECE_ENABLE_MASK 0x01 |
ThunderSoft | 0:293917667c17 | 561 | #define RANGE_CHECK_RANGE_ENABLE_MASK 0x02 |
ThunderSoft | 0:293917667c17 | 562 | #define RANGE_CHECK_SNR_ENABLE 0x10 |
ThunderSoft | 0:293917667c17 | 563 | |
ThunderSoft | 0:293917667c17 | 564 | #define SYSRANGE_VHV_RECALIBRATE 0x02E |
ThunderSoft | 0:293917667c17 | 565 | #define SYSRANGE_VHV_REPEAT_RATE 0x031 |
ThunderSoft | 0:293917667c17 | 566 | |
ThunderSoft | 0:293917667c17 | 567 | /** |
ThunderSoft | 0:293917667c17 | 568 | * @def SYSALS_START |
ThunderSoft | 0:293917667c17 | 569 | * @brief Start/stop and set operating als mode |
ThunderSoft | 0:293917667c17 | 570 | * |
ThunderSoft | 0:293917667c17 | 571 | * same bit definition as range \a #SYSRANGE_START \n |
ThunderSoft | 0:293917667c17 | 572 | */ |
ThunderSoft | 0:293917667c17 | 573 | #define SYSALS_START 0x038 |
ThunderSoft | 0:293917667c17 | 574 | |
ThunderSoft | 0:293917667c17 | 575 | /** ALS low Threshold high */ |
ThunderSoft | 0:293917667c17 | 576 | #define SYSALS_THRESH_HIGH 0x03A |
ThunderSoft | 0:293917667c17 | 577 | /** ALS low Threshold low */ |
ThunderSoft | 0:293917667c17 | 578 | #define SYSALS_THRESH_LOW 0x03C |
ThunderSoft | 0:293917667c17 | 579 | /** ALS intermeasurement period */ |
ThunderSoft | 0:293917667c17 | 580 | #define SYSALS_INTERMEASUREMENT_PERIOD 0x03E |
ThunderSoft | 0:293917667c17 | 581 | /** |
ThunderSoft | 0:293917667c17 | 582 | * @warning or value with 0x40 when writing to these register*/ |
ThunderSoft | 0:293917667c17 | 583 | #define SYSALS_ANALOGUE_GAIN 0x03F |
ThunderSoft | 0:293917667c17 | 584 | /** ALS integration period */ |
ThunderSoft | 0:293917667c17 | 585 | #define SYSALS_INTEGRATION_PERIOD 0x040 |
ThunderSoft | 0:293917667c17 | 586 | |
ThunderSoft | 0:293917667c17 | 587 | /** |
ThunderSoft | 0:293917667c17 | 588 | * @brief Result range status |
ThunderSoft | 0:293917667c17 | 589 | * |
ThunderSoft | 0:293917667c17 | 590 | * Hold the various range interrupt flags and error Specific error codes |
ThunderSoft | 0:293917667c17 | 591 | */ |
ThunderSoft | 0:293917667c17 | 592 | #define RESULT_RANGE_STATUS 0x04D |
ThunderSoft | 0:293917667c17 | 593 | /** Device ready for new command bit 0*/ |
ThunderSoft | 0:293917667c17 | 594 | #define RANGE_DEVICE_READY_MASK 0x01 |
ThunderSoft | 0:293917667c17 | 595 | /** mask for error status covers bits [7:4] in #RESULT_RANGE_STATUS @a ::RangeError_u */ |
ThunderSoft | 0:293917667c17 | 596 | #define RANGE_ERROR_CODE_MASK 0xF0 /* */ |
ThunderSoft | 0:293917667c17 | 597 | /** range error bit position in #RESULT_RANGE_STATUS */ |
ThunderSoft | 0:293917667c17 | 598 | #define RANGE_ERROR_CODE_SHIFT 4 |
ThunderSoft | 0:293917667c17 | 599 | |
ThunderSoft | 0:293917667c17 | 600 | /** |
ThunderSoft | 0:293917667c17 | 601 | * @def RESULT_ALS_STATUS |
ThunderSoft | 0:293917667c17 | 602 | * @brief Result als status \n |
ThunderSoft | 0:293917667c17 | 603 | * Hold the various als interrupt flags and Specific error codes |
ThunderSoft | 0:293917667c17 | 604 | */ |
ThunderSoft | 0:293917667c17 | 605 | #define RESULT_ALS_STATUS 0x4E |
ThunderSoft | 0:293917667c17 | 606 | /** Device ready for new command bit 0*/ |
ThunderSoft | 0:293917667c17 | 607 | #define ALS_DEVICE_READY_MASK 0x01 |
ThunderSoft | 0:293917667c17 | 608 | |
ThunderSoft | 0:293917667c17 | 609 | /** |
ThunderSoft | 0:293917667c17 | 610 | * @def RESULT_ALS_VAL |
ThunderSoft | 0:293917667c17 | 611 | * @brief 16 Bit ALS count output value. |
ThunderSoft | 0:293917667c17 | 612 | * |
ThunderSoft | 0:293917667c17 | 613 | * Lux value depends on Gain and integration settings and calibrated lux/count setting |
ThunderSoft | 0:293917667c17 | 614 | * \a VL6180x_AlsGetLux() \a VL6180x_AlsGetMeasurement() |
ThunderSoft | 0:293917667c17 | 615 | */ |
ThunderSoft | 0:293917667c17 | 616 | #define RESULT_ALS_VAL 0x50 |
ThunderSoft | 0:293917667c17 | 617 | |
ThunderSoft | 0:293917667c17 | 618 | /** |
ThunderSoft | 0:293917667c17 | 619 | * @def FW_ALS_RESULT_SCALER |
ThunderSoft | 0:293917667c17 | 620 | * @brief Als scaler register Bits [3:0] analogue gain 1 to 16x |
ThunderSoft | 0:293917667c17 | 621 | * these register content is cached by API in \a VL6180xDevData_t::AlsScaler |
ThunderSoft | 0:293917667c17 | 622 | * for lux computation acceleration |
ThunderSoft | 0:293917667c17 | 623 | */ |
ThunderSoft | 0:293917667c17 | 624 | #define FW_ALS_RESULT_SCALER 0x120 |
ThunderSoft | 0:293917667c17 | 625 | |
ThunderSoft | 0:293917667c17 | 626 | |
ThunderSoft | 0:293917667c17 | 627 | /** |
ThunderSoft | 0:293917667c17 | 628 | * these union can be use as a generic bit field type for map #RESULT_INTERRUPT_STATUS_GPIO register |
ThunderSoft | 0:293917667c17 | 629 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 630 | */ |
ThunderSoft | 0:293917667c17 | 631 | typedef union IntrStatus_u{ |
ThunderSoft | 0:293917667c17 | 632 | uint8_t val; /*!< raw 8 bit register value*/ |
ThunderSoft | 0:293917667c17 | 633 | struct { |
ThunderSoft | 0:293917667c17 | 634 | unsigned Range :3; /*!< Range status one of :\n \a #RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD \n \a #RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD \n \a #RES_INT_STAT_GPIO_OUT_OF_WINDOW \n \a #RES_INT_STAT_GPIO_NEW_SAMPLE_READY */ |
ThunderSoft | 0:293917667c17 | 635 | unsigned Als :3; /*!< Als status one of: \n \a #RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD \n \a #RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD \n \a #RES_INT_STAT_GPIO_OUT_OF_WINDOW \n \a #RES_INT_STAT_GPIO_NEW_SAMPLE_READY */ |
ThunderSoft | 0:293917667c17 | 636 | unsigned Error :2; /*!< Error status of: \n \a #RES_INT_ERROR_LASER_SAFETY \n \a #RES_INT_ERROR_PLL */ |
ThunderSoft | 0:293917667c17 | 637 | } status; /*!< interrupt status as bit field */ |
ThunderSoft | 0:293917667c17 | 638 | } IntrStatus_t; |
ThunderSoft | 0:293917667c17 | 639 | |
ThunderSoft | 0:293917667c17 | 640 | /** |
ThunderSoft | 0:293917667c17 | 641 | * @def RESULT_INTERRUPT_STATUS_GPIO |
ThunderSoft | 0:293917667c17 | 642 | * @brief System interrupt status report selected interrupt for als and ranging |
ThunderSoft | 0:293917667c17 | 643 | * |
ThunderSoft | 0:293917667c17 | 644 | * These register can be polled even if no gpio pins is active\n |
ThunderSoft | 0:293917667c17 | 645 | * What reported is selected by \a #SYSTEM_INTERRUPT_CONFIG_GPIO \n |
ThunderSoft | 0:293917667c17 | 646 | * Range mask with \a #RES_INT_RANGE_MASK and shit by \a #RES_INT_RANGE_SHIFT |
ThunderSoft | 0:293917667c17 | 647 | * Als mask with \a #RES_INT_ALS_MASK and shit by \a #RES_INT_ALS_SHIFT |
ThunderSoft | 0:293917667c17 | 648 | * Result value express condition (or combination?) |
ThunderSoft | 0:293917667c17 | 649 | * \a #RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD \n |
ThunderSoft | 0:293917667c17 | 650 | * \a #RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD \n |
ThunderSoft | 0:293917667c17 | 651 | * \a #RES_INT_STAT_GPIO_OUT_OF_WINDOW \n |
ThunderSoft | 0:293917667c17 | 652 | * \a #RES_INT_STAT_GPIO_NEW_SAMPLE_READY |
ThunderSoft | 0:293917667c17 | 653 | * |
ThunderSoft | 0:293917667c17 | 654 | * @ingroup device_regdef |
ThunderSoft | 0:293917667c17 | 655 | */ |
ThunderSoft | 0:293917667c17 | 656 | #define RESULT_INTERRUPT_STATUS_GPIO 0x4F |
ThunderSoft | 0:293917667c17 | 657 | /** ranging interrupt 1st bit position in #RESULT_INTERRUPT_STATUS_GPIO */ |
ThunderSoft | 0:293917667c17 | 658 | #define RES_INT_RANGE_SHIFT 0 |
ThunderSoft | 0:293917667c17 | 659 | /** ALS interrupt 1st bit position in #RESULT_INTERRUPT_STATUS_GPIO */ |
ThunderSoft | 0:293917667c17 | 660 | #define RES_INT_ALS_SHIFT 3 |
ThunderSoft | 0:293917667c17 | 661 | /** interrupt bit position in #RESULT_INTERRUPT_STATUS_GPIO */ |
ThunderSoft | 0:293917667c17 | 662 | #define RES_INT_ERROR_SHIFT 6 |
ThunderSoft | 0:293917667c17 | 663 | /** Ranging interrupt mask in #RESULT_INTERRUPT_STATUS_GPIO (prior to shift) \sa IntrStatus_t */ |
ThunderSoft | 0:293917667c17 | 664 | #define RES_INT_RANGE_MASK (0x7<<RES_INT_RANGE_SHIFT) |
ThunderSoft | 0:293917667c17 | 665 | /** als interrupt mask in #RESULT_INTERRUPT_STATUS_GPIO (prior to shift) \sa IntrStatus_t */ |
ThunderSoft | 0:293917667c17 | 666 | #define RES_INT_ALS_MASK (0x7<<RES_INT_ALS_SHIFT) |
ThunderSoft | 0:293917667c17 | 667 | |
ThunderSoft | 0:293917667c17 | 668 | /** low threshold condition in #RESULT_INTERRUPT_STATUS_GPIO for */ |
ThunderSoft | 0:293917667c17 | 669 | #define RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD 0x01 |
ThunderSoft | 0:293917667c17 | 670 | /** high threshold condition in #RESULT_INTERRUPT_STATUS_GPIO for ALs or Rage*/ |
ThunderSoft | 0:293917667c17 | 671 | #define RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD 0x02 |
ThunderSoft | 0:293917667c17 | 672 | /** out of window condition in #RESULT_INTERRUPT_STATUS_GPIO */ |
ThunderSoft | 0:293917667c17 | 673 | #define RES_INT_STAT_GPIO_OUT_OF_WINDOW 0x03 |
ThunderSoft | 0:293917667c17 | 674 | /** new sample ready in #RESULT_INTERRUPT_STATUS_GPIO */ |
ThunderSoft | 0:293917667c17 | 675 | #define RES_INT_STAT_GPIO_NEW_SAMPLE_READY 0x04 |
ThunderSoft | 0:293917667c17 | 676 | /** error in #RESULT_INTERRUPT_STATUS_GPIO */ |
ThunderSoft | 0:293917667c17 | 677 | #define RES_INT_ERROR_MASK (0x3<<RES_INT_ERROR_SHIFT) |
ThunderSoft | 0:293917667c17 | 678 | /** laser safety error on #RES_INT_ERROR_MASK of #RESULT_INTERRUPT_STATUS_GPIO */ |
ThunderSoft | 0:293917667c17 | 679 | #define RES_INT_ERROR_LASER_SAFETY 1 |
ThunderSoft | 0:293917667c17 | 680 | /** pll 1 or 2 error on #RES_INT_ERROR_MASK of #RESULT_INTERRUPT_STATUS_GPIO*/ |
ThunderSoft | 0:293917667c17 | 681 | #define RES_INT_ERROR_PLL 2 |
ThunderSoft | 0:293917667c17 | 682 | |
ThunderSoft | 0:293917667c17 | 683 | /** |
ThunderSoft | 0:293917667c17 | 684 | * Final range result value presented to the user for use. Unit is in mm. |
ThunderSoft | 0:293917667c17 | 685 | */ |
ThunderSoft | 0:293917667c17 | 686 | #define RESULT_RANGE_VAL 0x062 |
ThunderSoft | 0:293917667c17 | 687 | |
ThunderSoft | 0:293917667c17 | 688 | /** |
ThunderSoft | 0:293917667c17 | 689 | * Raw Range result value with offset applied (no cross talk compensation applied). Unit is in mm. |
ThunderSoft | 0:293917667c17 | 690 | */ |
ThunderSoft | 0:293917667c17 | 691 | #define RESULT_RANGE_RAW 0x064 |
ThunderSoft | 0:293917667c17 | 692 | |
ThunderSoft | 0:293917667c17 | 693 | /** |
ThunderSoft | 0:293917667c17 | 694 | * @brief Sensor count rate of signal returns correlated to IR emitter. |
ThunderSoft | 0:293917667c17 | 695 | * |
ThunderSoft | 0:293917667c17 | 696 | * Computed from RETURN_SIGNAL_COUNT / RETURN_CONV_TIME. Mcps 9.7 format |
ThunderSoft | 0:293917667c17 | 697 | */ |
ThunderSoft | 0:293917667c17 | 698 | #define RESULT_RANGE_SIGNAL_RATE 0x066 |
ThunderSoft | 0:293917667c17 | 699 | |
ThunderSoft | 0:293917667c17 | 700 | /** |
ThunderSoft | 0:293917667c17 | 701 | * @brief Return signal count |
ThunderSoft | 0:293917667c17 | 702 | * |
ThunderSoft | 0:293917667c17 | 703 | * Sensor count output value attributed to signal correlated to IR emitter on the Return array. |
ThunderSoft | 0:293917667c17 | 704 | */ |
ThunderSoft | 0:293917667c17 | 705 | #define RESULT_RANGE_RETURN_SIGNAL_COUNT 0x06C |
ThunderSoft | 0:293917667c17 | 706 | |
ThunderSoft | 0:293917667c17 | 707 | /** |
ThunderSoft | 0:293917667c17 | 708 | * @brief Reference signal count |
ThunderSoft | 0:293917667c17 | 709 | * |
ThunderSoft | 0:293917667c17 | 710 | * sensor count output value attributed to signal correlated to IR emitter on the Reference array. |
ThunderSoft | 0:293917667c17 | 711 | */ |
ThunderSoft | 0:293917667c17 | 712 | #define RESULT_RANGE_REFERENCE_SIGNAL_COUNT 0x070 |
ThunderSoft | 0:293917667c17 | 713 | |
ThunderSoft | 0:293917667c17 | 714 | /** |
ThunderSoft | 0:293917667c17 | 715 | * @brief Return ambient count |
ThunderSoft | 0:293917667c17 | 716 | * |
ThunderSoft | 0:293917667c17 | 717 | * sensor count output value attributed to uncorrelated ambient signal on the Return array. |
ThunderSoft | 0:293917667c17 | 718 | * Must be multiplied by 6 if used to calculate the ambient to signal threshold |
ThunderSoft | 0:293917667c17 | 719 | */ |
ThunderSoft | 0:293917667c17 | 720 | #define RESULT_RANGE_RETURN_AMB_COUNT 0x074 |
ThunderSoft | 0:293917667c17 | 721 | |
ThunderSoft | 0:293917667c17 | 722 | /** |
ThunderSoft | 0:293917667c17 | 723 | * @brief Reference ambient count |
ThunderSoft | 0:293917667c17 | 724 | * |
ThunderSoft | 0:293917667c17 | 725 | * Sensor count output value attributed to uncorrelated ambient signal on the Reference array. |
ThunderSoft | 0:293917667c17 | 726 | */ |
ThunderSoft | 0:293917667c17 | 727 | #define RESULT_RANGE_REFERENCE_AMB_COUNT 0x078 |
ThunderSoft | 0:293917667c17 | 728 | |
ThunderSoft | 0:293917667c17 | 729 | /** |
ThunderSoft | 0:293917667c17 | 730 | * sensor count output value attributed to signal on the Return array. |
ThunderSoft | 0:293917667c17 | 731 | */ |
ThunderSoft | 0:293917667c17 | 732 | #define RESULT_RANGE_RETURN_CONV_TIME 0x07C |
ThunderSoft | 0:293917667c17 | 733 | |
ThunderSoft | 0:293917667c17 | 734 | /** |
ThunderSoft | 0:293917667c17 | 735 | * sensor count output value attributed to signal on the Reference array. |
ThunderSoft | 0:293917667c17 | 736 | */ |
ThunderSoft | 0:293917667c17 | 737 | #define RESULT_RANGE_REFERENCE_CONV_TIME 0x080 |
ThunderSoft | 0:293917667c17 | 738 | |
ThunderSoft | 0:293917667c17 | 739 | |
ThunderSoft | 0:293917667c17 | 740 | /** |
ThunderSoft | 0:293917667c17 | 741 | * @def RANGE_SCALER |
ThunderSoft | 0:293917667c17 | 742 | * @brief RANGE scaling register |
ThunderSoft | 0:293917667c17 | 743 | * |
ThunderSoft | 0:293917667c17 | 744 | * Never should user write directly onto that register directly \a VL6180x_UpscaleSetScaling() |
ThunderSoft | 0:293917667c17 | 745 | */ |
ThunderSoft | 0:293917667c17 | 746 | #define RANGE_SCALER 0x096 |
ThunderSoft | 0:293917667c17 | 747 | |
ThunderSoft | 0:293917667c17 | 748 | /** |
ThunderSoft | 0:293917667c17 | 749 | * @def READOUT_AVERAGING_SAMPLE_PERIOD |
ThunderSoft | 0:293917667c17 | 750 | * @brief Readout averaging sample period register |
ThunderSoft | 0:293917667c17 | 751 | * |
ThunderSoft | 0:293917667c17 | 752 | * |
ThunderSoft | 0:293917667c17 | 753 | * The internal readout averaging sample period can be adjusted from 0 to 255. |
ThunderSoft | 0:293917667c17 | 754 | * Increasing the sampling period decreases noise but also reduces the effective |
ThunderSoft | 0:293917667c17 | 755 | * max convergence time and increases power consumption |
ThunderSoft | 0:293917667c17 | 756 | * Each unit sample period corresponds to around 64.5 μs additional processing time. |
ThunderSoft | 0:293917667c17 | 757 | * The recommended setting is 48 which equates to around 4.3 ms. |
ThunderSoft | 0:293917667c17 | 758 | * |
ThunderSoft | 0:293917667c17 | 759 | * see datasheet for more detail |
ThunderSoft | 0:293917667c17 | 760 | */ |
ThunderSoft | 0:293917667c17 | 761 | #define READOUT_AVERAGING_SAMPLE_PERIOD 0x10A |
ThunderSoft | 0:293917667c17 | 762 | |
ThunderSoft | 0:293917667c17 | 763 | /** |
ThunderSoft | 0:293917667c17 | 764 | * @def I2C_SLAVE_DEVICE_ADDRESS |
ThunderSoft | 0:293917667c17 | 765 | * User programmable I2C address (7-bit). Device address can be re-designated after power-up. |
ThunderSoft | 0:293917667c17 | 766 | * @warning What programmed in the register 7-0 are bit 8-1 of i2c address on bus (bit 0 is rd/wr) |
ThunderSoft | 0:293917667c17 | 767 | * so what prohamd is commonly whar ergfer as adrerss /2 |
ThunderSoft | 0:293917667c17 | 768 | * @sa VL6180x_SetI2CAddress() |
ThunderSoft | 0:293917667c17 | 769 | */ |
ThunderSoft | 0:293917667c17 | 770 | #define I2C_SLAVE_DEVICE_ADDRESS 0x212 |
ThunderSoft | 0:293917667c17 | 771 | |
ThunderSoft | 0:293917667c17 | 772 | #endif /* _VL6180x_DEF */ |
ThunderSoft | 0:293917667c17 | 773 |