Changes to the library related to interrupt mode.
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Dependents: Display_53L0A1_IntSatelites Display_53L0A1_InterruptMode
Fork of X_NUCLEO_53L0A1 by
Components/VL53L0X/vl53l0x_class.h@0:c523920bcc09, 2016-11-28 (annotated)
- Committer:
- johnAlexander
- Date:
- Mon Nov 28 11:25:33 2016 +0000
- Revision:
- 0:c523920bcc09
- Child:
- 2:58b5e9097aa3
- Child:
- 4:4e1576541eed
Singleshot, polled ranging example using central VL53L0X sensor.; Compatible with mass-market v1.1 C API.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
johnAlexander | 0:c523920bcc09 | 1 | /******************************************************************************* |
johnAlexander | 0:c523920bcc09 | 2 | Copyright © 2016, STMicroelectronics International N.V. |
johnAlexander | 0:c523920bcc09 | 3 | All rights reserved. |
johnAlexander | 0:c523920bcc09 | 4 | |
johnAlexander | 0:c523920bcc09 | 5 | Redistribution and use in source and binary forms, with or without |
johnAlexander | 0:c523920bcc09 | 6 | modification, are permitted provided that the following conditions are met: |
johnAlexander | 0:c523920bcc09 | 7 | * Redistributions of source code must retain the above copyright |
johnAlexander | 0:c523920bcc09 | 8 | notice, this list of conditions and the following disclaimer. |
johnAlexander | 0:c523920bcc09 | 9 | * Redistributions in binary form must reproduce the above copyright |
johnAlexander | 0:c523920bcc09 | 10 | notice, this list of conditions and the following disclaimer in the |
johnAlexander | 0:c523920bcc09 | 11 | documentation and/or other materials provided with the distribution. |
johnAlexander | 0:c523920bcc09 | 12 | * Neither the name of STMicroelectronics nor the |
johnAlexander | 0:c523920bcc09 | 13 | names of its contributors may be used to endorse or promote products |
johnAlexander | 0:c523920bcc09 | 14 | derived from this software without specific prior written permission. |
johnAlexander | 0:c523920bcc09 | 15 | |
johnAlexander | 0:c523920bcc09 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
johnAlexander | 0:c523920bcc09 | 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
johnAlexander | 0:c523920bcc09 | 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND |
johnAlexander | 0:c523920bcc09 | 19 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. |
johnAlexander | 0:c523920bcc09 | 20 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY |
johnAlexander | 0:c523920bcc09 | 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
johnAlexander | 0:c523920bcc09 | 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
johnAlexander | 0:c523920bcc09 | 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
johnAlexander | 0:c523920bcc09 | 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
johnAlexander | 0:c523920bcc09 | 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
johnAlexander | 0:c523920bcc09 | 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
johnAlexander | 0:c523920bcc09 | 27 | *****************************************************************************/ |
johnAlexander | 0:c523920bcc09 | 28 | |
johnAlexander | 0:c523920bcc09 | 29 | #ifndef __VL53L0X_CLASS_H |
johnAlexander | 0:c523920bcc09 | 30 | #define __VL53L0X_CLASS_H |
johnAlexander | 0:c523920bcc09 | 31 | |
johnAlexander | 0:c523920bcc09 | 32 | |
johnAlexander | 0:c523920bcc09 | 33 | #ifdef _MSC_VER |
johnAlexander | 0:c523920bcc09 | 34 | # ifdef VL53L0X_API_EXPORTS |
johnAlexander | 0:c523920bcc09 | 35 | # define VL53L0X_API __declspec(dllexport) |
johnAlexander | 0:c523920bcc09 | 36 | # else |
johnAlexander | 0:c523920bcc09 | 37 | # define VL53L0X_API |
johnAlexander | 0:c523920bcc09 | 38 | # endif |
johnAlexander | 0:c523920bcc09 | 39 | #else |
johnAlexander | 0:c523920bcc09 | 40 | # define VL53L0X_API |
johnAlexander | 0:c523920bcc09 | 41 | #endif |
johnAlexander | 0:c523920bcc09 | 42 | |
johnAlexander | 0:c523920bcc09 | 43 | |
johnAlexander | 0:c523920bcc09 | 44 | /* Includes ------------------------------------------------------------------*/ |
johnAlexander | 0:c523920bcc09 | 45 | #include "RangeSensor.h" |
johnAlexander | 0:c523920bcc09 | 46 | #include "DevI2C.h" |
johnAlexander | 0:c523920bcc09 | 47 | |
johnAlexander | 0:c523920bcc09 | 48 | #include "vl53l0x_def.h" |
johnAlexander | 0:c523920bcc09 | 49 | #include "vl53l0x_platform.h" |
johnAlexander | 0:c523920bcc09 | 50 | #include "stmpe1600_class.h" |
johnAlexander | 0:c523920bcc09 | 51 | |
johnAlexander | 0:c523920bcc09 | 52 | |
johnAlexander | 0:c523920bcc09 | 53 | /** |
johnAlexander | 0:c523920bcc09 | 54 | * The device model ID |
johnAlexander | 0:c523920bcc09 | 55 | */ |
johnAlexander | 0:c523920bcc09 | 56 | #define IDENTIFICATION_MODEL_ID 0x000 |
johnAlexander | 0:c523920bcc09 | 57 | |
johnAlexander | 0:c523920bcc09 | 58 | |
johnAlexander | 0:c523920bcc09 | 59 | #define STATUS_OK 0x00 |
johnAlexander | 0:c523920bcc09 | 60 | #define STATUS_FAIL 0x01 |
johnAlexander | 0:c523920bcc09 | 61 | |
johnAlexander | 0:c523920bcc09 | 62 | |
johnAlexander | 0:c523920bcc09 | 63 | #define VL53L0X_OsDelay(...) HAL_Delay(2) |
johnAlexander | 0:c523920bcc09 | 64 | |
johnAlexander | 0:c523920bcc09 | 65 | #ifdef USE_EMPTY_STRING |
johnAlexander | 0:c523920bcc09 | 66 | #define VL53L0X_STRING_DEVICE_INFO_NAME "" |
johnAlexander | 0:c523920bcc09 | 67 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "" |
johnAlexander | 0:c523920bcc09 | 68 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "" |
johnAlexander | 0:c523920bcc09 | 69 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "" |
johnAlexander | 0:c523920bcc09 | 70 | #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "" |
johnAlexander | 0:c523920bcc09 | 71 | #define VL53L0X_STRING_DEVICE_INFO_TYPE "" |
johnAlexander | 0:c523920bcc09 | 72 | |
johnAlexander | 0:c523920bcc09 | 73 | /* PAL ERROR strings */ |
johnAlexander | 0:c523920bcc09 | 74 | #define VL53L0X_STRING_ERROR_NONE "" |
johnAlexander | 0:c523920bcc09 | 75 | #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING "" |
johnAlexander | 0:c523920bcc09 | 76 | #define VL53L0X_STRING_ERROR_MIN_CLIPPED "" |
johnAlexander | 0:c523920bcc09 | 77 | #define VL53L0X_STRING_ERROR_UNDEFINED "" |
johnAlexander | 0:c523920bcc09 | 78 | #define VL53L0X_STRING_ERROR_INVALID_PARAMS "" |
johnAlexander | 0:c523920bcc09 | 79 | #define VL53L0X_STRING_ERROR_NOT_SUPPORTED "" |
johnAlexander | 0:c523920bcc09 | 80 | #define VL53L0X_STRING_ERROR_RANGE_ERROR "" |
johnAlexander | 0:c523920bcc09 | 81 | #define VL53L0X_STRING_ERROR_TIME_OUT "" |
johnAlexander | 0:c523920bcc09 | 82 | #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED "" |
johnAlexander | 0:c523920bcc09 | 83 | #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL "" |
johnAlexander | 0:c523920bcc09 | 84 | #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING "" |
johnAlexander | 0:c523920bcc09 | 85 | #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED "" |
johnAlexander | 0:c523920bcc09 | 86 | #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE "" |
johnAlexander | 0:c523920bcc09 | 87 | #define VL53L0X_STRING_ERROR_INVALID_COMMAND "" |
johnAlexander | 0:c523920bcc09 | 88 | #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO "" |
johnAlexander | 0:c523920bcc09 | 89 | #define VL53L0X_STRING_ERROR_REF_SPAD_INIT "" |
johnAlexander | 0:c523920bcc09 | 90 | #define VL53L0X_STRING_ERROR_NOT_IMPLEMENTED "" |
johnAlexander | 0:c523920bcc09 | 91 | |
johnAlexander | 0:c523920bcc09 | 92 | #define VL53L0X_STRING_UNKNOW_ERROR_CODE "" |
johnAlexander | 0:c523920bcc09 | 93 | |
johnAlexander | 0:c523920bcc09 | 94 | |
johnAlexander | 0:c523920bcc09 | 95 | |
johnAlexander | 0:c523920bcc09 | 96 | /* Range Status */ |
johnAlexander | 0:c523920bcc09 | 97 | #define VL53L0X_STRING_RANGESTATUS_NONE "" |
johnAlexander | 0:c523920bcc09 | 98 | #define VL53L0X_STRING_RANGESTATUS_RANGEVALID "" |
johnAlexander | 0:c523920bcc09 | 99 | #define VL53L0X_STRING_RANGESTATUS_SIGMA "" |
johnAlexander | 0:c523920bcc09 | 100 | #define VL53L0X_STRING_RANGESTATUS_SIGNAL "" |
johnAlexander | 0:c523920bcc09 | 101 | #define VL53L0X_STRING_RANGESTATUS_MINRANGE "" |
johnAlexander | 0:c523920bcc09 | 102 | #define VL53L0X_STRING_RANGESTATUS_PHASE "" |
johnAlexander | 0:c523920bcc09 | 103 | #define VL53L0X_STRING_RANGESTATUS_HW "" |
johnAlexander | 0:c523920bcc09 | 104 | |
johnAlexander | 0:c523920bcc09 | 105 | |
johnAlexander | 0:c523920bcc09 | 106 | /* Range Status */ |
johnAlexander | 0:c523920bcc09 | 107 | #define VL53L0X_STRING_STATE_POWERDOWN "" |
johnAlexander | 0:c523920bcc09 | 108 | #define VL53L0X_STRING_STATE_WAIT_STATICINIT "" |
johnAlexander | 0:c523920bcc09 | 109 | #define VL53L0X_STRING_STATE_STANDBY "" |
johnAlexander | 0:c523920bcc09 | 110 | #define VL53L0X_STRING_STATE_IDLE "" |
johnAlexander | 0:c523920bcc09 | 111 | #define VL53L0X_STRING_STATE_RUNNING "" |
johnAlexander | 0:c523920bcc09 | 112 | #define VL53L0X_STRING_STATE_UNKNOWN "" |
johnAlexander | 0:c523920bcc09 | 113 | #define VL53L0X_STRING_STATE_ERROR "" |
johnAlexander | 0:c523920bcc09 | 114 | |
johnAlexander | 0:c523920bcc09 | 115 | |
johnAlexander | 0:c523920bcc09 | 116 | /* Device Specific */ |
johnAlexander | 0:c523920bcc09 | 117 | #define VL53L0X_STRING_DEVICEERROR_NONE "" |
johnAlexander | 0:c523920bcc09 | 118 | #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE "" |
johnAlexander | 0:c523920bcc09 | 119 | #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE "" |
johnAlexander | 0:c523920bcc09 | 120 | #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND "" |
johnAlexander | 0:c523920bcc09 | 121 | #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET "" |
johnAlexander | 0:c523920bcc09 | 122 | #define VL53L0X_STRING_DEVICEERROR_SNRCHECK "" |
johnAlexander | 0:c523920bcc09 | 123 | #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK "" |
johnAlexander | 0:c523920bcc09 | 124 | #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK "" |
johnAlexander | 0:c523920bcc09 | 125 | #define VL53L0X_STRING_DEVICEERROR_TCC "" |
johnAlexander | 0:c523920bcc09 | 126 | #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY "" |
johnAlexander | 0:c523920bcc09 | 127 | #define VL53L0X_STRING_DEVICEERROR_MINCLIP "" |
johnAlexander | 0:c523920bcc09 | 128 | #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE "" |
johnAlexander | 0:c523920bcc09 | 129 | #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW "" |
johnAlexander | 0:c523920bcc09 | 130 | #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW "" |
johnAlexander | 0:c523920bcc09 | 131 | #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD "" |
johnAlexander | 0:c523920bcc09 | 132 | #define VL53L0X_STRING_DEVICEERROR_UNKNOWN "" |
johnAlexander | 0:c523920bcc09 | 133 | |
johnAlexander | 0:c523920bcc09 | 134 | /* Check Enable */ |
johnAlexander | 0:c523920bcc09 | 135 | #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE "" |
johnAlexander | 0:c523920bcc09 | 136 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE "" |
johnAlexander | 0:c523920bcc09 | 137 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP "" |
johnAlexander | 0:c523920bcc09 | 138 | #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD "" |
johnAlexander | 0:c523920bcc09 | 139 | |
johnAlexander | 0:c523920bcc09 | 140 | /* Sequence Step */ |
johnAlexander | 0:c523920bcc09 | 141 | #define VL53L0X_STRING_SEQUENCESTEP_TCC "" |
johnAlexander | 0:c523920bcc09 | 142 | #define VL53L0X_STRING_SEQUENCESTEP_DSS "" |
johnAlexander | 0:c523920bcc09 | 143 | #define VL53L0X_STRING_SEQUENCESTEP_MSRC "" |
johnAlexander | 0:c523920bcc09 | 144 | #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE "" |
johnAlexander | 0:c523920bcc09 | 145 | #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE "" |
johnAlexander | 0:c523920bcc09 | 146 | #else |
johnAlexander | 0:c523920bcc09 | 147 | #define VL53L0X_STRING_DEVICE_INFO_NAME "VL53L0X cut1.0" |
johnAlexander | 0:c523920bcc09 | 148 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "VL53L0X TS0" |
johnAlexander | 0:c523920bcc09 | 149 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "VL53L0X TS1" |
johnAlexander | 0:c523920bcc09 | 150 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "VL53L0X TS2" |
johnAlexander | 0:c523920bcc09 | 151 | #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "VL53L0X ES1 or later" |
johnAlexander | 0:c523920bcc09 | 152 | #define VL53L0X_STRING_DEVICE_INFO_TYPE "VL53L0X" |
johnAlexander | 0:c523920bcc09 | 153 | |
johnAlexander | 0:c523920bcc09 | 154 | /* PAL ERROR strings */ |
johnAlexander | 0:c523920bcc09 | 155 | #define VL53L0X_STRING_ERROR_NONE \ |
johnAlexander | 0:c523920bcc09 | 156 | "No Error" |
johnAlexander | 0:c523920bcc09 | 157 | #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING \ |
johnAlexander | 0:c523920bcc09 | 158 | "Calibration Warning Error" |
johnAlexander | 0:c523920bcc09 | 159 | #define VL53L0X_STRING_ERROR_MIN_CLIPPED \ |
johnAlexander | 0:c523920bcc09 | 160 | "Min clipped error" |
johnAlexander | 0:c523920bcc09 | 161 | #define VL53L0X_STRING_ERROR_UNDEFINED \ |
johnAlexander | 0:c523920bcc09 | 162 | "Undefined error" |
johnAlexander | 0:c523920bcc09 | 163 | #define VL53L0X_STRING_ERROR_INVALID_PARAMS \ |
johnAlexander | 0:c523920bcc09 | 164 | "Invalid parameters error" |
johnAlexander | 0:c523920bcc09 | 165 | #define VL53L0X_STRING_ERROR_NOT_SUPPORTED \ |
johnAlexander | 0:c523920bcc09 | 166 | "Not supported error" |
johnAlexander | 0:c523920bcc09 | 167 | #define VL53L0X_STRING_ERROR_RANGE_ERROR \ |
johnAlexander | 0:c523920bcc09 | 168 | "Range error" |
johnAlexander | 0:c523920bcc09 | 169 | #define VL53L0X_STRING_ERROR_TIME_OUT \ |
johnAlexander | 0:c523920bcc09 | 170 | "Time out error" |
johnAlexander | 0:c523920bcc09 | 171 | #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED \ |
johnAlexander | 0:c523920bcc09 | 172 | "Mode not supported error" |
johnAlexander | 0:c523920bcc09 | 173 | #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL \ |
johnAlexander | 0:c523920bcc09 | 174 | "Buffer too small" |
johnAlexander | 0:c523920bcc09 | 175 | #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING \ |
johnAlexander | 0:c523920bcc09 | 176 | "GPIO not existing" |
johnAlexander | 0:c523920bcc09 | 177 | #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \ |
johnAlexander | 0:c523920bcc09 | 178 | "GPIO funct not supported" |
johnAlexander | 0:c523920bcc09 | 179 | #define VL53L0X_STRING_ERROR_INTERRUPT_NOT_CLEARED \ |
johnAlexander | 0:c523920bcc09 | 180 | "Interrupt not Cleared" |
johnAlexander | 0:c523920bcc09 | 181 | #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE \ |
johnAlexander | 0:c523920bcc09 | 182 | "Control Interface Error" |
johnAlexander | 0:c523920bcc09 | 183 | #define VL53L0X_STRING_ERROR_INVALID_COMMAND \ |
johnAlexander | 0:c523920bcc09 | 184 | "Invalid Command Error" |
johnAlexander | 0:c523920bcc09 | 185 | #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO \ |
johnAlexander | 0:c523920bcc09 | 186 | "Division by zero Error" |
johnAlexander | 0:c523920bcc09 | 187 | #define VL53L0X_STRING_ERROR_REF_SPAD_INIT \ |
johnAlexander | 0:c523920bcc09 | 188 | "Reference Spad Init Error" |
johnAlexander | 0:c523920bcc09 | 189 | #define VL53L0X_STRING_ERROR_NOT_IMPLEMENTED \ |
johnAlexander | 0:c523920bcc09 | 190 | "Not implemented error" |
johnAlexander | 0:c523920bcc09 | 191 | |
johnAlexander | 0:c523920bcc09 | 192 | #define VL53L0X_STRING_UNKNOW_ERROR_CODE \ |
johnAlexander | 0:c523920bcc09 | 193 | "Unknown Error Code" |
johnAlexander | 0:c523920bcc09 | 194 | |
johnAlexander | 0:c523920bcc09 | 195 | |
johnAlexander | 0:c523920bcc09 | 196 | |
johnAlexander | 0:c523920bcc09 | 197 | /* Range Status */ |
johnAlexander | 0:c523920bcc09 | 198 | #define VL53L0X_STRING_RANGESTATUS_NONE "No Update" |
johnAlexander | 0:c523920bcc09 | 199 | #define VL53L0X_STRING_RANGESTATUS_RANGEVALID "Range Valid" |
johnAlexander | 0:c523920bcc09 | 200 | #define VL53L0X_STRING_RANGESTATUS_SIGMA "Sigma Fail" |
johnAlexander | 0:c523920bcc09 | 201 | #define VL53L0X_STRING_RANGESTATUS_SIGNAL "Signal Fail" |
johnAlexander | 0:c523920bcc09 | 202 | #define VL53L0X_STRING_RANGESTATUS_MINRANGE "Min Range Fail" |
johnAlexander | 0:c523920bcc09 | 203 | #define VL53L0X_STRING_RANGESTATUS_PHASE "Phase Fail" |
johnAlexander | 0:c523920bcc09 | 204 | #define VL53L0X_STRING_RANGESTATUS_HW "Hardware Fail" |
johnAlexander | 0:c523920bcc09 | 205 | |
johnAlexander | 0:c523920bcc09 | 206 | |
johnAlexander | 0:c523920bcc09 | 207 | /* Range Status */ |
johnAlexander | 0:c523920bcc09 | 208 | #define VL53L0X_STRING_STATE_POWERDOWN "POWERDOWN State" |
johnAlexander | 0:c523920bcc09 | 209 | #define VL53L0X_STRING_STATE_WAIT_STATICINIT \ |
johnAlexander | 0:c523920bcc09 | 210 | "Wait for staticinit State" |
johnAlexander | 0:c523920bcc09 | 211 | #define VL53L0X_STRING_STATE_STANDBY "STANDBY State" |
johnAlexander | 0:c523920bcc09 | 212 | #define VL53L0X_STRING_STATE_IDLE "IDLE State" |
johnAlexander | 0:c523920bcc09 | 213 | #define VL53L0X_STRING_STATE_RUNNING "RUNNING State" |
johnAlexander | 0:c523920bcc09 | 214 | #define VL53L0X_STRING_STATE_UNKNOWN "UNKNOWN State" |
johnAlexander | 0:c523920bcc09 | 215 | #define VL53L0X_STRING_STATE_ERROR "ERROR State" |
johnAlexander | 0:c523920bcc09 | 216 | |
johnAlexander | 0:c523920bcc09 | 217 | |
johnAlexander | 0:c523920bcc09 | 218 | /* Device Specific */ |
johnAlexander | 0:c523920bcc09 | 219 | #define VL53L0X_STRING_DEVICEERROR_NONE "No Update" |
johnAlexander | 0:c523920bcc09 | 220 | #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE \ |
johnAlexander | 0:c523920bcc09 | 221 | "VCSEL Continuity Test Failure" |
johnAlexander | 0:c523920bcc09 | 222 | #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE \ |
johnAlexander | 0:c523920bcc09 | 223 | "VCSEL Watchdog Test Failure" |
johnAlexander | 0:c523920bcc09 | 224 | #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND \ |
johnAlexander | 0:c523920bcc09 | 225 | "No VHV Value found" |
johnAlexander | 0:c523920bcc09 | 226 | #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET \ |
johnAlexander | 0:c523920bcc09 | 227 | "MSRC No Target Error" |
johnAlexander | 0:c523920bcc09 | 228 | #define VL53L0X_STRING_DEVICEERROR_SNRCHECK \ |
johnAlexander | 0:c523920bcc09 | 229 | "SNR Check Exit" |
johnAlexander | 0:c523920bcc09 | 230 | #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK \ |
johnAlexander | 0:c523920bcc09 | 231 | "Range Phase Check Error" |
johnAlexander | 0:c523920bcc09 | 232 | #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK \ |
johnAlexander | 0:c523920bcc09 | 233 | "Sigma Threshold Check Error" |
johnAlexander | 0:c523920bcc09 | 234 | #define VL53L0X_STRING_DEVICEERROR_TCC \ |
johnAlexander | 0:c523920bcc09 | 235 | "TCC Error" |
johnAlexander | 0:c523920bcc09 | 236 | #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY \ |
johnAlexander | 0:c523920bcc09 | 237 | "Phase Consistency Error" |
johnAlexander | 0:c523920bcc09 | 238 | #define VL53L0X_STRING_DEVICEERROR_MINCLIP \ |
johnAlexander | 0:c523920bcc09 | 239 | "Min Clip Error" |
johnAlexander | 0:c523920bcc09 | 240 | #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE \ |
johnAlexander | 0:c523920bcc09 | 241 | "Range Complete" |
johnAlexander | 0:c523920bcc09 | 242 | #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW \ |
johnAlexander | 0:c523920bcc09 | 243 | "Range Algo Underflow Error" |
johnAlexander | 0:c523920bcc09 | 244 | #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW \ |
johnAlexander | 0:c523920bcc09 | 245 | "Range Algo Overlow Error" |
johnAlexander | 0:c523920bcc09 | 246 | #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD \ |
johnAlexander | 0:c523920bcc09 | 247 | "Range Ignore Threshold Error" |
johnAlexander | 0:c523920bcc09 | 248 | #define VL53L0X_STRING_DEVICEERROR_UNKNOWN \ |
johnAlexander | 0:c523920bcc09 | 249 | "Unknown error code" |
johnAlexander | 0:c523920bcc09 | 250 | |
johnAlexander | 0:c523920bcc09 | 251 | /* Check Enable */ |
johnAlexander | 0:c523920bcc09 | 252 | #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \ |
johnAlexander | 0:c523920bcc09 | 253 | "SIGMA FINAL RANGE" |
johnAlexander | 0:c523920bcc09 | 254 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \ |
johnAlexander | 0:c523920bcc09 | 255 | "SIGNAL RATE FINAL RANGE" |
johnAlexander | 0:c523920bcc09 | 256 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP \ |
johnAlexander | 0:c523920bcc09 | 257 | "SIGNAL REF CLIP" |
johnAlexander | 0:c523920bcc09 | 258 | #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \ |
johnAlexander | 0:c523920bcc09 | 259 | "RANGE IGNORE THRESHOLD" |
johnAlexander | 0:c523920bcc09 | 260 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_MSRC \ |
johnAlexander | 0:c523920bcc09 | 261 | "SIGNAL RATE MSRC" |
johnAlexander | 0:c523920bcc09 | 262 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE \ |
johnAlexander | 0:c523920bcc09 | 263 | "SIGNAL RATE PRE RANGE" |
johnAlexander | 0:c523920bcc09 | 264 | |
johnAlexander | 0:c523920bcc09 | 265 | /* Sequence Step */ |
johnAlexander | 0:c523920bcc09 | 266 | #define VL53L0X_STRING_SEQUENCESTEP_TCC "TCC" |
johnAlexander | 0:c523920bcc09 | 267 | #define VL53L0X_STRING_SEQUENCESTEP_DSS "DSS" |
johnAlexander | 0:c523920bcc09 | 268 | #define VL53L0X_STRING_SEQUENCESTEP_MSRC "MSRC" |
johnAlexander | 0:c523920bcc09 | 269 | #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE "PRE RANGE" |
johnAlexander | 0:c523920bcc09 | 270 | #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE "FINAL RANGE" |
johnAlexander | 0:c523920bcc09 | 271 | #endif /* USE_EMPTY_STRING */ |
johnAlexander | 0:c523920bcc09 | 272 | |
johnAlexander | 0:c523920bcc09 | 273 | |
johnAlexander | 0:c523920bcc09 | 274 | |
johnAlexander | 0:c523920bcc09 | 275 | |
johnAlexander | 0:c523920bcc09 | 276 | |
johnAlexander | 0:c523920bcc09 | 277 | /* sensor operating modes */ |
johnAlexander | 0:c523920bcc09 | 278 | typedef enum |
johnAlexander | 0:c523920bcc09 | 279 | { |
johnAlexander | 0:c523920bcc09 | 280 | range_single_shot_polling=1, |
johnAlexander | 0:c523920bcc09 | 281 | range_continuous_polling, |
johnAlexander | 0:c523920bcc09 | 282 | range_continuous_interrupt, |
johnAlexander | 0:c523920bcc09 | 283 | range_continuous_polling_low_threshold, |
johnAlexander | 0:c523920bcc09 | 284 | range_continuous_polling_high_threshold, |
johnAlexander | 0:c523920bcc09 | 285 | range_continuous_polling_out_of_window, |
johnAlexander | 0:c523920bcc09 | 286 | range_continuous_interrupt_low_threshold, |
johnAlexander | 0:c523920bcc09 | 287 | range_continuous_interrupt_high_threshold, |
johnAlexander | 0:c523920bcc09 | 288 | range_continuous_interrupt_out_of_window, |
johnAlexander | 0:c523920bcc09 | 289 | }OperatingMode; |
johnAlexander | 0:c523920bcc09 | 290 | |
johnAlexander | 0:c523920bcc09 | 291 | /** default device address */ |
johnAlexander | 0:c523920bcc09 | 292 | #define DEFAULT_DEVICE_ADDRESS 0x52 /* (8-bit) */ |
johnAlexander | 0:c523920bcc09 | 293 | |
johnAlexander | 0:c523920bcc09 | 294 | /* Classes -------------------------------------------------------------------*/ |
johnAlexander | 0:c523920bcc09 | 295 | /** Class representing a VL53L0 sensor component |
johnAlexander | 0:c523920bcc09 | 296 | */ |
johnAlexander | 0:c523920bcc09 | 297 | class VL53L0X : public RangeSensor |
johnAlexander | 0:c523920bcc09 | 298 | { |
johnAlexander | 0:c523920bcc09 | 299 | public: |
johnAlexander | 0:c523920bcc09 | 300 | /** Constructor |
johnAlexander | 0:c523920bcc09 | 301 | * @param[in] &i2c device I2C to be used for communication |
johnAlexander | 0:c523920bcc09 | 302 | * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT |
johnAlexander | 0:c523920bcc09 | 303 | * @param[in] DevAddr device address, 0x29 by default |
johnAlexander | 0:c523920bcc09 | 304 | */ |
johnAlexander | 0:c523920bcc09 | 305 | VL53L0X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), dev_i2c(i2c), gpio0(&pin) |
johnAlexander | 0:c523920bcc09 | 306 | { |
johnAlexander | 0:c523920bcc09 | 307 | MyDevice.I2cDevAddr=DevAddr; |
johnAlexander | 0:c523920bcc09 | 308 | MyDevice.comms_type=1; // VL53L0X_COMMS_I2C |
johnAlexander | 0:c523920bcc09 | 309 | MyDevice.comms_speed_khz=400; |
johnAlexander | 0:c523920bcc09 | 310 | Device=&MyDevice; |
johnAlexander | 0:c523920bcc09 | 311 | expgpio0=NULL; |
johnAlexander | 0:c523920bcc09 | 312 | if (pin_gpio1 != NC) { gpio1Int = new InterruptIn(pin_gpio1); } |
johnAlexander | 0:c523920bcc09 | 313 | else { gpio1Int = NULL; } |
johnAlexander | 0:c523920bcc09 | 314 | } |
johnAlexander | 0:c523920bcc09 | 315 | |
johnAlexander | 0:c523920bcc09 | 316 | /** Constructor 2 (STMPE1600DigiOut) |
johnAlexander | 0:c523920bcc09 | 317 | * @param[in] i2c device I2C to be used for communication |
johnAlexander | 0:c523920bcc09 | 318 | * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE |
johnAlexander | 0:c523920bcc09 | 319 | * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT |
johnAlexander | 0:c523920bcc09 | 320 | * @param[in] device address, 0x29 by default |
johnAlexander | 0:c523920bcc09 | 321 | */ |
johnAlexander | 0:c523920bcc09 | 322 | VL53L0X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), dev_i2c(i2c), expgpio0(&pin) |
johnAlexander | 0:c523920bcc09 | 323 | { |
johnAlexander | 0:c523920bcc09 | 324 | MyDevice.I2cDevAddr=DevAddr; |
johnAlexander | 0:c523920bcc09 | 325 | MyDevice.comms_type=1; // VL53L0X_COMMS_I2C |
johnAlexander | 0:c523920bcc09 | 326 | MyDevice.comms_speed_khz=400; |
johnAlexander | 0:c523920bcc09 | 327 | Device=&MyDevice; |
johnAlexander | 0:c523920bcc09 | 328 | gpio0=NULL; |
johnAlexander | 0:c523920bcc09 | 329 | if (pin_gpio1 != NC) { gpio1Int = new InterruptIn(pin_gpio1); } |
johnAlexander | 0:c523920bcc09 | 330 | else { gpio1Int = NULL; } |
johnAlexander | 0:c523920bcc09 | 331 | } |
johnAlexander | 0:c523920bcc09 | 332 | |
johnAlexander | 0:c523920bcc09 | 333 | /** Destructor |
johnAlexander | 0:c523920bcc09 | 334 | */ |
johnAlexander | 0:c523920bcc09 | 335 | virtual ~VL53L0X(){ |
johnAlexander | 0:c523920bcc09 | 336 | if (gpio1Int != NULL) delete gpio1Int; |
johnAlexander | 0:c523920bcc09 | 337 | } |
johnAlexander | 0:c523920bcc09 | 338 | /* warning: VL53L0X class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor. |
johnAlexander | 0:c523920bcc09 | 339 | The warning should request to introduce a virtual destructor to make sure to delete the object */ |
johnAlexander | 0:c523920bcc09 | 340 | |
johnAlexander | 0:c523920bcc09 | 341 | /*** Interface Methods ***/ |
johnAlexander | 0:c523920bcc09 | 342 | /*** High level API ***/ |
johnAlexander | 0:c523920bcc09 | 343 | /** |
johnAlexander | 0:c523920bcc09 | 344 | * @brief PowerOn the sensor |
johnAlexander | 0:c523920bcc09 | 345 | * @return void |
johnAlexander | 0:c523920bcc09 | 346 | */ |
johnAlexander | 0:c523920bcc09 | 347 | /* turns on the sensor */ |
johnAlexander | 0:c523920bcc09 | 348 | void VL53L0X_On(void) |
johnAlexander | 0:c523920bcc09 | 349 | { |
johnAlexander | 0:c523920bcc09 | 350 | if (gpio0) |
johnAlexander | 0:c523920bcc09 | 351 | *gpio0 = 1; |
johnAlexander | 0:c523920bcc09 | 352 | else if (expgpio0) |
johnAlexander | 0:c523920bcc09 | 353 | *expgpio0 = 1; |
johnAlexander | 0:c523920bcc09 | 354 | } |
johnAlexander | 0:c523920bcc09 | 355 | |
johnAlexander | 0:c523920bcc09 | 356 | /** |
johnAlexander | 0:c523920bcc09 | 357 | * @brief PowerOff the sensor |
johnAlexander | 0:c523920bcc09 | 358 | * @return void |
johnAlexander | 0:c523920bcc09 | 359 | */ |
johnAlexander | 0:c523920bcc09 | 360 | /* turns off the sensor */ |
johnAlexander | 0:c523920bcc09 | 361 | void VL53L0X_Off(void) |
johnAlexander | 0:c523920bcc09 | 362 | { |
johnAlexander | 0:c523920bcc09 | 363 | if (gpio0) |
johnAlexander | 0:c523920bcc09 | 364 | *gpio0 = 0; |
johnAlexander | 0:c523920bcc09 | 365 | else if (expgpio0) |
johnAlexander | 0:c523920bcc09 | 366 | *expgpio0 = 0; |
johnAlexander | 0:c523920bcc09 | 367 | } |
johnAlexander | 0:c523920bcc09 | 368 | |
johnAlexander | 0:c523920bcc09 | 369 | /** |
johnAlexander | 0:c523920bcc09 | 370 | * @brief Initialize the sensor with default values |
johnAlexander | 0:c523920bcc09 | 371 | * @return 0 on Success |
johnAlexander | 0:c523920bcc09 | 372 | */ |
johnAlexander | 0:c523920bcc09 | 373 | int InitSensor(uint8_t NewAddr); |
johnAlexander | 0:c523920bcc09 | 374 | |
johnAlexander | 0:c523920bcc09 | 375 | int RawInitSensor(void); |
johnAlexander | 0:c523920bcc09 | 376 | int initDevice(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 377 | int setLongRangePresets(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 378 | int DoRanging(VL53L0X_Dev_t *pMyDevice); |
johnAlexander | 0:c523920bcc09 | 379 | |
johnAlexander | 0:c523920bcc09 | 380 | |
johnAlexander | 0:c523920bcc09 | 381 | |
johnAlexander | 0:c523920bcc09 | 382 | |
johnAlexander | 0:c523920bcc09 | 383 | /** |
johnAlexander | 0:c523920bcc09 | 384 | * @brief Start the measure indicated by operating mode |
johnAlexander | 0:c523920bcc09 | 385 | * @param[in] operating_mode specifies requested measure |
johnAlexander | 0:c523920bcc09 | 386 | * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure |
johnAlexander | 0:c523920bcc09 | 387 | * @return 0 on Success |
johnAlexander | 0:c523920bcc09 | 388 | */ |
johnAlexander | 0:c523920bcc09 | 389 | int StartMeasurement(OperatingMode operating_mode, void (*fptr)(void)); |
johnAlexander | 0:c523920bcc09 | 390 | |
johnAlexander | 0:c523920bcc09 | 391 | /** |
johnAlexander | 0:c523920bcc09 | 392 | * @brief Get results for the measure indicated by operating mode |
johnAlexander | 0:c523920bcc09 | 393 | * @param[in] operating_mode specifies requested measure results |
johnAlexander | 0:c523920bcc09 | 394 | * @param[out] Data pointer to the MeasureData_t structure to read data in to |
johnAlexander | 0:c523920bcc09 | 395 | * @return 0 on Success |
johnAlexander | 0:c523920bcc09 | 396 | */ |
johnAlexander | 0:c523920bcc09 | 397 | int GetMeasurement(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *Data); |
johnAlexander | 0:c523920bcc09 | 398 | |
johnAlexander | 0:c523920bcc09 | 399 | /** |
johnAlexander | 0:c523920bcc09 | 400 | * @brief Stop the currently running measure indicate by operating_mode |
johnAlexander | 0:c523920bcc09 | 401 | * @param[in] operating_mode specifies requested measure to stop |
johnAlexander | 0:c523920bcc09 | 402 | * @return 0 on Success |
johnAlexander | 0:c523920bcc09 | 403 | */ |
johnAlexander | 0:c523920bcc09 | 404 | int StopMeasurement(OperatingMode operating_mode); |
johnAlexander | 0:c523920bcc09 | 405 | |
johnAlexander | 0:c523920bcc09 | 406 | /** |
johnAlexander | 0:c523920bcc09 | 407 | * @brief Interrupt handling func to be called by user after an INT is occourred |
johnAlexander | 0:c523920bcc09 | 408 | * @param[in] opeating_mode indicating the in progress measure |
johnAlexander | 0:c523920bcc09 | 409 | * @param[out] Data pointer to the MeasureData_t structure to read data in to |
johnAlexander | 0:c523920bcc09 | 410 | * @return 0 on Success |
johnAlexander | 0:c523920bcc09 | 411 | */ |
johnAlexander | 0:c523920bcc09 | 412 | int HandleIRQ(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *Data); |
johnAlexander | 0:c523920bcc09 | 413 | |
johnAlexander | 0:c523920bcc09 | 414 | /** |
johnAlexander | 0:c523920bcc09 | 415 | * @brief Enable interrupt measure IRQ |
johnAlexander | 0:c523920bcc09 | 416 | * @return 0 on Success |
johnAlexander | 0:c523920bcc09 | 417 | */ |
johnAlexander | 0:c523920bcc09 | 418 | void EnableInterruptMeasureDetectionIRQ(void) |
johnAlexander | 0:c523920bcc09 | 419 | { |
johnAlexander | 0:c523920bcc09 | 420 | if (gpio1Int != NULL) gpio1Int->enable_irq(); |
johnAlexander | 0:c523920bcc09 | 421 | } |
johnAlexander | 0:c523920bcc09 | 422 | |
johnAlexander | 0:c523920bcc09 | 423 | /** |
johnAlexander | 0:c523920bcc09 | 424 | * @brief Disable interrupt measure IRQ |
johnAlexander | 0:c523920bcc09 | 425 | * @return 0 on Success |
johnAlexander | 0:c523920bcc09 | 426 | */ |
johnAlexander | 0:c523920bcc09 | 427 | void DisableInterruptMeasureDetectionIRQ(void) |
johnAlexander | 0:c523920bcc09 | 428 | { |
johnAlexander | 0:c523920bcc09 | 429 | if (gpio1Int != NULL) gpio1Int->disable_irq(); |
johnAlexander | 0:c523920bcc09 | 430 | } |
johnAlexander | 0:c523920bcc09 | 431 | /*** End High level API ***/ |
johnAlexander | 0:c523920bcc09 | 432 | |
johnAlexander | 0:c523920bcc09 | 433 | /** |
johnAlexander | 0:c523920bcc09 | 434 | * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready |
johnAlexander | 0:c523920bcc09 | 435 | * @param[in] fptr pointer to call back function to be called whenever an interrupt occours |
johnAlexander | 0:c523920bcc09 | 436 | * @return 0 on Success |
johnAlexander | 0:c523920bcc09 | 437 | */ |
johnAlexander | 0:c523920bcc09 | 438 | void AttachInterruptMeasureDetectionIRQ(void (*fptr)(void)) |
johnAlexander | 0:c523920bcc09 | 439 | { |
johnAlexander | 0:c523920bcc09 | 440 | if (gpio1Int != NULL) gpio1Int->rise(fptr); |
johnAlexander | 0:c523920bcc09 | 441 | } |
johnAlexander | 0:c523920bcc09 | 442 | |
johnAlexander | 0:c523920bcc09 | 443 | /** |
johnAlexander | 0:c523920bcc09 | 444 | * @brief Check the sensor presence |
johnAlexander | 0:c523920bcc09 | 445 | * @return 1 when device is present |
johnAlexander | 0:c523920bcc09 | 446 | */ |
johnAlexander | 0:c523920bcc09 | 447 | unsigned Present() |
johnAlexander | 0:c523920bcc09 | 448 | { |
johnAlexander | 0:c523920bcc09 | 449 | // return Device->Present; |
johnAlexander | 0:c523920bcc09 | 450 | return 1; |
johnAlexander | 0:c523920bcc09 | 451 | } |
johnAlexander | 0:c523920bcc09 | 452 | |
johnAlexander | 0:c523920bcc09 | 453 | /** Wrapper functions */ |
johnAlexander | 0:c523920bcc09 | 454 | /** @defgroup api_init Init functions |
johnAlexander | 0:c523920bcc09 | 455 | * @brief API init functions |
johnAlexander | 0:c523920bcc09 | 456 | * @ingroup api_hl |
johnAlexander | 0:c523920bcc09 | 457 | * @{ |
johnAlexander | 0:c523920bcc09 | 458 | */ |
johnAlexander | 0:c523920bcc09 | 459 | /** |
johnAlexander | 0:c523920bcc09 | 460 | * @brief Wait for device booted after chip enable (hardware standby) |
johnAlexander | 0:c523920bcc09 | 461 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 462 | * After Chip enable Application you can also simply wait at least 1ms to ensure device is ready |
johnAlexander | 0:c523920bcc09 | 463 | * @warning After device chip enable (gpio0) de-asserted user must wait gpio1 to get asserted (hardware standby). |
johnAlexander | 0:c523920bcc09 | 464 | * or wait at least 400usec prior to do any low level access or api call . |
johnAlexander | 0:c523920bcc09 | 465 | * |
johnAlexander | 0:c523920bcc09 | 466 | * This function implements polling for standby but you must ensure 400usec from chip enable passed\n |
johnAlexander | 0:c523920bcc09 | 467 | * @warning if device get prepared @a VL53L0X_Prepare() re-using these function can hold indefinitely\n |
johnAlexander | 0:c523920bcc09 | 468 | * |
johnAlexander | 0:c523920bcc09 | 469 | * @param void |
johnAlexander | 0:c523920bcc09 | 470 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 471 | */ |
johnAlexander | 0:c523920bcc09 | 472 | int WaitDeviceBooted() |
johnAlexander | 0:c523920bcc09 | 473 | { |
johnAlexander | 0:c523920bcc09 | 474 | return VL53L0X_WaitDeviceBooted(Device); |
johnAlexander | 0:c523920bcc09 | 475 | // return 1; |
johnAlexander | 0:c523920bcc09 | 476 | } |
johnAlexander | 0:c523920bcc09 | 477 | |
johnAlexander | 0:c523920bcc09 | 478 | /** |
johnAlexander | 0:c523920bcc09 | 479 | * |
johnAlexander | 0:c523920bcc09 | 480 | * @brief One time device initialization |
johnAlexander | 0:c523920bcc09 | 481 | * |
johnAlexander | 0:c523920bcc09 | 482 | * To be called once and only once after device is brought out of reset (Chip enable) and booted see @a VL6180x_WaitDeviceBooted() |
johnAlexander | 0:c523920bcc09 | 483 | * |
johnAlexander | 0:c523920bcc09 | 484 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 485 | * When not used after a fresh device "power up" or reset, it may return @a #CALIBRATION_WARNING |
johnAlexander | 0:c523920bcc09 | 486 | * meaning wrong calibration data may have been fetched from device that can result in ranging offset error\n |
johnAlexander | 0:c523920bcc09 | 487 | * If application cannot execute device reset or need to run VL6180x_InitData multiple time |
johnAlexander | 0:c523920bcc09 | 488 | * then it must ensure proper offset calibration saving and restore on its own |
johnAlexander | 0:c523920bcc09 | 489 | * by using @a VL6180x_GetOffsetCalibrationData() on first power up and then @a VL6180x_SetOffsetCalibrationData() all all subsequent init |
johnAlexander | 0:c523920bcc09 | 490 | * |
johnAlexander | 0:c523920bcc09 | 491 | * @param void |
johnAlexander | 0:c523920bcc09 | 492 | * @return 0 on success, @a #CALIBRATION_WARNING if failed |
johnAlexander | 0:c523920bcc09 | 493 | */ |
johnAlexander | 0:c523920bcc09 | 494 | virtual int Init() |
johnAlexander | 0:c523920bcc09 | 495 | { |
johnAlexander | 0:c523920bcc09 | 496 | return VL53L0X_DataInit(&MyDevice); |
johnAlexander | 0:c523920bcc09 | 497 | // return VL53L0X_DataInit(Device); |
johnAlexander | 0:c523920bcc09 | 498 | // return 1; |
johnAlexander | 0:c523920bcc09 | 499 | } |
johnAlexander | 0:c523920bcc09 | 500 | |
johnAlexander | 0:c523920bcc09 | 501 | /** |
johnAlexander | 0:c523920bcc09 | 502 | * @brief Configure GPIO1 function and set polarity. |
johnAlexander | 0:c523920bcc09 | 503 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 504 | * To be used prior to arm single shot measure or start continuous mode. |
johnAlexander | 0:c523920bcc09 | 505 | * |
johnAlexander | 0:c523920bcc09 | 506 | * The function uses @a VL6180x_SetupGPIOx() for setting gpio 1. |
johnAlexander | 0:c523920bcc09 | 507 | * @warning changing polarity can generate a spurious interrupt on pins. |
johnAlexander | 0:c523920bcc09 | 508 | * It sets an interrupt flags condition that must be cleared to avoid polling hangs. \n |
johnAlexander | 0:c523920bcc09 | 509 | * It is safe to run VL6180x_ClearAllInterrupt() just after. |
johnAlexander | 0:c523920bcc09 | 510 | * |
johnAlexander | 0:c523920bcc09 | 511 | * @param IntFunction The interrupt functionality to use one of :\n |
johnAlexander | 0:c523920bcc09 | 512 | * @a #GPIOx_SELECT_OFF \n |
johnAlexander | 0:c523920bcc09 | 513 | * @a #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT |
johnAlexander | 0:c523920bcc09 | 514 | * @param ActiveHigh The interrupt line polarity see ::IntrPol_e |
johnAlexander | 0:c523920bcc09 | 515 | * use @a #INTR_POL_LOW (falling edge) or @a #INTR_POL_HIGH (rising edge) |
johnAlexander | 0:c523920bcc09 | 516 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 517 | */ |
johnAlexander | 0:c523920bcc09 | 518 | int SetupGPIO1(uint8_t InitFunction, int ActiveHigh) |
johnAlexander | 0:c523920bcc09 | 519 | { |
johnAlexander | 0:c523920bcc09 | 520 | // return VL6180x_SetupGPIO1(Device, InitFunction, ActiveHigh); |
johnAlexander | 0:c523920bcc09 | 521 | return 1; |
johnAlexander | 0:c523920bcc09 | 522 | } |
johnAlexander | 0:c523920bcc09 | 523 | |
johnAlexander | 0:c523920bcc09 | 524 | /** |
johnAlexander | 0:c523920bcc09 | 525 | * @brief Prepare device for operation |
johnAlexander | 0:c523920bcc09 | 526 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 527 | * Does static initialization and reprogram common default settings \n |
johnAlexander | 0:c523920bcc09 | 528 | * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n |
johnAlexander | 0:c523920bcc09 | 529 | * After prepare user can : \n |
johnAlexander | 0:c523920bcc09 | 530 | * @li Call other API function to set other settings\n |
johnAlexander | 0:c523920bcc09 | 531 | * @li Configure the interrupt pins, etc... \n |
johnAlexander | 0:c523920bcc09 | 532 | * @li Then start ranging or ALS operations in single shot or continuous mode |
johnAlexander | 0:c523920bcc09 | 533 | * |
johnAlexander | 0:c523920bcc09 | 534 | * @param void |
johnAlexander | 0:c523920bcc09 | 535 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 536 | */ |
johnAlexander | 0:c523920bcc09 | 537 | int Prepare() |
johnAlexander | 0:c523920bcc09 | 538 | { |
johnAlexander | 0:c523920bcc09 | 539 | // return VL6180x_Prepare(Device); |
johnAlexander | 0:c523920bcc09 | 540 | // taken from rangingTest() in vl53l0x_SingleRanging_Example.c |
johnAlexander | 0:c523920bcc09 | 541 | VL53L0X_Error Status = VL53L0X_ERROR_NONE; |
johnAlexander | 0:c523920bcc09 | 542 | uint32_t refSpadCount; |
johnAlexander | 0:c523920bcc09 | 543 | uint8_t isApertureSpads; |
johnAlexander | 0:c523920bcc09 | 544 | uint8_t VhvSettings; |
johnAlexander | 0:c523920bcc09 | 545 | uint8_t PhaseCal; |
johnAlexander | 0:c523920bcc09 | 546 | |
johnAlexander | 0:c523920bcc09 | 547 | if(Status == VL53L0X_ERROR_NONE) |
johnAlexander | 0:c523920bcc09 | 548 | { |
johnAlexander | 0:c523920bcc09 | 549 | printf ("Call of VL53L0X_StaticInit\n"); |
johnAlexander | 0:c523920bcc09 | 550 | Status = VL53L0X_StaticInit(Device); // Device Initialization |
johnAlexander | 0:c523920bcc09 | 551 | } |
johnAlexander | 0:c523920bcc09 | 552 | |
johnAlexander | 0:c523920bcc09 | 553 | if(Status == VL53L0X_ERROR_NONE) |
johnAlexander | 0:c523920bcc09 | 554 | { |
johnAlexander | 0:c523920bcc09 | 555 | printf ("Call of VL53L0X_PerformRefCalibration\n"); |
johnAlexander | 0:c523920bcc09 | 556 | Status = VL53L0X_PerformRefCalibration(Device, |
johnAlexander | 0:c523920bcc09 | 557 | &VhvSettings, &PhaseCal); // Device Initialization |
johnAlexander | 0:c523920bcc09 | 558 | } |
johnAlexander | 0:c523920bcc09 | 559 | |
johnAlexander | 0:c523920bcc09 | 560 | if(Status == VL53L0X_ERROR_NONE) |
johnAlexander | 0:c523920bcc09 | 561 | { |
johnAlexander | 0:c523920bcc09 | 562 | printf ("Call of VL53L0X_PerformRefSpadManagement\n"); |
johnAlexander | 0:c523920bcc09 | 563 | Status = VL53L0X_PerformRefSpadManagement(Device, |
johnAlexander | 0:c523920bcc09 | 564 | &refSpadCount, &isApertureSpads); // Device Initialization |
johnAlexander | 0:c523920bcc09 | 565 | // printf ("refSpadCount = %d, isApertureSpads = %d\n", refSpadCount, isApertureSpads); |
johnAlexander | 0:c523920bcc09 | 566 | } |
johnAlexander | 0:c523920bcc09 | 567 | |
johnAlexander | 0:c523920bcc09 | 568 | return Status; |
johnAlexander | 0:c523920bcc09 | 569 | } |
johnAlexander | 0:c523920bcc09 | 570 | |
johnAlexander | 0:c523920bcc09 | 571 | /** |
johnAlexander | 0:c523920bcc09 | 572 | * @brief Start continuous ranging mode |
johnAlexander | 0:c523920bcc09 | 573 | * |
johnAlexander | 0:c523920bcc09 | 574 | * @details End user should ensure device is in idle state and not already running |
johnAlexander | 0:c523920bcc09 | 575 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 576 | */ |
johnAlexander | 0:c523920bcc09 | 577 | int RangeStartContinuousMode() |
johnAlexander | 0:c523920bcc09 | 578 | { |
johnAlexander | 0:c523920bcc09 | 579 | // return VL6180x_RangeStartContinuousMode(Device); |
johnAlexander | 0:c523920bcc09 | 580 | return 1; |
johnAlexander | 0:c523920bcc09 | 581 | } |
johnAlexander | 0:c523920bcc09 | 582 | |
johnAlexander | 0:c523920bcc09 | 583 | /** |
johnAlexander | 0:c523920bcc09 | 584 | * @brief Start single shot ranging measure |
johnAlexander | 0:c523920bcc09 | 585 | * |
johnAlexander | 0:c523920bcc09 | 586 | * @details End user should ensure device is in idle state and not already running |
johnAlexander | 0:c523920bcc09 | 587 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 588 | */ |
johnAlexander | 0:c523920bcc09 | 589 | int RangeStartSingleShot() |
johnAlexander | 0:c523920bcc09 | 590 | { |
johnAlexander | 0:c523920bcc09 | 591 | // return VL6180x_RangeStartSingleShot(Device); |
johnAlexander | 0:c523920bcc09 | 592 | return 1; |
johnAlexander | 0:c523920bcc09 | 593 | } |
johnAlexander | 0:c523920bcc09 | 594 | |
johnAlexander | 0:c523920bcc09 | 595 | /** |
johnAlexander | 0:c523920bcc09 | 596 | * @brief Set maximum convergence time |
johnAlexander | 0:c523920bcc09 | 597 | * |
johnAlexander | 0:c523920bcc09 | 598 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 599 | * Setting a low convergence time can impact maximal detectable distance. |
johnAlexander | 0:c523920bcc09 | 600 | * Refer to VL6180x Datasheet Table 7 : Typical range convergence time. |
johnAlexander | 0:c523920bcc09 | 601 | * A typical value for up to x3 scaling is 50 ms |
johnAlexander | 0:c523920bcc09 | 602 | * |
johnAlexander | 0:c523920bcc09 | 603 | * @param MaxConTime_msec |
johnAlexander | 0:c523920bcc09 | 604 | * @return 0 on success. <0 on error. >0 for calibration warning status |
johnAlexander | 0:c523920bcc09 | 605 | */ |
johnAlexander | 0:c523920bcc09 | 606 | int RangeSetMaxConvergenceTime(uint8_t MaxConTime_msec) |
johnAlexander | 0:c523920bcc09 | 607 | { |
johnAlexander | 0:c523920bcc09 | 608 | // return VL6180x_RangeSetMaxConvergenceTime(Device, MaxConTime_msec); |
johnAlexander | 0:c523920bcc09 | 609 | return 1; |
johnAlexander | 0:c523920bcc09 | 610 | } |
johnAlexander | 0:c523920bcc09 | 611 | |
johnAlexander | 0:c523920bcc09 | 612 | /** |
johnAlexander | 0:c523920bcc09 | 613 | * @brief Single shot Range measurement in polling mode. |
johnAlexander | 0:c523920bcc09 | 614 | * |
johnAlexander | 0:c523920bcc09 | 615 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 616 | * Kick off a new single shot range then wait for ready to retrieve it by polling interrupt status \n |
johnAlexander | 0:c523920bcc09 | 617 | * Ranging must be prepared by a first call to @a VL6180x_Prepare() and it is safer to clear very first poll call \n |
johnAlexander | 0:c523920bcc09 | 618 | * This function reference VL6180x_PollDelay(dev) porting macro/call on each polling loop, |
johnAlexander | 0:c523920bcc09 | 619 | * but PollDelay(dev) may never be called if measure in ready on first poll loop \n |
johnAlexander | 0:c523920bcc09 | 620 | * Should not be use in continuous mode operation as it will stop it and cause stop/start misbehaviour \n |
johnAlexander | 0:c523920bcc09 | 621 | * \n This function clears Range Interrupt status , but not error one. For that uses @a VL6180x_ClearErrorInterrupt() \n |
johnAlexander | 0:c523920bcc09 | 622 | * This range error is not related VL6180x_RangeData_t::errorStatus that refer measure status \n |
johnAlexander | 0:c523920bcc09 | 623 | * |
johnAlexander | 0:c523920bcc09 | 624 | * @param pRangeData Will be populated with the result ranging data @a VL6180x_RangeData_t |
johnAlexander | 0:c523920bcc09 | 625 | * @return 0 on success , @a #RANGE_ERROR if device reports an error case in it status (not cleared) use |
johnAlexander | 0:c523920bcc09 | 626 | * |
johnAlexander | 0:c523920bcc09 | 627 | * \sa ::VL6180x_RangeData_t |
johnAlexander | 0:c523920bcc09 | 628 | */ |
johnAlexander | 0:c523920bcc09 | 629 | int RangePollMeasurement(VL53L0X_RangingMeasurementData_t *pRangeData) |
johnAlexander | 0:c523920bcc09 | 630 | { |
johnAlexander | 0:c523920bcc09 | 631 | // return VL6180x_RangePollMeasurement(Device, pRangeData); |
johnAlexander | 0:c523920bcc09 | 632 | return 1; |
johnAlexander | 0:c523920bcc09 | 633 | } |
johnAlexander | 0:c523920bcc09 | 634 | |
johnAlexander | 0:c523920bcc09 | 635 | /** |
johnAlexander | 0:c523920bcc09 | 636 | * @brief Check for measure readiness and get it if ready |
johnAlexander | 0:c523920bcc09 | 637 | * |
johnAlexander | 0:c523920bcc09 | 638 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 639 | * Using this function is an alternative to @a VL6180x_RangePollMeasurement() to avoid polling operation. This is suitable for applications |
johnAlexander | 0:c523920bcc09 | 640 | * where host CPU is triggered on a interrupt (not from VL6180X) to perform ranging operation. In this scenario, we assume that the very first ranging |
johnAlexander | 0:c523920bcc09 | 641 | * operation is triggered by a call to @a VL6180x_RangeStartSingleShot(). Then, host CPU regularly calls @a VL6180x_RangeGetMeasurementIfReady() to |
johnAlexander | 0:c523920bcc09 | 642 | * get a distance measure if ready. In case the distance is not ready, host may get it at the next call.\n |
johnAlexander | 0:c523920bcc09 | 643 | * |
johnAlexander | 0:c523920bcc09 | 644 | * @warning |
johnAlexander | 0:c523920bcc09 | 645 | * This function does not re-start a new measurement : this is up to the host CPU to do it.\n |
johnAlexander | 0:c523920bcc09 | 646 | * This function clears Range Interrupt for measure ready , but not error interrupts. For that, uses @a VL6180x_ClearErrorInterrupt() \n |
johnAlexander | 0:c523920bcc09 | 647 | * |
johnAlexander | 0:c523920bcc09 | 648 | * @param pRangeData Will be populated with the result ranging data if available |
johnAlexander | 0:c523920bcc09 | 649 | * @return 0 when measure is ready pRange data is updated (untouched when not ready), >0 for warning and @a #NOT_READY if measurement not yet ready, <0 for error @a #RANGE_ERROR if device report an error, |
johnAlexander | 0:c523920bcc09 | 650 | */ |
johnAlexander | 0:c523920bcc09 | 651 | int RangeGetMeasurementIfReady(VL53L0X_RangingMeasurementData_t *pRangeData) |
johnAlexander | 0:c523920bcc09 | 652 | { |
johnAlexander | 0:c523920bcc09 | 653 | // return VL6180x_RangeGetMeasurementIfReady(Device, pRangeData); |
johnAlexander | 0:c523920bcc09 | 654 | return 1; |
johnAlexander | 0:c523920bcc09 | 655 | } |
johnAlexander | 0:c523920bcc09 | 656 | |
johnAlexander | 0:c523920bcc09 | 657 | /** |
johnAlexander | 0:c523920bcc09 | 658 | * @brief Retrieve range measurements set from device |
johnAlexander | 0:c523920bcc09 | 659 | * |
johnAlexander | 0:c523920bcc09 | 660 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 661 | * The measurement is made of range_mm status and error code @a VL6180x_RangeData_t \n |
johnAlexander | 0:c523920bcc09 | 662 | * Based on configuration selected extra measures are included. |
johnAlexander | 0:c523920bcc09 | 663 | * |
johnAlexander | 0:c523920bcc09 | 664 | * @warning should not be used in continuous if wrap around filter is active \n |
johnAlexander | 0:c523920bcc09 | 665 | * Does not perform any wait nor check for result availability or validity. |
johnAlexander | 0:c523920bcc09 | 666 | *\sa VL6180x_RangeGetResult for "range only" measurement |
johnAlexander | 0:c523920bcc09 | 667 | * |
johnAlexander | 0:c523920bcc09 | 668 | * @param pRangeData Pointer to the data structure to fill up |
johnAlexander | 0:c523920bcc09 | 669 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 670 | */ |
johnAlexander | 0:c523920bcc09 | 671 | int RangeGetMeasurement(VL53L0X_RangingMeasurementData_t *pRangeData) |
johnAlexander | 0:c523920bcc09 | 672 | { |
johnAlexander | 0:c523920bcc09 | 673 | // return VL6180x_RangeGetMeasurement(Device, pRangeData); |
johnAlexander | 0:c523920bcc09 | 674 | return 1; |
johnAlexander | 0:c523920bcc09 | 675 | } |
johnAlexander | 0:c523920bcc09 | 676 | |
johnAlexander | 0:c523920bcc09 | 677 | /** |
johnAlexander | 0:c523920bcc09 | 678 | * @brief Get ranging result and only that |
johnAlexander | 0:c523920bcc09 | 679 | * |
johnAlexander | 0:c523920bcc09 | 680 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 681 | * Unlike @a VL6180x_RangeGetMeasurement() this function only retrieves the range in millimeter \n |
johnAlexander | 0:c523920bcc09 | 682 | * It does any required up-scale translation\n |
johnAlexander | 0:c523920bcc09 | 683 | * It can be called after success status polling or in interrupt mode \n |
johnAlexander | 0:c523920bcc09 | 684 | * @warning these function is not doing wrap around filtering \n |
johnAlexander | 0:c523920bcc09 | 685 | * This function doesn't perform any data ready check! |
johnAlexander | 0:c523920bcc09 | 686 | * |
johnAlexander | 0:c523920bcc09 | 687 | * @param pRange_mm Pointer to range distance |
johnAlexander | 0:c523920bcc09 | 688 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 689 | */ |
johnAlexander | 0:c523920bcc09 | 690 | virtual int GetRange(int32_t *piData) |
johnAlexander | 0:c523920bcc09 | 691 | { |
johnAlexander | 0:c523920bcc09 | 692 | // return VL6180x_RangeGetResult(Device, piData); |
johnAlexander | 0:c523920bcc09 | 693 | return 1; |
johnAlexander | 0:c523920bcc09 | 694 | } |
johnAlexander | 0:c523920bcc09 | 695 | |
johnAlexander | 0:c523920bcc09 | 696 | /** |
johnAlexander | 0:c523920bcc09 | 697 | * @brief Configure ranging interrupt reported to application |
johnAlexander | 0:c523920bcc09 | 698 | * |
johnAlexander | 0:c523920bcc09 | 699 | * @param ConfigGpioInt Select ranging report\n select one (and only one) of:\n |
johnAlexander | 0:c523920bcc09 | 700 | * @a #CONFIG_GPIO_INTERRUPT_DISABLED \n |
johnAlexander | 0:c523920bcc09 | 701 | * @a #CONFIG_GPIO_INTERRUPT_LEVEL_LOW \n |
johnAlexander | 0:c523920bcc09 | 702 | * @a #CONFIG_GPIO_INTERRUPT_LEVEL_HIGH \n |
johnAlexander | 0:c523920bcc09 | 703 | * @a #CONFIG_GPIO_INTERRUPT_OUT_OF_WINDOW \n |
johnAlexander | 0:c523920bcc09 | 704 | * @a #CONFIG_GPIO_INTERRUPT_NEW_SAMPLE_READY |
johnAlexander | 0:c523920bcc09 | 705 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 706 | */ |
johnAlexander | 0:c523920bcc09 | 707 | int RangeConfigInterrupt(uint8_t ConfigGpioInt) |
johnAlexander | 0:c523920bcc09 | 708 | { |
johnAlexander | 0:c523920bcc09 | 709 | // return VL6180x_RangeConfigInterrupt(Device, ConfigGpioInt); |
johnAlexander | 0:c523920bcc09 | 710 | return 1; |
johnAlexander | 0:c523920bcc09 | 711 | } |
johnAlexander | 0:c523920bcc09 | 712 | |
johnAlexander | 0:c523920bcc09 | 713 | /** |
johnAlexander | 0:c523920bcc09 | 714 | * @brief Return ranging error interrupt status |
johnAlexander | 0:c523920bcc09 | 715 | * |
johnAlexander | 0:c523920bcc09 | 716 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 717 | * Appropriate Interrupt report must have been selected first by @a VL6180x_RangeConfigInterrupt() or @a VL6180x_Prepare() \n |
johnAlexander | 0:c523920bcc09 | 718 | * |
johnAlexander | 0:c523920bcc09 | 719 | * Can be used in polling loop to wait for a given ranging event or in interrupt to read the trigger \n |
johnAlexander | 0:c523920bcc09 | 720 | * Events triggers are : \n |
johnAlexander | 0:c523920bcc09 | 721 | * @a #RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD \n |
johnAlexander | 0:c523920bcc09 | 722 | * @a #RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD \n |
johnAlexander | 0:c523920bcc09 | 723 | * @a #RES_INT_STAT_GPIO_OUT_OF_WINDOW \n (RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD|RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD) |
johnAlexander | 0:c523920bcc09 | 724 | * @a #RES_INT_STAT_GPIO_NEW_SAMPLE_READY \n |
johnAlexander | 0:c523920bcc09 | 725 | * |
johnAlexander | 0:c523920bcc09 | 726 | * @sa IntrStatus_t |
johnAlexander | 0:c523920bcc09 | 727 | * @param pIntStatus Pointer to status variable to update |
johnAlexander | 0:c523920bcc09 | 728 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 729 | */ |
johnAlexander | 0:c523920bcc09 | 730 | int RangeGetInterruptStatus(uint8_t *pIntStatus) |
johnAlexander | 0:c523920bcc09 | 731 | { |
johnAlexander | 0:c523920bcc09 | 732 | // return VL6180x_RangeGetInterruptStatus(Device, pIntStatus); |
johnAlexander | 0:c523920bcc09 | 733 | return 1; |
johnAlexander | 0:c523920bcc09 | 734 | } |
johnAlexander | 0:c523920bcc09 | 735 | |
johnAlexander | 0:c523920bcc09 | 736 | /** |
johnAlexander | 0:c523920bcc09 | 737 | * @brief Low level ranging and ALS register static settings (you should call @a VL6180x_Prepare() function instead) |
johnAlexander | 0:c523920bcc09 | 738 | * |
johnAlexander | 0:c523920bcc09 | 739 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 740 | */ |
johnAlexander | 0:c523920bcc09 | 741 | int StaticInit() |
johnAlexander | 0:c523920bcc09 | 742 | { |
johnAlexander | 0:c523920bcc09 | 743 | // return VL6180x_StaticInit(Device); |
johnAlexander | 0:c523920bcc09 | 744 | return 1; |
johnAlexander | 0:c523920bcc09 | 745 | } |
johnAlexander | 0:c523920bcc09 | 746 | |
johnAlexander | 0:c523920bcc09 | 747 | /** |
johnAlexander | 0:c523920bcc09 | 748 | * @brief Wait for device to be ready (before a new ranging command can be issued by application) |
johnAlexander | 0:c523920bcc09 | 749 | * @param MaxLoop Max Number of i2c polling loop see @a #msec_2_i2cloop |
johnAlexander | 0:c523920bcc09 | 750 | * @return 0 on success. <0 when fail \n |
johnAlexander | 0:c523920bcc09 | 751 | * @ref VL6180x_ErrCode_t::TIME_OUT for time out \n |
johnAlexander | 0:c523920bcc09 | 752 | * @ref VL6180x_ErrCode_t::INVALID_PARAMS if MaxLop<1 |
johnAlexander | 0:c523920bcc09 | 753 | */ |
johnAlexander | 0:c523920bcc09 | 754 | int RangeWaitDeviceReady(int MaxLoop ) |
johnAlexander | 0:c523920bcc09 | 755 | { |
johnAlexander | 0:c523920bcc09 | 756 | // return VL6180x_RangeWaitDeviceReady(Device, MaxLoop); |
johnAlexander | 0:c523920bcc09 | 757 | return 1; |
johnAlexander | 0:c523920bcc09 | 758 | } |
johnAlexander | 0:c523920bcc09 | 759 | |
johnAlexander | 0:c523920bcc09 | 760 | /** |
johnAlexander | 0:c523920bcc09 | 761 | * @brief Program Inter measurement period (used only in continuous mode) |
johnAlexander | 0:c523920bcc09 | 762 | * |
johnAlexander | 0:c523920bcc09 | 763 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 764 | * When trying to set too long time, it returns #INVALID_PARAMS |
johnAlexander | 0:c523920bcc09 | 765 | * |
johnAlexander | 0:c523920bcc09 | 766 | * @param InterMeasTime_msec Requires inter-measurement time in msec |
johnAlexander | 0:c523920bcc09 | 767 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 768 | */ |
johnAlexander | 0:c523920bcc09 | 769 | int RangeSetInterMeasPeriod(uint32_t InterMeasTime_msec) |
johnAlexander | 0:c523920bcc09 | 770 | { |
johnAlexander | 0:c523920bcc09 | 771 | // return VL6180x_RangeSetInterMeasPeriod(Device, InterMeasTime_msec); |
johnAlexander | 0:c523920bcc09 | 772 | return 1; |
johnAlexander | 0:c523920bcc09 | 773 | } |
johnAlexander | 0:c523920bcc09 | 774 | |
johnAlexander | 0:c523920bcc09 | 775 | /** |
johnAlexander | 0:c523920bcc09 | 776 | * @brief Set device ranging scaling factor |
johnAlexander | 0:c523920bcc09 | 777 | * |
johnAlexander | 0:c523920bcc09 | 778 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 779 | * The ranging scaling factor is applied on the raw distance measured by the device to increase operating ranging at the price of the precision. |
johnAlexander | 0:c523920bcc09 | 780 | * Changing the scaling factor when device is not in f/w standby state (free running) is not safe. |
johnAlexander | 0:c523920bcc09 | 781 | * It can be source of spurious interrupt, wrongly scaled range etc ... |
johnAlexander | 0:c523920bcc09 | 782 | * @warning __This function doesns't update high/low threshold and other programmed settings linked to scaling factor__. |
johnAlexander | 0:c523920bcc09 | 783 | * To ensure proper operation, threshold and scaling changes should be done following this procedure: \n |
johnAlexander | 0:c523920bcc09 | 784 | * @li Set Group hold : @a VL6180x_SetGroupParamHold() \n |
johnAlexander | 0:c523920bcc09 | 785 | * @li Get Threshold @a VL6180x_RangeGetThresholds() \n |
johnAlexander | 0:c523920bcc09 | 786 | * @li Change scaling : @a VL6180x_UpscaleSetScaling() \n |
johnAlexander | 0:c523920bcc09 | 787 | * @li Set Threshold : @a VL6180x_RangeSetThresholds() \n |
johnAlexander | 0:c523920bcc09 | 788 | * @li Unset Group Hold : @a VL6180x_SetGroupParamHold() |
johnAlexander | 0:c523920bcc09 | 789 | * |
johnAlexander | 0:c523920bcc09 | 790 | * @param scaling Scaling factor to apply (1,2 or 3) |
johnAlexander | 0:c523920bcc09 | 791 | * @return 0 on success when up-scale support is not configured it fail for any |
johnAlexander | 0:c523920bcc09 | 792 | * scaling than the one statically configured. |
johnAlexander | 0:c523920bcc09 | 793 | */ |
johnAlexander | 0:c523920bcc09 | 794 | int UpscaleSetScaling(uint8_t scaling) |
johnAlexander | 0:c523920bcc09 | 795 | { |
johnAlexander | 0:c523920bcc09 | 796 | // return VL6180x_UpscaleSetScaling(Device, scaling); |
johnAlexander | 0:c523920bcc09 | 797 | return 1; |
johnAlexander | 0:c523920bcc09 | 798 | } |
johnAlexander | 0:c523920bcc09 | 799 | |
johnAlexander | 0:c523920bcc09 | 800 | /** |
johnAlexander | 0:c523920bcc09 | 801 | * @brief Get current ranging scaling factor |
johnAlexander | 0:c523920bcc09 | 802 | * |
johnAlexander | 0:c523920bcc09 | 803 | * @return The current scaling factor |
johnAlexander | 0:c523920bcc09 | 804 | */ |
johnAlexander | 0:c523920bcc09 | 805 | int UpscaleGetScaling() |
johnAlexander | 0:c523920bcc09 | 806 | { |
johnAlexander | 0:c523920bcc09 | 807 | // return VL6180x_UpscaleGetScaling(Device); |
johnAlexander | 0:c523920bcc09 | 808 | return 1; |
johnAlexander | 0:c523920bcc09 | 809 | } |
johnAlexander | 0:c523920bcc09 | 810 | |
johnAlexander | 0:c523920bcc09 | 811 | /** |
johnAlexander | 0:c523920bcc09 | 812 | * @brief Get the maximal distance for actual scaling |
johnAlexander | 0:c523920bcc09 | 813 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 814 | * Do not use prior to @a VL6180x_Prepare() or at least @a VL6180x_InitData() |
johnAlexander | 0:c523920bcc09 | 815 | * |
johnAlexander | 0:c523920bcc09 | 816 | * Any range value more than the value returned by this function is to be considered as "no target detected" |
johnAlexander | 0:c523920bcc09 | 817 | * or "no target in detectable range" \n |
johnAlexander | 0:c523920bcc09 | 818 | * @warning The maximal distance depends on the scaling |
johnAlexander | 0:c523920bcc09 | 819 | * |
johnAlexander | 0:c523920bcc09 | 820 | * @return The maximal range limit for actual mode and scaling |
johnAlexander | 0:c523920bcc09 | 821 | */ |
johnAlexander | 0:c523920bcc09 | 822 | uint16_t GetUpperLimit() |
johnAlexander | 0:c523920bcc09 | 823 | { |
johnAlexander | 0:c523920bcc09 | 824 | // return VL6180x_GetUpperLimit(Device); |
johnAlexander | 0:c523920bcc09 | 825 | return 1; |
johnAlexander | 0:c523920bcc09 | 826 | } |
johnAlexander | 0:c523920bcc09 | 827 | |
johnAlexander | 0:c523920bcc09 | 828 | /** |
johnAlexander | 0:c523920bcc09 | 829 | * @brief Apply low and high ranging thresholds that are considered only in continuous mode |
johnAlexander | 0:c523920bcc09 | 830 | * |
johnAlexander | 0:c523920bcc09 | 831 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 832 | * This function programs low and high ranging thresholds that are considered in continuous mode : |
johnAlexander | 0:c523920bcc09 | 833 | * interrupt will be raised only when an object is detected at a distance inside this [low:high] range. |
johnAlexander | 0:c523920bcc09 | 834 | * The function takes care of applying current scaling factor if any.\n |
johnAlexander | 0:c523920bcc09 | 835 | * To be safe, in continuous operation, thresholds must be changed under "group parameter hold" cover. |
johnAlexander | 0:c523920bcc09 | 836 | * Group hold can be activated/deactivated directly in the function or externally (then set 0) |
johnAlexander | 0:c523920bcc09 | 837 | * using /a VL6180x_SetGroupParamHold() function. |
johnAlexander | 0:c523920bcc09 | 838 | * |
johnAlexander | 0:c523920bcc09 | 839 | * @param low Low threshold in mm |
johnAlexander | 0:c523920bcc09 | 840 | * @param high High threshold in mm |
johnAlexander | 0:c523920bcc09 | 841 | * @param SafeHold Use of group parameters hold to surround threshold programming. |
johnAlexander | 0:c523920bcc09 | 842 | * @return 0 On success |
johnAlexander | 0:c523920bcc09 | 843 | */ |
johnAlexander | 0:c523920bcc09 | 844 | int RangeSetThresholds(uint16_t low, uint16_t high, int SafeHold) |
johnAlexander | 0:c523920bcc09 | 845 | { |
johnAlexander | 0:c523920bcc09 | 846 | // return VL6180x_RangeSetThresholds(Device, low, high, SafeHold); |
johnAlexander | 0:c523920bcc09 | 847 | return 1; |
johnAlexander | 0:c523920bcc09 | 848 | } |
johnAlexander | 0:c523920bcc09 | 849 | |
johnAlexander | 0:c523920bcc09 | 850 | /** |
johnAlexander | 0:c523920bcc09 | 851 | * @brief Get scaled high and low threshold from device |
johnAlexander | 0:c523920bcc09 | 852 | * |
johnAlexander | 0:c523920bcc09 | 853 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 854 | * Due to scaling factor, the returned value may be different from what has been programmed first (precision lost). |
johnAlexander | 0:c523920bcc09 | 855 | * For instance VL6180x_RangeSetThresholds(dev,11,22) with scale 3 |
johnAlexander | 0:c523920bcc09 | 856 | * will read back 9 ((11/3)x3) and 21 ((22/3)x3). |
johnAlexander | 0:c523920bcc09 | 857 | * |
johnAlexander | 0:c523920bcc09 | 858 | * @param low scaled low Threshold ptr can be NULL if not needed |
johnAlexander | 0:c523920bcc09 | 859 | * @param high scaled High Threshold ptr can be NULL if not needed |
johnAlexander | 0:c523920bcc09 | 860 | * @return 0 on success, return value is undefined if both low and high are NULL |
johnAlexander | 0:c523920bcc09 | 861 | * @warning return value is undefined if both low and high are NULL |
johnAlexander | 0:c523920bcc09 | 862 | */ |
johnAlexander | 0:c523920bcc09 | 863 | int RangeGetThresholds(uint16_t *low, uint16_t *high) |
johnAlexander | 0:c523920bcc09 | 864 | { |
johnAlexander | 0:c523920bcc09 | 865 | // return VL6180x_RangeGetThresholds(Device, low, high); |
johnAlexander | 0:c523920bcc09 | 866 | return 1; |
johnAlexander | 0:c523920bcc09 | 867 | } |
johnAlexander | 0:c523920bcc09 | 868 | |
johnAlexander | 0:c523920bcc09 | 869 | /** |
johnAlexander | 0:c523920bcc09 | 870 | * @brief Set ranging raw thresholds (scaling not considered so not recommended to use it) |
johnAlexander | 0:c523920bcc09 | 871 | * |
johnAlexander | 0:c523920bcc09 | 872 | * @param low raw low threshold set to raw register |
johnAlexander | 0:c523920bcc09 | 873 | * @param high raw high threshold set to raw register |
johnAlexander | 0:c523920bcc09 | 874 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 875 | */ |
johnAlexander | 0:c523920bcc09 | 876 | int RangeSetRawThresholds(uint8_t low, uint8_t high) |
johnAlexander | 0:c523920bcc09 | 877 | { |
johnAlexander | 0:c523920bcc09 | 878 | // return VL6180x_RangeSetRawThresholds(Device, low, high); |
johnAlexander | 0:c523920bcc09 | 879 | return 1; |
johnAlexander | 0:c523920bcc09 | 880 | } |
johnAlexander | 0:c523920bcc09 | 881 | |
johnAlexander | 0:c523920bcc09 | 882 | /** |
johnAlexander | 0:c523920bcc09 | 883 | * @brief Set Early Convergence Estimate ratio |
johnAlexander | 0:c523920bcc09 | 884 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 885 | * For more information on ECE check datasheet |
johnAlexander | 0:c523920bcc09 | 886 | * @warning May return a calibration warning in some use cases |
johnAlexander | 0:c523920bcc09 | 887 | * |
johnAlexander | 0:c523920bcc09 | 888 | * @param FactorM ECE factor M in M/D |
johnAlexander | 0:c523920bcc09 | 889 | * @param FactorD ECE factor D in M/D |
johnAlexander | 0:c523920bcc09 | 890 | * @return 0 on success. <0 on error. >0 on warning |
johnAlexander | 0:c523920bcc09 | 891 | */ |
johnAlexander | 0:c523920bcc09 | 892 | int RangeSetEceFactor(uint16_t FactorM, uint16_t FactorD) |
johnAlexander | 0:c523920bcc09 | 893 | { |
johnAlexander | 0:c523920bcc09 | 894 | // return VL6180x_RangeSetEceFactor(Device, FactorM, FactorD); |
johnAlexander | 0:c523920bcc09 | 895 | return 1; |
johnAlexander | 0:c523920bcc09 | 896 | } |
johnAlexander | 0:c523920bcc09 | 897 | |
johnAlexander | 0:c523920bcc09 | 898 | /** |
johnAlexander | 0:c523920bcc09 | 899 | * @brief Set Early Convergence Estimate state (See #SYSRANGE_RANGE_CHECK_ENABLES register) |
johnAlexander | 0:c523920bcc09 | 900 | * @param enable State to be set 0=disabled, otherwise enabled |
johnAlexander | 0:c523920bcc09 | 901 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 902 | */ |
johnAlexander | 0:c523920bcc09 | 903 | int RangeSetEceState(int enable) |
johnAlexander | 0:c523920bcc09 | 904 | { |
johnAlexander | 0:c523920bcc09 | 905 | // return VL6180x_RangeSetEceState(Device, enable); |
johnAlexander | 0:c523920bcc09 | 906 | return 1; |
johnAlexander | 0:c523920bcc09 | 907 | } |
johnAlexander | 0:c523920bcc09 | 908 | |
johnAlexander | 0:c523920bcc09 | 909 | /** |
johnAlexander | 0:c523920bcc09 | 910 | * @brief Set activation state of the wrap around filter |
johnAlexander | 0:c523920bcc09 | 911 | * @param state New activation state (0=off, otherwise on) |
johnAlexander | 0:c523920bcc09 | 912 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 913 | */ |
johnAlexander | 0:c523920bcc09 | 914 | int FilterSetState(int state) |
johnAlexander | 0:c523920bcc09 | 915 | { |
johnAlexander | 0:c523920bcc09 | 916 | // return VL6180x_FilterSetState(Device, state); |
johnAlexander | 0:c523920bcc09 | 917 | return 1; |
johnAlexander | 0:c523920bcc09 | 918 | } |
johnAlexander | 0:c523920bcc09 | 919 | |
johnAlexander | 0:c523920bcc09 | 920 | /** |
johnAlexander | 0:c523920bcc09 | 921 | * Get activation state of the wrap around filter |
johnAlexander | 0:c523920bcc09 | 922 | * @return Filter enabled or not, when filter is not supported it always returns 0S |
johnAlexander | 0:c523920bcc09 | 923 | */ |
johnAlexander | 0:c523920bcc09 | 924 | int FilterGetState() |
johnAlexander | 0:c523920bcc09 | 925 | { |
johnAlexander | 0:c523920bcc09 | 926 | // return VL6180x_FilterGetState(Device); |
johnAlexander | 0:c523920bcc09 | 927 | return 1; |
johnAlexander | 0:c523920bcc09 | 928 | } |
johnAlexander | 0:c523920bcc09 | 929 | |
johnAlexander | 0:c523920bcc09 | 930 | /** |
johnAlexander | 0:c523920bcc09 | 931 | * @brief Set activation state of DMax computation |
johnAlexander | 0:c523920bcc09 | 932 | * @param state New activation state (0=off, otherwise on) |
johnAlexander | 0:c523920bcc09 | 933 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 934 | */ |
johnAlexander | 0:c523920bcc09 | 935 | int DMaxSetState(int state) |
johnAlexander | 0:c523920bcc09 | 936 | { |
johnAlexander | 0:c523920bcc09 | 937 | // return VL6180x_DMaxSetState(Device, state); |
johnAlexander | 0:c523920bcc09 | 938 | return 1; |
johnAlexander | 0:c523920bcc09 | 939 | } |
johnAlexander | 0:c523920bcc09 | 940 | |
johnAlexander | 0:c523920bcc09 | 941 | /** |
johnAlexander | 0:c523920bcc09 | 942 | * Get activation state of DMax computation |
johnAlexander | 0:c523920bcc09 | 943 | * @return Filter enabled or not, when filter is not supported it always returns 0S |
johnAlexander | 0:c523920bcc09 | 944 | */ |
johnAlexander | 0:c523920bcc09 | 945 | int DMaxGetState() |
johnAlexander | 0:c523920bcc09 | 946 | { |
johnAlexander | 0:c523920bcc09 | 947 | // return VL6180x_DMaxGetState(Device); |
johnAlexander | 0:c523920bcc09 | 948 | return 1; |
johnAlexander | 0:c523920bcc09 | 949 | } |
johnAlexander | 0:c523920bcc09 | 950 | |
johnAlexander | 0:c523920bcc09 | 951 | /** |
johnAlexander | 0:c523920bcc09 | 952 | * @brief Set ranging mode and start/stop measure (use high level functions instead : @a VL6180x_RangeStartSingleShot() or @a VL6180x_RangeStartContinuousMode()) |
johnAlexander | 0:c523920bcc09 | 953 | * |
johnAlexander | 0:c523920bcc09 | 954 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 955 | * When used outside scope of known polling single shot stopped state, \n |
johnAlexander | 0:c523920bcc09 | 956 | * user must ensure the device state is "idle" before to issue a new command. |
johnAlexander | 0:c523920bcc09 | 957 | * |
johnAlexander | 0:c523920bcc09 | 958 | * @param mode A combination of working mode (#MODE_SINGLESHOT or #MODE_CONTINUOUS) and start/stop condition (#MODE_START_STOP) \n |
johnAlexander | 0:c523920bcc09 | 959 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 960 | */ |
johnAlexander | 0:c523920bcc09 | 961 | int RangeSetSystemMode(uint8_t mode) |
johnAlexander | 0:c523920bcc09 | 962 | { |
johnAlexander | 0:c523920bcc09 | 963 | // return VL6180x_RangeSetSystemMode(Device, mode); |
johnAlexander | 0:c523920bcc09 | 964 | return 1; |
johnAlexander | 0:c523920bcc09 | 965 | } |
johnAlexander | 0:c523920bcc09 | 966 | |
johnAlexander | 0:c523920bcc09 | 967 | /** @} */ |
johnAlexander | 0:c523920bcc09 | 968 | |
johnAlexander | 0:c523920bcc09 | 969 | /** @defgroup api_ll_range_calibration Ranging calibration functions |
johnAlexander | 0:c523920bcc09 | 970 | * @brief Ranging calibration functions |
johnAlexander | 0:c523920bcc09 | 971 | * @ingroup api_ll |
johnAlexander | 0:c523920bcc09 | 972 | * @{ |
johnAlexander | 0:c523920bcc09 | 973 | */ |
johnAlexander | 0:c523920bcc09 | 974 | /** |
johnAlexander | 0:c523920bcc09 | 975 | * @brief Get part to part calibration offset |
johnAlexander | 0:c523920bcc09 | 976 | * |
johnAlexander | 0:c523920bcc09 | 977 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 978 | * Should only be used after a successful call to @a VL6180x_InitData to backup device nvm value |
johnAlexander | 0:c523920bcc09 | 979 | * |
johnAlexander | 0:c523920bcc09 | 980 | * @return part to part calibration offset from device |
johnAlexander | 0:c523920bcc09 | 981 | */ |
johnAlexander | 0:c523920bcc09 | 982 | int8_t GetOffsetCalibrationData() |
johnAlexander | 0:c523920bcc09 | 983 | { |
johnAlexander | 0:c523920bcc09 | 984 | // return VL6180x_GetOffsetCalibrationData(Device); |
johnAlexander | 0:c523920bcc09 | 985 | return 1; |
johnAlexander | 0:c523920bcc09 | 986 | } |
johnAlexander | 0:c523920bcc09 | 987 | |
johnAlexander | 0:c523920bcc09 | 988 | /** |
johnAlexander | 0:c523920bcc09 | 989 | * Set or over-write part to part calibration offset |
johnAlexander | 0:c523920bcc09 | 990 | * \sa VL6180x_InitData(), VL6180x_GetOffsetCalibrationData() |
johnAlexander | 0:c523920bcc09 | 991 | * @param offset Offset |
johnAlexander | 0:c523920bcc09 | 992 | */ |
johnAlexander | 0:c523920bcc09 | 993 | void SetOffsetCalibrationData(int8_t offset) |
johnAlexander | 0:c523920bcc09 | 994 | { |
johnAlexander | 0:c523920bcc09 | 995 | // return VL6180x_SetOffsetCalibrationData(Device, offset); |
johnAlexander | 0:c523920bcc09 | 996 | return; |
johnAlexander | 0:c523920bcc09 | 997 | } |
johnAlexander | 0:c523920bcc09 | 998 | |
johnAlexander | 0:c523920bcc09 | 999 | /** |
johnAlexander | 0:c523920bcc09 | 1000 | * @brief Set Cross talk compensation rate |
johnAlexander | 0:c523920bcc09 | 1001 | * |
johnAlexander | 0:c523920bcc09 | 1002 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 1003 | * It programs register @a #SYSRANGE_CROSSTALK_COMPENSATION_RATE |
johnAlexander | 0:c523920bcc09 | 1004 | * |
johnAlexander | 0:c523920bcc09 | 1005 | * @param Rate Compensation rate (9.7 fix point) see datasheet for details |
johnAlexander | 0:c523920bcc09 | 1006 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 1007 | */ |
johnAlexander | 0:c523920bcc09 | 1008 | int SetXTalkCompensationRate(uint16_t Rate) |
johnAlexander | 0:c523920bcc09 | 1009 | { |
johnAlexander | 0:c523920bcc09 | 1010 | // return VL6180x_SetXTalkCompensationRate(Device, Rate); |
johnAlexander | 0:c523920bcc09 | 1011 | return 1; |
johnAlexander | 0:c523920bcc09 | 1012 | } |
johnAlexander | 0:c523920bcc09 | 1013 | /** @} */ |
johnAlexander | 0:c523920bcc09 | 1014 | |
johnAlexander | 0:c523920bcc09 | 1015 | /** |
johnAlexander | 0:c523920bcc09 | 1016 | * @brief Set new device i2c address |
johnAlexander | 0:c523920bcc09 | 1017 | * |
johnAlexander | 0:c523920bcc09 | 1018 | * After completion the device will answer to the new address programmed. |
johnAlexander | 0:c523920bcc09 | 1019 | * |
johnAlexander | 0:c523920bcc09 | 1020 | * @sa AN4478: Using multiple VL6180X's in a single design |
johnAlexander | 0:c523920bcc09 | 1021 | * @param NewAddr The new i2c address (7bit) |
johnAlexander | 0:c523920bcc09 | 1022 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 1023 | */ |
johnAlexander | 0:c523920bcc09 | 1024 | int SetDeviceAddress(int NewAddr) |
johnAlexander | 0:c523920bcc09 | 1025 | { |
johnAlexander | 0:c523920bcc09 | 1026 | int status; |
johnAlexander | 0:c523920bcc09 | 1027 | |
johnAlexander | 0:c523920bcc09 | 1028 | status=VL53L0X_SetDeviceAddress(Device, NewAddr); |
johnAlexander | 0:c523920bcc09 | 1029 | if(!status) |
johnAlexander | 0:c523920bcc09 | 1030 | Device->I2cDevAddr=NewAddr; |
johnAlexander | 0:c523920bcc09 | 1031 | return status; |
johnAlexander | 0:c523920bcc09 | 1032 | |
johnAlexander | 0:c523920bcc09 | 1033 | // return 1; |
johnAlexander | 0:c523920bcc09 | 1034 | } |
johnAlexander | 0:c523920bcc09 | 1035 | |
johnAlexander | 0:c523920bcc09 | 1036 | /** |
johnAlexander | 0:c523920bcc09 | 1037 | * @brief Fully configure gpio 0/1 pin : polarity and functionality |
johnAlexander | 0:c523920bcc09 | 1038 | * |
johnAlexander | 0:c523920bcc09 | 1039 | * @param pin gpio pin 0 or 1 |
johnAlexander | 0:c523920bcc09 | 1040 | * @param IntFunction Pin functionality : either #GPIOx_SELECT_OFF or #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to #SYSTEM_MODE_GPIO1 register definition) |
johnAlexander | 0:c523920bcc09 | 1041 | * @param ActiveHigh Set active high polarity, or active low see @a ::IntrPol_e |
johnAlexander | 0:c523920bcc09 | 1042 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 1043 | */ |
johnAlexander | 0:c523920bcc09 | 1044 | int SetupGPIOx(int pin, uint8_t IntFunction, int ActiveHigh) |
johnAlexander | 0:c523920bcc09 | 1045 | { |
johnAlexander | 0:c523920bcc09 | 1046 | // return VL6180x_SetupGPIOx(Device, pin, IntFunction, ActiveHigh); |
johnAlexander | 0:c523920bcc09 | 1047 | return 1; |
johnAlexander | 0:c523920bcc09 | 1048 | } |
johnAlexander | 0:c523920bcc09 | 1049 | |
johnAlexander | 0:c523920bcc09 | 1050 | /** |
johnAlexander | 0:c523920bcc09 | 1051 | * @brief Set interrupt pin polarity for the given GPIO |
johnAlexander | 0:c523920bcc09 | 1052 | * |
johnAlexander | 0:c523920bcc09 | 1053 | * @param pin Pin 0 or 1 |
johnAlexander | 0:c523920bcc09 | 1054 | * @param active_high select active high or low polarity using @ref IntrPol_e |
johnAlexander | 0:c523920bcc09 | 1055 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 1056 | */ |
johnAlexander | 0:c523920bcc09 | 1057 | int SetGPIOxPolarity(int pin, int active_high) |
johnAlexander | 0:c523920bcc09 | 1058 | { |
johnAlexander | 0:c523920bcc09 | 1059 | // return VL6180x_SetGPIOxPolarity(Device, pin, active_high); |
johnAlexander | 0:c523920bcc09 | 1060 | return 1; |
johnAlexander | 0:c523920bcc09 | 1061 | } |
johnAlexander | 0:c523920bcc09 | 1062 | |
johnAlexander | 0:c523920bcc09 | 1063 | /** |
johnAlexander | 0:c523920bcc09 | 1064 | * Select interrupt functionality for the given GPIO |
johnAlexander | 0:c523920bcc09 | 1065 | * |
johnAlexander | 0:c523920bcc09 | 1066 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 1067 | * Functionality refer to @a SYSTEM_MODE_GPIO0 |
johnAlexander | 0:c523920bcc09 | 1068 | * |
johnAlexander | 0:c523920bcc09 | 1069 | * @param pin Pin to configure 0 or 1 (gpio0 or gpio1)\nNote that gpio0 is chip enable at power up ! |
johnAlexander | 0:c523920bcc09 | 1070 | * @param functionality Pin functionality : either #GPIOx_SELECT_OFF or #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to #SYSTEM_MODE_GPIO1 register definition) |
johnAlexander | 0:c523920bcc09 | 1071 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 1072 | */ |
johnAlexander | 0:c523920bcc09 | 1073 | int SetGPIOxFunctionality(int pin, uint8_t functionality) |
johnAlexander | 0:c523920bcc09 | 1074 | { |
johnAlexander | 0:c523920bcc09 | 1075 | // return VL6180x_SetGPIOxFunctionality(Device, pin, functionality); |
johnAlexander | 0:c523920bcc09 | 1076 | return 1; |
johnAlexander | 0:c523920bcc09 | 1077 | } |
johnAlexander | 0:c523920bcc09 | 1078 | |
johnAlexander | 0:c523920bcc09 | 1079 | /** |
johnAlexander | 0:c523920bcc09 | 1080 | * #brief Disable and turn to Hi-Z gpio output pin |
johnAlexander | 0:c523920bcc09 | 1081 | * |
johnAlexander | 0:c523920bcc09 | 1082 | * @param pin The pin number to disable 0 or 1 |
johnAlexander | 0:c523920bcc09 | 1083 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 1084 | */ |
johnAlexander | 0:c523920bcc09 | 1085 | int DisableGPIOxOut(int pin) |
johnAlexander | 0:c523920bcc09 | 1086 | { |
johnAlexander | 0:c523920bcc09 | 1087 | // return VL6180x_DisableGPIOxOut(Device, pin); |
johnAlexander | 0:c523920bcc09 | 1088 | return 1; |
johnAlexander | 0:c523920bcc09 | 1089 | } |
johnAlexander | 0:c523920bcc09 | 1090 | |
johnAlexander | 0:c523920bcc09 | 1091 | /** @} */ |
johnAlexander | 0:c523920bcc09 | 1092 | |
johnAlexander | 0:c523920bcc09 | 1093 | /** @defgroup api_ll_intr Interrupts management functions |
johnAlexander | 0:c523920bcc09 | 1094 | * @brief Interrupts management functions |
johnAlexander | 0:c523920bcc09 | 1095 | * @ingroup api_ll |
johnAlexander | 0:c523920bcc09 | 1096 | * @{ |
johnAlexander | 0:c523920bcc09 | 1097 | */ |
johnAlexander | 0:c523920bcc09 | 1098 | |
johnAlexander | 0:c523920bcc09 | 1099 | /** |
johnAlexander | 0:c523920bcc09 | 1100 | * @brief Get all interrupts cause |
johnAlexander | 0:c523920bcc09 | 1101 | * |
johnAlexander | 0:c523920bcc09 | 1102 | * @param status Ptr to interrupt status. You can use @a IntrStatus_t::val |
johnAlexander | 0:c523920bcc09 | 1103 | * @return 0 on success |
johnAlexander | 0:c523920bcc09 | 1104 | */ |
johnAlexander | 0:c523920bcc09 | 1105 | int GetInterruptStatus(uint8_t *status) |
johnAlexander | 0:c523920bcc09 | 1106 | { |
johnAlexander | 0:c523920bcc09 | 1107 | // return VL6180x_GetInterruptStatus(Device, status); |
johnAlexander | 0:c523920bcc09 | 1108 | return 1; |
johnAlexander | 0:c523920bcc09 | 1109 | } |
johnAlexander | 0:c523920bcc09 | 1110 | |
johnAlexander | 0:c523920bcc09 | 1111 | /** |
johnAlexander | 0:c523920bcc09 | 1112 | * @brief Clear given system interrupt condition |
johnAlexander | 0:c523920bcc09 | 1113 | * |
johnAlexander | 0:c523920bcc09 | 1114 | * @par Function Description |
johnAlexander | 0:c523920bcc09 | 1115 | * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register. |
johnAlexander | 0:c523920bcc09 | 1116 | * @param dev The device |
johnAlexander | 0:c523920bcc09 | 1117 | * @param IntClear Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR. |
johnAlexander | 0:c523920bcc09 | 1118 | * @return 0 On success |
johnAlexander | 0:c523920bcc09 | 1119 | */ |
johnAlexander | 0:c523920bcc09 | 1120 | int ClearInterrupt(uint8_t IntClear) |
johnAlexander | 0:c523920bcc09 | 1121 | { |
johnAlexander | 0:c523920bcc09 | 1122 | // return VL6180x_ClearInterrupt(Device, IntClear ); |
johnAlexander | 0:c523920bcc09 | 1123 | return 1; |
johnAlexander | 0:c523920bcc09 | 1124 | } |
johnAlexander | 0:c523920bcc09 | 1125 | |
johnAlexander | 0:c523920bcc09 | 1126 | /** |
johnAlexander | 0:c523920bcc09 | 1127 | * @brief Clear error interrupt |
johnAlexander | 0:c523920bcc09 | 1128 | * |
johnAlexander | 0:c523920bcc09 | 1129 | * @param dev The device |
johnAlexander | 0:c523920bcc09 | 1130 | * @return 0 On success |
johnAlexander | 0:c523920bcc09 | 1131 | */ |
johnAlexander | 0:c523920bcc09 | 1132 | #define VL6180x_ClearErrorInterrupt(dev) VL6180x_ClearInterrupt(dev, INTERRUPT_CLEAR_ERROR) |
johnAlexander | 0:c523920bcc09 | 1133 | |
johnAlexander | 0:c523920bcc09 | 1134 | /** |
johnAlexander | 0:c523920bcc09 | 1135 | * @brief Clear All interrupt causes (als+range+error) |
johnAlexander | 0:c523920bcc09 | 1136 | * |
johnAlexander | 0:c523920bcc09 | 1137 | * @param dev The device |
johnAlexander | 0:c523920bcc09 | 1138 | * @return 0 On success |
johnAlexander | 0:c523920bcc09 | 1139 | */ |
johnAlexander | 0:c523920bcc09 | 1140 | #define VL6180x_ClearAllInterrupt(dev) VL6180x_ClearInterrupt(dev, INTERRUPT_CLEAR_ERROR|INTERRUPT_CLEAR_RANGING|INTERRUPT_CLEAR_ALS) |
johnAlexander | 0:c523920bcc09 | 1141 | |
johnAlexander | 0:c523920bcc09 | 1142 | |
johnAlexander | 0:c523920bcc09 | 1143 | private: |
johnAlexander | 0:c523920bcc09 | 1144 | /* api.h functions */ |
johnAlexander | 0:c523920bcc09 | 1145 | VL53L0X_Error VL53L0X_DataInit(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1146 | VL53L0X_Error VL53L0X_GetOffsetCalibrationDataMicroMeter(VL53L0X_DEV Dev, int32_t *pOffsetCalibrationDataMicroMeter); |
johnAlexander | 0:c523920bcc09 | 1147 | VL53L0X_Error VL53L0X_SetOffsetCalibrationDataMicroMeter(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1148 | int32_t OffsetCalibrationDataMicroMeter); |
johnAlexander | 0:c523920bcc09 | 1149 | VL53L0X_Error VL53L0X_GetDeviceParameters(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1150 | VL53L0X_DeviceParameters_t *pDeviceParameters); |
johnAlexander | 0:c523920bcc09 | 1151 | VL53L0X_Error VL53L0X_GetDeviceMode(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1152 | VL53L0X_DeviceModes *pDeviceMode); |
johnAlexander | 0:c523920bcc09 | 1153 | VL53L0X_Error VL53L0X_GetInterMeasurementPeriodMilliSeconds(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1154 | uint32_t *pInterMeasurementPeriodMilliSeconds); |
johnAlexander | 0:c523920bcc09 | 1155 | VL53L0X_Error VL53L0X_GetXTalkCompensationRateMegaCps(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1156 | FixPoint1616_t *pXTalkCompensationRateMegaCps); |
johnAlexander | 0:c523920bcc09 | 1157 | VL53L0X_Error VL53L0X_GetLimitCheckValue(VL53L0X_DEV Dev, uint16_t LimitCheckId, |
johnAlexander | 0:c523920bcc09 | 1158 | FixPoint1616_t *pLimitCheckValue); |
johnAlexander | 0:c523920bcc09 | 1159 | VL53L0X_Error VL53L0X_GetLimitCheckEnable(VL53L0X_DEV Dev, uint16_t LimitCheckId, |
johnAlexander | 0:c523920bcc09 | 1160 | uint8_t *pLimitCheckEnable); |
johnAlexander | 0:c523920bcc09 | 1161 | VL53L0X_Error VL53L0X_GetWrapAroundCheckEnable(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1162 | uint8_t *pWrapAroundCheckEnable); |
johnAlexander | 0:c523920bcc09 | 1163 | VL53L0X_Error VL53L0X_GetMeasurementTimingBudgetMicroSeconds(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1164 | uint32_t *pMeasurementTimingBudgetMicroSeconds); |
johnAlexander | 0:c523920bcc09 | 1165 | VL53L0X_Error VL53L0X_GetSequenceStepEnables(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1166 | VL53L0X_SchedulerSequenceSteps_t *pSchedulerSequenceSteps); |
johnAlexander | 0:c523920bcc09 | 1167 | VL53L0X_Error sequence_step_enabled(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1168 | VL53L0X_SequenceStepId SequenceStepId, uint8_t SequenceConfig, |
johnAlexander | 0:c523920bcc09 | 1169 | uint8_t *pSequenceStepEnabled); |
johnAlexander | 0:c523920bcc09 | 1170 | VL53L0X_Error VL53L0X_GetVcselPulsePeriod(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1171 | VL53L0X_VcselPeriod VcselPeriodType, uint8_t *pVCSELPulsePeriodPCLK); |
johnAlexander | 0:c523920bcc09 | 1172 | VL53L0X_Error VL53L0X_GetDeviceInfo(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1173 | VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo); |
johnAlexander | 0:c523920bcc09 | 1174 | VL53L0X_Error VL53L0X_StaticInit(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1175 | VL53L0X_Error VL53L0X_GetMeasurementDataReady(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1176 | uint8_t *pMeasurementDataReady); |
johnAlexander | 0:c523920bcc09 | 1177 | VL53L0X_Error VL53L0X_GetInterruptMaskStatus(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1178 | uint32_t *pInterruptMaskStatus); |
johnAlexander | 0:c523920bcc09 | 1179 | VL53L0X_Error VL53L0X_ClearInterruptMask(VL53L0X_DEV Dev, uint32_t InterruptMask); |
johnAlexander | 0:c523920bcc09 | 1180 | VL53L0X_Error VL53L0X_PerformSingleRangingMeasurement(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1181 | VL53L0X_RangingMeasurementData_t *pRangingMeasurementData); |
johnAlexander | 0:c523920bcc09 | 1182 | VL53L0X_Error VL53L0X_SetDeviceMode(VL53L0X_DEV Dev, VL53L0X_DeviceModes DeviceMode); |
johnAlexander | 0:c523920bcc09 | 1183 | VL53L0X_Error VL53L0X_PerformSingleMeasurement(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1184 | VL53L0X_Error VL53L0X_StartMeasurement(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1185 | VL53L0X_Error VL53L0X_CheckAndLoadInterruptSettings(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1186 | uint8_t StartNotStopFlag); |
johnAlexander | 0:c523920bcc09 | 1187 | VL53L0X_Error VL53L0X_GetInterruptThresholds(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1188 | VL53L0X_DeviceModes DeviceMode, FixPoint1616_t *pThresholdLow, |
johnAlexander | 0:c523920bcc09 | 1189 | FixPoint1616_t *pThresholdHigh); |
johnAlexander | 0:c523920bcc09 | 1190 | VL53L0X_Error VL53L0X_GetRangingMeasurementData(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1191 | VL53L0X_RangingMeasurementData_t *pRangingMeasurementData); |
johnAlexander | 0:c523920bcc09 | 1192 | VL53L0X_Error VL53L0X_GetXTalkCompensationEnable(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1193 | uint8_t *pXTalkCompensationEnable); |
johnAlexander | 0:c523920bcc09 | 1194 | VL53L0X_Error VL53L0X_WaitDeviceBooted(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1195 | VL53L0X_Error VL53L0X_PerformRefCalibration(VL53L0X_DEV Dev, uint8_t *pVhvSettings, |
johnAlexander | 0:c523920bcc09 | 1196 | uint8_t *pPhaseCal); |
johnAlexander | 0:c523920bcc09 | 1197 | VL53L0X_Error VL53L0X_PerformRefSpadManagement(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1198 | uint32_t *refSpadCount, uint8_t *isApertureSpads); |
johnAlexander | 0:c523920bcc09 | 1199 | VL53L0X_Error VL53L0X_SetDeviceAddress(VL53L0X_DEV Dev, uint8_t DeviceAddress); |
johnAlexander | 0:c523920bcc09 | 1200 | VL53L0X_Error VL53L0X_SetGpioConfig(VL53L0X_DEV Dev, uint8_t Pin, |
johnAlexander | 0:c523920bcc09 | 1201 | VL53L0X_DeviceModes DeviceMode, VL53L0X_GpioFunctionality Functionality, |
johnAlexander | 0:c523920bcc09 | 1202 | VL53L0X_InterruptPolarity Polarity); |
johnAlexander | 0:c523920bcc09 | 1203 | VL53L0X_Error VL53L0X_GetFractionEnable(VL53L0X_DEV Dev, uint8_t *pEnabled); |
johnAlexander | 0:c523920bcc09 | 1204 | VL53L0X_Error VL53L0X_SetSequenceStepEnable(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1205 | VL53L0X_SequenceStepId SequenceStepId, uint8_t SequenceStepEnabled); |
johnAlexander | 0:c523920bcc09 | 1206 | VL53L0X_Error VL53L0X_SetMeasurementTimingBudgetMicroSeconds(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1207 | uint32_t MeasurementTimingBudgetMicroSeconds); |
johnAlexander | 0:c523920bcc09 | 1208 | VL53L0X_Error VL53L0X_SetLimitCheckEnable(VL53L0X_DEV Dev, uint16_t LimitCheckId, |
johnAlexander | 0:c523920bcc09 | 1209 | uint8_t LimitCheckEnable); |
johnAlexander | 0:c523920bcc09 | 1210 | VL53L0X_Error VL53L0X_SetLimitCheckValue(VL53L0X_DEV Dev, uint16_t LimitCheckId, |
johnAlexander | 0:c523920bcc09 | 1211 | FixPoint1616_t LimitCheckValue); |
johnAlexander | 0:c523920bcc09 | 1212 | VL53L0X_Error VL53L0X_StopMeasurement(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1213 | VL53L0X_Error VL53L0X_GetStopCompletedStatus(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1214 | uint32_t *pStopStatus); |
johnAlexander | 0:c523920bcc09 | 1215 | VL53L0X_Error VL53L0X_SetVcselPulsePeriod(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1216 | VL53L0X_VcselPeriod VcselPeriodType, uint8_t VCSELPulsePeriod); |
johnAlexander | 0:c523920bcc09 | 1217 | |
johnAlexander | 0:c523920bcc09 | 1218 | /* api_core.h functions */ |
johnAlexander | 0:c523920bcc09 | 1219 | VL53L0X_Error VL53L0X_get_info_from_device(VL53L0X_DEV Dev, uint8_t option); |
johnAlexander | 0:c523920bcc09 | 1220 | VL53L0X_Error VL53L0X_device_read_strobe(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1221 | VL53L0X_Error VL53L0X_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1222 | uint32_t *pMeasurementTimingBudgetMicroSeconds); |
johnAlexander | 0:c523920bcc09 | 1223 | VL53L0X_Error VL53L0X_get_vcsel_pulse_period(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1224 | VL53L0X_VcselPeriod VcselPeriodType, uint8_t *pVCSELPulsePeriodPCLK); |
johnAlexander | 0:c523920bcc09 | 1225 | uint8_t VL53L0X_decode_vcsel_period(uint8_t vcsel_period_reg); |
johnAlexander | 0:c523920bcc09 | 1226 | uint32_t VL53L0X_decode_timeout(uint16_t encoded_timeout); |
johnAlexander | 0:c523920bcc09 | 1227 | uint32_t VL53L0X_calc_timeout_us(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1228 | uint16_t timeout_period_mclks, |
johnAlexander | 0:c523920bcc09 | 1229 | uint8_t vcsel_period_pclks); |
johnAlexander | 0:c523920bcc09 | 1230 | uint32_t VL53L0X_calc_macro_period_ps(VL53L0X_DEV Dev, uint8_t vcsel_period_pclks); |
johnAlexander | 0:c523920bcc09 | 1231 | VL53L0X_Error VL53L0X_measurement_poll_for_completion(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1232 | VL53L0X_Error VL53L0X_load_tuning_settings(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1233 | uint8_t *pTuningSettingBuffer); |
johnAlexander | 0:c523920bcc09 | 1234 | VL53L0X_Error VL53L0X_get_pal_range_status(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1235 | uint8_t DeviceRangeStatus, |
johnAlexander | 0:c523920bcc09 | 1236 | FixPoint1616_t SignalRate, |
johnAlexander | 0:c523920bcc09 | 1237 | uint16_t EffectiveSpadRtnCount, |
johnAlexander | 0:c523920bcc09 | 1238 | VL53L0X_RangingMeasurementData_t *pRangingMeasurementData, |
johnAlexander | 0:c523920bcc09 | 1239 | uint8_t *pPalRangeStatus); |
johnAlexander | 0:c523920bcc09 | 1240 | VL53L0X_Error VL53L0X_calc_sigma_estimate(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1241 | VL53L0X_RangingMeasurementData_t *pRangingMeasurementData, |
johnAlexander | 0:c523920bcc09 | 1242 | FixPoint1616_t *pSigmaEstimate, |
johnAlexander | 0:c523920bcc09 | 1243 | uint32_t *pDmax_mm); |
johnAlexander | 0:c523920bcc09 | 1244 | VL53L0X_Error VL53L0X_get_total_signal_rate(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1245 | VL53L0X_RangingMeasurementData_t *pRangingMeasurementData, |
johnAlexander | 0:c523920bcc09 | 1246 | FixPoint1616_t *ptotal_signal_rate_mcps); |
johnAlexander | 0:c523920bcc09 | 1247 | VL53L0X_Error VL53L0X_get_total_xtalk_rate(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1248 | VL53L0X_RangingMeasurementData_t *pRangingMeasurementData, |
johnAlexander | 0:c523920bcc09 | 1249 | FixPoint1616_t *ptotal_xtalk_rate_mcps); |
johnAlexander | 0:c523920bcc09 | 1250 | uint32_t VL53L0X_calc_timeout_mclks(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1251 | uint32_t timeout_period_us, |
johnAlexander | 0:c523920bcc09 | 1252 | uint8_t vcsel_period_pclks); |
johnAlexander | 0:c523920bcc09 | 1253 | uint32_t VL53L0X_isqrt(uint32_t num); |
johnAlexander | 0:c523920bcc09 | 1254 | VL53L0X_Error VL53L0X_calc_dmax( |
johnAlexander | 0:c523920bcc09 | 1255 | VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1256 | FixPoint1616_t totalSignalRate_mcps, |
johnAlexander | 0:c523920bcc09 | 1257 | FixPoint1616_t totalCorrSignalRate_mcps, |
johnAlexander | 0:c523920bcc09 | 1258 | FixPoint1616_t pwMult, |
johnAlexander | 0:c523920bcc09 | 1259 | uint32_t sigmaEstimateP1, |
johnAlexander | 0:c523920bcc09 | 1260 | FixPoint1616_t sigmaEstimateP2, |
johnAlexander | 0:c523920bcc09 | 1261 | uint32_t peakVcselDuration_us, |
johnAlexander | 0:c523920bcc09 | 1262 | uint32_t *pdmax_mm); |
johnAlexander | 0:c523920bcc09 | 1263 | VL53L0X_Error VL53L0X_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1264 | uint32_t MeasurementTimingBudgetMicroSeconds); |
johnAlexander | 0:c523920bcc09 | 1265 | VL53L0X_Error get_sequence_step_timeout(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1266 | VL53L0X_SequenceStepId SequenceStepId, |
johnAlexander | 0:c523920bcc09 | 1267 | uint32_t *pTimeOutMicroSecs); |
johnAlexander | 0:c523920bcc09 | 1268 | VL53L0X_Error set_sequence_step_timeout(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1269 | VL53L0X_SequenceStepId SequenceStepId, |
johnAlexander | 0:c523920bcc09 | 1270 | uint32_t TimeOutMicroSecs); |
johnAlexander | 0:c523920bcc09 | 1271 | uint16_t VL53L0X_encode_timeout(uint32_t timeout_macro_clks); |
johnAlexander | 0:c523920bcc09 | 1272 | VL53L0X_Error VL53L0X_set_vcsel_pulse_period(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1273 | VL53L0X_VcselPeriod VcselPeriodType, uint8_t VCSELPulsePeriodPCLK); |
johnAlexander | 0:c523920bcc09 | 1274 | uint8_t VL53L0X_encode_vcsel_period(uint8_t vcsel_period_pclks); |
johnAlexander | 0:c523920bcc09 | 1275 | |
johnAlexander | 0:c523920bcc09 | 1276 | /* api_calibration.h functions */ |
johnAlexander | 0:c523920bcc09 | 1277 | VL53L0X_Error VL53L0X_apply_offset_adjustment(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1278 | VL53L0X_Error VL53L0X_get_offset_calibration_data_micro_meter(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1279 | int32_t *pOffsetCalibrationDataMicroMeter); |
johnAlexander | 0:c523920bcc09 | 1280 | VL53L0X_Error VL53L0X_set_offset_calibration_data_micro_meter(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1281 | int32_t OffsetCalibrationDataMicroMeter); |
johnAlexander | 0:c523920bcc09 | 1282 | VL53L0X_Error VL53L0X_perform_ref_spad_management(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1283 | uint32_t *refSpadCount, |
johnAlexander | 0:c523920bcc09 | 1284 | uint8_t *isApertureSpads); |
johnAlexander | 0:c523920bcc09 | 1285 | VL53L0X_Error VL53L0X_perform_ref_calibration(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1286 | uint8_t *pVhvSettings, uint8_t *pPhaseCal, uint8_t get_data_enable); |
johnAlexander | 0:c523920bcc09 | 1287 | VL53L0X_Error VL53L0X_perform_vhv_calibration(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1288 | uint8_t *pVhvSettings, const uint8_t get_data_enable, |
johnAlexander | 0:c523920bcc09 | 1289 | const uint8_t restore_config); |
johnAlexander | 0:c523920bcc09 | 1290 | VL53L0X_Error VL53L0X_perform_single_ref_calibration(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1291 | uint8_t vhv_init_byte); |
johnAlexander | 0:c523920bcc09 | 1292 | VL53L0X_Error VL53L0X_ref_calibration_io(VL53L0X_DEV Dev, uint8_t read_not_write, |
johnAlexander | 0:c523920bcc09 | 1293 | uint8_t VhvSettings, uint8_t PhaseCal, |
johnAlexander | 0:c523920bcc09 | 1294 | uint8_t *pVhvSettings, uint8_t *pPhaseCal, |
johnAlexander | 0:c523920bcc09 | 1295 | const uint8_t vhv_enable, const uint8_t phase_enable); |
johnAlexander | 0:c523920bcc09 | 1296 | VL53L0X_Error VL53L0X_perform_phase_calibration(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1297 | uint8_t *pPhaseCal, const uint8_t get_data_enable, |
johnAlexander | 0:c523920bcc09 | 1298 | const uint8_t restore_config); |
johnAlexander | 0:c523920bcc09 | 1299 | VL53L0X_Error enable_ref_spads(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1300 | uint8_t apertureSpads, |
johnAlexander | 0:c523920bcc09 | 1301 | uint8_t goodSpadArray[], |
johnAlexander | 0:c523920bcc09 | 1302 | uint8_t spadArray[], |
johnAlexander | 0:c523920bcc09 | 1303 | uint32_t size, |
johnAlexander | 0:c523920bcc09 | 1304 | uint32_t start, |
johnAlexander | 0:c523920bcc09 | 1305 | uint32_t offset, |
johnAlexander | 0:c523920bcc09 | 1306 | uint32_t spadCount, |
johnAlexander | 0:c523920bcc09 | 1307 | uint32_t *lastSpad); |
johnAlexander | 0:c523920bcc09 | 1308 | void get_next_good_spad(uint8_t goodSpadArray[], uint32_t size, |
johnAlexander | 0:c523920bcc09 | 1309 | uint32_t curr, int32_t *next); |
johnAlexander | 0:c523920bcc09 | 1310 | uint8_t is_aperture(uint32_t spadIndex); |
johnAlexander | 0:c523920bcc09 | 1311 | VL53L0X_Error enable_spad_bit(uint8_t spadArray[], uint32_t size, |
johnAlexander | 0:c523920bcc09 | 1312 | uint32_t spadIndex); |
johnAlexander | 0:c523920bcc09 | 1313 | VL53L0X_Error set_ref_spad_map(VL53L0X_DEV Dev, uint8_t *refSpadArray); |
johnAlexander | 0:c523920bcc09 | 1314 | VL53L0X_Error get_ref_spad_map(VL53L0X_DEV Dev, uint8_t *refSpadArray); |
johnAlexander | 0:c523920bcc09 | 1315 | VL53L0X_Error perform_ref_signal_measurement(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1316 | uint16_t *refSignalRate); |
johnAlexander | 0:c523920bcc09 | 1317 | VL53L0X_Error VL53L0X_set_reference_spads(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1318 | uint32_t count, uint8_t isApertureSpads); |
johnAlexander | 0:c523920bcc09 | 1319 | |
johnAlexander | 0:c523920bcc09 | 1320 | /* api_strings.h functions */ |
johnAlexander | 0:c523920bcc09 | 1321 | VL53L0X_Error VL53L0X_get_device_info(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1322 | VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo); |
johnAlexander | 0:c523920bcc09 | 1323 | VL53L0X_Error VL53L0X_check_part_used(VL53L0X_DEV Dev, |
johnAlexander | 0:c523920bcc09 | 1324 | uint8_t *Revision, |
johnAlexander | 0:c523920bcc09 | 1325 | VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo); |
johnAlexander | 0:c523920bcc09 | 1326 | |
johnAlexander | 0:c523920bcc09 | 1327 | /* Read function of the ID device */ |
johnAlexander | 0:c523920bcc09 | 1328 | virtual int ReadID(); |
johnAlexander | 0:c523920bcc09 | 1329 | |
johnAlexander | 0:c523920bcc09 | 1330 | VL53L0X_Error WaitMeasurementDataReady(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1331 | VL53L0X_Error WaitStopCompleted(VL53L0X_DEV Dev); |
johnAlexander | 0:c523920bcc09 | 1332 | |
johnAlexander | 0:c523920bcc09 | 1333 | /* Write and read functions from I2C */ |
johnAlexander | 0:c523920bcc09 | 1334 | |
johnAlexander | 0:c523920bcc09 | 1335 | VL53L0X_Error VL53L0X_WrByte(VL53L0X_DEV dev, uint8_t index, uint8_t data); |
johnAlexander | 0:c523920bcc09 | 1336 | VL53L0X_Error VL53L0X_WrWord(VL53L0X_DEV dev, uint8_t index, uint16_t data); |
johnAlexander | 0:c523920bcc09 | 1337 | VL53L0X_Error VL53L0X_WrDWord(VL53L0X_DEV dev, uint8_t index, uint32_t data); |
johnAlexander | 0:c523920bcc09 | 1338 | VL53L0X_Error VL53L0X_RdByte(VL53L0X_DEV dev, uint8_t index, uint8_t *data); |
johnAlexander | 0:c523920bcc09 | 1339 | VL53L0X_Error VL53L0X_RdWord(VL53L0X_DEV dev, uint8_t index, uint16_t *data); |
johnAlexander | 0:c523920bcc09 | 1340 | VL53L0X_Error VL53L0X_RdDWord(VL53L0X_DEV dev, uint8_t index, uint32_t *data); |
johnAlexander | 0:c523920bcc09 | 1341 | VL53L0X_Error VL53L0X_UpdateByte(VL53L0X_DEV dev, uint8_t index, uint8_t AndData, uint8_t OrData); |
johnAlexander | 0:c523920bcc09 | 1342 | |
johnAlexander | 0:c523920bcc09 | 1343 | VL53L0X_Error VL53L0X_WriteMulti(VL53L0X_DEV Dev, uint8_t index, uint8_t *pdata, uint32_t count); |
johnAlexander | 0:c523920bcc09 | 1344 | VL53L0X_Error VL53L0X_ReadMulti(VL53L0X_DEV Dev, uint8_t index, uint8_t *pdata, uint32_t count); |
johnAlexander | 0:c523920bcc09 | 1345 | |
johnAlexander | 0:c523920bcc09 | 1346 | VL53L0X_Error VL53L0X_I2CWrite(uint8_t dev, uint8_t index, uint8_t *data, uint16_t number_of_bytes); |
johnAlexander | 0:c523920bcc09 | 1347 | VL53L0X_Error VL53L0X_I2CRead(uint8_t dev, uint8_t index, uint8_t *data, uint16_t number_of_bytes); |
johnAlexander | 0:c523920bcc09 | 1348 | |
johnAlexander | 0:c523920bcc09 | 1349 | VL53L0X_Error VL53L0X_PollingDelay(VL53L0X_DEV Dev); /* usually best implemented as a real function */ |
johnAlexander | 0:c523920bcc09 | 1350 | |
johnAlexander | 0:c523920bcc09 | 1351 | int IsPresent() |
johnAlexander | 0:c523920bcc09 | 1352 | { |
johnAlexander | 0:c523920bcc09 | 1353 | int status; |
johnAlexander | 0:c523920bcc09 | 1354 | |
johnAlexander | 0:c523920bcc09 | 1355 | status=ReadID(); |
johnAlexander | 0:c523920bcc09 | 1356 | if(status) |
johnAlexander | 0:c523920bcc09 | 1357 | VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r"); |
johnAlexander | 0:c523920bcc09 | 1358 | return status; |
johnAlexander | 0:c523920bcc09 | 1359 | } |
johnAlexander | 0:c523920bcc09 | 1360 | int StopRangeMeasurement(OperatingMode operating_mode); |
johnAlexander | 0:c523920bcc09 | 1361 | int GetRangeMeas(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *Data); |
johnAlexander | 0:c523920bcc09 | 1362 | int RangeSetLowThreshold(uint16_t threshold); |
johnAlexander | 0:c523920bcc09 | 1363 | int RangeSetHighThreshold(uint16_t threshold); |
johnAlexander | 0:c523920bcc09 | 1364 | int GetRangeError(VL53L0X_RangingMeasurementData_t *Data, VL53L0X_RangingMeasurementData_t RangeData); |
johnAlexander | 0:c523920bcc09 | 1365 | int RangeMeasPollSingleShot(); |
johnAlexander | 0:c523920bcc09 | 1366 | int RangeMeasPollContinuousMode(); |
johnAlexander | 0:c523920bcc09 | 1367 | int RangeMeasIntContinuousMode(void (*fptr)(void)); |
johnAlexander | 0:c523920bcc09 | 1368 | |
johnAlexander | 0:c523920bcc09 | 1369 | |
johnAlexander | 0:c523920bcc09 | 1370 | VL53L0X_DeviceInfo_t DeviceInfo; |
johnAlexander | 0:c523920bcc09 | 1371 | |
johnAlexander | 0:c523920bcc09 | 1372 | /* IO Device */ |
johnAlexander | 0:c523920bcc09 | 1373 | DevI2C &dev_i2c; |
johnAlexander | 0:c523920bcc09 | 1374 | /* GPIO expander */ |
johnAlexander | 0:c523920bcc09 | 1375 | // STMPE1600 &io_expander; |
johnAlexander | 0:c523920bcc09 | 1376 | // ExpGpioPinName xshutdown; |
johnAlexander | 0:c523920bcc09 | 1377 | /* Digital out pin */ |
johnAlexander | 0:c523920bcc09 | 1378 | DigitalOut *gpio0; |
johnAlexander | 0:c523920bcc09 | 1379 | /* GPIO expander */ |
johnAlexander | 0:c523920bcc09 | 1380 | STMPE1600DigiOut *expgpio0; |
johnAlexander | 0:c523920bcc09 | 1381 | /* Measure detection IRQ */ |
johnAlexander | 0:c523920bcc09 | 1382 | InterruptIn *gpio1Int; |
johnAlexander | 0:c523920bcc09 | 1383 | /* Device data */ |
johnAlexander | 0:c523920bcc09 | 1384 | VL53L0X_Dev_t MyDevice; |
johnAlexander | 0:c523920bcc09 | 1385 | VL53L0X_DEV Device; |
johnAlexander | 0:c523920bcc09 | 1386 | }; |
johnAlexander | 0:c523920bcc09 | 1387 | |
johnAlexander | 0:c523920bcc09 | 1388 | |
johnAlexander | 0:c523920bcc09 | 1389 | #endif /* _VL53L0X_CLASS_H_ */ |
johnAlexander | 0:c523920bcc09 | 1390 | |
johnAlexander | 0:c523920bcc09 | 1391 |