Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Dependents: 53L0A1_Satellites_with_Interrupts_OS5 Display_53L0A1_OS5
Fork of X_NUCLEO_53L0A1 by
Components/VL53L0X/vl53l0x_class.h@16:98ce55ddbb1a, 2017-06-22 (annotated)
- Committer:
- johnAlexander
- Date:
- Thu Jun 22 09:55:10 2017 +0000
- Revision:
- 16:98ce55ddbb1a
- Parent:
- 15:932d8b4e52c9
- Child:
- 17:1b842521063a
further code refactoring with resharper & astyle.; removal of deprecated interfaces.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| johnAlexander | 0:c523920bcc09 | 1 | /******************************************************************************* |
| johnAlexander | 14:d84672f45f7b | 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 | 10:faf8d62ce6d1 | 45 | #include "mbed.h" |
| johnAlexander | 0:c523920bcc09 | 46 | #include "RangeSensor.h" |
| johnAlexander | 15:932d8b4e52c9 | 47 | #include "DevI2C.h" |
| johnAlexander | 16:98ce55ddbb1a | 48 | #include "PinNames.h" |
| johnAlexander | 0:c523920bcc09 | 49 | #include "vl53l0x_def.h" |
| johnAlexander | 0:c523920bcc09 | 50 | #include "vl53l0x_platform.h" |
| johnAlexander | 0:c523920bcc09 | 51 | #include "stmpe1600_class.h" |
| johnAlexander | 0:c523920bcc09 | 52 | |
| johnAlexander | 0:c523920bcc09 | 53 | |
| johnAlexander | 0:c523920bcc09 | 54 | /** |
| johnAlexander | 0:c523920bcc09 | 55 | * The device model ID |
| johnAlexander | 0:c523920bcc09 | 56 | */ |
| johnAlexander | 0:c523920bcc09 | 57 | #define IDENTIFICATION_MODEL_ID 0x000 |
| johnAlexander | 15:932d8b4e52c9 | 58 | |
| johnAlexander | 0:c523920bcc09 | 59 | |
| johnAlexander | 0:c523920bcc09 | 60 | #define STATUS_OK 0x00 |
| johnAlexander | 0:c523920bcc09 | 61 | #define STATUS_FAIL 0x01 |
| johnAlexander | 0:c523920bcc09 | 62 | |
| johnAlexander | 0:c523920bcc09 | 63 | |
| johnAlexander | 14:d84672f45f7b | 64 | #define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int) |
| johnAlexander | 0:c523920bcc09 | 65 | |
| johnAlexander | 0:c523920bcc09 | 66 | #ifdef USE_EMPTY_STRING |
| johnAlexander | 15:932d8b4e52c9 | 67 | #define VL53L0X_STRING_DEVICE_INFO_NAME "" |
| johnAlexander | 15:932d8b4e52c9 | 68 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "" |
| johnAlexander | 15:932d8b4e52c9 | 69 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "" |
| johnAlexander | 15:932d8b4e52c9 | 70 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "" |
| johnAlexander | 15:932d8b4e52c9 | 71 | #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "" |
| johnAlexander | 15:932d8b4e52c9 | 72 | #define VL53L0X_STRING_DEVICE_INFO_TYPE "" |
| johnAlexander | 0:c523920bcc09 | 73 | |
| johnAlexander | 15:932d8b4e52c9 | 74 | /* PAL ERROR strings */ |
| johnAlexander | 15:932d8b4e52c9 | 75 | #define VL53L0X_STRING_ERROR_NONE "" |
| johnAlexander | 15:932d8b4e52c9 | 76 | #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING "" |
| johnAlexander | 15:932d8b4e52c9 | 77 | #define VL53L0X_STRING_ERROR_MIN_CLIPPED "" |
| johnAlexander | 15:932d8b4e52c9 | 78 | #define VL53L0X_STRING_ERROR_UNDEFINED "" |
| johnAlexander | 15:932d8b4e52c9 | 79 | #define VL53L0X_STRING_ERROR_INVALID_PARAMS "" |
| johnAlexander | 15:932d8b4e52c9 | 80 | #define VL53L0X_STRING_ERROR_NOT_SUPPORTED "" |
| johnAlexander | 15:932d8b4e52c9 | 81 | #define VL53L0X_STRING_ERROR_RANGE_ERROR "" |
| johnAlexander | 15:932d8b4e52c9 | 82 | #define VL53L0X_STRING_ERROR_TIME_OUT "" |
| johnAlexander | 15:932d8b4e52c9 | 83 | #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED "" |
| johnAlexander | 15:932d8b4e52c9 | 84 | #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL "" |
| johnAlexander | 15:932d8b4e52c9 | 85 | #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING "" |
| johnAlexander | 15:932d8b4e52c9 | 86 | #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED "" |
| johnAlexander | 15:932d8b4e52c9 | 87 | #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE "" |
| johnAlexander | 15:932d8b4e52c9 | 88 | #define VL53L0X_STRING_ERROR_INVALID_COMMAND "" |
| johnAlexander | 15:932d8b4e52c9 | 89 | #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO "" |
| johnAlexander | 15:932d8b4e52c9 | 90 | #define VL53L0X_STRING_ERROR_REF_SPAD_INIT "" |
| johnAlexander | 15:932d8b4e52c9 | 91 | #define VL53L0X_STRING_ERROR_NOT_IMPLEMENTED "" |
| johnAlexander | 0:c523920bcc09 | 92 | |
| johnAlexander | 15:932d8b4e52c9 | 93 | #define VL53L0X_STRING_UNKNOW_ERROR_CODE "" |
| johnAlexander | 0:c523920bcc09 | 94 | |
| johnAlexander | 0:c523920bcc09 | 95 | |
| johnAlexander | 0:c523920bcc09 | 96 | |
| johnAlexander | 15:932d8b4e52c9 | 97 | /* Range Status */ |
| johnAlexander | 15:932d8b4e52c9 | 98 | #define VL53L0X_STRING_RANGESTATUS_NONE "" |
| johnAlexander | 15:932d8b4e52c9 | 99 | #define VL53L0X_STRING_RANGESTATUS_RANGEVALID "" |
| johnAlexander | 15:932d8b4e52c9 | 100 | #define VL53L0X_STRING_RANGESTATUS_SIGMA "" |
| johnAlexander | 15:932d8b4e52c9 | 101 | #define VL53L0X_STRING_RANGESTATUS_SIGNAL "" |
| johnAlexander | 15:932d8b4e52c9 | 102 | #define VL53L0X_STRING_RANGESTATUS_MINRANGE "" |
| johnAlexander | 15:932d8b4e52c9 | 103 | #define VL53L0X_STRING_RANGESTATUS_PHASE "" |
| johnAlexander | 15:932d8b4e52c9 | 104 | #define VL53L0X_STRING_RANGESTATUS_HW "" |
| johnAlexander | 0:c523920bcc09 | 105 | |
| johnAlexander | 0:c523920bcc09 | 106 | |
| johnAlexander | 15:932d8b4e52c9 | 107 | /* Range Status */ |
| johnAlexander | 15:932d8b4e52c9 | 108 | #define VL53L0X_STRING_STATE_POWERDOWN "" |
| johnAlexander | 15:932d8b4e52c9 | 109 | #define VL53L0X_STRING_STATE_WAIT_STATICINIT "" |
| johnAlexander | 15:932d8b4e52c9 | 110 | #define VL53L0X_STRING_STATE_STANDBY "" |
| johnAlexander | 15:932d8b4e52c9 | 111 | #define VL53L0X_STRING_STATE_IDLE "" |
| johnAlexander | 15:932d8b4e52c9 | 112 | #define VL53L0X_STRING_STATE_RUNNING "" |
| johnAlexander | 15:932d8b4e52c9 | 113 | #define VL53L0X_STRING_STATE_UNKNOWN "" |
| johnAlexander | 15:932d8b4e52c9 | 114 | #define VL53L0X_STRING_STATE_ERROR "" |
| johnAlexander | 0:c523920bcc09 | 115 | |
| johnAlexander | 0:c523920bcc09 | 116 | |
| johnAlexander | 15:932d8b4e52c9 | 117 | /* Device Specific */ |
| johnAlexander | 15:932d8b4e52c9 | 118 | #define VL53L0X_STRING_DEVICEERROR_NONE "" |
| johnAlexander | 15:932d8b4e52c9 | 119 | #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE "" |
| johnAlexander | 15:932d8b4e52c9 | 120 | #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE "" |
| johnAlexander | 15:932d8b4e52c9 | 121 | #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND "" |
| johnAlexander | 15:932d8b4e52c9 | 122 | #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET "" |
| johnAlexander | 15:932d8b4e52c9 | 123 | #define VL53L0X_STRING_DEVICEERROR_SNRCHECK "" |
| johnAlexander | 15:932d8b4e52c9 | 124 | #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK "" |
| johnAlexander | 15:932d8b4e52c9 | 125 | #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK "" |
| johnAlexander | 15:932d8b4e52c9 | 126 | #define VL53L0X_STRING_DEVICEERROR_TCC "" |
| johnAlexander | 15:932d8b4e52c9 | 127 | #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY "" |
| johnAlexander | 15:932d8b4e52c9 | 128 | #define VL53L0X_STRING_DEVICEERROR_MINCLIP "" |
| johnAlexander | 15:932d8b4e52c9 | 129 | #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE "" |
| johnAlexander | 15:932d8b4e52c9 | 130 | #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW "" |
| johnAlexander | 15:932d8b4e52c9 | 131 | #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW "" |
| johnAlexander | 15:932d8b4e52c9 | 132 | #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD "" |
| johnAlexander | 15:932d8b4e52c9 | 133 | #define VL53L0X_STRING_DEVICEERROR_UNKNOWN "" |
| johnAlexander | 0:c523920bcc09 | 134 | |
| johnAlexander | 15:932d8b4e52c9 | 135 | /* Check Enable */ |
| johnAlexander | 15:932d8b4e52c9 | 136 | #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE "" |
| johnAlexander | 15:932d8b4e52c9 | 137 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE "" |
| johnAlexander | 15:932d8b4e52c9 | 138 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP "" |
| johnAlexander | 15:932d8b4e52c9 | 139 | #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD "" |
| johnAlexander | 0:c523920bcc09 | 140 | |
| johnAlexander | 15:932d8b4e52c9 | 141 | /* Sequence Step */ |
| johnAlexander | 15:932d8b4e52c9 | 142 | #define VL53L0X_STRING_SEQUENCESTEP_TCC "" |
| johnAlexander | 15:932d8b4e52c9 | 143 | #define VL53L0X_STRING_SEQUENCESTEP_DSS "" |
| johnAlexander | 15:932d8b4e52c9 | 144 | #define VL53L0X_STRING_SEQUENCESTEP_MSRC "" |
| johnAlexander | 15:932d8b4e52c9 | 145 | #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE "" |
| johnAlexander | 15:932d8b4e52c9 | 146 | #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE "" |
| johnAlexander | 0:c523920bcc09 | 147 | #else |
| johnAlexander | 15:932d8b4e52c9 | 148 | #define VL53L0X_STRING_DEVICE_INFO_NAME "VL53L0X cut1.0" |
| johnAlexander | 15:932d8b4e52c9 | 149 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "VL53L0X TS0" |
| johnAlexander | 15:932d8b4e52c9 | 150 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "VL53L0X TS1" |
| johnAlexander | 15:932d8b4e52c9 | 151 | #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "VL53L0X TS2" |
| johnAlexander | 15:932d8b4e52c9 | 152 | #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "VL53L0X ES1 or later" |
| johnAlexander | 15:932d8b4e52c9 | 153 | #define VL53L0X_STRING_DEVICE_INFO_TYPE "VL53L0X" |
| johnAlexander | 0:c523920bcc09 | 154 | |
| johnAlexander | 15:932d8b4e52c9 | 155 | /* PAL ERROR strings */ |
| johnAlexander | 15:932d8b4e52c9 | 156 | #define VL53L0X_STRING_ERROR_NONE \ |
| johnAlexander | 0:c523920bcc09 | 157 | "No Error" |
| johnAlexander | 15:932d8b4e52c9 | 158 | #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING \ |
| johnAlexander | 0:c523920bcc09 | 159 | "Calibration Warning Error" |
| johnAlexander | 15:932d8b4e52c9 | 160 | #define VL53L0X_STRING_ERROR_MIN_CLIPPED \ |
| johnAlexander | 0:c523920bcc09 | 161 | "Min clipped error" |
| johnAlexander | 15:932d8b4e52c9 | 162 | #define VL53L0X_STRING_ERROR_UNDEFINED \ |
| johnAlexander | 0:c523920bcc09 | 163 | "Undefined error" |
| johnAlexander | 15:932d8b4e52c9 | 164 | #define VL53L0X_STRING_ERROR_INVALID_PARAMS \ |
| johnAlexander | 0:c523920bcc09 | 165 | "Invalid parameters error" |
| johnAlexander | 15:932d8b4e52c9 | 166 | #define VL53L0X_STRING_ERROR_NOT_SUPPORTED \ |
| johnAlexander | 0:c523920bcc09 | 167 | "Not supported error" |
| johnAlexander | 15:932d8b4e52c9 | 168 | #define VL53L0X_STRING_ERROR_RANGE_ERROR \ |
| johnAlexander | 0:c523920bcc09 | 169 | "Range error" |
| johnAlexander | 15:932d8b4e52c9 | 170 | #define VL53L0X_STRING_ERROR_TIME_OUT \ |
| johnAlexander | 0:c523920bcc09 | 171 | "Time out error" |
| johnAlexander | 15:932d8b4e52c9 | 172 | #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED \ |
| johnAlexander | 0:c523920bcc09 | 173 | "Mode not supported error" |
| johnAlexander | 15:932d8b4e52c9 | 174 | #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL \ |
| johnAlexander | 0:c523920bcc09 | 175 | "Buffer too small" |
| johnAlexander | 15:932d8b4e52c9 | 176 | #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING \ |
| johnAlexander | 0:c523920bcc09 | 177 | "GPIO not existing" |
| johnAlexander | 15:932d8b4e52c9 | 178 | #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \ |
| johnAlexander | 0:c523920bcc09 | 179 | "GPIO funct not supported" |
| johnAlexander | 15:932d8b4e52c9 | 180 | #define VL53L0X_STRING_ERROR_INTERRUPT_NOT_CLEARED \ |
| johnAlexander | 0:c523920bcc09 | 181 | "Interrupt not Cleared" |
| johnAlexander | 15:932d8b4e52c9 | 182 | #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE \ |
| johnAlexander | 0:c523920bcc09 | 183 | "Control Interface Error" |
| johnAlexander | 15:932d8b4e52c9 | 184 | #define VL53L0X_STRING_ERROR_INVALID_COMMAND \ |
| johnAlexander | 0:c523920bcc09 | 185 | "Invalid Command Error" |
| johnAlexander | 15:932d8b4e52c9 | 186 | #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO \ |
| johnAlexander | 0:c523920bcc09 | 187 | "Division by zero Error" |
| johnAlexander | 15:932d8b4e52c9 | 188 | #define VL53L0X_STRING_ERROR_REF_SPAD_INIT \ |
| johnAlexander | 0:c523920bcc09 | 189 | "Reference Spad Init Error" |
| johnAlexander | 15:932d8b4e52c9 | 190 | #define VL53L0X_STRING_ERROR_NOT_IMPLEMENTED \ |
| johnAlexander | 0:c523920bcc09 | 191 | "Not implemented error" |
| johnAlexander | 0:c523920bcc09 | 192 | |
| johnAlexander | 15:932d8b4e52c9 | 193 | #define VL53L0X_STRING_UNKNOW_ERROR_CODE \ |
| johnAlexander | 0:c523920bcc09 | 194 | "Unknown Error Code" |
| johnAlexander | 0:c523920bcc09 | 195 | |
| johnAlexander | 0:c523920bcc09 | 196 | |
| johnAlexander | 0:c523920bcc09 | 197 | |
| johnAlexander | 15:932d8b4e52c9 | 198 | /* Range Status */ |
| johnAlexander | 15:932d8b4e52c9 | 199 | #define VL53L0X_STRING_RANGESTATUS_NONE "No Update" |
| johnAlexander | 15:932d8b4e52c9 | 200 | #define VL53L0X_STRING_RANGESTATUS_RANGEVALID "Range Valid" |
| johnAlexander | 15:932d8b4e52c9 | 201 | #define VL53L0X_STRING_RANGESTATUS_SIGMA "Sigma Fail" |
| johnAlexander | 15:932d8b4e52c9 | 202 | #define VL53L0X_STRING_RANGESTATUS_SIGNAL "Signal Fail" |
| johnAlexander | 15:932d8b4e52c9 | 203 | #define VL53L0X_STRING_RANGESTATUS_MINRANGE "Min Range Fail" |
| johnAlexander | 15:932d8b4e52c9 | 204 | #define VL53L0X_STRING_RANGESTATUS_PHASE "Phase Fail" |
| johnAlexander | 15:932d8b4e52c9 | 205 | #define VL53L0X_STRING_RANGESTATUS_HW "Hardware Fail" |
| johnAlexander | 0:c523920bcc09 | 206 | |
| johnAlexander | 0:c523920bcc09 | 207 | |
| johnAlexander | 15:932d8b4e52c9 | 208 | /* Range Status */ |
| johnAlexander | 15:932d8b4e52c9 | 209 | #define VL53L0X_STRING_STATE_POWERDOWN "POWERDOWN State" |
| johnAlexander | 15:932d8b4e52c9 | 210 | #define VL53L0X_STRING_STATE_WAIT_STATICINIT \ |
| johnAlexander | 0:c523920bcc09 | 211 | "Wait for staticinit State" |
| johnAlexander | 15:932d8b4e52c9 | 212 | #define VL53L0X_STRING_STATE_STANDBY "STANDBY State" |
| johnAlexander | 15:932d8b4e52c9 | 213 | #define VL53L0X_STRING_STATE_IDLE "IDLE State" |
| johnAlexander | 15:932d8b4e52c9 | 214 | #define VL53L0X_STRING_STATE_RUNNING "RUNNING State" |
| johnAlexander | 15:932d8b4e52c9 | 215 | #define VL53L0X_STRING_STATE_UNKNOWN "UNKNOWN State" |
| johnAlexander | 15:932d8b4e52c9 | 216 | #define VL53L0X_STRING_STATE_ERROR "ERROR State" |
| johnAlexander | 0:c523920bcc09 | 217 | |
| johnAlexander | 0:c523920bcc09 | 218 | |
| johnAlexander | 15:932d8b4e52c9 | 219 | /* Device Specific */ |
| johnAlexander | 15:932d8b4e52c9 | 220 | #define VL53L0X_STRING_DEVICEERROR_NONE "No Update" |
| johnAlexander | 15:932d8b4e52c9 | 221 | #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE \ |
| johnAlexander | 0:c523920bcc09 | 222 | "VCSEL Continuity Test Failure" |
| johnAlexander | 15:932d8b4e52c9 | 223 | #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE \ |
| johnAlexander | 0:c523920bcc09 | 224 | "VCSEL Watchdog Test Failure" |
| johnAlexander | 15:932d8b4e52c9 | 225 | #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND \ |
| johnAlexander | 0:c523920bcc09 | 226 | "No VHV Value found" |
| johnAlexander | 15:932d8b4e52c9 | 227 | #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET \ |
| johnAlexander | 0:c523920bcc09 | 228 | "MSRC No Target Error" |
| johnAlexander | 15:932d8b4e52c9 | 229 | #define VL53L0X_STRING_DEVICEERROR_SNRCHECK \ |
| johnAlexander | 0:c523920bcc09 | 230 | "SNR Check Exit" |
| johnAlexander | 15:932d8b4e52c9 | 231 | #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK \ |
| johnAlexander | 0:c523920bcc09 | 232 | "Range Phase Check Error" |
| johnAlexander | 15:932d8b4e52c9 | 233 | #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK \ |
| johnAlexander | 0:c523920bcc09 | 234 | "Sigma Threshold Check Error" |
| johnAlexander | 15:932d8b4e52c9 | 235 | #define VL53L0X_STRING_DEVICEERROR_TCC \ |
| johnAlexander | 0:c523920bcc09 | 236 | "TCC Error" |
| johnAlexander | 15:932d8b4e52c9 | 237 | #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY \ |
| johnAlexander | 0:c523920bcc09 | 238 | "Phase Consistency Error" |
| johnAlexander | 15:932d8b4e52c9 | 239 | #define VL53L0X_STRING_DEVICEERROR_MINCLIP \ |
| johnAlexander | 0:c523920bcc09 | 240 | "Min Clip Error" |
| johnAlexander | 15:932d8b4e52c9 | 241 | #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE \ |
| johnAlexander | 0:c523920bcc09 | 242 | "Range Complete" |
| johnAlexander | 15:932d8b4e52c9 | 243 | #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW \ |
| johnAlexander | 0:c523920bcc09 | 244 | "Range Algo Underflow Error" |
| johnAlexander | 15:932d8b4e52c9 | 245 | #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW \ |
| johnAlexander | 0:c523920bcc09 | 246 | "Range Algo Overlow Error" |
| johnAlexander | 15:932d8b4e52c9 | 247 | #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD \ |
| johnAlexander | 0:c523920bcc09 | 248 | "Range Ignore Threshold Error" |
| johnAlexander | 15:932d8b4e52c9 | 249 | #define VL53L0X_STRING_DEVICEERROR_UNKNOWN \ |
| johnAlexander | 0:c523920bcc09 | 250 | "Unknown error code" |
| johnAlexander | 0:c523920bcc09 | 251 | |
| johnAlexander | 15:932d8b4e52c9 | 252 | /* Check Enable */ |
| johnAlexander | 15:932d8b4e52c9 | 253 | #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \ |
| johnAlexander | 0:c523920bcc09 | 254 | "SIGMA FINAL RANGE" |
| johnAlexander | 15:932d8b4e52c9 | 255 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \ |
| johnAlexander | 0:c523920bcc09 | 256 | "SIGNAL RATE FINAL RANGE" |
| johnAlexander | 15:932d8b4e52c9 | 257 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP \ |
| johnAlexander | 0:c523920bcc09 | 258 | "SIGNAL REF CLIP" |
| johnAlexander | 15:932d8b4e52c9 | 259 | #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \ |
| johnAlexander | 0:c523920bcc09 | 260 | "RANGE IGNORE THRESHOLD" |
| johnAlexander | 15:932d8b4e52c9 | 261 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_MSRC \ |
| johnAlexander | 0:c523920bcc09 | 262 | "SIGNAL RATE MSRC" |
| johnAlexander | 15:932d8b4e52c9 | 263 | #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE \ |
| johnAlexander | 0:c523920bcc09 | 264 | "SIGNAL RATE PRE RANGE" |
| johnAlexander | 0:c523920bcc09 | 265 | |
| johnAlexander | 15:932d8b4e52c9 | 266 | /* Sequence Step */ |
| johnAlexander | 15:932d8b4e52c9 | 267 | #define VL53L0X_STRING_SEQUENCESTEP_TCC "TCC" |
| johnAlexander | 15:932d8b4e52c9 | 268 | #define VL53L0X_STRING_SEQUENCESTEP_DSS "DSS" |
| johnAlexander | 15:932d8b4e52c9 | 269 | #define VL53L0X_STRING_SEQUENCESTEP_MSRC "MSRC" |
| johnAlexander | 15:932d8b4e52c9 | 270 | #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE "PRE RANGE" |
| johnAlexander | 15:932d8b4e52c9 | 271 | #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE "FINAL RANGE" |
| johnAlexander | 0:c523920bcc09 | 272 | #endif /* USE_EMPTY_STRING */ |
| johnAlexander | 0:c523920bcc09 | 273 | |
| johnAlexander | 0:c523920bcc09 | 274 | |
| johnAlexander | 0:c523920bcc09 | 275 | |
| johnAlexander | 0:c523920bcc09 | 276 | |
| johnAlexander | 0:c523920bcc09 | 277 | |
| johnAlexander | 15:932d8b4e52c9 | 278 | /* sensor operating modes */ |
| johnAlexander | 15:932d8b4e52c9 | 279 | typedef enum { |
| johnAlexander | 15:932d8b4e52c9 | 280 | range_single_shot_polling=1, |
| johnAlexander | 15:932d8b4e52c9 | 281 | range_continuous_polling, |
| johnAlexander | 15:932d8b4e52c9 | 282 | range_continuous_interrupt, |
| johnAlexander | 15:932d8b4e52c9 | 283 | range_continuous_polling_low_threshold, |
| johnAlexander | 15:932d8b4e52c9 | 284 | range_continuous_polling_high_threshold, |
| johnAlexander | 15:932d8b4e52c9 | 285 | range_continuous_polling_out_of_window, |
| johnAlexander | 15:932d8b4e52c9 | 286 | range_continuous_interrupt_low_threshold, |
| johnAlexander | 15:932d8b4e52c9 | 287 | range_continuous_interrupt_high_threshold, |
| johnAlexander | 15:932d8b4e52c9 | 288 | range_continuous_interrupt_out_of_window, |
| johnAlexander | 15:932d8b4e52c9 | 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 | 15:932d8b4e52c9 | 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 | 16:98ce55ddbb1a | 303 | * @param[in] dev_addr device address, 0x29 by default |
| johnAlexander | 0:c523920bcc09 | 304 | */ |
| johnAlexander | 16:98ce55ddbb1a | 305 | VL53L0X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t dev_addr=DEFAULT_DEVICE_ADDRESS) : dev_i2c(i2c), gpio0(&pin) |
| johnAlexander | 0:c523920bcc09 | 306 | { |
| johnAlexander | 16:98ce55ddbb1a | 307 | _my_device.I2cDevAddr=dev_addr; |
| johnAlexander | 16:98ce55ddbb1a | 308 | _my_device.comms_type=1; // VL53L0X_COMMS_I2C |
| johnAlexander | 16:98ce55ddbb1a | 309 | _my_device.comms_speed_khz=400; |
| johnAlexander | 16:98ce55ddbb1a | 310 | _device=&_my_device; |
| johnAlexander | 15:932d8b4e52c9 | 311 | expgpio0=NULL; |
| johnAlexander | 15:932d8b4e52c9 | 312 | if (pin_gpio1 != NC) { |
| johnAlexander | 15:932d8b4e52c9 | 313 | gpio1Int = new InterruptIn(pin_gpio1); |
| johnAlexander | 15:932d8b4e52c9 | 314 | } else { |
| johnAlexander | 15:932d8b4e52c9 | 315 | gpio1Int = NULL; |
| johnAlexander | 15:932d8b4e52c9 | 316 | } |
| johnAlexander | 15:932d8b4e52c9 | 317 | } |
| johnAlexander | 15:932d8b4e52c9 | 318 | |
| johnAlexander | 0:c523920bcc09 | 319 | /** Constructor 2 (STMPE1600DigiOut) |
| johnAlexander | 0:c523920bcc09 | 320 | * @param[in] i2c device I2C to be used for communication |
| johnAlexander | 0:c523920bcc09 | 321 | * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE |
| johnAlexander | 0:c523920bcc09 | 322 | * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT |
| johnAlexander | 15:932d8b4e52c9 | 323 | * @param[in] device address, 0x29 by default |
| johnAlexander | 15:932d8b4e52c9 | 324 | */ |
| johnAlexander | 16:98ce55ddbb1a | 325 | VL53L0X(DevI2C &i2c, Stmpe1600DigiOut &pin, PinName pin_gpio1, uint8_t dev_addr=DEFAULT_DEVICE_ADDRESS) : dev_i2c(i2c), expgpio0(&pin) |
| johnAlexander | 0:c523920bcc09 | 326 | { |
| johnAlexander | 16:98ce55ddbb1a | 327 | _my_device.I2cDevAddr=dev_addr; |
| johnAlexander | 16:98ce55ddbb1a | 328 | _my_device.comms_type=1; // VL53L0X_COMMS_I2C |
| johnAlexander | 16:98ce55ddbb1a | 329 | _my_device.comms_speed_khz=400; |
| johnAlexander | 16:98ce55ddbb1a | 330 | _device=&_my_device; |
| johnAlexander | 15:932d8b4e52c9 | 331 | gpio0=NULL; |
| johnAlexander | 15:932d8b4e52c9 | 332 | if (pin_gpio1 != NC) { |
| johnAlexander | 15:932d8b4e52c9 | 333 | gpio1Int = new InterruptIn(pin_gpio1); |
| johnAlexander | 15:932d8b4e52c9 | 334 | } else { |
| johnAlexander | 15:932d8b4e52c9 | 335 | gpio1Int = NULL; |
| johnAlexander | 15:932d8b4e52c9 | 336 | } |
| johnAlexander | 15:932d8b4e52c9 | 337 | } |
| johnAlexander | 15:932d8b4e52c9 | 338 | |
| johnAlexander | 15:932d8b4e52c9 | 339 | /** Destructor |
| johnAlexander | 15:932d8b4e52c9 | 340 | */ |
| johnAlexander | 15:932d8b4e52c9 | 341 | virtual ~VL53L0X() |
| johnAlexander | 15:932d8b4e52c9 | 342 | { |
| johnAlexander | 15:932d8b4e52c9 | 343 | if (gpio1Int != NULL) delete gpio1Int; |
| johnAlexander | 15:932d8b4e52c9 | 344 | } |
| johnAlexander | 0:c523920bcc09 | 345 | /* warning: VL53L0X class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor. |
| johnAlexander | 0:c523920bcc09 | 346 | The warning should request to introduce a virtual destructor to make sure to delete the object */ |
| johnAlexander | 0:c523920bcc09 | 347 | |
| johnAlexander | 15:932d8b4e52c9 | 348 | /*** Interface Methods ***/ |
| johnAlexander | 15:932d8b4e52c9 | 349 | /*** High level API ***/ |
| johnAlexander | 15:932d8b4e52c9 | 350 | /** |
| johnAlexander | 15:932d8b4e52c9 | 351 | * @brief PowerOn the sensor |
| johnAlexander | 15:932d8b4e52c9 | 352 | * @return void |
| johnAlexander | 15:932d8b4e52c9 | 353 | */ |
| johnAlexander | 15:932d8b4e52c9 | 354 | /* turns on the sensor */ |
| johnAlexander | 16:98ce55ddbb1a | 355 | void vl53l0x_on(void) |
| johnAlexander | 0:c523920bcc09 | 356 | { |
| johnAlexander | 15:932d8b4e52c9 | 357 | if (gpio0) |
| johnAlexander | 15:932d8b4e52c9 | 358 | *gpio0 = 1; |
| johnAlexander | 15:932d8b4e52c9 | 359 | else if (expgpio0) |
| johnAlexander | 0:c523920bcc09 | 360 | *expgpio0 = 1; |
| johnAlexander | 9:367d1f390cb2 | 361 | wait_ms(10); |
| johnAlexander | 15:932d8b4e52c9 | 362 | } |
| johnAlexander | 0:c523920bcc09 | 363 | |
| johnAlexander | 15:932d8b4e52c9 | 364 | /** |
| johnAlexander | 15:932d8b4e52c9 | 365 | * @brief PowerOff the sensor |
| johnAlexander | 15:932d8b4e52c9 | 366 | * @return void |
| johnAlexander | 15:932d8b4e52c9 | 367 | */ |
| johnAlexander | 0:c523920bcc09 | 368 | /* turns off the sensor */ |
| johnAlexander | 16:98ce55ddbb1a | 369 | void vl53l0x_off(void) |
| johnAlexander | 0:c523920bcc09 | 370 | { |
| johnAlexander | 15:932d8b4e52c9 | 371 | if (gpio0) |
| johnAlexander | 15:932d8b4e52c9 | 372 | *gpio0 = 0; |
| johnAlexander | 15:932d8b4e52c9 | 373 | else if (expgpio0) |
| johnAlexander | 0:c523920bcc09 | 374 | *expgpio0 = 0; |
| johnAlexander | 9:367d1f390cb2 | 375 | wait_ms(10); |
| johnAlexander | 0:c523920bcc09 | 376 | } |
| johnAlexander | 15:932d8b4e52c9 | 377 | |
| johnAlexander | 15:932d8b4e52c9 | 378 | /** |
| johnAlexander | 15:932d8b4e52c9 | 379 | * @brief Initialize the sensor with default values |
| johnAlexander | 15:932d8b4e52c9 | 380 | * @return 0 on Success |
| johnAlexander | 15:932d8b4e52c9 | 381 | */ |
| johnAlexander | 16:98ce55ddbb1a | 382 | int init_sensor(uint8_t new_addr); |
| johnAlexander | 0:c523920bcc09 | 383 | |
| johnAlexander | 15:932d8b4e52c9 | 384 | /** |
| johnAlexander | 15:932d8b4e52c9 | 385 | * @brief Start the measure indicated by operating mode |
| johnAlexander | 15:932d8b4e52c9 | 386 | * @param[in] operating_mode specifies requested measure |
| johnAlexander | 15:932d8b4e52c9 | 387 | * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure |
| johnAlexander | 15:932d8b4e52c9 | 388 | * @return 0 on Success |
| johnAlexander | 15:932d8b4e52c9 | 389 | */ |
| johnAlexander | 16:98ce55ddbb1a | 390 | int start_measurement(OperatingMode operating_mode, void (*fptr)(void)); |
| johnAlexander | 0:c523920bcc09 | 391 | |
| johnAlexander | 15:932d8b4e52c9 | 392 | /** |
| johnAlexander | 15:932d8b4e52c9 | 393 | * @brief Get results for the measure indicated by operating mode |
| johnAlexander | 15:932d8b4e52c9 | 394 | * @param[in] operating_mode specifies requested measure results |
| johnAlexander | 16:98ce55ddbb1a | 395 | * @param[out] p_data pointer to the MeasureData_t structure to read data in to |
| johnAlexander | 15:932d8b4e52c9 | 396 | * @return 0 on Success |
| johnAlexander | 15:932d8b4e52c9 | 397 | */ |
| johnAlexander | 16:98ce55ddbb1a | 398 | int get_measurement(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *p_data); |
| johnAlexander | 0:c523920bcc09 | 399 | |
| johnAlexander | 15:932d8b4e52c9 | 400 | /** |
| johnAlexander | 15:932d8b4e52c9 | 401 | * @brief Stop the currently running measure indicate by operating_mode |
| johnAlexander | 15:932d8b4e52c9 | 402 | * @param[in] operating_mode specifies requested measure to stop |
| johnAlexander | 15:932d8b4e52c9 | 403 | * @return 0 on Success |
| johnAlexander | 15:932d8b4e52c9 | 404 | */ |
| johnAlexander | 16:98ce55ddbb1a | 405 | int stop_measurement(OperatingMode operating_mode); |
| johnAlexander | 0:c523920bcc09 | 406 | |
| johnAlexander | 15:932d8b4e52c9 | 407 | /** |
| johnAlexander | 15:932d8b4e52c9 | 408 | * @brief Interrupt handling func to be called by user after an INT is occourred |
| johnAlexander | 15:932d8b4e52c9 | 409 | * @param[in] opeating_mode indicating the in progress measure |
| johnAlexander | 15:932d8b4e52c9 | 410 | * @param[out] Data pointer to the MeasureData_t structure to read data in to |
| johnAlexander | 15:932d8b4e52c9 | 411 | * @return 0 on Success |
| johnAlexander | 15:932d8b4e52c9 | 412 | */ |
| johnAlexander | 15:932d8b4e52c9 | 413 | int HandleIRQ(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *Data); |
| johnAlexander | 15:932d8b4e52c9 | 414 | |
| johnAlexander | 15:932d8b4e52c9 | 415 | /** |
| johnAlexander | 15:932d8b4e52c9 | 416 | * @brief Enable interrupt measure IRQ |
| johnAlexander | 15:932d8b4e52c9 | 417 | * @return 0 on Success |
| johnAlexander | 15:932d8b4e52c9 | 418 | */ |
| johnAlexander | 16:98ce55ddbb1a | 419 | void enable_interrupt_measure_detection_irq(void) |
| johnAlexander | 0:c523920bcc09 | 420 | { |
| johnAlexander | 15:932d8b4e52c9 | 421 | if (gpio1Int != NULL) gpio1Int->enable_irq(); |
| johnAlexander | 0:c523920bcc09 | 422 | } |
| johnAlexander | 0:c523920bcc09 | 423 | |
| johnAlexander | 15:932d8b4e52c9 | 424 | /** |
| johnAlexander | 15:932d8b4e52c9 | 425 | * @brief Disable interrupt measure IRQ |
| johnAlexander | 15:932d8b4e52c9 | 426 | * @return 0 on Success |
| johnAlexander | 15:932d8b4e52c9 | 427 | */ |
| johnAlexander | 16:98ce55ddbb1a | 428 | void disable_interrupt_measure_detection_irq(void) |
| johnAlexander | 0:c523920bcc09 | 429 | { |
| johnAlexander | 15:932d8b4e52c9 | 430 | if (gpio1Int != NULL) gpio1Int->disable_irq(); |
| johnAlexander | 0:c523920bcc09 | 431 | } |
| johnAlexander | 15:932d8b4e52c9 | 432 | /*** End High level API ***/ |
| johnAlexander | 15:932d8b4e52c9 | 433 | |
| johnAlexander | 15:932d8b4e52c9 | 434 | /** |
| johnAlexander | 15:932d8b4e52c9 | 435 | * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready |
| johnAlexander | 15:932d8b4e52c9 | 436 | * @param[in] fptr pointer to call back function to be called whenever an interrupt occours |
| johnAlexander | 15:932d8b4e52c9 | 437 | * @return 0 on Success |
| johnAlexander | 15:932d8b4e52c9 | 438 | */ |
| johnAlexander | 16:98ce55ddbb1a | 439 | void attach_interrupt_measure_detection_irq(void (*fptr)(void)) |
| johnAlexander | 0:c523920bcc09 | 440 | { |
| johnAlexander | 15:932d8b4e52c9 | 441 | if (gpio1Int != NULL) gpio1Int->rise(fptr); |
| johnAlexander | 0:c523920bcc09 | 442 | } |
| johnAlexander | 15:932d8b4e52c9 | 443 | |
| johnAlexander | 15:932d8b4e52c9 | 444 | /** |
| johnAlexander | 15:932d8b4e52c9 | 445 | * @brief Check the sensor presence |
| johnAlexander | 15:932d8b4e52c9 | 446 | * @return 1 when device is present |
| johnAlexander | 15:932d8b4e52c9 | 447 | */ |
| johnAlexander | 16:98ce55ddbb1a | 448 | unsigned present() |
| johnAlexander | 0:c523920bcc09 | 449 | { |
| johnAlexander | 0:c523920bcc09 | 450 | // return Device->Present; |
| johnAlexander | 15:932d8b4e52c9 | 451 | return 1; |
| johnAlexander | 0:c523920bcc09 | 452 | } |
| johnAlexander | 15:932d8b4e52c9 | 453 | |
| johnAlexander | 15:932d8b4e52c9 | 454 | /** Wrapper functions */ |
| johnAlexander | 15:932d8b4e52c9 | 455 | /** @defgroup api_init Init functions |
| johnAlexander | 15:932d8b4e52c9 | 456 | * @brief API init functions |
| johnAlexander | 15:932d8b4e52c9 | 457 | * @ingroup api_hl |
| johnAlexander | 15:932d8b4e52c9 | 458 | * @{ |
| johnAlexander | 15:932d8b4e52c9 | 459 | */ |
| johnAlexander | 15:932d8b4e52c9 | 460 | /** |
| johnAlexander | 15:932d8b4e52c9 | 461 | * @brief Wait for device booted after chip enable (hardware standby) |
| johnAlexander | 15:932d8b4e52c9 | 462 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 463 | * After Chip enable Application you can also simply wait at least 1ms to ensure device is ready |
| johnAlexander | 15:932d8b4e52c9 | 464 | * @warning After device chip enable (gpio0) de-asserted user must wait gpio1 to get asserted (hardware standby). |
| johnAlexander | 15:932d8b4e52c9 | 465 | * or wait at least 400usec prior to do any low level access or api call . |
| johnAlexander | 15:932d8b4e52c9 | 466 | * |
| johnAlexander | 15:932d8b4e52c9 | 467 | * This function implements polling for standby but you must ensure 400usec from chip enable passed\n |
| johnAlexander | 15:932d8b4e52c9 | 468 | * @warning if device get prepared @a VL53L0X_Prepare() re-using these function can hold indefinitely\n |
| johnAlexander | 15:932d8b4e52c9 | 469 | * |
| johnAlexander | 15:932d8b4e52c9 | 470 | * @param void |
| johnAlexander | 15:932d8b4e52c9 | 471 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 472 | */ |
| johnAlexander | 16:98ce55ddbb1a | 473 | int wait_device_booted() |
| johnAlexander | 0:c523920bcc09 | 474 | { |
| johnAlexander | 13:615f7e38568c | 475 | // return VL53L0X_WaitDeviceBooted(Device); |
| johnAlexander | 15:932d8b4e52c9 | 476 | return 1; |
| johnAlexander | 0:c523920bcc09 | 477 | } |
| johnAlexander | 0:c523920bcc09 | 478 | |
| JerrySzczurak | 11:ceaa5a026412 | 479 | |
| johnAlexander | 15:932d8b4e52c9 | 480 | /** |
| johnAlexander | 15:932d8b4e52c9 | 481 | * |
| johnAlexander | 15:932d8b4e52c9 | 482 | * @brief One time device initialization |
| johnAlexander | 15:932d8b4e52c9 | 483 | * |
| johnAlexander | 15:932d8b4e52c9 | 484 | * To be called once and only once after device is brought out of reset (Chip enable) and booted see @a VL6180x_WaitDeviceBooted() |
| johnAlexander | 15:932d8b4e52c9 | 485 | * |
| johnAlexander | 15:932d8b4e52c9 | 486 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 487 | * When not used after a fresh device "power up" or reset, it may return @a #CALIBRATION_WARNING |
| johnAlexander | 15:932d8b4e52c9 | 488 | * meaning wrong calibration data may have been fetched from device that can result in ranging offset error\n |
| johnAlexander | 15:932d8b4e52c9 | 489 | * If application cannot execute device reset or need to run VL6180x_InitData multiple time |
| johnAlexander | 15:932d8b4e52c9 | 490 | * then it must ensure proper offset calibration saving and restore on its own |
| johnAlexander | 15:932d8b4e52c9 | 491 | * by using @a VL6180x_GetOffsetCalibrationData() on first power up and then @a VL6180x_SetOffsetCalibrationData() all all subsequent init |
| johnAlexander | 15:932d8b4e52c9 | 492 | * |
| johnAlexander | 15:932d8b4e52c9 | 493 | * @param void |
| johnAlexander | 15:932d8b4e52c9 | 494 | * @return 0 on success, @a #CALIBRATION_WARNING if failed |
| johnAlexander | 15:932d8b4e52c9 | 495 | */ |
| johnAlexander | 15:932d8b4e52c9 | 496 | virtual int init(void *init) |
| johnAlexander | 15:932d8b4e52c9 | 497 | { |
| johnAlexander | 16:98ce55ddbb1a | 498 | return vl53l0x_data_init(_device); |
| johnAlexander | 0:c523920bcc09 | 499 | } |
| johnAlexander | 0:c523920bcc09 | 500 | |
| johnAlexander | 15:932d8b4e52c9 | 501 | /** |
| johnAlexander | 15:932d8b4e52c9 | 502 | * @brief Configure GPIO1 function and set polarity. |
| johnAlexander | 15:932d8b4e52c9 | 503 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 504 | * To be used prior to arm single shot measure or start continuous mode. |
| johnAlexander | 15:932d8b4e52c9 | 505 | * |
| johnAlexander | 15:932d8b4e52c9 | 506 | * The function uses @a VL6180x_SetupGPIOx() for setting gpio 1. |
| johnAlexander | 15:932d8b4e52c9 | 507 | * @warning changing polarity can generate a spurious interrupt on pins. |
| johnAlexander | 15:932d8b4e52c9 | 508 | * It sets an interrupt flags condition that must be cleared to avoid polling hangs. \n |
| johnAlexander | 15:932d8b4e52c9 | 509 | * It is safe to run VL6180x_ClearAllInterrupt() just after. |
| johnAlexander | 15:932d8b4e52c9 | 510 | * |
| johnAlexander | 15:932d8b4e52c9 | 511 | * @param IntFunction The interrupt functionality to use one of :\n |
| johnAlexander | 15:932d8b4e52c9 | 512 | * @a #GPIOx_SELECT_OFF \n |
| johnAlexander | 15:932d8b4e52c9 | 513 | * @a #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT |
| johnAlexander | 15:932d8b4e52c9 | 514 | * @param ActiveHigh The interrupt line polarity see ::IntrPol_e |
| johnAlexander | 15:932d8b4e52c9 | 515 | * use @a #INTR_POL_LOW (falling edge) or @a #INTR_POL_HIGH (rising edge) |
| johnAlexander | 15:932d8b4e52c9 | 516 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 517 | */ |
| johnAlexander | 16:98ce55ddbb1a | 518 | int setup_gpio1(uint8_t InitFunction, int ActiveHigh) |
| johnAlexander | 0:c523920bcc09 | 519 | { |
| johnAlexander | 15:932d8b4e52c9 | 520 | return 1; |
| johnAlexander | 0:c523920bcc09 | 521 | } |
| johnAlexander | 0:c523920bcc09 | 522 | |
| johnAlexander | 15:932d8b4e52c9 | 523 | /** |
| johnAlexander | 15:932d8b4e52c9 | 524 | * @brief Prepare device for operation |
| johnAlexander | 15:932d8b4e52c9 | 525 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 526 | * Does static initialization and reprogram common default settings \n |
| johnAlexander | 15:932d8b4e52c9 | 527 | * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n |
| johnAlexander | 15:932d8b4e52c9 | 528 | * After prepare user can : \n |
| johnAlexander | 15:932d8b4e52c9 | 529 | * @li Call other API function to set other settings\n |
| johnAlexander | 15:932d8b4e52c9 | 530 | * @li Configure the interrupt pins, etc... \n |
| johnAlexander | 15:932d8b4e52c9 | 531 | * @li Then start ranging or ALS operations in single shot or continuous mode |
| johnAlexander | 15:932d8b4e52c9 | 532 | * |
| johnAlexander | 15:932d8b4e52c9 | 533 | * @param void |
| johnAlexander | 15:932d8b4e52c9 | 534 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 535 | */ |
| johnAlexander | 16:98ce55ddbb1a | 536 | int prepare() |
| johnAlexander | 0:c523920bcc09 | 537 | { |
| johnAlexander | 16:98ce55ddbb1a | 538 | VL53L0X_Error status = VL53L0X_ERROR_NONE; |
| johnAlexander | 16:98ce55ddbb1a | 539 | uint32_t ref_spad_count; |
| johnAlexander | 16:98ce55ddbb1a | 540 | uint8_t is_aperture_spads; |
| johnAlexander | 16:98ce55ddbb1a | 541 | uint8_t vhv_settings; |
| johnAlexander | 16:98ce55ddbb1a | 542 | uint8_t phase_cal; |
| johnAlexander | 0:c523920bcc09 | 543 | |
| johnAlexander | 16:98ce55ddbb1a | 544 | if(status == VL53L0X_ERROR_NONE) { |
| johnAlexander | 0:c523920bcc09 | 545 | printf ("Call of VL53L0X_StaticInit\n"); |
| johnAlexander | 16:98ce55ddbb1a | 546 | status = vl53l0x_static_init(_device); // Device Initialization |
| johnAlexander | 0:c523920bcc09 | 547 | } |
| johnAlexander | 15:932d8b4e52c9 | 548 | |
| johnAlexander | 16:98ce55ddbb1a | 549 | if(status == VL53L0X_ERROR_NONE) { |
| johnAlexander | 0:c523920bcc09 | 550 | printf ("Call of VL53L0X_PerformRefCalibration\n"); |
| johnAlexander | 16:98ce55ddbb1a | 551 | status = vl53l0x_perform_ref_calibration(_device, |
| johnAlexander | 16:98ce55ddbb1a | 552 | &vhv_settings, &phase_cal); // Device Initialization |
| johnAlexander | 0:c523920bcc09 | 553 | } |
| johnAlexander | 0:c523920bcc09 | 554 | |
| johnAlexander | 16:98ce55ddbb1a | 555 | if(status == VL53L0X_ERROR_NONE) { |
| johnAlexander | 0:c523920bcc09 | 556 | printf ("Call of VL53L0X_PerformRefSpadManagement\n"); |
| johnAlexander | 16:98ce55ddbb1a | 557 | status = vl53l0x_perform_ref_spad_management(_device, |
| johnAlexander | 16:98ce55ddbb1a | 558 | &ref_spad_count, &is_aperture_spads); // Device Initialization |
| johnAlexander | 0:c523920bcc09 | 559 | // printf ("refSpadCount = %d, isApertureSpads = %d\n", refSpadCount, isApertureSpads); |
| johnAlexander | 0:c523920bcc09 | 560 | } |
| johnAlexander | 15:932d8b4e52c9 | 561 | |
| johnAlexander | 16:98ce55ddbb1a | 562 | return status; |
| johnAlexander | 0:c523920bcc09 | 563 | } |
| johnAlexander | 0:c523920bcc09 | 564 | |
| johnAlexander | 15:932d8b4e52c9 | 565 | /** |
| johnAlexander | 15:932d8b4e52c9 | 566 | * @brief Start continuous ranging mode |
| johnAlexander | 15:932d8b4e52c9 | 567 | * |
| johnAlexander | 15:932d8b4e52c9 | 568 | * @details End user should ensure device is in idle state and not already running |
| johnAlexander | 15:932d8b4e52c9 | 569 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 570 | */ |
| johnAlexander | 16:98ce55ddbb1a | 571 | int range_start_continuous_mode() |
| johnAlexander | 0:c523920bcc09 | 572 | { |
| johnAlexander | 15:932d8b4e52c9 | 573 | int status; |
| johnAlexander | 16:98ce55ddbb1a | 574 | status = vl53l0x_set_device_mode(_device, VL53L0X_DEVICEMODE_CONTINUOUS_RANGING); |
| johnAlexander | 13:615f7e38568c | 575 | |
| johnAlexander | 15:932d8b4e52c9 | 576 | if(status == VL53L0X_ERROR_NONE) { |
| johnAlexander | 15:932d8b4e52c9 | 577 | printf ("Call of VL53L0X_StartMeasurement\n"); |
| johnAlexander | 16:98ce55ddbb1a | 578 | status = vl53l0x_start_measurement(_device); |
| johnAlexander | 13:615f7e38568c | 579 | } |
| johnAlexander | 13:615f7e38568c | 580 | |
| johnAlexander | 15:932d8b4e52c9 | 581 | return status; |
| johnAlexander | 0:c523920bcc09 | 582 | } |
| johnAlexander | 0:c523920bcc09 | 583 | |
| johnAlexander | 15:932d8b4e52c9 | 584 | /** |
| johnAlexander | 15:932d8b4e52c9 | 585 | * @brief Start single shot ranging measure |
| johnAlexander | 15:932d8b4e52c9 | 586 | * |
| johnAlexander | 15:932d8b4e52c9 | 587 | * @details End user should ensure device is in idle state and not already running |
| johnAlexander | 15:932d8b4e52c9 | 588 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 589 | */ |
| johnAlexander | 16:98ce55ddbb1a | 590 | int range_start_single_shot() |
| johnAlexander | 0:c523920bcc09 | 591 | { |
| johnAlexander | 15:932d8b4e52c9 | 592 | return 1; |
| johnAlexander | 0:c523920bcc09 | 593 | } |
| johnAlexander | 0:c523920bcc09 | 594 | |
| johnAlexander | 15:932d8b4e52c9 | 595 | /** |
| johnAlexander | 15:932d8b4e52c9 | 596 | * @brief Set maximum convergence time |
| johnAlexander | 15:932d8b4e52c9 | 597 | * |
| johnAlexander | 15:932d8b4e52c9 | 598 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 599 | * Setting a low convergence time can impact maximal detectable distance. |
| johnAlexander | 15:932d8b4e52c9 | 600 | * Refer to VL6180x Datasheet Table 7 : Typical range convergence time. |
| johnAlexander | 15:932d8b4e52c9 | 601 | * A typical value for up to x3 scaling is 50 ms |
| johnAlexander | 15:932d8b4e52c9 | 602 | * |
| johnAlexander | 16:98ce55ddbb1a | 603 | * @param max_con_time_msec |
| johnAlexander | 15:932d8b4e52c9 | 604 | * @return 0 on success. <0 on error. >0 for calibration warning status |
| johnAlexander | 15:932d8b4e52c9 | 605 | */ |
| johnAlexander | 16:98ce55ddbb1a | 606 | int range_set_max_convergence_time(uint8_t max_con_time_msec) |
| johnAlexander | 0:c523920bcc09 | 607 | { |
| johnAlexander | 15:932d8b4e52c9 | 608 | return 1; |
| johnAlexander | 0:c523920bcc09 | 609 | } |
| johnAlexander | 0:c523920bcc09 | 610 | |
| johnAlexander | 15:932d8b4e52c9 | 611 | /** |
| johnAlexander | 15:932d8b4e52c9 | 612 | * @brief Single shot Range measurement in polling mode. |
| johnAlexander | 15:932d8b4e52c9 | 613 | * |
| johnAlexander | 15:932d8b4e52c9 | 614 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 615 | * Kick off a new single shot range then wait for ready to retrieve it by polling interrupt status \n |
| johnAlexander | 15:932d8b4e52c9 | 616 | * Ranging must be prepared by a first call to @a VL6180x_Prepare() and it is safer to clear very first poll call \n |
| johnAlexander | 15:932d8b4e52c9 | 617 | * This function reference VL6180x_PollDelay(dev) porting macro/call on each polling loop, |
| johnAlexander | 15:932d8b4e52c9 | 618 | * but PollDelay(dev) may never be called if measure in ready on first poll loop \n |
| johnAlexander | 15:932d8b4e52c9 | 619 | * Should not be use in continuous mode operation as it will stop it and cause stop/start misbehaviour \n |
| johnAlexander | 15:932d8b4e52c9 | 620 | * \n This function clears Range Interrupt status , but not error one. For that uses @a VL6180x_ClearErrorInterrupt() \n |
| johnAlexander | 15:932d8b4e52c9 | 621 | * This range error is not related VL6180x_RangeData_t::errorStatus that refer measure status \n |
| johnAlexander | 15:932d8b4e52c9 | 622 | * |
| johnAlexander | 16:98ce55ddbb1a | 623 | * @param p_range_data Will be populated with the result ranging data @a VL6180x_RangeData_t |
| johnAlexander | 15:932d8b4e52c9 | 624 | * @return 0 on success , @a #RANGE_ERROR if device reports an error case in it status (not cleared) use |
| johnAlexander | 15:932d8b4e52c9 | 625 | * |
| johnAlexander | 15:932d8b4e52c9 | 626 | * \sa ::VL6180x_RangeData_t |
| johnAlexander | 15:932d8b4e52c9 | 627 | */ |
| johnAlexander | 16:98ce55ddbb1a | 628 | int range_poll_measurement(VL53L0X_RangingMeasurementData_t *p_range_data) |
| johnAlexander | 0:c523920bcc09 | 629 | { |
| johnAlexander | 15:932d8b4e52c9 | 630 | return 1; |
| johnAlexander | 0:c523920bcc09 | 631 | } |
| johnAlexander | 0:c523920bcc09 | 632 | |
| johnAlexander | 15:932d8b4e52c9 | 633 | /** |
| johnAlexander | 15:932d8b4e52c9 | 634 | * @brief Check for measure readiness and get it if ready |
| johnAlexander | 15:932d8b4e52c9 | 635 | * |
| johnAlexander | 15:932d8b4e52c9 | 636 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 637 | * Using this function is an alternative to @a VL6180x_RangePollMeasurement() to avoid polling operation. This is suitable for applications |
| johnAlexander | 15:932d8b4e52c9 | 638 | * 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 | 15:932d8b4e52c9 | 639 | * operation is triggered by a call to @a VL6180x_RangeStartSingleShot(). Then, host CPU regularly calls @a VL6180x_RangeGetMeasurementIfReady() to |
| johnAlexander | 15:932d8b4e52c9 | 640 | * get a distance measure if ready. In case the distance is not ready, host may get it at the next call.\n |
| johnAlexander | 15:932d8b4e52c9 | 641 | * |
| johnAlexander | 15:932d8b4e52c9 | 642 | * @warning |
| johnAlexander | 15:932d8b4e52c9 | 643 | * This function does not re-start a new measurement : this is up to the host CPU to do it.\n |
| johnAlexander | 15:932d8b4e52c9 | 644 | * This function clears Range Interrupt for measure ready , but not error interrupts. For that, uses @a VL6180x_ClearErrorInterrupt() \n |
| johnAlexander | 15:932d8b4e52c9 | 645 | * |
| johnAlexander | 16:98ce55ddbb1a | 646 | * @param p_range_data Will be populated with the result ranging data if available |
| johnAlexander | 15:932d8b4e52c9 | 647 | * @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 | 15:932d8b4e52c9 | 648 | */ |
| johnAlexander | 16:98ce55ddbb1a | 649 | int range_get_measurement_if_ready(VL53L0X_RangingMeasurementData_t *p_range_data) |
| johnAlexander | 0:c523920bcc09 | 650 | { |
| johnAlexander | 15:932d8b4e52c9 | 651 | return 1; |
| johnAlexander | 0:c523920bcc09 | 652 | } |
| johnAlexander | 0:c523920bcc09 | 653 | |
| johnAlexander | 15:932d8b4e52c9 | 654 | /** |
| johnAlexander | 15:932d8b4e52c9 | 655 | * @brief Retrieve range measurements set from device |
| johnAlexander | 15:932d8b4e52c9 | 656 | * |
| johnAlexander | 15:932d8b4e52c9 | 657 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 658 | * The measurement is made of range_mm status and error code @a VL6180x_RangeData_t \n |
| johnAlexander | 15:932d8b4e52c9 | 659 | * Based on configuration selected extra measures are included. |
| johnAlexander | 15:932d8b4e52c9 | 660 | * |
| johnAlexander | 15:932d8b4e52c9 | 661 | * @warning should not be used in continuous if wrap around filter is active \n |
| johnAlexander | 15:932d8b4e52c9 | 662 | * Does not perform any wait nor check for result availability or validity. |
| johnAlexander | 15:932d8b4e52c9 | 663 | *\sa VL6180x_RangeGetResult for "range only" measurement |
| johnAlexander | 15:932d8b4e52c9 | 664 | * |
| johnAlexander | 16:98ce55ddbb1a | 665 | * @param p_range_data Pointer to the data structure to fill up |
| johnAlexander | 15:932d8b4e52c9 | 666 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 667 | */ |
| johnAlexander | 16:98ce55ddbb1a | 668 | int range_get_measurement(VL53L0X_RangingMeasurementData_t *p_range_data) |
| johnAlexander | 0:c523920bcc09 | 669 | { |
| johnAlexander | 15:932d8b4e52c9 | 670 | return 1; |
| johnAlexander | 0:c523920bcc09 | 671 | } |
| johnAlexander | 0:c523920bcc09 | 672 | |
| johnAlexander | 15:932d8b4e52c9 | 673 | /** |
| johnAlexander | 15:932d8b4e52c9 | 674 | * @brief Get ranging result and only that |
| johnAlexander | 15:932d8b4e52c9 | 675 | * |
| johnAlexander | 15:932d8b4e52c9 | 676 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 677 | * Unlike @a VL6180x_RangeGetMeasurement() this function only retrieves the range in millimeter \n |
| johnAlexander | 15:932d8b4e52c9 | 678 | * It does any required up-scale translation\n |
| johnAlexander | 15:932d8b4e52c9 | 679 | * It can be called after success status polling or in interrupt mode \n |
| johnAlexander | 15:932d8b4e52c9 | 680 | * @warning these function is not doing wrap around filtering \n |
| johnAlexander | 15:932d8b4e52c9 | 681 | * This function doesn't perform any data ready check! |
| johnAlexander | 15:932d8b4e52c9 | 682 | * |
| johnAlexander | 16:98ce55ddbb1a | 683 | * @param p_data Pointer to range distance |
| johnAlexander | 15:932d8b4e52c9 | 684 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 685 | */ |
| johnAlexander | 16:98ce55ddbb1a | 686 | virtual int get_distance(uint32_t *p_data) |
| johnAlexander | 0:c523920bcc09 | 687 | { |
| johnAlexander | 10:faf8d62ce6d1 | 688 | int status=0; |
| johnAlexander | 16:98ce55ddbb1a | 689 | VL53L0X_RangingMeasurementData_t p_ranging_measurement_data; |
| johnAlexander | 10:faf8d62ce6d1 | 690 | |
| johnAlexander | 16:98ce55ddbb1a | 691 | status=start_measurement(range_single_shot_polling, NULL); |
| johnAlexander | 10:faf8d62ce6d1 | 692 | if (!status) { |
| johnAlexander | 16:98ce55ddbb1a | 693 | status=get_measurement(range_single_shot_polling, &p_ranging_measurement_data); |
| johnAlexander | 10:faf8d62ce6d1 | 694 | } |
| johnAlexander | 16:98ce55ddbb1a | 695 | if (p_ranging_measurement_data.RangeStatus == 0) { |
| johnAlexander | 15:932d8b4e52c9 | 696 | // we have a valid range. |
| johnAlexander | 16:98ce55ddbb1a | 697 | *p_data = p_ranging_measurement_data.RangeMilliMeter; |
| johnAlexander | 15:932d8b4e52c9 | 698 | } else { |
| johnAlexander | 16:98ce55ddbb1a | 699 | *p_data = 0; |
| johnAlexander | 10:faf8d62ce6d1 | 700 | status = VL53L0X_ERROR_RANGE_ERROR; |
| johnAlexander | 10:faf8d62ce6d1 | 701 | } |
| johnAlexander | 16:98ce55ddbb1a | 702 | stop_measurement(range_single_shot_polling); |
| johnAlexander | 10:faf8d62ce6d1 | 703 | return status; |
| johnAlexander | 0:c523920bcc09 | 704 | } |
| johnAlexander | 16:98ce55ddbb1a | 705 | |
| johnAlexander | 15:932d8b4e52c9 | 706 | /** |
| johnAlexander | 15:932d8b4e52c9 | 707 | * @brief Configure ranging interrupt reported to application |
| johnAlexander | 15:932d8b4e52c9 | 708 | * |
| johnAlexander | 16:98ce55ddbb1a | 709 | * @param config_gpio_int Select ranging report\n select one (and only one) of:\n |
| johnAlexander | 15:932d8b4e52c9 | 710 | * @a #CONFIG_GPIO_INTERRUPT_DISABLED \n |
| johnAlexander | 15:932d8b4e52c9 | 711 | * @a #CONFIG_GPIO_INTERRUPT_LEVEL_LOW \n |
| johnAlexander | 15:932d8b4e52c9 | 712 | * @a #CONFIG_GPIO_INTERRUPT_LEVEL_HIGH \n |
| johnAlexander | 15:932d8b4e52c9 | 713 | * @a #CONFIG_GPIO_INTERRUPT_OUT_OF_WINDOW \n |
| johnAlexander | 15:932d8b4e52c9 | 714 | * @a #CONFIG_GPIO_INTERRUPT_NEW_SAMPLE_READY |
| johnAlexander | 15:932d8b4e52c9 | 715 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 716 | */ |
| johnAlexander | 16:98ce55ddbb1a | 717 | int range_config_interrupt(uint8_t config_gpio_int) |
| johnAlexander | 0:c523920bcc09 | 718 | { |
| johnAlexander | 15:932d8b4e52c9 | 719 | int status = VL53L0X_ERROR_NONE; |
| johnAlexander | 15:932d8b4e52c9 | 720 | /* if( ConfigGpioInt<= VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY) |
| johnAlexander | 15:932d8b4e52c9 | 721 | { |
| johnAlexander | 15:932d8b4e52c9 | 722 | status = VL53L0X_UpdateByte(Device, VL53L0X_REG_SYSTEM_INTERRUPT_CONFIG_GPIO, (uint8_t)(~(0x7<<0)), ConfigGpioInt); |
| johnAlexander | 15:932d8b4e52c9 | 723 | } |
| johnAlexander | 15:932d8b4e52c9 | 724 | else |
| johnAlexander | 15:932d8b4e52c9 | 725 | { |
| johnAlexander | 15:932d8b4e52c9 | 726 | status = 1; |
| johnAlexander | 15:932d8b4e52c9 | 727 | } |
| johnAlexander | 15:932d8b4e52c9 | 728 | */ |
| johnAlexander | 15:932d8b4e52c9 | 729 | return status; |
| johnAlexander | 0:c523920bcc09 | 730 | } |
| johnAlexander | 0:c523920bcc09 | 731 | |
| johnAlexander | 15:932d8b4e52c9 | 732 | /** |
| johnAlexander | 15:932d8b4e52c9 | 733 | * @brief Return ranging error interrupt status |
| johnAlexander | 15:932d8b4e52c9 | 734 | * |
| johnAlexander | 15:932d8b4e52c9 | 735 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 736 | * Appropriate Interrupt report must have been selected first by @a VL6180x_RangeConfigInterrupt() or @a VL6180x_Prepare() \n |
| johnAlexander | 15:932d8b4e52c9 | 737 | * |
| johnAlexander | 15:932d8b4e52c9 | 738 | * Can be used in polling loop to wait for a given ranging event or in interrupt to read the trigger \n |
| johnAlexander | 15:932d8b4e52c9 | 739 | * Events triggers are : \n |
| johnAlexander | 15:932d8b4e52c9 | 740 | * @a #RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD \n |
| johnAlexander | 15:932d8b4e52c9 | 741 | * @a #RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD \n |
| johnAlexander | 15:932d8b4e52c9 | 742 | * @a #RES_INT_STAT_GPIO_OUT_OF_WINDOW \n (RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD|RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD) |
| johnAlexander | 15:932d8b4e52c9 | 743 | * @a #RES_INT_STAT_GPIO_NEW_SAMPLE_READY \n |
| johnAlexander | 15:932d8b4e52c9 | 744 | * |
| johnAlexander | 15:932d8b4e52c9 | 745 | * @sa IntrStatus_t |
| johnAlexander | 16:98ce55ddbb1a | 746 | * @param p_status Pointer to status variable to update |
| johnAlexander | 15:932d8b4e52c9 | 747 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 748 | */ |
| johnAlexander | 16:98ce55ddbb1a | 749 | int range_get_interrupt_status(uint8_t *p_status) |
| johnAlexander | 0:c523920bcc09 | 750 | { |
| johnAlexander | 15:932d8b4e52c9 | 751 | return 1; |
| johnAlexander | 0:c523920bcc09 | 752 | } |
| johnAlexander | 0:c523920bcc09 | 753 | |
| johnAlexander | 15:932d8b4e52c9 | 754 | /** |
| johnAlexander | 15:932d8b4e52c9 | 755 | * @brief Low level ranging and ALS register static settings (you should call @a VL6180x_Prepare() function instead) |
| johnAlexander | 15:932d8b4e52c9 | 756 | * |
| johnAlexander | 15:932d8b4e52c9 | 757 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 758 | */ |
| johnAlexander | 16:98ce55ddbb1a | 759 | int static_init() |
| johnAlexander | 0:c523920bcc09 | 760 | { |
| johnAlexander | 15:932d8b4e52c9 | 761 | return 1; |
| johnAlexander | 0:c523920bcc09 | 762 | } |
| johnAlexander | 0:c523920bcc09 | 763 | |
| johnAlexander | 15:932d8b4e52c9 | 764 | /** |
| johnAlexander | 15:932d8b4e52c9 | 765 | * @brief Wait for device to be ready (before a new ranging command can be issued by application) |
| johnAlexander | 16:98ce55ddbb1a | 766 | * @param max_loop Max Number of i2c polling loop see @a #msec_2_i2cloop |
| johnAlexander | 15:932d8b4e52c9 | 767 | * @return 0 on success. <0 when fail \n |
| johnAlexander | 15:932d8b4e52c9 | 768 | * @ref VL6180x_ErrCode_t::TIME_OUT for time out \n |
| johnAlexander | 15:932d8b4e52c9 | 769 | * @ref VL6180x_ErrCode_t::INVALID_PARAMS if MaxLop<1 |
| johnAlexander | 15:932d8b4e52c9 | 770 | */ |
| johnAlexander | 16:98ce55ddbb1a | 771 | int range_wait_device_deady(int max_loop) |
| johnAlexander | 0:c523920bcc09 | 772 | { |
| johnAlexander | 15:932d8b4e52c9 | 773 | return 1; |
| johnAlexander | 0:c523920bcc09 | 774 | } |
| johnAlexander | 0:c523920bcc09 | 775 | |
| johnAlexander | 15:932d8b4e52c9 | 776 | /** |
| johnAlexander | 15:932d8b4e52c9 | 777 | * @brief Program Inter measurement period (used only in continuous mode) |
| johnAlexander | 15:932d8b4e52c9 | 778 | * |
| johnAlexander | 15:932d8b4e52c9 | 779 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 780 | * When trying to set too long time, it returns #INVALID_PARAMS |
| johnAlexander | 15:932d8b4e52c9 | 781 | * |
| johnAlexander | 16:98ce55ddbb1a | 782 | * @param inter_meas_time_msec Requires inter-measurement time in msec |
| johnAlexander | 15:932d8b4e52c9 | 783 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 784 | */ |
| johnAlexander | 16:98ce55ddbb1a | 785 | int range_set_inter_meas_period(uint32_t inter_meas_time_msec) |
| johnAlexander | 0:c523920bcc09 | 786 | { |
| johnAlexander | 15:932d8b4e52c9 | 787 | return 1; |
| johnAlexander | 0:c523920bcc09 | 788 | } |
| johnAlexander | 0:c523920bcc09 | 789 | |
| johnAlexander | 15:932d8b4e52c9 | 790 | /** |
| johnAlexander | 15:932d8b4e52c9 | 791 | * @brief Set device ranging scaling factor |
| johnAlexander | 15:932d8b4e52c9 | 792 | * |
| johnAlexander | 15:932d8b4e52c9 | 793 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 794 | * 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 | 15:932d8b4e52c9 | 795 | * Changing the scaling factor when device is not in f/w standby state (free running) is not safe. |
| johnAlexander | 15:932d8b4e52c9 | 796 | * It can be source of spurious interrupt, wrongly scaled range etc ... |
| johnAlexander | 15:932d8b4e52c9 | 797 | * @warning __This function doesns't update high/low threshold and other programmed settings linked to scaling factor__. |
| johnAlexander | 15:932d8b4e52c9 | 798 | * To ensure proper operation, threshold and scaling changes should be done following this procedure: \n |
| johnAlexander | 15:932d8b4e52c9 | 799 | * @li Set Group hold : @a VL6180x_SetGroupParamHold() \n |
| johnAlexander | 15:932d8b4e52c9 | 800 | * @li Get Threshold @a VL6180x_RangeGetThresholds() \n |
| johnAlexander | 15:932d8b4e52c9 | 801 | * @li Change scaling : @a VL6180x_UpscaleSetScaling() \n |
| johnAlexander | 15:932d8b4e52c9 | 802 | * @li Set Threshold : @a VL6180x_RangeSetThresholds() \n |
| johnAlexander | 15:932d8b4e52c9 | 803 | * @li Unset Group Hold : @a VL6180x_SetGroupParamHold() |
| johnAlexander | 15:932d8b4e52c9 | 804 | * |
| johnAlexander | 15:932d8b4e52c9 | 805 | * @param scaling Scaling factor to apply (1,2 or 3) |
| johnAlexander | 15:932d8b4e52c9 | 806 | * @return 0 on success when up-scale support is not configured it fail for any |
| johnAlexander | 15:932d8b4e52c9 | 807 | * scaling than the one statically configured. |
| johnAlexander | 15:932d8b4e52c9 | 808 | */ |
| johnAlexander | 16:98ce55ddbb1a | 809 | int upscale_set_scaling(uint8_t scaling) |
| johnAlexander | 0:c523920bcc09 | 810 | { |
| johnAlexander | 15:932d8b4e52c9 | 811 | return 1; |
| johnAlexander | 0:c523920bcc09 | 812 | } |
| johnAlexander | 0:c523920bcc09 | 813 | |
| johnAlexander | 15:932d8b4e52c9 | 814 | /** |
| johnAlexander | 15:932d8b4e52c9 | 815 | * @brief Get current ranging scaling factor |
| johnAlexander | 15:932d8b4e52c9 | 816 | * |
| johnAlexander | 15:932d8b4e52c9 | 817 | * @return The current scaling factor |
| johnAlexander | 15:932d8b4e52c9 | 818 | */ |
| johnAlexander | 16:98ce55ddbb1a | 819 | int upscale_get_scaling() |
| johnAlexander | 0:c523920bcc09 | 820 | { |
| johnAlexander | 15:932d8b4e52c9 | 821 | return 1; |
| johnAlexander | 0:c523920bcc09 | 822 | } |
| johnAlexander | 0:c523920bcc09 | 823 | |
| johnAlexander | 15:932d8b4e52c9 | 824 | /** |
| johnAlexander | 15:932d8b4e52c9 | 825 | * @brief Get the maximal distance for actual scaling |
| johnAlexander | 15:932d8b4e52c9 | 826 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 827 | * Do not use prior to @a VL6180x_Prepare() or at least @a VL6180x_InitData() |
| johnAlexander | 15:932d8b4e52c9 | 828 | * |
| johnAlexander | 15:932d8b4e52c9 | 829 | * Any range value more than the value returned by this function is to be considered as "no target detected" |
| johnAlexander | 15:932d8b4e52c9 | 830 | * or "no target in detectable range" \n |
| johnAlexander | 15:932d8b4e52c9 | 831 | * @warning The maximal distance depends on the scaling |
| johnAlexander | 15:932d8b4e52c9 | 832 | * |
| johnAlexander | 15:932d8b4e52c9 | 833 | * @return The maximal range limit for actual mode and scaling |
| johnAlexander | 15:932d8b4e52c9 | 834 | */ |
| johnAlexander | 16:98ce55ddbb1a | 835 | uint16_t get_upper_limit() |
| johnAlexander | 0:c523920bcc09 | 836 | { |
| johnAlexander | 15:932d8b4e52c9 | 837 | return 1; |
| johnAlexander | 0:c523920bcc09 | 838 | } |
| johnAlexander | 0:c523920bcc09 | 839 | |
| johnAlexander | 15:932d8b4e52c9 | 840 | /** |
| johnAlexander | 15:932d8b4e52c9 | 841 | * @brief Apply low and high ranging thresholds that are considered only in continuous mode |
| johnAlexander | 15:932d8b4e52c9 | 842 | * |
| johnAlexander | 15:932d8b4e52c9 | 843 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 844 | * This function programs low and high ranging thresholds that are considered in continuous mode : |
| johnAlexander | 15:932d8b4e52c9 | 845 | * interrupt will be raised only when an object is detected at a distance inside this [low:high] range. |
| johnAlexander | 15:932d8b4e52c9 | 846 | * The function takes care of applying current scaling factor if any.\n |
| johnAlexander | 15:932d8b4e52c9 | 847 | * To be safe, in continuous operation, thresholds must be changed under "group parameter hold" cover. |
| johnAlexander | 15:932d8b4e52c9 | 848 | * Group hold can be activated/deactivated directly in the function or externally (then set 0) |
| johnAlexander | 15:932d8b4e52c9 | 849 | * using /a VL6180x_SetGroupParamHold() function. |
| johnAlexander | 15:932d8b4e52c9 | 850 | * |
| johnAlexander | 15:932d8b4e52c9 | 851 | * @param low Low threshold in mm |
| johnAlexander | 15:932d8b4e52c9 | 852 | * @param high High threshold in mm |
| johnAlexander | 16:98ce55ddbb1a | 853 | * @param safe_hold Use of group parameters hold to surround threshold programming. |
| johnAlexander | 15:932d8b4e52c9 | 854 | * @return 0 On success |
| johnAlexander | 15:932d8b4e52c9 | 855 | */ |
| johnAlexander | 16:98ce55ddbb1a | 856 | int range_set_thresholds(uint16_t low, uint16_t high, int safe_hold) |
| johnAlexander | 0:c523920bcc09 | 857 | { |
| johnAlexander | 15:932d8b4e52c9 | 858 | return 1; |
| johnAlexander | 0:c523920bcc09 | 859 | } |
| johnAlexander | 0:c523920bcc09 | 860 | |
| johnAlexander | 15:932d8b4e52c9 | 861 | /** |
| johnAlexander | 15:932d8b4e52c9 | 862 | * @brief Get scaled high and low threshold from device |
| johnAlexander | 15:932d8b4e52c9 | 863 | * |
| johnAlexander | 15:932d8b4e52c9 | 864 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 865 | * Due to scaling factor, the returned value may be different from what has been programmed first (precision lost). |
| johnAlexander | 15:932d8b4e52c9 | 866 | * For instance VL6180x_RangeSetThresholds(dev,11,22) with scale 3 |
| johnAlexander | 15:932d8b4e52c9 | 867 | * will read back 9 ((11/3)x3) and 21 ((22/3)x3). |
| johnAlexander | 15:932d8b4e52c9 | 868 | * |
| johnAlexander | 15:932d8b4e52c9 | 869 | * @param low scaled low Threshold ptr can be NULL if not needed |
| johnAlexander | 15:932d8b4e52c9 | 870 | * @param high scaled High Threshold ptr can be NULL if not needed |
| johnAlexander | 15:932d8b4e52c9 | 871 | * @return 0 on success, return value is undefined if both low and high are NULL |
| johnAlexander | 15:932d8b4e52c9 | 872 | * @warning return value is undefined if both low and high are NULL |
| johnAlexander | 15:932d8b4e52c9 | 873 | */ |
| johnAlexander | 16:98ce55ddbb1a | 874 | int range_get_thresholds(uint16_t *low, uint16_t *high) |
| johnAlexander | 0:c523920bcc09 | 875 | { |
| johnAlexander | 15:932d8b4e52c9 | 876 | return 1; |
| johnAlexander | 0:c523920bcc09 | 877 | } |
| johnAlexander | 0:c523920bcc09 | 878 | |
| johnAlexander | 15:932d8b4e52c9 | 879 | /** |
| johnAlexander | 15:932d8b4e52c9 | 880 | * @brief Set ranging raw thresholds (scaling not considered so not recommended to use it) |
| johnAlexander | 15:932d8b4e52c9 | 881 | * |
| johnAlexander | 15:932d8b4e52c9 | 882 | * @param low raw low threshold set to raw register |
| johnAlexander | 15:932d8b4e52c9 | 883 | * @param high raw high threshold set to raw register |
| johnAlexander | 15:932d8b4e52c9 | 884 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 885 | */ |
| johnAlexander | 16:98ce55ddbb1a | 886 | int range_set_raw_thresholds(uint8_t low, uint8_t high) |
| johnAlexander | 0:c523920bcc09 | 887 | { |
| johnAlexander | 15:932d8b4e52c9 | 888 | return 1; |
| johnAlexander | 0:c523920bcc09 | 889 | } |
| johnAlexander | 0:c523920bcc09 | 890 | |
| johnAlexander | 15:932d8b4e52c9 | 891 | /** |
| johnAlexander | 15:932d8b4e52c9 | 892 | * @brief Set Early Convergence Estimate ratio |
| johnAlexander | 15:932d8b4e52c9 | 893 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 894 | * For more information on ECE check datasheet |
| johnAlexander | 15:932d8b4e52c9 | 895 | * @warning May return a calibration warning in some use cases |
| johnAlexander | 15:932d8b4e52c9 | 896 | * |
| johnAlexander | 16:98ce55ddbb1a | 897 | * @param factor_m ECE factor M in M/D |
| johnAlexander | 16:98ce55ddbb1a | 898 | * @param factor_d ECE factor D in M/D |
| johnAlexander | 15:932d8b4e52c9 | 899 | * @return 0 on success. <0 on error. >0 on warning |
| johnAlexander | 15:932d8b4e52c9 | 900 | */ |
| johnAlexander | 16:98ce55ddbb1a | 901 | int range_set_ece_factor(uint16_t factor_m, uint16_t factor_d) |
| johnAlexander | 0:c523920bcc09 | 902 | { |
| johnAlexander | 15:932d8b4e52c9 | 903 | return 1; |
| johnAlexander | 0:c523920bcc09 | 904 | } |
| johnAlexander | 0:c523920bcc09 | 905 | |
| johnAlexander | 15:932d8b4e52c9 | 906 | /** |
| johnAlexander | 15:932d8b4e52c9 | 907 | * @brief Set Early Convergence Estimate state (See #SYSRANGE_RANGE_CHECK_ENABLES register) |
| johnAlexander | 15:932d8b4e52c9 | 908 | * @param enable State to be set 0=disabled, otherwise enabled |
| johnAlexander | 15:932d8b4e52c9 | 909 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 910 | */ |
| johnAlexander | 16:98ce55ddbb1a | 911 | int range_set_ece_state(int enable) |
| johnAlexander | 0:c523920bcc09 | 912 | { |
| johnAlexander | 15:932d8b4e52c9 | 913 | return 1; |
| johnAlexander | 0:c523920bcc09 | 914 | } |
| johnAlexander | 0:c523920bcc09 | 915 | |
| johnAlexander | 15:932d8b4e52c9 | 916 | /** |
| johnAlexander | 15:932d8b4e52c9 | 917 | * @brief Set activation state of the wrap around filter |
| johnAlexander | 15:932d8b4e52c9 | 918 | * @param state New activation state (0=off, otherwise on) |
| johnAlexander | 15:932d8b4e52c9 | 919 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 920 | */ |
| johnAlexander | 16:98ce55ddbb1a | 921 | int filter_set_state(int state) |
| johnAlexander | 0:c523920bcc09 | 922 | { |
| johnAlexander | 15:932d8b4e52c9 | 923 | return 1; |
| johnAlexander | 0:c523920bcc09 | 924 | } |
| johnAlexander | 0:c523920bcc09 | 925 | |
| johnAlexander | 15:932d8b4e52c9 | 926 | /** |
| johnAlexander | 15:932d8b4e52c9 | 927 | * Get activation state of the wrap around filter |
| johnAlexander | 15:932d8b4e52c9 | 928 | * @return Filter enabled or not, when filter is not supported it always returns 0S |
| johnAlexander | 15:932d8b4e52c9 | 929 | */ |
| johnAlexander | 16:98ce55ddbb1a | 930 | int filter_get_state() |
| johnAlexander | 0:c523920bcc09 | 931 | { |
| johnAlexander | 15:932d8b4e52c9 | 932 | return 1; |
| johnAlexander | 0:c523920bcc09 | 933 | } |
| johnAlexander | 0:c523920bcc09 | 934 | |
| johnAlexander | 15:932d8b4e52c9 | 935 | /** |
| johnAlexander | 15:932d8b4e52c9 | 936 | * @brief Set activation state of DMax computation |
| johnAlexander | 15:932d8b4e52c9 | 937 | * @param state New activation state (0=off, otherwise on) |
| johnAlexander | 15:932d8b4e52c9 | 938 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 939 | */ |
| johnAlexander | 16:98ce55ddbb1a | 940 | int dmax_set_state(int state) |
| johnAlexander | 0:c523920bcc09 | 941 | { |
| johnAlexander | 15:932d8b4e52c9 | 942 | return 1; |
| johnAlexander | 0:c523920bcc09 | 943 | } |
| johnAlexander | 0:c523920bcc09 | 944 | |
| johnAlexander | 15:932d8b4e52c9 | 945 | /** |
| johnAlexander | 15:932d8b4e52c9 | 946 | * Get activation state of DMax computation |
| johnAlexander | 15:932d8b4e52c9 | 947 | * @return Filter enabled or not, when filter is not supported it always returns 0S |
| johnAlexander | 15:932d8b4e52c9 | 948 | */ |
| johnAlexander | 16:98ce55ddbb1a | 949 | int dmax_get_state() |
| johnAlexander | 0:c523920bcc09 | 950 | { |
| johnAlexander | 15:932d8b4e52c9 | 951 | return 1; |
| johnAlexander | 0:c523920bcc09 | 952 | } |
| johnAlexander | 0:c523920bcc09 | 953 | |
| johnAlexander | 15:932d8b4e52c9 | 954 | /** |
| johnAlexander | 15:932d8b4e52c9 | 955 | * @brief Set ranging mode and start/stop measure (use high level functions instead : @a VL6180x_RangeStartSingleShot() or @a VL6180x_RangeStartContinuousMode()) |
| johnAlexander | 15:932d8b4e52c9 | 956 | * |
| johnAlexander | 15:932d8b4e52c9 | 957 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 958 | * When used outside scope of known polling single shot stopped state, \n |
| johnAlexander | 15:932d8b4e52c9 | 959 | * user must ensure the device state is "idle" before to issue a new command. |
| johnAlexander | 15:932d8b4e52c9 | 960 | * |
| johnAlexander | 15:932d8b4e52c9 | 961 | * @param mode A combination of working mode (#MODE_SINGLESHOT or #MODE_CONTINUOUS) and start/stop condition (#MODE_START_STOP) \n |
| johnAlexander | 15:932d8b4e52c9 | 962 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 963 | */ |
| johnAlexander | 16:98ce55ddbb1a | 964 | int range_set_system_mode(uint8_t mode) |
| johnAlexander | 15:932d8b4e52c9 | 965 | { |
| johnAlexander | 15:932d8b4e52c9 | 966 | int status; |
| johnAlexander | 15:932d8b4e52c9 | 967 | /* FIXME we are not checking device is ready via @a VL6180X_RangeWaitDeviceReady |
| johnAlexander | 15:932d8b4e52c9 | 968 | * so if called back to back real fast we are not checking |
| johnAlexander | 15:932d8b4e52c9 | 969 | * if previous mode "set" got absorbed => bit 0 must be 0 so that it work |
| johnAlexander | 15:932d8b4e52c9 | 970 | */ |
| johnAlexander | 15:932d8b4e52c9 | 971 | if( mode <= 3) { |
| johnAlexander | 16:98ce55ddbb1a | 972 | status=vl53l0x_write_byte(_device, VL53L0X_REG_SYSRANGE_START, mode); |
| johnAlexander | 15:932d8b4e52c9 | 973 | if( status ) { |
| johnAlexander | 15:932d8b4e52c9 | 974 | VL53L0X_ErrLog("SYSRANGE_START wr fail"); |
| johnAlexander | 15:932d8b4e52c9 | 975 | } |
| johnAlexander | 15:932d8b4e52c9 | 976 | } else { |
| johnAlexander | 15:932d8b4e52c9 | 977 | status = 1; |
| johnAlexander | 15:932d8b4e52c9 | 978 | } |
| johnAlexander | 15:932d8b4e52c9 | 979 | return status; |
| johnAlexander | 0:c523920bcc09 | 980 | } |
| johnAlexander | 0:c523920bcc09 | 981 | |
| johnAlexander | 15:932d8b4e52c9 | 982 | /** @} */ |
| johnAlexander | 0:c523920bcc09 | 983 | |
| johnAlexander | 15:932d8b4e52c9 | 984 | /** @defgroup api_ll_range_calibration Ranging calibration functions |
| johnAlexander | 15:932d8b4e52c9 | 985 | * @brief Ranging calibration functions |
| johnAlexander | 15:932d8b4e52c9 | 986 | * @ingroup api_ll |
| johnAlexander | 15:932d8b4e52c9 | 987 | * @{ |
| johnAlexander | 15:932d8b4e52c9 | 988 | */ |
| johnAlexander | 15:932d8b4e52c9 | 989 | /** |
| johnAlexander | 15:932d8b4e52c9 | 990 | * @brief Get part to part calibration offset |
| johnAlexander | 15:932d8b4e52c9 | 991 | * |
| johnAlexander | 15:932d8b4e52c9 | 992 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 993 | * Should only be used after a successful call to @a VL6180x_InitData to backup device nvm value |
| johnAlexander | 15:932d8b4e52c9 | 994 | * |
| johnAlexander | 15:932d8b4e52c9 | 995 | * @return part to part calibration offset from device |
| johnAlexander | 15:932d8b4e52c9 | 996 | */ |
| johnAlexander | 16:98ce55ddbb1a | 997 | int8_t get_offset_calibration_data() |
| johnAlexander | 0:c523920bcc09 | 998 | { |
| johnAlexander | 15:932d8b4e52c9 | 999 | return 1; |
| johnAlexander | 0:c523920bcc09 | 1000 | } |
| johnAlexander | 0:c523920bcc09 | 1001 | |
| johnAlexander | 15:932d8b4e52c9 | 1002 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1003 | * Set or over-write part to part calibration offset |
| johnAlexander | 15:932d8b4e52c9 | 1004 | * \sa VL6180x_InitData(), VL6180x_GetOffsetCalibrationData() |
| johnAlexander | 15:932d8b4e52c9 | 1005 | * @param offset Offset |
| johnAlexander | 15:932d8b4e52c9 | 1006 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1007 | void set_offset_calibration_data(int8_t offset) |
| johnAlexander | 0:c523920bcc09 | 1008 | { |
| johnAlexander | 15:932d8b4e52c9 | 1009 | return; |
| johnAlexander | 0:c523920bcc09 | 1010 | } |
| johnAlexander | 0:c523920bcc09 | 1011 | |
| johnAlexander | 15:932d8b4e52c9 | 1012 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1013 | * @brief Set Cross talk compensation rate |
| johnAlexander | 15:932d8b4e52c9 | 1014 | * |
| johnAlexander | 15:932d8b4e52c9 | 1015 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 1016 | * It programs register @a #SYSRANGE_CROSSTALK_COMPENSATION_RATE |
| johnAlexander | 15:932d8b4e52c9 | 1017 | * |
| johnAlexander | 16:98ce55ddbb1a | 1018 | * @param rate Compensation rate (9.7 fix point) see datasheet for details |
| johnAlexander | 15:932d8b4e52c9 | 1019 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 1020 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1021 | int set_xtalk_compensation_rate(uint16_t rate) |
| johnAlexander | 0:c523920bcc09 | 1022 | { |
| johnAlexander | 15:932d8b4e52c9 | 1023 | return 1; |
| johnAlexander | 0:c523920bcc09 | 1024 | } |
| johnAlexander | 15:932d8b4e52c9 | 1025 | /** @} */ |
| johnAlexander | 0:c523920bcc09 | 1026 | |
| johnAlexander | 15:932d8b4e52c9 | 1027 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1028 | * @brief Set new device i2c address |
| johnAlexander | 15:932d8b4e52c9 | 1029 | * |
| johnAlexander | 15:932d8b4e52c9 | 1030 | * After completion the device will answer to the new address programmed. |
| johnAlexander | 15:932d8b4e52c9 | 1031 | * |
| johnAlexander | 15:932d8b4e52c9 | 1032 | * @sa AN4478: Using multiple VL6180X's in a single design |
| johnAlexander | 16:98ce55ddbb1a | 1033 | * @param new_addr The new i2c address (7bit) |
| johnAlexander | 15:932d8b4e52c9 | 1034 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 1035 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1036 | int set_device_address(int new_addr) |
| johnAlexander | 0:c523920bcc09 | 1037 | { |
| johnAlexander | 15:932d8b4e52c9 | 1038 | int status; |
| johnAlexander | 15:932d8b4e52c9 | 1039 | |
| johnAlexander | 16:98ce55ddbb1a | 1040 | status=vl53l0x_set_device_address(_device, new_addr); |
| johnAlexander | 15:932d8b4e52c9 | 1041 | if(!status) |
| johnAlexander | 16:98ce55ddbb1a | 1042 | _device->I2cDevAddr=new_addr; |
| johnAlexander | 15:932d8b4e52c9 | 1043 | return status; |
| johnAlexander | 12:f6e2bad00dc7 | 1044 | |
| johnAlexander | 0:c523920bcc09 | 1045 | } |
| johnAlexander | 0:c523920bcc09 | 1046 | |
| johnAlexander | 15:932d8b4e52c9 | 1047 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1048 | * @brief Fully configure gpio 0/1 pin : polarity and functionality |
| johnAlexander | 15:932d8b4e52c9 | 1049 | * |
| johnAlexander | 15:932d8b4e52c9 | 1050 | * @param pin gpio pin 0 or 1 |
| johnAlexander | 16:98ce55ddbb1a | 1051 | * @param int_function Pin functionality : either #GPIOx_SELECT_OFF or #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to #SYSTEM_MODE_GPIO1 register definition) |
| johnAlexander | 16:98ce55ddbb1a | 1052 | * @param active_high Set active high polarity, or active low see @a ::IntrPol_e |
| johnAlexander | 15:932d8b4e52c9 | 1053 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 1054 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1055 | int setup_gpiox(int pin, uint8_t int_function, int active_high) |
| johnAlexander | 0:c523920bcc09 | 1056 | { |
| johnAlexander | 15:932d8b4e52c9 | 1057 | return 1; |
| johnAlexander | 0:c523920bcc09 | 1058 | } |
| johnAlexander | 0:c523920bcc09 | 1059 | |
| johnAlexander | 15:932d8b4e52c9 | 1060 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1061 | * @brief Set interrupt pin polarity for the given GPIO |
| johnAlexander | 15:932d8b4e52c9 | 1062 | * |
| johnAlexander | 15:932d8b4e52c9 | 1063 | * @param pin Pin 0 or 1 |
| johnAlexander | 15:932d8b4e52c9 | 1064 | * @param active_high select active high or low polarity using @ref IntrPol_e |
| johnAlexander | 15:932d8b4e52c9 | 1065 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 1066 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1067 | int set_gpiox_polarity(int pin, int active_high) |
| johnAlexander | 0:c523920bcc09 | 1068 | { |
| johnAlexander | 15:932d8b4e52c9 | 1069 | return 1; |
| johnAlexander | 0:c523920bcc09 | 1070 | } |
| johnAlexander | 0:c523920bcc09 | 1071 | |
| johnAlexander | 15:932d8b4e52c9 | 1072 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1073 | * Select interrupt functionality for the given GPIO |
| johnAlexander | 15:932d8b4e52c9 | 1074 | * |
| johnAlexander | 15:932d8b4e52c9 | 1075 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 1076 | * Functionality refer to @a SYSTEM_MODE_GPIO0 |
| johnAlexander | 15:932d8b4e52c9 | 1077 | * |
| johnAlexander | 15:932d8b4e52c9 | 1078 | * @param pin Pin to configure 0 or 1 (gpio0 or gpio1)\nNote that gpio0 is chip enable at power up ! |
| johnAlexander | 15:932d8b4e52c9 | 1079 | * @param functionality Pin functionality : either #GPIOx_SELECT_OFF or #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to #SYSTEM_MODE_GPIO1 register definition) |
| johnAlexander | 15:932d8b4e52c9 | 1080 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 1081 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1082 | int set_gpiox_functionality(int pin, uint8_t functionality) |
| johnAlexander | 0:c523920bcc09 | 1083 | { |
| johnAlexander | 15:932d8b4e52c9 | 1084 | return 1; |
| johnAlexander | 0:c523920bcc09 | 1085 | } |
| johnAlexander | 0:c523920bcc09 | 1086 | |
| johnAlexander | 15:932d8b4e52c9 | 1087 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1088 | * #brief Disable and turn to Hi-Z gpio output pin |
| johnAlexander | 15:932d8b4e52c9 | 1089 | * |
| johnAlexander | 15:932d8b4e52c9 | 1090 | * @param pin The pin number to disable 0 or 1 |
| johnAlexander | 15:932d8b4e52c9 | 1091 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 1092 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1093 | int disable_gpiox_out(int pin) |
| johnAlexander | 0:c523920bcc09 | 1094 | { |
| johnAlexander | 15:932d8b4e52c9 | 1095 | return 1; |
| johnAlexander | 0:c523920bcc09 | 1096 | } |
| johnAlexander | 0:c523920bcc09 | 1097 | |
| johnAlexander | 15:932d8b4e52c9 | 1098 | /** @} */ |
| johnAlexander | 0:c523920bcc09 | 1099 | |
| johnAlexander | 15:932d8b4e52c9 | 1100 | /** @defgroup api_ll_intr Interrupts management functions |
| johnAlexander | 15:932d8b4e52c9 | 1101 | * @brief Interrupts management functions |
| johnAlexander | 15:932d8b4e52c9 | 1102 | * @ingroup api_ll |
| johnAlexander | 15:932d8b4e52c9 | 1103 | * @{ |
| johnAlexander | 15:932d8b4e52c9 | 1104 | */ |
| johnAlexander | 0:c523920bcc09 | 1105 | |
| johnAlexander | 15:932d8b4e52c9 | 1106 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1107 | * @brief Get all interrupts cause |
| johnAlexander | 15:932d8b4e52c9 | 1108 | * |
| johnAlexander | 15:932d8b4e52c9 | 1109 | * @param status Ptr to interrupt status. You can use @a IntrStatus_t::val |
| johnAlexander | 15:932d8b4e52c9 | 1110 | * @return 0 on success |
| johnAlexander | 15:932d8b4e52c9 | 1111 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1112 | int get_interrupt_status(uint8_t *status) |
| johnAlexander | 0:c523920bcc09 | 1113 | { |
| johnAlexander | 15:932d8b4e52c9 | 1114 | return 1; |
| johnAlexander | 0:c523920bcc09 | 1115 | } |
| johnAlexander | 0:c523920bcc09 | 1116 | |
| johnAlexander | 15:932d8b4e52c9 | 1117 | /** |
| johnAlexander | 15:932d8b4e52c9 | 1118 | * @brief Clear given system interrupt condition |
| johnAlexander | 15:932d8b4e52c9 | 1119 | * |
| johnAlexander | 15:932d8b4e52c9 | 1120 | * @par Function Description |
| johnAlexander | 15:932d8b4e52c9 | 1121 | * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register. |
| johnAlexander | 15:932d8b4e52c9 | 1122 | * @param dev The device |
| johnAlexander | 16:98ce55ddbb1a | 1123 | * @param int_clear Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR. |
| johnAlexander | 15:932d8b4e52c9 | 1124 | * @return 0 On success |
| johnAlexander | 15:932d8b4e52c9 | 1125 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1126 | int clear_interrupt(uint8_t int_clear) |
| johnAlexander | 0:c523920bcc09 | 1127 | { |
| johnAlexander | 16:98ce55ddbb1a | 1128 | return vl53l0x_clear_interrupt_mask(_device, int_clear); |
| johnAlexander | 0:c523920bcc09 | 1129 | } |
| johnAlexander | 0:c523920bcc09 | 1130 | |
| johnAlexander | 0:c523920bcc09 | 1131 | |
| johnAlexander | 15:932d8b4e52c9 | 1132 | private: |
| johnAlexander | 0:c523920bcc09 | 1133 | /* api.h functions */ |
| johnAlexander | 16:98ce55ddbb1a | 1134 | VL53L0X_Error vl53l0x_data_init(VL53L0X_DEV Dev); |
| johnAlexander | 16:98ce55ddbb1a | 1135 | VL53L0X_Error vl53l0x_get_offset_calibration_data_micro_meter(VL53L0X_DEV Dev, int32_t *pOffsetCalibrationDataMicroMeter); |
| johnAlexander | 16:98ce55ddbb1a | 1136 | VL53L0X_Error vl53l0x_set_offset_calibration_data_micro_meter(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1137 | int32_t OffsetCalibrationDataMicroMeter); |
| johnAlexander | 16:98ce55ddbb1a | 1138 | VL53L0X_Error vl53l0x_get_device_parameters(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1139 | VL53L0X_DeviceParameters_t *pDeviceParameters); |
| johnAlexander | 16:98ce55ddbb1a | 1140 | VL53L0X_Error vl53l0x_get_device_mode(VL53L0X_DEV Dev, |
| johnAlexander | 16:98ce55ddbb1a | 1141 | VL53L0X_DeviceModes *pDeviceMode); |
| johnAlexander | 16:98ce55ddbb1a | 1142 | VL53L0X_Error vl53l0x_get_inter_measurement_period_milli_seconds(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1143 | uint32_t *pInterMeasurementPeriodMilliSeconds); |
| johnAlexander | 16:98ce55ddbb1a | 1144 | VL53L0X_Error vl53l0x_get_x_talk_compensation_rate_mega_cps(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1145 | FixPoint1616_t *pXTalkCompensationRateMegaCps); |
| johnAlexander | 16:98ce55ddbb1a | 1146 | VL53L0X_Error vl53l0x_get_limit_check_value(VL53L0X_DEV Dev, uint16_t LimitCheckId, |
| johnAlexander | 15:932d8b4e52c9 | 1147 | FixPoint1616_t *pLimitCheckValue); |
| johnAlexander | 16:98ce55ddbb1a | 1148 | VL53L0X_Error vl53l0x_get_limit_check_enable(VL53L0X_DEV Dev, uint16_t LimitCheckId, |
| johnAlexander | 15:932d8b4e52c9 | 1149 | uint8_t *pLimitCheckEnable); |
| johnAlexander | 16:98ce55ddbb1a | 1150 | VL53L0X_Error vl53l0x_get_wrap_around_check_enable(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1151 | uint8_t *pWrapAroundCheckEnable); |
| johnAlexander | 16:98ce55ddbb1a | 1152 | VL53L0X_Error vl53l0x_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1153 | uint32_t *pMeasurementTimingBudgetMicroSeconds); |
| johnAlexander | 16:98ce55ddbb1a | 1154 | VL53L0X_Error vl53l0x_get_sequence_step_enables(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1155 | VL53L0X_SchedulerSequenceSteps_t *pSchedulerSequenceSteps); |
| johnAlexander | 0:c523920bcc09 | 1156 | VL53L0X_Error sequence_step_enabled(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1157 | VL53L0X_SequenceStepId SequenceStepId, uint8_t SequenceConfig, |
| johnAlexander | 15:932d8b4e52c9 | 1158 | uint8_t *pSequenceStepEnabled); |
| johnAlexander | 16:98ce55ddbb1a | 1159 | VL53L0X_Error vl53l0x_get_vcsel_pulse_period(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1160 | VL53L0X_VcselPeriod VcselPeriodType, uint8_t *pVCSELPulsePeriodPCLK); |
| johnAlexander | 16:98ce55ddbb1a | 1161 | VL53L0X_Error vl53l0x_get_device_info(VL53L0X_DEV Dev, |
| johnAlexander | 16:98ce55ddbb1a | 1162 | VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo); |
| johnAlexander | 16:98ce55ddbb1a | 1163 | VL53L0X_Error vl53l0x_static_init(VL53L0X_DEV Dev); |
| johnAlexander | 16:98ce55ddbb1a | 1164 | VL53L0X_Error vl53l0x_get_measurement_data_ready(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1165 | uint8_t *pMeasurementDataReady); |
| johnAlexander | 16:98ce55ddbb1a | 1166 | VL53L0X_Error vl53l0x_get_interrupt_mask_status(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1167 | uint32_t *pInterruptMaskStatus); |
| johnAlexander | 16:98ce55ddbb1a | 1168 | VL53L0X_Error vl53l0x_clear_interrupt_mask(VL53L0X_DEV Dev, uint32_t InterruptMask); |
| johnAlexander | 16:98ce55ddbb1a | 1169 | VL53L0X_Error vl53l0x_perform_single_ranging_measurement(VL53L0X_DEV Dev, |
| johnAlexander | 15:932d8b4e52c9 | 1170 | VL53L0X_RangingMeasurementData_t *pRangingMeasurementData); |
| johnAlexander | 16:98ce55ddbb1a | 1171 | VL53L0X_Error vl53l0x_set_device_mode(VL53L0X_DEV Dev, VL53L0X_DeviceModes device_mode); |
| johnAlexander | 16:98ce55ddbb1a | 1172 | VL53L0X_Error vl53l0x_perform_single_measurement(VL53L0X_DEV Dev); |
| johnAlexander | 16:98ce55ddbb1a | 1173 | VL53L0X_Error vl53l0x_start_measurement(VL53L0X_DEV Dev); |
| johnAlexander | 16:98ce55ddbb1a | 1174 | VL53L0X_Error vl53l0x_check_and_load_interrupt_settings(VL53L0X_DEV Dev, |
| johnAlexander | 16:98ce55ddbb1a | 1175 | uint8_t start_not_stopflag); |
| johnAlexander | 16:98ce55ddbb1a | 1176 | VL53L0X_Error vl53l0x_set_interrupt_thresholds(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1177 | VL53L0X_DeviceModes device_mode, FixPoint1616_t threshold_low, |
| johnAlexander | 16:98ce55ddbb1a | 1178 | FixPoint1616_t threshold_high); |
| johnAlexander | 16:98ce55ddbb1a | 1179 | VL53L0X_Error vl53l0x_get_interrupt_thresholds(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1180 | VL53L0X_DeviceModes device_mode, FixPoint1616_t *p_threshold_low, |
| johnAlexander | 16:98ce55ddbb1a | 1181 | FixPoint1616_t *p_threshold_high); |
| johnAlexander | 16:98ce55ddbb1a | 1182 | VL53L0X_Error vl53l0x_get_ranging_measurement_data(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1183 | VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data); |
| johnAlexander | 16:98ce55ddbb1a | 1184 | VL53L0X_Error vl53l0x_get_x_talk_compensation_enable(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1185 | uint8_t *p_x_talk_compensation_enable); |
| johnAlexander | 16:98ce55ddbb1a | 1186 | VL53L0X_Error vl53l0x_wait_device_booted(VL53L0X_DEV dev); |
| johnAlexander | 16:98ce55ddbb1a | 1187 | VL53L0X_Error vl53l0x_perform_ref_calibration(VL53L0X_DEV dev, uint8_t *p_vhv_settings, |
| johnAlexander | 16:98ce55ddbb1a | 1188 | uint8_t *p_phase_cal); |
| johnAlexander | 16:98ce55ddbb1a | 1189 | VL53L0X_Error vl53l0x_perform_ref_spad_management(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1190 | uint32_t *ref_spad_count, uint8_t *is_aperture_spads); |
| johnAlexander | 16:98ce55ddbb1a | 1191 | VL53L0X_Error vl53l0x_set_device_address(VL53L0X_DEV dev, uint8_t device_address); |
| johnAlexander | 16:98ce55ddbb1a | 1192 | VL53L0X_Error vl53l0x_set_gpio_config(VL53L0X_DEV dev, uint8_t pin, |
| johnAlexander | 16:98ce55ddbb1a | 1193 | VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality, |
| johnAlexander | 16:98ce55ddbb1a | 1194 | VL53L0X_InterruptPolarity polarity); |
| johnAlexander | 16:98ce55ddbb1a | 1195 | VL53L0X_Error vl53l0x_get_fraction_enable(VL53L0X_DEV dev, uint8_t *p_enabled); |
| johnAlexander | 16:98ce55ddbb1a | 1196 | VL53L0X_Error vl53l0x_set_sequence_step_enable(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1197 | VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_step_enabled); |
| johnAlexander | 16:98ce55ddbb1a | 1198 | VL53L0X_Error vl53l0x_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1199 | uint32_t measurement_timing_budget_micro_seconds); |
| johnAlexander | 16:98ce55ddbb1a | 1200 | VL53L0X_Error vl53l0x_set_limit_check_enable(VL53L0X_DEV dev, uint16_t limit_check_id, |
| johnAlexander | 16:98ce55ddbb1a | 1201 | uint8_t limit_check_enable); |
| johnAlexander | 16:98ce55ddbb1a | 1202 | VL53L0X_Error vl53l0x_set_limit_check_value(VL53L0X_DEV dev, uint16_t limit_check_id, |
| johnAlexander | 16:98ce55ddbb1a | 1203 | FixPoint1616_t limit_check_value); |
| johnAlexander | 16:98ce55ddbb1a | 1204 | VL53L0X_Error vl53l0x_stop_measurement(VL53L0X_DEV dev); |
| johnAlexander | 16:98ce55ddbb1a | 1205 | VL53L0X_Error vl53l0x_get_stop_completed_status(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1206 | uint32_t *p_stop_status); |
| johnAlexander | 16:98ce55ddbb1a | 1207 | VL53L0X_Error vl53l0x_set_vcsel_pulse_period(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1208 | VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period); |
| johnAlexander | 0:c523920bcc09 | 1209 | |
| johnAlexander | 0:c523920bcc09 | 1210 | /* api_core.h functions */ |
| johnAlexander | 16:98ce55ddbb1a | 1211 | VL53L0X_Error vl53l0x_get_info_from_device(VL53L0X_DEV dev, uint8_t option); |
| johnAlexander | 16:98ce55ddbb1a | 1212 | VL53L0X_Error vl53l0x_device_read_strobe(VL53L0X_DEV dev); |
| johnAlexander | 16:98ce55ddbb1a | 1213 | VL53L0X_Error wrapped_vl53l0x_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1214 | uint32_t *p_measurement_timing_budget_micro_seconds); |
| johnAlexander | 16:98ce55ddbb1a | 1215 | VL53L0X_Error wrapped_vl53l0x_get_vcsel_pulse_period(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1216 | VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk); |
| johnAlexander | 16:98ce55ddbb1a | 1217 | uint8_t vl53l0x_decode_vcsel_period(uint8_t vcsel_period_reg); |
| johnAlexander | 16:98ce55ddbb1a | 1218 | uint32_t vl53l0x_decode_timeout(uint16_t encoded_timeout); |
| johnAlexander | 16:98ce55ddbb1a | 1219 | uint32_t vl53l0x_calc_timeout_us(VL53L0X_DEV dev, |
| johnAlexander | 15:932d8b4e52c9 | 1220 | uint16_t timeout_period_mclks, |
| johnAlexander | 15:932d8b4e52c9 | 1221 | uint8_t vcsel_period_pclks); |
| johnAlexander | 16:98ce55ddbb1a | 1222 | uint32_t vl53l0x_calc_macro_period_ps(VL53L0X_DEV dev, uint8_t vcsel_period_pclks); |
| johnAlexander | 16:98ce55ddbb1a | 1223 | VL53L0X_Error vl53l0x_measurement_poll_for_completion(VL53L0X_DEV dev); |
| johnAlexander | 16:98ce55ddbb1a | 1224 | VL53L0X_Error vl53l0x_load_tuning_settings(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1225 | uint8_t *p_tuning_setting_buffer); |
| johnAlexander | 16:98ce55ddbb1a | 1226 | VL53L0X_Error vl53l0x_get_pal_range_status(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1227 | uint8_t device_range_status, |
| johnAlexander | 16:98ce55ddbb1a | 1228 | FixPoint1616_t signal_rate, |
| johnAlexander | 16:98ce55ddbb1a | 1229 | uint16_t effective_spad_rtn_count, |
| johnAlexander | 16:98ce55ddbb1a | 1230 | VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, |
| johnAlexander | 16:98ce55ddbb1a | 1231 | uint8_t *p_pal_range_status); |
| johnAlexander | 16:98ce55ddbb1a | 1232 | VL53L0X_Error vl53l0x_calc_sigma_estimate(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1233 | VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, |
| johnAlexander | 16:98ce55ddbb1a | 1234 | FixPoint1616_t *p_sigma_estimate, |
| johnAlexander | 16:98ce55ddbb1a | 1235 | uint32_t *p_dmax_mm); |
| johnAlexander | 16:98ce55ddbb1a | 1236 | VL53L0X_Error vl53l0x_get_total_signal_rate(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1237 | VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, |
| johnAlexander | 16:98ce55ddbb1a | 1238 | FixPoint1616_t *p_total_signal_rate_mcps); |
| johnAlexander | 16:98ce55ddbb1a | 1239 | VL53L0X_Error vl53l0x_get_total_xtalk_rate(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1240 | VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, |
| johnAlexander | 16:98ce55ddbb1a | 1241 | FixPoint1616_t *p_total_xtalk_rate_mcps); |
| johnAlexander | 16:98ce55ddbb1a | 1242 | uint32_t vl53l0x_calc_timeout_mclks(VL53L0X_DEV dev, |
| johnAlexander | 15:932d8b4e52c9 | 1243 | uint32_t timeout_period_us, |
| johnAlexander | 15:932d8b4e52c9 | 1244 | uint8_t vcsel_period_pclks); |
| johnAlexander | 16:98ce55ddbb1a | 1245 | uint32_t vl53l0x_isqrt(uint32_t num); |
| johnAlexander | 16:98ce55ddbb1a | 1246 | VL53L0X_Error vl53l0x_calc_dmax( |
| johnAlexander | 16:98ce55ddbb1a | 1247 | VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1248 | FixPoint1616_t total_signal_rate_mcps, |
| johnAlexander | 16:98ce55ddbb1a | 1249 | FixPoint1616_t total_corr_signal_rate_mcps, |
| johnAlexander | 16:98ce55ddbb1a | 1250 | FixPoint1616_t pw_mult, |
| johnAlexander | 16:98ce55ddbb1a | 1251 | uint32_t sigma_estimate_p1, |
| johnAlexander | 16:98ce55ddbb1a | 1252 | FixPoint1616_t sigma_estimate_p2, |
| johnAlexander | 16:98ce55ddbb1a | 1253 | uint32_t peak_vcsel_duration_us, |
| johnAlexander | 16:98ce55ddbb1a | 1254 | uint32_t *pd_max_mm); |
| johnAlexander | 16:98ce55ddbb1a | 1255 | VL53L0X_Error wrapped_vl53l0x_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1256 | uint32_t measurement_timing_budget_micro_seconds); |
| johnAlexander | 16:98ce55ddbb1a | 1257 | VL53L0X_Error get_sequence_step_timeout(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1258 | VL53L0X_SequenceStepId sequence_step_id, |
| johnAlexander | 16:98ce55ddbb1a | 1259 | uint32_t *p_time_out_micro_secs); |
| johnAlexander | 16:98ce55ddbb1a | 1260 | VL53L0X_Error set_sequence_step_timeout(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1261 | VL53L0X_SequenceStepId sequence_step_id, |
| johnAlexander | 16:98ce55ddbb1a | 1262 | uint32_t timeout_micro_secs); |
| johnAlexander | 16:98ce55ddbb1a | 1263 | uint16_t vl53l0x_encode_timeout(uint32_t timeout_macro_clks); |
| johnAlexander | 16:98ce55ddbb1a | 1264 | VL53L0X_Error wrapped_vl53l0x_set_vcsel_pulse_period(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1265 | VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period_pclk); |
| johnAlexander | 16:98ce55ddbb1a | 1266 | uint8_t lv53l0x_encode_vcsel_period(uint8_t vcsel_period_pclks); |
| johnAlexander | 0:c523920bcc09 | 1267 | |
| johnAlexander | 0:c523920bcc09 | 1268 | /* api_calibration.h functions */ |
| johnAlexander | 16:98ce55ddbb1a | 1269 | VL53L0X_Error vl53l0x_apply_offset_adjustment(VL53L0X_DEV dev); |
| johnAlexander | 16:98ce55ddbb1a | 1270 | VL53L0X_Error wrapped_vl53l0x_get_offset_calibration_data_micro_meter(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1271 | int32_t *p_offset_calibration_data_micro_meter); |
| johnAlexander | 16:98ce55ddbb1a | 1272 | VL53L0X_Error wrapped_vl53l0x_set_offset_calibration_data_micro_meter(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1273 | int32_t offset_calibration_data_micro_meter); |
| johnAlexander | 16:98ce55ddbb1a | 1274 | VL53L0X_Error wrapped_vl53l0x_perform_ref_spad_management(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1275 | uint32_t *ref_spad_count, |
| johnAlexander | 16:98ce55ddbb1a | 1276 | uint8_t *is_aperture_spads); |
| johnAlexander | 16:98ce55ddbb1a | 1277 | VL53L0X_Error vl53l0x_perform_ref_calibration(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1278 | uint8_t *p_vhv_settings, uint8_t *p_phase_cal, uint8_t get_data_enable); |
| johnAlexander | 16:98ce55ddbb1a | 1279 | VL53L0X_Error vl53l0x_perform_vhv_calibration(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1280 | uint8_t *p_vhv_settings, const uint8_t get_data_enable, |
| johnAlexander | 15:932d8b4e52c9 | 1281 | const uint8_t restore_config); |
| johnAlexander | 16:98ce55ddbb1a | 1282 | VL53L0X_Error vl53l0x_perform_single_ref_calibration(VL53L0X_DEV dev, |
| johnAlexander | 15:932d8b4e52c9 | 1283 | uint8_t vhv_init_byte); |
| johnAlexander | 16:98ce55ddbb1a | 1284 | VL53L0X_Error vl53l0x_ref_calibration_io(VL53L0X_DEV dev, uint8_t read_not_write, |
| johnAlexander | 16:98ce55ddbb1a | 1285 | uint8_t vhv_settings, uint8_t phase_cal, |
| johnAlexander | 16:98ce55ddbb1a | 1286 | uint8_t *p_vhv_settings, uint8_t *p_phase_cal, |
| johnAlexander | 15:932d8b4e52c9 | 1287 | const uint8_t vhv_enable, const uint8_t phase_enable); |
| johnAlexander | 16:98ce55ddbb1a | 1288 | VL53L0X_Error vl53l0x_perform_phase_calibration(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1289 | uint8_t *p_phase_cal, const uint8_t get_data_enable, |
| johnAlexander | 15:932d8b4e52c9 | 1290 | const uint8_t restore_config); |
| johnAlexander | 16:98ce55ddbb1a | 1291 | VL53L0X_Error enable_ref_spads(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1292 | uint8_t aperture_spads, |
| johnAlexander | 16:98ce55ddbb1a | 1293 | uint8_t good_spad_array[], |
| johnAlexander | 16:98ce55ddbb1a | 1294 | uint8_t spad_array[], |
| johnAlexander | 15:932d8b4e52c9 | 1295 | uint32_t size, |
| johnAlexander | 15:932d8b4e52c9 | 1296 | uint32_t start, |
| johnAlexander | 15:932d8b4e52c9 | 1297 | uint32_t offset, |
| johnAlexander | 16:98ce55ddbb1a | 1298 | uint32_t spad_count, |
| johnAlexander | 16:98ce55ddbb1a | 1299 | uint32_t *p_last_spad); |
| johnAlexander | 16:98ce55ddbb1a | 1300 | void get_next_good_spad(uint8_t good_spad_array[], uint32_t size, |
| johnAlexander | 16:98ce55ddbb1a | 1301 | uint32_t curr, int32_t *p_next); |
| johnAlexander | 16:98ce55ddbb1a | 1302 | uint8_t is_aperture(uint32_t spad_index); |
| johnAlexander | 16:98ce55ddbb1a | 1303 | VL53L0X_Error enable_spad_bit(uint8_t spad_array[], uint32_t size, |
| johnAlexander | 16:98ce55ddbb1a | 1304 | uint32_t spad_index); |
| johnAlexander | 16:98ce55ddbb1a | 1305 | VL53L0X_Error set_ref_spad_map(VL53L0X_DEV dev, uint8_t *p_ref_spad_array); |
| johnAlexander | 16:98ce55ddbb1a | 1306 | VL53L0X_Error get_ref_spad_map(VL53L0X_DEV dev, uint8_t *p_ref_spad_array); |
| johnAlexander | 16:98ce55ddbb1a | 1307 | VL53L0X_Error perform_ref_signal_measurement(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1308 | uint16_t *p_ref_signal_rate); |
| johnAlexander | 16:98ce55ddbb1a | 1309 | VL53L0X_Error vl53l0x_set_reference_spads(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1310 | uint32_t count, uint8_t is_aperture_spads); |
| johnAlexander | 0:c523920bcc09 | 1311 | |
| johnAlexander | 0:c523920bcc09 | 1312 | /* api_strings.h functions */ |
| johnAlexander | 16:98ce55ddbb1a | 1313 | VL53L0X_Error wrapped_vl53l0x_get_device_info(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1314 | VL53L0X_DeviceInfo_t *p_vl53l0x_device_info); |
| johnAlexander | 16:98ce55ddbb1a | 1315 | VL53L0X_Error vl53l0x_check_part_used(VL53L0X_DEV dev, |
| johnAlexander | 16:98ce55ddbb1a | 1316 | uint8_t *revision, |
| johnAlexander | 16:98ce55ddbb1a | 1317 | VL53L0X_DeviceInfo_t *p_vl53l0x_device_info); |
| johnAlexander | 0:c523920bcc09 | 1318 | |
| johnAlexander | 15:932d8b4e52c9 | 1319 | /* deprecated Read function from Component class for backward compatibility*/ |
| johnAlexander | 15:932d8b4e52c9 | 1320 | // virtual int ReadID(); |
| johnAlexander | 4:4e1576541eed | 1321 | virtual int ReadID(uint8_t *id); |
| JerrySzczurak | 11:ceaa5a026412 | 1322 | |
| johnAlexander | 15:932d8b4e52c9 | 1323 | /* Read function of the ID device */ |
| johnAlexander | 15:932d8b4e52c9 | 1324 | // virtual int read_id(); |
| JerrySzczurak | 11:ceaa5a026412 | 1325 | virtual int read_id(uint8_t *id); |
| johnAlexander | 15:932d8b4e52c9 | 1326 | |
| johnAlexander | 16:98ce55ddbb1a | 1327 | VL53L0X_Error wait_measurement_data_ready(VL53L0X_DEV dev); |
| johnAlexander | 16:98ce55ddbb1a | 1328 | VL53L0X_Error wait_stop_completed(VL53L0X_DEV dev); |
| johnAlexander | 0:c523920bcc09 | 1329 | |
| johnAlexander | 0:c523920bcc09 | 1330 | /* Write and read functions from I2C */ |
| johnAlexander | 15:932d8b4e52c9 | 1331 | |
| johnAlexander | 16:98ce55ddbb1a | 1332 | VL53L0X_Error vl53l0x_write_byte(VL53L0X_DEV dev, uint8_t index, uint8_t data); |
| johnAlexander | 16:98ce55ddbb1a | 1333 | VL53L0X_Error vl53l0x_write_word(VL53L0X_DEV dev, uint8_t index, uint16_t data); |
| johnAlexander | 16:98ce55ddbb1a | 1334 | VL53L0X_Error vl53l0x_write_dword(VL53L0X_DEV dev, uint8_t index, uint32_t data); |
| johnAlexander | 16:98ce55ddbb1a | 1335 | VL53L0X_Error vl53l0x_read_byte(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data); |
| johnAlexander | 16:98ce55ddbb1a | 1336 | VL53L0X_Error vl53l0x_read_word(VL53L0X_DEV dev, uint8_t index, uint16_t *p_data); |
| johnAlexander | 16:98ce55ddbb1a | 1337 | VL53L0X_Error vl53l0x_read_dword(VL53L0X_DEV dev, uint8_t index, uint32_t *p_data); |
| johnAlexander | 16:98ce55ddbb1a | 1338 | VL53L0X_Error vl53l0x_update_byte(VL53L0X_DEV dev, uint8_t index, uint8_t and_data, uint8_t or_data); |
| johnAlexander | 15:932d8b4e52c9 | 1339 | |
| johnAlexander | 16:98ce55ddbb1a | 1340 | VL53L0X_Error vl53l0x_write_multi(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count); |
| johnAlexander | 16:98ce55ddbb1a | 1341 | VL53L0X_Error vl53l0x_read_multi(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count); |
| johnAlexander | 15:932d8b4e52c9 | 1342 | |
| johnAlexander | 16:98ce55ddbb1a | 1343 | VL53L0X_Error vl53l0x_i2c_write(uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes); |
| johnAlexander | 16:98ce55ddbb1a | 1344 | VL53L0X_Error vl53l0x_i2c_read(uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes); |
| johnAlexander | 15:932d8b4e52c9 | 1345 | |
| johnAlexander | 16:98ce55ddbb1a | 1346 | VL53L0X_Error vl53l0x_polling_delay(VL53L0X_DEV dev); /* usually best implemented as a real function */ |
| johnAlexander | 15:932d8b4e52c9 | 1347 | |
| johnAlexander | 16:98ce55ddbb1a | 1348 | int is_present() |
| johnAlexander | 0:c523920bcc09 | 1349 | { |
| johnAlexander | 15:932d8b4e52c9 | 1350 | int status; |
| johnAlexander | 15:932d8b4e52c9 | 1351 | uint8_t id=0; |
| johnAlexander | 15:932d8b4e52c9 | 1352 | |
| johnAlexander | 16:98ce55ddbb1a | 1353 | status=read_id(&id); |
| johnAlexander | 15:932d8b4e52c9 | 1354 | if(status) |
| johnAlexander | 15:932d8b4e52c9 | 1355 | VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r"); |
| johnAlexander | 15:932d8b4e52c9 | 1356 | return status; |
| johnAlexander | 15:932d8b4e52c9 | 1357 | } |
| johnAlexander | 16:98ce55ddbb1a | 1358 | /* |
| johnAlexander | 0:c523920bcc09 | 1359 | int StopRangeMeasurement(OperatingMode operating_mode); |
| johnAlexander | 15:932d8b4e52c9 | 1360 | int GetRangeMeas(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *Data); |
| johnAlexander | 0:c523920bcc09 | 1361 | int RangeSetLowThreshold(uint16_t threshold); |
| johnAlexander | 0:c523920bcc09 | 1362 | int RangeSetHighThreshold(uint16_t threshold); |
| johnAlexander | 0:c523920bcc09 | 1363 | int GetRangeError(VL53L0X_RangingMeasurementData_t *Data, VL53L0X_RangingMeasurementData_t RangeData); |
| johnAlexander | 0:c523920bcc09 | 1364 | int RangeMeasPollSingleShot(); |
| johnAlexander | 15:932d8b4e52c9 | 1365 | int RangeMeasPollContinuousMode(); |
| johnAlexander | 16:98ce55ddbb1a | 1366 | */ |
| johnAlexander | 16:98ce55ddbb1a | 1367 | int range_meas_int_continuous_mode(void (*fptr)(void)); |
| johnAlexander | 0:c523920bcc09 | 1368 | |
| johnAlexander | 0:c523920bcc09 | 1369 | |
| johnAlexander | 16:98ce55ddbb1a | 1370 | VL53L0X_DeviceInfo_t _device_info; |
| johnAlexander | 15:932d8b4e52c9 | 1371 | |
| johnAlexander | 0:c523920bcc09 | 1372 | /* IO Device */ |
| johnAlexander | 0:c523920bcc09 | 1373 | DevI2C &dev_i2c; |
| johnAlexander | 0:c523920bcc09 | 1374 | /* Digital out pin */ |
| johnAlexander | 0:c523920bcc09 | 1375 | DigitalOut *gpio0; |
| johnAlexander | 0:c523920bcc09 | 1376 | /* GPIO expander */ |
| johnAlexander | 14:d84672f45f7b | 1377 | Stmpe1600DigiOut *expgpio0; |
| johnAlexander | 0:c523920bcc09 | 1378 | /* Measure detection IRQ */ |
| johnAlexander | 0:c523920bcc09 | 1379 | InterruptIn *gpio1Int; |
| johnAlexander | 0:c523920bcc09 | 1380 | /* Device data */ |
| johnAlexander | 16:98ce55ddbb1a | 1381 | VL53L0X_Dev_t _my_device; |
| johnAlexander | 16:98ce55ddbb1a | 1382 | VL53L0X_DEV _device; |
| johnAlexander | 0:c523920bcc09 | 1383 | }; |
| johnAlexander | 0:c523920bcc09 | 1384 | |
| johnAlexander | 0:c523920bcc09 | 1385 | |
| johnAlexander | 0:c523920bcc09 | 1386 | #endif /* _VL53L0X_CLASS_H_ */ |
| johnAlexander | 0:c523920bcc09 | 1387 | |
| johnAlexander | 0:c523920bcc09 | 1388 | |
| johnAlexander | 9:367d1f390cb2 | 1389 | |
| johnAlexander | 9:367d1f390cb2 | 1390 |
