INSAT Mini Project

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

Committer:
gallonm
Date:
Tue Oct 06 09:03:10 2015 +0200
Revision:
10:4954b09b72d8
Parent:
8:f943a1fca15f
Fitted all api files (reinserted original api files)
Modified file platform.h and removed vl6180x_appcfg.h from the include
Modified value of the define SINGLE_DEVICE_DRIVER
Updated file stmpe1600_class.h
Fitted the ReadID function and I2C functions (read and write)
Updated file vl6180x_class.cpp
Introduced functions InitSensor and StartMeasurement
Fitted the constructor and the destructor of x_nucleo_6180xa1
Added the instance to create a singleton object
Introduced InitBoard function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gallonm 1:1de1ea2994d9 1 /*******************************************************************************
gallonm 1:1de1ea2994d9 2 Copyright © 2014, STMicroelectronics International N.V.
gallonm 1:1de1ea2994d9 3 All rights reserved.
gallonm 1:1de1ea2994d9 4
gallonm 1:1de1ea2994d9 5 Redistribution and use in source and binary forms, with or without
gallonm 1:1de1ea2994d9 6 modification, are permitted provided that the following conditions are met:
gallonm 1:1de1ea2994d9 7 * Redistributions of source code must retain the above copyright
gallonm 1:1de1ea2994d9 8 notice, this list of conditions and the following disclaimer.
gallonm 1:1de1ea2994d9 9 * Redistributions in binary form must reproduce the above copyright
gallonm 1:1de1ea2994d9 10 notice, this list of conditions and the following disclaimer in the
gallonm 1:1de1ea2994d9 11 documentation and/or other materials provided with the distribution.
gallonm 1:1de1ea2994d9 12 * Neither the name of STMicroelectronics nor the
gallonm 1:1de1ea2994d9 13 names of its contributors may be used to endorse or promote products
gallonm 1:1de1ea2994d9 14 derived from this software without specific prior written permission.
gallonm 1:1de1ea2994d9 15
gallonm 1:1de1ea2994d9 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
gallonm 1:1de1ea2994d9 17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
gallonm 1:1de1ea2994d9 18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
gallonm 1:1de1ea2994d9 19 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
gallonm 1:1de1ea2994d9 20 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
gallonm 1:1de1ea2994d9 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
gallonm 1:1de1ea2994d9 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
gallonm 1:1de1ea2994d9 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
gallonm 1:1de1ea2994d9 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
gallonm 1:1de1ea2994d9 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
gallonm 1:1de1ea2994d9 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gallonm 1:1de1ea2994d9 27 ********************************************************************************/
gallonm 1:1de1ea2994d9 28 /*
gallonm 1:1de1ea2994d9 29 * @file VL6180x_api.h
gallonm 1:1de1ea2994d9 30 * $Date: 2015-03-24 14:15:14 +0100 (Tue, 24 Mar 2015) $
gallonm 1:1de1ea2994d9 31 * $Revision: 2213 $
gallonm 1:1de1ea2994d9 32 */
gallonm 1:1de1ea2994d9 33
gallonm 1:1de1ea2994d9 34
gallonm 1:1de1ea2994d9 35
gallonm 1:1de1ea2994d9 36 #ifndef VL6180x_API_H_
gallonm 1:1de1ea2994d9 37 #define VL6180x_API_H_
gallonm 1:1de1ea2994d9 38
gallonm 1:1de1ea2994d9 39 #include "vl6180x_def.h"
gallonm 1:1de1ea2994d9 40 #include "vl6180x_platform.h"
gallonm 1:1de1ea2994d9 41
gallonm 1:1de1ea2994d9 42 #ifdef __cplusplus
gallonm 1:1de1ea2994d9 43 extern "C" {
gallonm 1:1de1ea2994d9 44 #endif
gallonm 1:1de1ea2994d9 45
gallonm 1:1de1ea2994d9 46 /** @defgroup api_ll API Low Level Functions
gallonm 1:1de1ea2994d9 47 * @brief API Low level functions
gallonm 1:1de1ea2994d9 48 */
gallonm 1:1de1ea2994d9 49
gallonm 1:1de1ea2994d9 50 /** @defgroup api_hl API High Level Functions
gallonm 1:1de1ea2994d9 51 * @brief API High level functions
gallonm 1:1de1ea2994d9 52 */
gallonm 10:4954b09b72d8 53
gallonm 10:4954b09b72d8 54
gallonm 10:4954b09b72d8 55 /*
gallonm 10:4954b09b72d8 56 * Check and set default platform dependent configuration
gallonm 10:4954b09b72d8 57 */
gallonm 10:4954b09b72d8 58 #ifndef VL6180x_SINGLE_DEVICE_DRIVER
gallonm 10:4954b09b72d8 59 #error "VL6180x_SINGLE_DEVICE_DRIVER not defined"
gallonm 10:4954b09b72d8 60 /* TODO you may remove or comment these #error but it is best you update your vl6180x_platform.h file to define it*/
gallonm 10:4954b09b72d8 61 #endif
gallonm 1:1de1ea2994d9 62
gallonm 1:1de1ea2994d9 63
gallonm 1:1de1ea2994d9 64 #ifndef VL6180x_RANGE_STATUS_ERRSTRING
gallonm 1:1de1ea2994d9 65 #warning "VL6180x_RANGE_STATUS_ERRSTRING not defined ?"
gallonm 1:1de1ea2994d9 66 /* TODO you may remove or comment these #warning and keep the default below to keep compatibility
gallonm 1:1de1ea2994d9 67 or update your vl6180x_platform.h file */
gallonm 1:1de1ea2994d9 68 /**
gallonm 1:1de1ea2994d9 69 * force VL6180x_RANGE_STATUS_ERRSTRING to not supported when not part of any cfg file
gallonm 1:1de1ea2994d9 70 */
gallonm 1:1de1ea2994d9 71 #define VL6180x_RANGE_STATUS_ERRSTRING 0
gallonm 1:1de1ea2994d9 72 #endif
gallonm 1:1de1ea2994d9 73
gallonm 1:1de1ea2994d9 74 #ifndef VL6180X_SAFE_POLLING_ENTER
gallonm 1:1de1ea2994d9 75 #warning "VL6180X_SAFE_POLLING_ENTER not defined, likely old vl6180x_cfg.h file ?"
gallonm 1:1de1ea2994d9 76 /* TODO you may remove or comment these #warning and keep the default below to keep compatibility
gallonm 1:1de1ea2994d9 77 or update your vl6180x_platform.h file */
gallonm 1:1de1ea2994d9 78 /**
gallonm 1:1de1ea2994d9 79 * force VL6180X_SAFE_POLLING_ENTER to off when not in cfg file
gallonm 1:1de1ea2994d9 80 */
gallonm 1:1de1ea2994d9 81 #define VL6180X_SAFE_POLLING_ENTER 0 /* off by default as in api 2.0 */
gallonm 1:1de1ea2994d9 82 #endif
gallonm 1:1de1ea2994d9 83
gallonm 1:1de1ea2994d9 84 #ifndef VL6180X_LOG_ENABLE
gallonm 1:1de1ea2994d9 85 /**
gallonm 1:1de1ea2994d9 86 * Force VL6180X_LOG_ENABLE to none as default
gallonm 1:1de1ea2994d9 87 */
gallonm 1:1de1ea2994d9 88 #define VL6180X_LOG_ENABLE 0
gallonm 1:1de1ea2994d9 89 #endif
gallonm 1:1de1ea2994d9 90
gallonm 1:1de1ea2994d9 91 #if VL6180x_RANGE_STATUS_ERRSTRING
gallonm 1:1de1ea2994d9 92 /**@def VL6180x_HAVE_RANGE_STATUS_ERRSTRING
gallonm 1:1de1ea2994d9 93 * @brief is defined when @a #VL6180x_RANGE_STATUS_ERRSTRING is enable
gallonm 1:1de1ea2994d9 94 */
gallonm 1:1de1ea2994d9 95 #define VL6180x_HAVE_RANGE_STATUS_ERRSTRING
gallonm 1:1de1ea2994d9 96 #endif
gallonm 1:1de1ea2994d9 97
gallonm 1:1de1ea2994d9 98
gallonm 1:1de1ea2994d9 99 /** @brief Get API version as "hex integer" 0xMMnnss
gallonm 1:1de1ea2994d9 100 */
gallonm 1:1de1ea2994d9 101 #define VL6180x_ApiRevInt ((VL6180x_API_REV_MAJOR<<24)+(VL6180x_API_REV_MINOR<<16)+VL6180x_API_REV_SUB)
gallonm 1:1de1ea2994d9 102
gallonm 1:1de1ea2994d9 103 /** Get API version as string for exe "2.1.12" "
gallonm 1:1de1ea2994d9 104 */
gallonm 1:1de1ea2994d9 105 #define VL6180x_ApiRevStr VL6180X_STR(VL6180x_API_REV_MAJOR) "." VL6180X_STR(VL6180x_API_REV_MINOR) "." VL6180X_STR(VL6180x_API_REV_SUB)
gallonm 1:1de1ea2994d9 106
gallonm 1:1de1ea2994d9 107 /** @defgroup api_init Init functions
gallonm 1:1de1ea2994d9 108 * @brief API init functions
gallonm 1:1de1ea2994d9 109 * @ingroup api_hl
gallonm 1:1de1ea2994d9 110 * @{
gallonm 1:1de1ea2994d9 111 */
gallonm 10:4954b09b72d8 112 /**
gallonm 10:4954b09b72d8 113 * @brief Wait for device booted after chip enable (hardware standby)
gallonm 10:4954b09b72d8 114 * @par Function Description
gallonm 10:4954b09b72d8 115 * After Chip enable Application you can also simply wait at least 1ms to ensure device is ready
gallonm 10:4954b09b72d8 116 * @warning After device chip enable (gpio0) de-asserted user must wait gpio1 to get asserted (hardware standby).
gallonm 10:4954b09b72d8 117 * or wait at least 400usec prior to do any low level access or api call .
gallonm 10:4954b09b72d8 118 *
gallonm 10:4954b09b72d8 119 * This function implements polling for standby but you must ensure 400usec from chip enable passed\n
gallonm 10:4954b09b72d8 120 * @warning if device get prepared @a VL6180x_Prepare() re-using these function can hold indefinitely\n
gallonm 10:4954b09b72d8 121 *
gallonm 10:4954b09b72d8 122 * @param dev The device
gallonm 10:4954b09b72d8 123 * @return 0 on success
gallonm 10:4954b09b72d8 124 */
gallonm 10:4954b09b72d8 125 int VL6180x_WaitDeviceBooted(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 126
gallonm 10:4954b09b72d8 127 /**
gallonm 10:4954b09b72d8 128 *
gallonm 10:4954b09b72d8 129 * @brief One time device initialization
gallonm 10:4954b09b72d8 130 *
gallonm 10:4954b09b72d8 131 * To be called once and only once after device is brought out of reset (Chip enable) and booted see @a VL6180x_WaitDeviceBooted()
gallonm 10:4954b09b72d8 132 *
gallonm 10:4954b09b72d8 133 * @par Function Description
gallonm 10:4954b09b72d8 134 * When not used after a fresh device "power up" or reset, it may return @a #CALIBRATION_WARNING
gallonm 10:4954b09b72d8 135 * meaning wrong calibration data may have been fetched from device that can result in ranging offset error\n
gallonm 10:4954b09b72d8 136 * If application cannot execute device reset or need to run VL6180x_InitData multiple time
gallonm 10:4954b09b72d8 137 * then it must ensure proper offset calibration saving and restore on its own
gallonm 10:4954b09b72d8 138 * by using @a VL6180x_GetOffsetCalibrationData() on first power up and then @a VL6180x_SetOffsetCalibrationData() all all subsequent init
gallonm 10:4954b09b72d8 139 *
gallonm 10:4954b09b72d8 140 * @param dev The device
gallonm 10:4954b09b72d8 141 * @return 0 on success, @a #CALIBRATION_WARNING if failed
gallonm 10:4954b09b72d8 142 */
gallonm 10:4954b09b72d8 143 int VL6180x_InitData(VL6180xDev_t dev );
gallonm 10:4954b09b72d8 144
gallonm 10:4954b09b72d8 145 /**
gallonm 10:4954b09b72d8 146 * @brief Configure GPIO1 function and set polarity.
gallonm 10:4954b09b72d8 147 * @par Function Description
gallonm 10:4954b09b72d8 148 * To be used prior to arm single shot measure or start continuous mode.
gallonm 10:4954b09b72d8 149 *
gallonm 10:4954b09b72d8 150 * The function uses @a VL6180x_SetupGPIOx() for setting gpio 1.
gallonm 10:4954b09b72d8 151 * @warning changing polarity can generate a spurious interrupt on pins.
gallonm 10:4954b09b72d8 152 * It sets an interrupt flags condition that must be cleared to avoid polling hangs. \n
gallonm 10:4954b09b72d8 153 * It is safe to run VL6180x_ClearAllInterrupt() just after.
gallonm 10:4954b09b72d8 154 *
gallonm 10:4954b09b72d8 155 * @param dev The device
gallonm 10:4954b09b72d8 156 * @param IntFunction The interrupt functionality to use one of :\n
gallonm 10:4954b09b72d8 157 * @a #GPIOx_SELECT_OFF \n
gallonm 10:4954b09b72d8 158 * @a #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT
gallonm 10:4954b09b72d8 159 * @param ActiveHigh The interrupt line polarity see ::IntrPol_e
gallonm 10:4954b09b72d8 160 * use @a #INTR_POL_LOW (falling edge) or @a #INTR_POL_HIGH (rising edge)
gallonm 10:4954b09b72d8 161 * @return 0 on success
gallonm 10:4954b09b72d8 162 */
gallonm 10:4954b09b72d8 163 int VL6180x_SetupGPIO1(VL6180xDev_t dev, uint8_t IntFunction, int ActiveHigh);
gallonm 10:4954b09b72d8 164
gallonm 10:4954b09b72d8 165 /**
gallonm 10:4954b09b72d8 166 * @brief Prepare device for operation
gallonm 10:4954b09b72d8 167 * @par Function Description
gallonm 10:4954b09b72d8 168 * Does static initialization and reprogram common default settings \n
gallonm 10:4954b09b72d8 169 * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n
gallonm 10:4954b09b72d8 170 * After prepare user can : \n
gallonm 10:4954b09b72d8 171 * @li Call other API function to set other settings\n
gallonm 10:4954b09b72d8 172 * @li Configure the interrupt pins, etc... \n
gallonm 10:4954b09b72d8 173 * @li Then start ranging or ALS operations in single shot or continuous mode
gallonm 10:4954b09b72d8 174 *
gallonm 10:4954b09b72d8 175 * @param dev The device
gallonm 10:4954b09b72d8 176 * @return 0 on success
gallonm 10:4954b09b72d8 177 */
gallonm 10:4954b09b72d8 178 int VL6180x_Prepare(VL6180xDev_t dev);
gallonm 1:1de1ea2994d9 179
gallonm 10:4954b09b72d8 180 /** @} */
gallonm 10:4954b09b72d8 181
gallonm 10:4954b09b72d8 182
gallonm 10:4954b09b72d8 183 /** @defgroup api_hl_range Ranging functions
gallonm 10:4954b09b72d8 184 * @brief Ranging functions
gallonm 10:4954b09b72d8 185 * @ingroup api_hl
gallonm 10:4954b09b72d8 186 * @{
gallonm 10:4954b09b72d8 187 */
gallonm 10:4954b09b72d8 188
gallonm 10:4954b09b72d8 189 /**
gallonm 10:4954b09b72d8 190 * @brief Start continuous ranging mode
gallonm 10:4954b09b72d8 191 *
gallonm 10:4954b09b72d8 192 * @details End user should ensure device is in idle state and not already running
gallonm 10:4954b09b72d8 193 */
gallonm 10:4954b09b72d8 194 int VL6180x_RangeStartContinuousMode(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 195
gallonm 10:4954b09b72d8 196 /**
gallonm 10:4954b09b72d8 197 * @brief Start single shot ranging measure
gallonm 10:4954b09b72d8 198 *
gallonm 10:4954b09b72d8 199 * @details End user should ensure device is in idle state and not already running
gallonm 10:4954b09b72d8 200 */
gallonm 10:4954b09b72d8 201 int VL6180x_RangeStartSingleShot(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 202
gallonm 10:4954b09b72d8 203 /**
gallonm 10:4954b09b72d8 204 * @brief Set maximum convergence time
gallonm 10:4954b09b72d8 205 *
gallonm 10:4954b09b72d8 206 * @par Function Description
gallonm 10:4954b09b72d8 207 * Setting a low convergence time can impact maximal detectable distance.
gallonm 10:4954b09b72d8 208 * Refer to VL6180x Datasheet Table 7 : Typical range convergence time.
gallonm 10:4954b09b72d8 209 * A typical value for up to x3 scaling is 50 ms
gallonm 10:4954b09b72d8 210 *
gallonm 10:4954b09b72d8 211 * @param dev
gallonm 10:4954b09b72d8 212 * @param MaxConTime_msec
gallonm 10:4954b09b72d8 213 * @return 0 on success. <0 on error. >0 for calibration warning status
gallonm 10:4954b09b72d8 214 */
gallonm 10:4954b09b72d8 215 int VL6180x_RangeSetMaxConvergenceTime(VL6180xDev_t dev, uint8_t MaxConTime_msec);
gallonm 10:4954b09b72d8 216
gallonm 10:4954b09b72d8 217 /**
gallonm 10:4954b09b72d8 218 * @brief Single shot Range measurement in polling mode.
gallonm 10:4954b09b72d8 219 *
gallonm 10:4954b09b72d8 220 * @par Function Description
gallonm 10:4954b09b72d8 221 * Kick off a new single shot range then wait for ready to retrieve it by polling interrupt status \n
gallonm 10:4954b09b72d8 222 * Ranging must be prepared by a first call to @a VL6180x_Prepare() and it is safer to clear very first poll call \n
gallonm 10:4954b09b72d8 223 * This function reference VL6180x_PollDelay(dev) porting macro/call on each polling loop,
gallonm 10:4954b09b72d8 224 * but PollDelay(dev) may never be called if measure in ready on first poll loop \n
gallonm 10:4954b09b72d8 225 * Should not be use in continuous mode operation as it will stop it and cause stop/start misbehaviour \n
gallonm 10:4954b09b72d8 226 * \n This function clears Range Interrupt status , but not error one. For that uses @a VL6180x_ClearErrorInterrupt() \n
gallonm 10:4954b09b72d8 227 * This range error is not related VL6180x_RangeData_t::errorStatus that refer measure status \n
gallonm 10:4954b09b72d8 228 *
gallonm 10:4954b09b72d8 229 * @param dev The device
gallonm 10:4954b09b72d8 230 * @param pRangeData Will be populated with the result ranging data @a VL6180x_RangeData_t
gallonm 10:4954b09b72d8 231 * @return 0 on success , @a #RANGE_ERROR if device reports an error case in it status (not cleared) use
gallonm 10:4954b09b72d8 232 *
gallonm 10:4954b09b72d8 233 * \sa ::VL6180x_RangeData_t
gallonm 10:4954b09b72d8 234 */
gallonm 10:4954b09b72d8 235 int VL6180x_RangePollMeasurement(VL6180xDev_t dev, VL6180x_RangeData_t *pRangeData);
gallonm 10:4954b09b72d8 236
gallonm 10:4954b09b72d8 237 /**
gallonm 10:4954b09b72d8 238 * @brief Check for measure readiness and get it if ready
gallonm 10:4954b09b72d8 239 *
gallonm 10:4954b09b72d8 240 * @par Function Description
gallonm 10:4954b09b72d8 241 * Using this function is an alternative to @a VL6180x_RangePollMeasurement() to avoid polling operation. This is suitable for applications
gallonm 10:4954b09b72d8 242 * 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
gallonm 10:4954b09b72d8 243 * operation is triggered by a call to @a VL6180x_RangeStartSingleShot(). Then, host CPU regularly calls @a VL6180x_RangeGetMeasurementIfReady() to
gallonm 10:4954b09b72d8 244 * get a distance measure if ready. In case the distance is not ready, host may get it at the next call.\n
gallonm 10:4954b09b72d8 245 *
gallonm 10:4954b09b72d8 246 * @warning
gallonm 10:4954b09b72d8 247 * This function does not re-start a new measurement : this is up to the host CPU to do it.\n
gallonm 10:4954b09b72d8 248 * This function clears Range Interrupt for measure ready , but not error interrupts. For that, uses @a VL6180x_ClearErrorInterrupt() \n
gallonm 10:4954b09b72d8 249 *
gallonm 10:4954b09b72d8 250 * @param dev The device
gallonm 10:4954b09b72d8 251 * @param pRangeData Will be populated with the result ranging data if available
gallonm 10:4954b09b72d8 252 * @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,
gallonm 10:4954b09b72d8 253 */
gallonm 10:4954b09b72d8 254 int VL6180x_RangeGetMeasurementIfReady(VL6180xDev_t dev, VL6180x_RangeData_t *pRangeData);
gallonm 10:4954b09b72d8 255
gallonm 10:4954b09b72d8 256 /**
gallonm 10:4954b09b72d8 257 * @brief Retrieve range measurements set from device
gallonm 10:4954b09b72d8 258 *
gallonm 10:4954b09b72d8 259 * @par Function Description
gallonm 10:4954b09b72d8 260 * The measurement is made of range_mm status and error code @a VL6180x_RangeData_t \n
gallonm 10:4954b09b72d8 261 * Based on configuration selected extra measures are included.
gallonm 10:4954b09b72d8 262 *
gallonm 10:4954b09b72d8 263 * @warning should not be used in continuous if wrap around filter is active \n
gallonm 10:4954b09b72d8 264 * Does not perform any wait nor check for result availability or validity.
gallonm 10:4954b09b72d8 265 *\sa VL6180x_RangeGetResult for "range only" measurement
gallonm 10:4954b09b72d8 266 *
gallonm 10:4954b09b72d8 267 * @param dev The device
gallonm 10:4954b09b72d8 268 * @param pRangeData Pointer to the data structure to fill up
gallonm 10:4954b09b72d8 269 * @return 0 on success
gallonm 10:4954b09b72d8 270 */
gallonm 10:4954b09b72d8 271 int VL6180x_RangeGetMeasurement(VL6180xDev_t dev, VL6180x_RangeData_t *pRangeData);
gallonm 10:4954b09b72d8 272
gallonm 10:4954b09b72d8 273 /**
gallonm 10:4954b09b72d8 274 * @brief Get ranging result and only that
gallonm 10:4954b09b72d8 275 *
gallonm 10:4954b09b72d8 276 * @par Function Description
gallonm 10:4954b09b72d8 277 * Unlike @a VL6180x_RangeGetMeasurement() this function only retrieves the range in millimeter \n
gallonm 10:4954b09b72d8 278 * It does any required up-scale translation\n
gallonm 10:4954b09b72d8 279 * It can be called after success status polling or in interrupt mode \n
gallonm 10:4954b09b72d8 280 * @warning these function is not doing wrap around filtering \n
gallonm 10:4954b09b72d8 281 * This function doesn't perform any data ready check!
gallonm 10:4954b09b72d8 282 *
gallonm 10:4954b09b72d8 283 * @param dev The device
gallonm 10:4954b09b72d8 284 * @param pRange_mm Pointer to range distance
gallonm 10:4954b09b72d8 285 * @return 0 on success
gallonm 10:4954b09b72d8 286 */
gallonm 10:4954b09b72d8 287 int VL6180x_RangeGetResult(VL6180xDev_t dev, int32_t *pRange_mm);
gallonm 10:4954b09b72d8 288
gallonm 10:4954b09b72d8 289 /**
gallonm 10:4954b09b72d8 290 * @brief Configure ranging interrupt reported to application
gallonm 10:4954b09b72d8 291 *
gallonm 10:4954b09b72d8 292 * @param dev The device
gallonm 10:4954b09b72d8 293 * @param ConfigGpioInt Select ranging report\n select one (and only one) of:\n
gallonm 10:4954b09b72d8 294 * @a #CONFIG_GPIO_INTERRUPT_DISABLED \n
gallonm 10:4954b09b72d8 295 * @a #CONFIG_GPIO_INTERRUPT_LEVEL_LOW \n
gallonm 10:4954b09b72d8 296 * @a #CONFIG_GPIO_INTERRUPT_LEVEL_HIGH \n
gallonm 10:4954b09b72d8 297 * @a #CONFIG_GPIO_INTERRUPT_OUT_OF_WINDOW \n
gallonm 10:4954b09b72d8 298 * @a #CONFIG_GPIO_INTERRUPT_NEW_SAMPLE_READY
gallonm 10:4954b09b72d8 299 * @return 0 on success
gallonm 10:4954b09b72d8 300 */
gallonm 10:4954b09b72d8 301 int VL6180x_RangeConfigInterrupt(VL6180xDev_t dev, uint8_t ConfigGpioInt);
gallonm 10:4954b09b72d8 302
gallonm 10:4954b09b72d8 303
gallonm 10:4954b09b72d8 304 /**
gallonm 10:4954b09b72d8 305 * @brief Clear range interrupt
gallonm 10:4954b09b72d8 306 *
gallonm 10:4954b09b72d8 307 * @param dev The device
gallonm 10:4954b09b72d8 308 * @return 0 On success
gallonm 10:4954b09b72d8 309 */
gallonm 10:4954b09b72d8 310 #define VL6180x_RangeClearInterrupt(dev) VL6180x_ClearInterrupt(dev, INTERRUPT_CLEAR_RANGING)
gallonm 10:4954b09b72d8 311
gallonm 10:4954b09b72d8 312 /**
gallonm 10:4954b09b72d8 313 * @brief Return ranging error interrupt status
gallonm 10:4954b09b72d8 314 *
gallonm 10:4954b09b72d8 315 * @par Function Description
gallonm 10:4954b09b72d8 316 * Appropriate Interrupt report must have been selected first by @a VL6180x_RangeConfigInterrupt() or @a VL6180x_Prepare() \n
gallonm 10:4954b09b72d8 317 *
gallonm 10:4954b09b72d8 318 * Can be used in polling loop to wait for a given ranging event or in interrupt to read the trigger \n
gallonm 10:4954b09b72d8 319 * Events triggers are : \n
gallonm 10:4954b09b72d8 320 * @a #RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD \n
gallonm 10:4954b09b72d8 321 * @a #RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD \n
gallonm 10:4954b09b72d8 322 * @a #RES_INT_STAT_GPIO_OUT_OF_WINDOW \n (RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD|RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD)
gallonm 10:4954b09b72d8 323 * @a #RES_INT_STAT_GPIO_NEW_SAMPLE_READY \n
gallonm 10:4954b09b72d8 324 *
gallonm 10:4954b09b72d8 325 * @sa IntrStatus_t
gallonm 10:4954b09b72d8 326 * @param dev The device
gallonm 10:4954b09b72d8 327 * @param pIntStatus Pointer to status variable to update
gallonm 10:4954b09b72d8 328 * @return 0 on success
gallonm 10:4954b09b72d8 329 */
gallonm 10:4954b09b72d8 330 int VL6180x_RangeGetInterruptStatus(VL6180xDev_t dev, uint8_t *pIntStatus);
gallonm 10:4954b09b72d8 331
gallonm 10:4954b09b72d8 332 #if VL6180x_RANGE_STATUS_ERRSTRING
gallonm 10:4954b09b72d8 333
gallonm 10:4954b09b72d8 334 extern const char * ROMABLE_DATA VL6180x_RangeStatusErrString[];
gallonm 10:4954b09b72d8 335 /**
gallonm 10:4954b09b72d8 336 * @brief Human readable error string for range error status
gallonm 10:4954b09b72d8 337 *
gallonm 10:4954b09b72d8 338 * @param RangeErrCode The error code as stored on @a VL6180x_RangeData_t::errorStatus
gallonm 10:4954b09b72d8 339 * @return error string , NULL for invalid RangeErrCode
gallonm 10:4954b09b72d8 340 * @sa ::RangeError_u
gallonm 10:4954b09b72d8 341 */
gallonm 10:4954b09b72d8 342 const char * VL6180x_RangeGetStatusErrString(uint8_t RangeErrCode);
gallonm 10:4954b09b72d8 343 #else
gallonm 10:4954b09b72d8 344 #define VL6180x_RangeGetStatusErrString(...) NULL
gallonm 10:4954b09b72d8 345 #endif
gallonm 10:4954b09b72d8 346
gallonm 10:4954b09b72d8 347 /** @} */
gallonm 10:4954b09b72d8 348
gallonm 10:4954b09b72d8 349 #if VL6180x_ALS_SUPPORT
gallonm 10:4954b09b72d8 350
gallonm 10:4954b09b72d8 351 /** @defgroup api_hl_als ALS functions
gallonm 10:4954b09b72d8 352 * @brief ALS functions
gallonm 10:4954b09b72d8 353 * @ingroup api_hl
gallonm 10:4954b09b72d8 354 * @{
gallonm 10:4954b09b72d8 355 */
gallonm 10:4954b09b72d8 356
gallonm 10:4954b09b72d8 357 /**
gallonm 10:4954b09b72d8 358 * @brief Run a single ALS measurement in single shot polling mode
gallonm 10:4954b09b72d8 359 *
gallonm 10:4954b09b72d8 360 * @par Function Description
gallonm 10:4954b09b72d8 361 * Kick off a new single shot ALS then wait new measurement ready to retrieve it ( polling system interrupt status register for als) \n
gallonm 10:4954b09b72d8 362 * ALS must be prepared by a first call to @a VL6180x_Prepare() \n
gallonm 10:4954b09b72d8 363 * \n Should not be used in continuous or interrupt mode it will break it and create hazard in start/stop \n
gallonm 10:4954b09b72d8 364 *
gallonm 10:4954b09b72d8 365 * @param dev The device
gallonm 10:4954b09b72d8 366 * @param pAlsData Als data structure to fill up @a VL6180x_AlsData_t
gallonm 10:4954b09b72d8 367 * @return 0 on success
gallonm 10:4954b09b72d8 368 */
gallonm 10:4954b09b72d8 369 int VL6180x_AlsPollMeasurement(VL6180xDev_t dev, VL6180x_AlsData_t *pAlsData);
gallonm 10:4954b09b72d8 370
gallonm 10:4954b09b72d8 371
gallonm 10:4954b09b72d8 372 /**
gallonm 10:4954b09b72d8 373 * @brief Get actual ALS measurement
gallonm 10:4954b09b72d8 374 *
gallonm 10:4954b09b72d8 375 * @par Function Description
gallonm 10:4954b09b72d8 376 * Can be called after success status polling or in interrupt mode to retrieve ALS measurement from device \n
gallonm 10:4954b09b72d8 377 * This function doesn't perform any data ready check !
gallonm 10:4954b09b72d8 378 *
gallonm 10:4954b09b72d8 379 * @param dev The device
gallonm 10:4954b09b72d8 380 * @param pAlsData Pointer to measurement struct @a VL6180x_AlsData_t
gallonm 10:4954b09b72d8 381 * @return 0 on success
gallonm 10:4954b09b72d8 382 */
gallonm 10:4954b09b72d8 383 int VL6180x_AlsGetMeasurement(VL6180xDev_t dev, VL6180x_AlsData_t *pAlsData);
gallonm 10:4954b09b72d8 384
gallonm 10:4954b09b72d8 385 /**
gallonm 10:4954b09b72d8 386 * @brief Configure ALS interrupts provide to application
gallonm 10:4954b09b72d8 387 *
gallonm 10:4954b09b72d8 388 * @param dev The Device
gallonm 10:4954b09b72d8 389 * @param ConfigGpioInt Select one (and only one) of : \n
gallonm 10:4954b09b72d8 390 * @a #CONFIG_GPIO_INTERRUPT_DISABLED \n
gallonm 10:4954b09b72d8 391 * @a #CONFIG_GPIO_INTERRUPT_LEVEL_LOW \n
gallonm 10:4954b09b72d8 392 * @a #CONFIG_GPIO_INTERRUPT_LEVEL_HIGH \n
gallonm 10:4954b09b72d8 393 * @a #CONFIG_GPIO_INTERRUPT_OUT_OF_WINDOW \n
gallonm 10:4954b09b72d8 394 * @a #CONFIG_GPIO_INTERRUPT_NEW_SAMPLE_READY
gallonm 10:4954b09b72d8 395 * @return 0 on success may return #INVALID_PARAMS for invalid mode
gallonm 10:4954b09b72d8 396 */
gallonm 10:4954b09b72d8 397 int VL6180x_AlsConfigInterrupt(VL6180xDev_t dev, uint8_t ConfigGpioInt);
gallonm 10:4954b09b72d8 398
gallonm 10:4954b09b72d8 399
gallonm 10:4954b09b72d8 400 /**
gallonm 10:4954b09b72d8 401 * @brief Set ALS integration period
gallonm 10:4954b09b72d8 402 *
gallonm 10:4954b09b72d8 403 * @param dev The device
gallonm 10:4954b09b72d8 404 * @param period_ms Integration period in msec. Value in between 50 to 100 msec is recommended\n
gallonm 10:4954b09b72d8 405 * @return 0 on success
gallonm 10:4954b09b72d8 406 */
gallonm 10:4954b09b72d8 407 int VL6180x_AlsSetIntegrationPeriod(VL6180xDev_t dev, uint16_t period_ms);
gallonm 10:4954b09b72d8 408
gallonm 10:4954b09b72d8 409 /**
gallonm 10:4954b09b72d8 410 * @brief Set ALS "inter-measurement period"
gallonm 10:4954b09b72d8 411 *
gallonm 10:4954b09b72d8 412 * @par Function Description
gallonm 10:4954b09b72d8 413 * The so call data-sheet "inter measurement period" is actually an extra inter-measurement delay
gallonm 10:4954b09b72d8 414 *
gallonm 10:4954b09b72d8 415 * @param dev The device
gallonm 10:4954b09b72d8 416 * @param intermeasurement_period_ms Inter measurement time in milli second\n
gallonm 10:4954b09b72d8 417 * @warning applied value is clipped to 2550 ms\n
gallonm 10:4954b09b72d8 418 * @return 0 on success if value is
gallonm 10:4954b09b72d8 419 */
gallonm 10:4954b09b72d8 420 int VL6180x_AlsSetInterMeasurementPeriod(VL6180xDev_t dev, uint16_t intermeasurement_period_ms);
gallonm 10:4954b09b72d8 421
gallonm 10:4954b09b72d8 422 /**
gallonm 10:4954b09b72d8 423 * @brief Set ALS analog gain code
gallonm 10:4954b09b72d8 424 *
gallonm 10:4954b09b72d8 425 * @par Function Description
gallonm 10:4954b09b72d8 426 * ALS gain code value programmed in @a SYSALS_ANALOGUE_GAIN .
gallonm 10:4954b09b72d8 427 * @param dev The device
gallonm 10:4954b09b72d8 428 * @param gain Gain code see datasheet or AlsGainLookUp for real value. Value is clipped to 7.
gallonm 10:4954b09b72d8 429 * @return 0 on success
gallonm 10:4954b09b72d8 430 */
gallonm 10:4954b09b72d8 431
gallonm 10:4954b09b72d8 432 int VL6180x_AlsSetAnalogueGain(VL6180xDev_t dev, uint8_t gain);
gallonm 10:4954b09b72d8 433 /**
gallonm 10:4954b09b72d8 434 * @brief Set thresholds for ALS continuous mode
gallonm 10:4954b09b72d8 435 * @warning Threshold are raw device value not lux!
gallonm 10:4954b09b72d8 436 *
gallonm 10:4954b09b72d8 437 * @par Function Description
gallonm 10:4954b09b72d8 438 * Basically value programmed in @a SYSALS_THRESH_LOW and @a SYSALS_THRESH_HIGH registers
gallonm 10:4954b09b72d8 439 * @param dev The device
gallonm 10:4954b09b72d8 440 * @param low ALS low raw threshold for @a SYSALS_THRESH_LOW
gallonm 10:4954b09b72d8 441 * @param high ALS high raw threshold for @a SYSALS_THRESH_HIGH
gallonm 10:4954b09b72d8 442 * @return 0 on success
gallonm 10:4954b09b72d8 443 */
gallonm 10:4954b09b72d8 444 int VL6180x_AlsSetThresholds(VL6180xDev_t dev, uint8_t low, uint8_t high);
gallonm 10:4954b09b72d8 445
gallonm 10:4954b09b72d8 446 /**
gallonm 10:4954b09b72d8 447 * @brief Clear ALS interrupt
gallonm 10:4954b09b72d8 448 *
gallonm 10:4954b09b72d8 449 * @param dev The device
gallonm 10:4954b09b72d8 450 * @return 0 On success
gallonm 10:4954b09b72d8 451 */
gallonm 10:4954b09b72d8 452 #define VL6180x_AlsClearInterrupt(dev) VL6180x_ClearInterrupt(dev, INTERRUPT_CLEAR_ALS)
gallonm 10:4954b09b72d8 453
gallonm 10:4954b09b72d8 454 /**
gallonm 10:4954b09b72d8 455 * Read ALS interrupt status
gallonm 10:4954b09b72d8 456 * @param dev Device
gallonm 10:4954b09b72d8 457 * @param pIntStatus Pointer to status
gallonm 10:4954b09b72d8 458 * @return 0 on success
gallonm 10:4954b09b72d8 459 */
gallonm 10:4954b09b72d8 460 int VL6180x_AlsGetInterruptStatus(VL6180xDev_t dev, uint8_t *pIntStatus);
gallonm 10:4954b09b72d8 461
gallonm 10:4954b09b72d8 462 /** @} */
gallonm 10:4954b09b72d8 463 #endif
gallonm 10:4954b09b72d8 464
gallonm 10:4954b09b72d8 465 /** @defgroup api_ll_init Init functions
gallonm 10:4954b09b72d8 466 * @brief Init functions
gallonm 10:4954b09b72d8 467 * @ingroup api_ll
gallonm 10:4954b09b72d8 468 * @{
gallonm 10:4954b09b72d8 469 */
gallonm 10:4954b09b72d8 470
gallonm 10:4954b09b72d8 471 /**
gallonm 10:4954b09b72d8 472 * @brief Low level ranging and ALS register static settings (you should call @a VL6180x_Prepare() function instead)
gallonm 10:4954b09b72d8 473 *
gallonm 10:4954b09b72d8 474 * @param dev
gallonm 10:4954b09b72d8 475 * @return 0 on success
gallonm 10:4954b09b72d8 476 */
gallonm 10:4954b09b72d8 477 int VL6180x_StaticInit(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 478
gallonm 10:4954b09b72d8 479 /** @} */
gallonm 10:4954b09b72d8 480
gallonm 10:4954b09b72d8 481 /** @defgroup api_ll_range Ranging functions
gallonm 10:4954b09b72d8 482 * @brief Ranging Low Level functions
gallonm 10:4954b09b72d8 483 * @ingroup api_ll
gallonm 10:4954b09b72d8 484 * @{
gallonm 10:4954b09b72d8 485 */
gallonm 10:4954b09b72d8 486
gallonm 10:4954b09b72d8 487 /**
gallonm 10:4954b09b72d8 488 * @brief Wait for device to be ready (before a new ranging command can be issued by application)
gallonm 10:4954b09b72d8 489 * @param dev The device
gallonm 10:4954b09b72d8 490 * @param MaxLoop Max Number of i2c polling loop see @a #msec_2_i2cloop
gallonm 10:4954b09b72d8 491 * @return 0 on success. <0 when fail \n
gallonm 10:4954b09b72d8 492 * @ref VL6180x_ErrCode_t::TIME_OUT for time out \n
gallonm 10:4954b09b72d8 493 * @ref VL6180x_ErrCode_t::INVALID_PARAMS if MaxLop<1
gallonm 10:4954b09b72d8 494 */
gallonm 10:4954b09b72d8 495 int VL6180x_RangeWaitDeviceReady(VL6180xDev_t dev, int MaxLoop );
gallonm 10:4954b09b72d8 496
gallonm 10:4954b09b72d8 497 /**
gallonm 10:4954b09b72d8 498 * @brief Program Inter measurement period (used only in continuous mode)
gallonm 10:4954b09b72d8 499 *
gallonm 10:4954b09b72d8 500 * @par Function Description
gallonm 10:4954b09b72d8 501 * When trying to set too long time, it returns #INVALID_PARAMS
gallonm 10:4954b09b72d8 502 *
gallonm 10:4954b09b72d8 503 * @param dev The device
gallonm 10:4954b09b72d8 504 * @param InterMeasTime_msec Requires inter-measurement time in msec
gallonm 10:4954b09b72d8 505 * @return 0 on success
gallonm 10:4954b09b72d8 506 */
gallonm 10:4954b09b72d8 507 int VL6180x_RangeSetInterMeasPeriod(VL6180xDev_t dev, uint32_t InterMeasTime_msec);
gallonm 10:4954b09b72d8 508
gallonm 10:4954b09b72d8 509
gallonm 10:4954b09b72d8 510 /**
gallonm 10:4954b09b72d8 511 * @brief Set device ranging scaling factor
gallonm 10:4954b09b72d8 512 *
gallonm 10:4954b09b72d8 513 * @par Function Description
gallonm 10:4954b09b72d8 514 * The ranging scaling factor is applied on the raw distance measured by the device to increase operating ranging at the price of the precision.
gallonm 10:4954b09b72d8 515 * Changing the scaling factor when device is not in f/w standby state (free running) is not safe.
gallonm 10:4954b09b72d8 516 * It can be source of spurious interrupt, wrongly scaled range etc ...
gallonm 10:4954b09b72d8 517 * @warning __This function doesns't update high/low threshold and other programmed settings linked to scaling factor__.
gallonm 10:4954b09b72d8 518 * To ensure proper operation, threshold and scaling changes should be done following this procedure: \n
gallonm 10:4954b09b72d8 519 * @li Set Group hold : @a VL6180x_SetGroupParamHold() \n
gallonm 10:4954b09b72d8 520 * @li Get Threshold @a VL6180x_RangeGetThresholds() \n
gallonm 10:4954b09b72d8 521 * @li Change scaling : @a VL6180x_UpscaleSetScaling() \n
gallonm 10:4954b09b72d8 522 * @li Set Threshold : @a VL6180x_RangeSetThresholds() \n
gallonm 10:4954b09b72d8 523 * @li Unset Group Hold : @a VL6180x_SetGroupParamHold()
gallonm 10:4954b09b72d8 524 *
gallonm 10:4954b09b72d8 525 * @param dev The device
gallonm 10:4954b09b72d8 526 * @param scaling Scaling factor to apply (1,2 or 3)
gallonm 10:4954b09b72d8 527 * @return 0 on success when up-scale support is not configured it fail for any
gallonm 10:4954b09b72d8 528 * scaling than the one statically configured.
gallonm 10:4954b09b72d8 529 */
gallonm 10:4954b09b72d8 530 int VL6180x_UpscaleSetScaling(VL6180xDev_t dev, uint8_t scaling);
gallonm 10:4954b09b72d8 531
gallonm 10:4954b09b72d8 532 /**
gallonm 10:4954b09b72d8 533 * @brief Get current ranging scaling factor
gallonm 10:4954b09b72d8 534 *
gallonm 10:4954b09b72d8 535 * @param dev The device
gallonm 10:4954b09b72d8 536 * @return The current scaling factor
gallonm 10:4954b09b72d8 537 */
gallonm 10:4954b09b72d8 538 int VL6180x_UpscaleGetScaling(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 539
gallonm 10:4954b09b72d8 540
gallonm 10:4954b09b72d8 541 /**
gallonm 10:4954b09b72d8 542 * @brief Give filtered state (wrap-around filter) of a range measurement
gallonm 10:4954b09b72d8 543 * @param pRangeData Range measurement data
gallonm 10:4954b09b72d8 544 * @return 0 means measure was not filtered, when not 0 range from device got filtered by filter post processing
gallonm 10:4954b09b72d8 545 */
gallonm 10:4954b09b72d8 546 #define VL6180x_RangeIsFilteredMeasurement(pRangeData) ((pRangeData)->errorStatus == RangingFiltered)
gallonm 10:4954b09b72d8 547
gallonm 10:4954b09b72d8 548 /**
gallonm 10:4954b09b72d8 549 * @brief Get the maximal distance for actual scaling
gallonm 10:4954b09b72d8 550 * @par Function Description
gallonm 10:4954b09b72d8 551 * Do not use prior to @a VL6180x_Prepare() or at least @a VL6180x_InitData()
gallonm 10:4954b09b72d8 552 *
gallonm 10:4954b09b72d8 553 * Any range value more than the value returned by this function is to be considered as "no target detected"
gallonm 10:4954b09b72d8 554 * or "no target in detectable range" \n
gallonm 10:4954b09b72d8 555 * @warning The maximal distance depends on the scaling
gallonm 10:4954b09b72d8 556 *
gallonm 10:4954b09b72d8 557 * @param dev The device
gallonm 10:4954b09b72d8 558 * @return The maximal range limit for actual mode and scaling
gallonm 10:4954b09b72d8 559 */
gallonm 10:4954b09b72d8 560 uint16_t VL6180x_GetUpperLimit(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 561
gallonm 10:4954b09b72d8 562 /**
gallonm 10:4954b09b72d8 563 * @brief Apply low and high ranging thresholds that are considered only in continuous mode
gallonm 10:4954b09b72d8 564 *
gallonm 10:4954b09b72d8 565 * @par Function Description
gallonm 10:4954b09b72d8 566 * This function programs low and high ranging thresholds that are considered in continuous mode :
gallonm 10:4954b09b72d8 567 * interrupt will be raised only when an object is detected at a distance inside this [low:high] range.
gallonm 10:4954b09b72d8 568 * The function takes care of applying current scaling factor if any.\n
gallonm 10:4954b09b72d8 569 * To be safe, in continuous operation, thresholds must be changed under "group parameter hold" cover.
gallonm 10:4954b09b72d8 570 * Group hold can be activated/deactivated directly in the function or externally (then set 0)
gallonm 10:4954b09b72d8 571 * using /a VL6180x_SetGroupParamHold() function.
gallonm 10:4954b09b72d8 572 *
gallonm 10:4954b09b72d8 573 * @param dev The device
gallonm 10:4954b09b72d8 574 * @param low Low threshold in mm
gallonm 10:4954b09b72d8 575 * @param high High threshold in mm
gallonm 10:4954b09b72d8 576 * @param SafeHold Use of group parameters hold to surround threshold programming.
gallonm 10:4954b09b72d8 577 * @return 0 On success
gallonm 10:4954b09b72d8 578 */
gallonm 10:4954b09b72d8 579 int VL6180x_RangeSetThresholds(VL6180xDev_t dev, uint16_t low, uint16_t high, int SafeHold);
gallonm 10:4954b09b72d8 580
gallonm 10:4954b09b72d8 581 /**
gallonm 10:4954b09b72d8 582 * @brief Get scaled high and low threshold from device
gallonm 10:4954b09b72d8 583 *
gallonm 10:4954b09b72d8 584 * @par Function Description
gallonm 10:4954b09b72d8 585 * Due to scaling factor, the returned value may be different from what has been programmed first (precision lost).
gallonm 10:4954b09b72d8 586 * For instance VL6180x_RangeSetThresholds(dev,11,22) with scale 3
gallonm 10:4954b09b72d8 587 * will read back 9 ((11/3)x3) and 21 ((22/3)x3).
gallonm 10:4954b09b72d8 588
gallonm 10:4954b09b72d8 589 * @param dev The device
gallonm 10:4954b09b72d8 590 * @param low scaled low Threshold ptr can be NULL if not needed
gallonm 10:4954b09b72d8 591 * @param high scaled High Threshold ptr can be NULL if not needed
gallonm 10:4954b09b72d8 592 * @return 0 on success, return value is undefined if both low and high are NULL
gallonm 10:4954b09b72d8 593 * @warning return value is undefined if both low and high are NULL
gallonm 10:4954b09b72d8 594 */
gallonm 10:4954b09b72d8 595 int VL6180x_RangeGetThresholds(VL6180xDev_t dev, uint16_t *low, uint16_t *high);
gallonm 10:4954b09b72d8 596
gallonm 10:4954b09b72d8 597 /**
gallonm 10:4954b09b72d8 598 * @brief Set ranging raw thresholds (scaling not considered so not recommended to use it)
gallonm 10:4954b09b72d8 599 *
gallonm 10:4954b09b72d8 600 * @param dev The device
gallonm 10:4954b09b72d8 601 * @param low raw low threshold set to raw register
gallonm 10:4954b09b72d8 602 * @param high raw high threshold set to raw register
gallonm 10:4954b09b72d8 603 * @return 0 on success
gallonm 10:4954b09b72d8 604 */
gallonm 10:4954b09b72d8 605 int VL6180x_RangeSetRawThresholds(VL6180xDev_t dev, uint8_t low, uint8_t high);
gallonm 10:4954b09b72d8 606
gallonm 10:4954b09b72d8 607 /**
gallonm 10:4954b09b72d8 608 * @brief Set Early Convergence Estimate ratio
gallonm 10:4954b09b72d8 609 * @par Function Description
gallonm 10:4954b09b72d8 610 * For more information on ECE check datasheet
gallonm 10:4954b09b72d8 611 * @warning May return a calibration warning in some use cases
gallonm 10:4954b09b72d8 612 *
gallonm 10:4954b09b72d8 613 * @param dev The device
gallonm 10:4954b09b72d8 614 * @param FactorM ECE factor M in M/D
gallonm 10:4954b09b72d8 615 * @param FactorD ECE factor D in M/D
gallonm 10:4954b09b72d8 616 * @return 0 on success. <0 on error. >0 on warning
gallonm 10:4954b09b72d8 617 */
gallonm 10:4954b09b72d8 618 int VL6180x_RangeSetEceFactor(VL6180xDev_t dev, uint16_t FactorM, uint16_t FactorD);
gallonm 10:4954b09b72d8 619
gallonm 10:4954b09b72d8 620 /**
gallonm 10:4954b09b72d8 621 * @brief Set Early Convergence Estimate state (See #SYSRANGE_RANGE_CHECK_ENABLES register)
gallonm 10:4954b09b72d8 622 * @param dev The device
gallonm 10:4954b09b72d8 623 * @param enable State to be set 0=disabled, otherwise enabled
gallonm 10:4954b09b72d8 624 * @return 0 on success
gallonm 10:4954b09b72d8 625 */
gallonm 10:4954b09b72d8 626 int VL6180x_RangeSetEceState(VL6180xDev_t dev, int enable );
gallonm 10:4954b09b72d8 627
gallonm 10:4954b09b72d8 628 /**
gallonm 10:4954b09b72d8 629 * @brief Set activation state of the wrap around filter
gallonm 10:4954b09b72d8 630 * @param dev The device
gallonm 10:4954b09b72d8 631 * @param state New activation state (0=off, otherwise on)
gallonm 10:4954b09b72d8 632 * @return 0 on success
gallonm 10:4954b09b72d8 633 */
gallonm 10:4954b09b72d8 634 int VL6180x_FilterSetState(VL6180xDev_t dev, int state);
gallonm 10:4954b09b72d8 635
gallonm 10:4954b09b72d8 636 /**
gallonm 10:4954b09b72d8 637 * Get activation state of the wrap around filter
gallonm 10:4954b09b72d8 638 * @param dev The device
gallonm 10:4954b09b72d8 639 * @return Filter enabled or not, when filter is not supported it always returns 0S
gallonm 10:4954b09b72d8 640 */
gallonm 10:4954b09b72d8 641 int VL6180x_FilterGetState(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 642
gallonm 10:4954b09b72d8 643
gallonm 10:4954b09b72d8 644 /**
gallonm 10:4954b09b72d8 645 * @brief Set activation state of DMax computation
gallonm 10:4954b09b72d8 646 * @param dev The device
gallonm 10:4954b09b72d8 647 * @param state New activation state (0=off, otherwise on)
gallonm 10:4954b09b72d8 648 * @return 0 on success
gallonm 10:4954b09b72d8 649 */
gallonm 10:4954b09b72d8 650 int VL6180x_DMaxSetState(VL6180xDev_t dev, int state);
gallonm 10:4954b09b72d8 651
gallonm 10:4954b09b72d8 652 /**
gallonm 10:4954b09b72d8 653 * Get activation state of DMax computation
gallonm 10:4954b09b72d8 654 * @param dev The device
gallonm 10:4954b09b72d8 655 * @return Filter enabled or not, when filter is not supported it always returns 0S
gallonm 10:4954b09b72d8 656 */
gallonm 10:4954b09b72d8 657 int VL6180x_DMaxGetState(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 658
gallonm 10:4954b09b72d8 659
gallonm 10:4954b09b72d8 660 /**
gallonm 10:4954b09b72d8 661 * @brief Set ranging mode and start/stop measure (use high level functions instead : @a VL6180x_RangeStartSingleShot() or @a VL6180x_RangeStartContinuousMode())
gallonm 10:4954b09b72d8 662 *
gallonm 10:4954b09b72d8 663 * @par Function Description
gallonm 10:4954b09b72d8 664 * When used outside scope of known polling single shot stopped state, \n
gallonm 10:4954b09b72d8 665 * user must ensure the device state is "idle" before to issue a new command.
gallonm 10:4954b09b72d8 666 *
gallonm 10:4954b09b72d8 667 * @param dev The device
gallonm 10:4954b09b72d8 668 * @param mode A combination of working mode (#MODE_SINGLESHOT or #MODE_CONTINUOUS) and start/stop condition (#MODE_START_STOP) \n
gallonm 10:4954b09b72d8 669 * @return 0 on success
gallonm 10:4954b09b72d8 670 */
gallonm 10:4954b09b72d8 671 int VL6180x_RangeSetSystemMode(VL6180xDev_t dev, uint8_t mode);
gallonm 10:4954b09b72d8 672
gallonm 10:4954b09b72d8 673 /** @} */
gallonm 10:4954b09b72d8 674
gallonm 10:4954b09b72d8 675 /** @defgroup api_ll_range_calibration Ranging calibration functions
gallonm 10:4954b09b72d8 676 * @brief Ranging calibration functions
gallonm 10:4954b09b72d8 677 * @ingroup api_ll
gallonm 10:4954b09b72d8 678 * @{
gallonm 10:4954b09b72d8 679 */
gallonm 10:4954b09b72d8 680 /**
gallonm 10:4954b09b72d8 681 * @brief Get part to part calibration offset
gallonm 10:4954b09b72d8 682 *
gallonm 10:4954b09b72d8 683 * @par Function Description
gallonm 10:4954b09b72d8 684 * Should only be used after a successful call to @a VL6180x_InitData to backup device nvm value
gallonm 10:4954b09b72d8 685 *
gallonm 10:4954b09b72d8 686 * @param dev The device
gallonm 10:4954b09b72d8 687 * @return part to part calibration offset from device
gallonm 10:4954b09b72d8 688 */
gallonm 10:4954b09b72d8 689 int8_t VL6180x_GetOffsetCalibrationData(VL6180xDev_t dev);
gallonm 10:4954b09b72d8 690
gallonm 10:4954b09b72d8 691 /**
gallonm 10:4954b09b72d8 692 * Set or over-write part to part calibration offset
gallonm 10:4954b09b72d8 693 * \sa VL6180x_InitData(), VL6180x_GetOffsetCalibrationData()
gallonm 10:4954b09b72d8 694 * @param dev The device
gallonm 10:4954b09b72d8 695 * @param offset Offset
gallonm 10:4954b09b72d8 696 */
gallonm 10:4954b09b72d8 697 void VL6180x_SetOffsetCalibrationData(VL6180xDev_t dev, int8_t offset);
gallonm 10:4954b09b72d8 698
gallonm 10:4954b09b72d8 699 /**
gallonm 10:4954b09b72d8 700 * @brief Set Cross talk compensation rate
gallonm 10:4954b09b72d8 701 *
gallonm 10:4954b09b72d8 702 * @par Function Description
gallonm 10:4954b09b72d8 703 * It programs register @a #SYSRANGE_CROSSTALK_COMPENSATION_RATE
gallonm 10:4954b09b72d8 704 *
gallonm 10:4954b09b72d8 705 * @param dev The device
gallonm 10:4954b09b72d8 706 * @param Rate Compensation rate (9.7 fix point) see datasheet for details
gallonm 10:4954b09b72d8 707 * @return 0 on success
gallonm 10:4954b09b72d8 708 */
gallonm 10:4954b09b72d8 709 int VL6180x_SetXTalkCompensationRate(VL6180xDev_t dev, FixPoint97_t Rate);
gallonm 10:4954b09b72d8 710
gallonm 10:4954b09b72d8 711 /** @} */
gallonm 10:4954b09b72d8 712
gallonm 10:4954b09b72d8 713
gallonm 10:4954b09b72d8 714
gallonm 10:4954b09b72d8 715 #if VL6180x_ALS_SUPPORT
gallonm 10:4954b09b72d8 716 /** @defgroup api_ll_als ALS functions
gallonm 10:4954b09b72d8 717 * @brief ALS functions
gallonm 10:4954b09b72d8 718 * @ingroup api_ll
gallonm 10:4954b09b72d8 719 * @{
gallonm 10:4954b09b72d8 720 */
gallonm 10:4954b09b72d8 721
gallonm 10:4954b09b72d8 722 /**
gallonm 10:4954b09b72d8 723 * @brief Wait for device to be ready for new als operation or max pollign loop (time out)
gallonm 10:4954b09b72d8 724 * @param dev The device
gallonm 10:4954b09b72d8 725 * @param MaxLoop Max Number of i2c polling loop see @a #msec_2_i2cloop
gallonm 10:4954b09b72d8 726 * @return 0 on success. <0 when @a VL6180x_ErrCode_t::TIME_OUT if timed out
gallonm 10:4954b09b72d8 727 */
gallonm 10:4954b09b72d8 728 int VL6180x_AlsWaitDeviceReady(VL6180xDev_t dev, int MaxLoop );
gallonm 10:4954b09b72d8 729
gallonm 10:4954b09b72d8 730 /**
gallonm 10:4954b09b72d8 731 * @brief Set ALS system mode and start/stop measure
gallonm 10:4954b09b72d8 732 *
gallonm 10:4954b09b72d8 733 * @warning When used outside after single shot polling, \n
gallonm 10:4954b09b72d8 734 * User must ensure the device state is ready before issuing a new command (using @a VL6180x_AlsWaitDeviceReady()). \n
gallonm 10:4954b09b72d8 735 * Non respect of this, can cause loss of interrupt or device hanging.
gallonm 10:4954b09b72d8 736 *
gallonm 10:4954b09b72d8 737 * @param dev The device
gallonm 10:4954b09b72d8 738 * @param mode A combination of working mode (#MODE_SINGLESHOT or #MODE_CONTINUOUS) and start condition (#MODE_START_STOP) \n
gallonm 10:4954b09b72d8 739 * @return 0 on success
gallonm 10:4954b09b72d8 740 */
gallonm 10:4954b09b72d8 741 int VL6180x_AlsSetSystemMode(VL6180xDev_t dev, uint8_t mode);
gallonm 10:4954b09b72d8 742
gallonm 10:4954b09b72d8 743 /** @} */
gallonm 10:4954b09b72d8 744 #endif
gallonm 10:4954b09b72d8 745
gallonm 10:4954b09b72d8 746 /** @defgroup api_ll_misc Misc functions
gallonm 10:4954b09b72d8 747 * @brief Misc functions
gallonm 10:4954b09b72d8 748 * @ingroup api_ll
gallonm 10:4954b09b72d8 749 * @{
gallonm 10:4954b09b72d8 750 */
gallonm 10:4954b09b72d8 751
gallonm 10:4954b09b72d8 752 /**
gallonm 10:4954b09b72d8 753 * Set Group parameter Hold state
gallonm 10:4954b09b72d8 754 *
gallonm 10:4954b09b72d8 755 * @par Function Description
gallonm 10:4954b09b72d8 756 * Group parameter holds @a #SYSTEM_GROUPED_PARAMETER_HOLD enable safe update (non atomic across multiple measure) by host
gallonm 10:4954b09b72d8 757 * \n The critical register group is composed of: \n
gallonm 10:4954b09b72d8 758 * #SYSTEM_INTERRUPT_CONFIG_GPIO \n
gallonm 10:4954b09b72d8 759 * #SYSRANGE_THRESH_HIGH \n
gallonm 10:4954b09b72d8 760 * #SYSRANGE_THRESH_LOW \n
gallonm 10:4954b09b72d8 761 * #SYSALS_INTEGRATION_PERIOD \n
gallonm 10:4954b09b72d8 762 * #SYSALS_ANALOGUE_GAIN \n
gallonm 10:4954b09b72d8 763 * #SYSALS_THRESH_HIGH \n
gallonm 10:4954b09b72d8 764 * #SYSALS_THRESH_LOW
gallonm 10:4954b09b72d8 765 *
gallonm 10:4954b09b72d8 766 *
gallonm 10:4954b09b72d8 767 * @param dev The device
gallonm 10:4954b09b72d8 768 * @param Hold Group parameter Hold state to be set (on/off)
gallonm 10:4954b09b72d8 769 * @return 0 on success
gallonm 10:4954b09b72d8 770 */
gallonm 10:4954b09b72d8 771 int VL6180x_SetGroupParamHold(VL6180xDev_t dev, int Hold);
gallonm 10:4954b09b72d8 772
gallonm 10:4954b09b72d8 773 /**
gallonm 10:4954b09b72d8 774 * @brief Set new device i2c address
gallonm 10:4954b09b72d8 775 *
gallonm 10:4954b09b72d8 776 * After completion the device will answer to the new address programmed.
gallonm 10:4954b09b72d8 777 *
gallonm 10:4954b09b72d8 778 * @sa AN4478: Using multiple VL6180X's in a single design
gallonm 10:4954b09b72d8 779 * @param dev The device
gallonm 10:4954b09b72d8 780 * @param NewAddr The new i2c address (7bit)
gallonm 10:4954b09b72d8 781 * @return 0 on success
gallonm 10:4954b09b72d8 782 */
gallonm 10:4954b09b72d8 783 int VL6180x_SetI2CAddress(VL6180xDev_t dev, uint8_t NewAddr);
gallonm 10:4954b09b72d8 784
gallonm 10:4954b09b72d8 785 /**
gallonm 10:4954b09b72d8 786 * @brief Fully configure gpio 0/1 pin : polarity and functionality
gallonm 10:4954b09b72d8 787 *
gallonm 10:4954b09b72d8 788 * @param dev The device
gallonm 10:4954b09b72d8 789 * @param pin gpio pin 0 or 1
gallonm 10:4954b09b72d8 790 * @param IntFunction Pin functionality : either #GPIOx_SELECT_OFF or #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to #SYSTEM_MODE_GPIO1 register definition)
gallonm 10:4954b09b72d8 791 * @param ActiveHigh Set active high polarity, or active low see @a ::IntrPol_e
gallonm 10:4954b09b72d8 792 * @return 0 on success
gallonm 10:4954b09b72d8 793 */
gallonm 10:4954b09b72d8 794 int VL6180x_SetupGPIOx(VL6180xDev_t dev, int pin, uint8_t IntFunction, int ActiveHigh);
gallonm 10:4954b09b72d8 795
gallonm 10:4954b09b72d8 796
gallonm 10:4954b09b72d8 797 /**
gallonm 10:4954b09b72d8 798 * @brief Set interrupt pin polarity for the given GPIO
gallonm 10:4954b09b72d8 799 *
gallonm 10:4954b09b72d8 800 * @param dev The device
gallonm 10:4954b09b72d8 801 * @param pin Pin 0 or 1
gallonm 10:4954b09b72d8 802 * @param active_high select active high or low polarity using @ref IntrPol_e
gallonm 10:4954b09b72d8 803 * @return 0 on success
gallonm 10:4954b09b72d8 804 */
gallonm 10:4954b09b72d8 805 int VL6180x_SetGPIOxPolarity(VL6180xDev_t dev, int pin, int active_high);
gallonm 10:4954b09b72d8 806
gallonm 10:4954b09b72d8 807 /**
gallonm 10:4954b09b72d8 808 * Select interrupt functionality for the given GPIO
gallonm 10:4954b09b72d8 809 *
gallonm 10:4954b09b72d8 810 * @par Function Description
gallonm 10:4954b09b72d8 811 * Functionality refer to @a SYSTEM_MODE_GPIO0
gallonm 10:4954b09b72d8 812 *
gallonm 10:4954b09b72d8 813 * @param dev The device
gallonm 10:4954b09b72d8 814 * @param pin Pin to configure 0 or 1 (gpio0 or gpio1)\nNote that gpio0 is chip enable at power up !
gallonm 10:4954b09b72d8 815 * @param functionality Pin functionality : either #GPIOx_SELECT_OFF or #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to #SYSTEM_MODE_GPIO1 register definition)
gallonm 10:4954b09b72d8 816 * @return 0 on success
gallonm 10:4954b09b72d8 817 */
gallonm 10:4954b09b72d8 818 int VL6180x_SetGPIOxFunctionality(VL6180xDev_t dev, int pin, uint8_t functionality);
gallonm 10:4954b09b72d8 819
gallonm 10:4954b09b72d8 820 /**
gallonm 10:4954b09b72d8 821 * #brief Disable and turn to Hi-Z gpio output pin
gallonm 10:4954b09b72d8 822 *
gallonm 10:4954b09b72d8 823 * @param dev The device
gallonm 10:4954b09b72d8 824 * @param pin The pin number to disable 0 or 1
gallonm 10:4954b09b72d8 825 * @return 0 on success
gallonm 10:4954b09b72d8 826 */
gallonm 10:4954b09b72d8 827 int VL6180x_DisableGPIOxOut(VL6180xDev_t dev, int pin);
gallonm 10:4954b09b72d8 828
gallonm 10:4954b09b72d8 829 /**
gallonm 10:4954b09b72d8 830 * @def msec_2_i2cloop
gallonm 10:4954b09b72d8 831 * @brief Number of I2C polling loop (an 8 bit register) to run for maximal wait time.
gallonm 10:4954b09b72d8 832 *
gallonm 10:4954b09b72d8 833 * @par Function Description
gallonm 10:4954b09b72d8 834 * When polling via I2C the overall time is mainly the I2C transaction time because it is a slow bus
gallonm 10:4954b09b72d8 835 * one 8 bit register poll on I2C bus timing is shown below: \n
gallonm 10:4954b09b72d8 836 * start + addr_w(a) + 2x8bit index(a) + stop + start + addr_rd(a) + 1x8bit data_rd(a) + stop \n
gallonm 10:4954b09b72d8 837 * 1 8 1 2*(8+1) 1 1 8 1 8 1 1 \n
gallonm 10:4954b09b72d8 838 * so 49 serial bits
gallonm 10:4954b09b72d8 839 *
gallonm 10:4954b09b72d8 840 * @param time_ms Time to wait in milli second 10
gallonm 10:4954b09b72d8 841 * @param i2c_khz I2C bus frequencies in KHz for instance 400
gallonm 10:4954b09b72d8 842 * @return The number of loops (at least 1)
gallonm 10:4954b09b72d8 843 */
gallonm 10:4954b09b72d8 844 #define msec_2_i2cloop( time_ms, i2c_khz ) (((time_ms)*(i2c_khz)/49)+1)
gallonm 10:4954b09b72d8 845
gallonm 10:4954b09b72d8 846 /** @} */
gallonm 10:4954b09b72d8 847
gallonm 10:4954b09b72d8 848
gallonm 10:4954b09b72d8 849
gallonm 10:4954b09b72d8 850 /**
gallonm 10:4954b09b72d8 851 * polarity use in @a VL6180x_SetupGPIOx() , @a VL6180x_SetupGPIO1()
gallonm 10:4954b09b72d8 852 */
gallonm 10:4954b09b72d8 853 typedef enum {
gallonm 10:4954b09b72d8 854 INTR_POL_LOW =0, /*!< set active low polarity best setup for falling edge */
gallonm 10:4954b09b72d8 855 INTR_POL_HIGH =1, /*!< set active high polarity best setup for rising edge */
gallonm 10:4954b09b72d8 856 }IntrPol_e;
gallonm 10:4954b09b72d8 857
gallonm 10:4954b09b72d8 858 /** @defgroup api_ll_intr Interrupts management functions
gallonm 10:4954b09b72d8 859 * @brief Interrupts management functions
gallonm 10:4954b09b72d8 860 * @ingroup api_ll
gallonm 10:4954b09b72d8 861 * @{
gallonm 10:4954b09b72d8 862 */
gallonm 10:4954b09b72d8 863
gallonm 10:4954b09b72d8 864 /**
gallonm 10:4954b09b72d8 865 * @brief Get all interrupts cause
gallonm 10:4954b09b72d8 866 *
gallonm 10:4954b09b72d8 867 * @param dev The device
gallonm 10:4954b09b72d8 868 * @param status Ptr to interrupt status. You can use @a IntrStatus_t::val
gallonm 10:4954b09b72d8 869 * @return 0 on success
gallonm 10:4954b09b72d8 870 */
gallonm 10:4954b09b72d8 871 int VL6180x_GetInterruptStatus(VL6180xDev_t dev, uint8_t *status);
gallonm 10:4954b09b72d8 872
gallonm 10:4954b09b72d8 873 /**
gallonm 10:4954b09b72d8 874 * @brief Clear given system interrupt condition
gallonm 10:4954b09b72d8 875 *
gallonm 10:4954b09b72d8 876 * @par Function Description
gallonm 10:4954b09b72d8 877 * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register.
gallonm 10:4954b09b72d8 878 * @param dev The device
gallonm 10:4954b09b72d8 879 * @param IntClear Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR.
gallonm 10:4954b09b72d8 880 * @return 0 On success
gallonm 10:4954b09b72d8 881 */
gallonm 10:4954b09b72d8 882 int VL6180x_ClearInterrupt(VL6180xDev_t dev, uint8_t IntClear );
gallonm 10:4954b09b72d8 883
gallonm 10:4954b09b72d8 884 /**
gallonm 10:4954b09b72d8 885 * @brief Clear error interrupt
gallonm 10:4954b09b72d8 886 *
gallonm 10:4954b09b72d8 887 * @param dev The device
gallonm 10:4954b09b72d8 888 * @return 0 On success
gallonm 10:4954b09b72d8 889 */
gallonm 10:4954b09b72d8 890 #define VL6180x_ClearErrorInterrupt(dev) VL6180x_ClearInterrupt(dev, INTERRUPT_CLEAR_ERROR)
gallonm 10:4954b09b72d8 891
gallonm 10:4954b09b72d8 892 /**
gallonm 10:4954b09b72d8 893 * @brief Clear All interrupt causes (als+range+error)
gallonm 10:4954b09b72d8 894 *
gallonm 10:4954b09b72d8 895 * @param dev The device
gallonm 10:4954b09b72d8 896 * @return 0 On success
gallonm 10:4954b09b72d8 897 */
gallonm 10:4954b09b72d8 898 #define VL6180x_ClearAllInterrupt(dev) VL6180x_ClearInterrupt(dev, INTERRUPT_CLEAR_ERROR|INTERRUPT_CLEAR_RANGING|INTERRUPT_CLEAR_ALS)
gallonm 10:4954b09b72d8 899
gallonm 10:4954b09b72d8 900 /** @} */
gallonm 10:4954b09b72d8 901
gallonm 10:4954b09b72d8 902
gallonm 10:4954b09b72d8 903 /** @defgroup api_reg API Register access functions
gallonm 10:4954b09b72d8 904 * @brief Registers access functions called by API core functions
gallonm 10:4954b09b72d8 905 * @ingroup api_ll
gallonm 10:4954b09b72d8 906 * @{
gallonm 10:4954b09b72d8 907 */
gallonm 10:4954b09b72d8 908
gallonm 10:4954b09b72d8 909 /**
gallonm 10:4954b09b72d8 910 * Write VL6180x single byte register
gallonm 10:4954b09b72d8 911 * @param dev The device
gallonm 10:4954b09b72d8 912 * @param index The register index
gallonm 10:4954b09b72d8 913 * @param data 8 bit register data
gallonm 10:4954b09b72d8 914 * @return success
gallonm 10:4954b09b72d8 915 */
gallonm 10:4954b09b72d8 916 int VL6180x_WrByte(VL6180xDev_t dev, uint16_t index, uint8_t data);
gallonm 10:4954b09b72d8 917 /**
gallonm 10:4954b09b72d8 918 * Thread safe VL6180x Update (rd/modify/write) single byte register
gallonm 10:4954b09b72d8 919 *
gallonm 10:4954b09b72d8 920 * Final_reg = (Initial_reg & and_data) |or_data
gallonm 10:4954b09b72d8 921 *
gallonm 10:4954b09b72d8 922 * @param dev The device
gallonm 10:4954b09b72d8 923 * @param index The register index
gallonm 10:4954b09b72d8 924 * @param AndData 8 bit and data
gallonm 10:4954b09b72d8 925 * @param OrData 8 bit or data
gallonm 10:4954b09b72d8 926 * @return 0 on success
gallonm 10:4954b09b72d8 927 */
gallonm 10:4954b09b72d8 928 int VL6180x_UpdateByte(VL6180xDev_t dev, uint16_t index, uint8_t AndData, uint8_t OrData);
gallonm 10:4954b09b72d8 929 /**
gallonm 10:4954b09b72d8 930 * Write VL6180x word register
gallonm 10:4954b09b72d8 931 * @param dev The device
gallonm 10:4954b09b72d8 932 * @param index The register index
gallonm 10:4954b09b72d8 933 * @param data 16 bit register data
gallonm 10:4954b09b72d8 934 * @return 0 on success
gallonm 10:4954b09b72d8 935 */
gallonm 10:4954b09b72d8 936 int VL6180x_WrWord(VL6180xDev_t dev, uint16_t index, uint16_t data);
gallonm 10:4954b09b72d8 937 /**
gallonm 10:4954b09b72d8 938 * Write VL6180x double word (4 byte) register
gallonm 10:4954b09b72d8 939 * @param dev The device
gallonm 10:4954b09b72d8 940 * @param index The register index
gallonm 10:4954b09b72d8 941 * @param data 32 bit register data
gallonm 10:4954b09b72d8 942 * @return 0 on success
gallonm 10:4954b09b72d8 943 */
gallonm 10:4954b09b72d8 944 int VL6180x_WrDWord(VL6180xDev_t dev, uint16_t index, uint32_t data);
gallonm 10:4954b09b72d8 945
gallonm 10:4954b09b72d8 946 /**
gallonm 10:4954b09b72d8 947 * Read VL6180x single byte register
gallonm 10:4954b09b72d8 948 * @param dev The device
gallonm 10:4954b09b72d8 949 * @param index The register index
gallonm 10:4954b09b72d8 950 * @param data pointer to 8 bit data
gallonm 10:4954b09b72d8 951 * @return 0 on success
gallonm 10:4954b09b72d8 952 */
gallonm 10:4954b09b72d8 953 int VL6180x_RdByte(VL6180xDev_t dev, uint16_t index, uint8_t *data);
gallonm 10:4954b09b72d8 954
gallonm 10:4954b09b72d8 955 /**
gallonm 10:4954b09b72d8 956 * Read VL6180x word (2byte) register
gallonm 10:4954b09b72d8 957 * @param dev The device
gallonm 10:4954b09b72d8 958 * @param index The register index
gallonm 10:4954b09b72d8 959 * @param data pointer to 16 bit data
gallonm 10:4954b09b72d8 960 * @return 0 on success
gallonm 10:4954b09b72d8 961 */
gallonm 10:4954b09b72d8 962 int VL6180x_RdWord(VL6180xDev_t dev, uint16_t index, uint16_t *data);
gallonm 10:4954b09b72d8 963
gallonm 10:4954b09b72d8 964 /**
gallonm 10:4954b09b72d8 965 * Read VL6180x dword (4byte) register
gallonm 10:4954b09b72d8 966 * @param dev The device
gallonm 10:4954b09b72d8 967 * @param index The register index
gallonm 10:4954b09b72d8 968 * @param data pointer to 32 bit data
gallonm 10:4954b09b72d8 969 * @return 0 on success
gallonm 10:4954b09b72d8 970 */
gallonm 10:4954b09b72d8 971 int VL6180x_RdDWord(VL6180xDev_t dev, uint16_t index, uint32_t *data);
gallonm 10:4954b09b72d8 972
gallonm 10:4954b09b72d8 973 /** @} */
gallonm 10:4954b09b72d8 974
gallonm 10:4954b09b72d8 975
gallonm 10:4954b09b72d8 976
gallonm 1:1de1ea2994d9 977
gallonm 1:1de1ea2994d9 978 #ifdef __cplusplus
gallonm 1:1de1ea2994d9 979 }
gallonm 1:1de1ea2994d9 980 #endif
gallonm 1:1de1ea2994d9 981
gallonm 1:1de1ea2994d9 982 #endif /* VL6180x_API_H_ */