Simple VL6180x demo for VL6180x Explorer shield with Nucleo F401 adapted from SparkFun example.

Dependents:   VL6180X VL6180X_Explorer VL6180X_Explorer VL6180X ... more

Committer:
highroads
Date:
Fri Jun 17 17:11:04 2016 +0000
Revision:
6:99fb447bba81
Parent:
5:fa7d17a114d2
Change address should change m_addr

Who changed what in which revision?

UserRevisionLine numberNew contents of line
highroads 2:31313127c530 1 /**
highroads 2:31313127c530 2 * @file VL6180x.h
highroads 2:31313127c530 3 * @brief Library for VL6180x time of flight range finder.
highroads 3:4a20f2102acf 4 * Version for mbed
highroads 3:4a20f2102acf 5 * Ian Kilburn 5/10/2015
highroads 0:4a5d4b4a40c4 6 * Casey Kuhns @ SparkFun Electronics
highroads 0:4a5d4b4a40c4 7 * 10/29/2014
highroads 0:4a5d4b4a40c4 8 * https://github.com/sparkfun/
highroads 0:4a5d4b4a40c4 9 *
highroads 0:4a5d4b4a40c4 10 * The VL6180x by ST micro is a time of flight range finder that
highroads 0:4a5d4b4a40c4 11 * uses pulsed IR light to determine distances from object at close
highroads 0:4a5d4b4a40c4 12 * range. The average range of a sensor is between 0-200mm
highroads 0:4a5d4b4a40c4 13 *
highroads 0:4a5d4b4a40c4 14 * In this file are the function prototypes in the VL6180x class
highroads 0:4a5d4b4a40c4 15 *
highroads 0:4a5d4b4a40c4 16 * Resources:
highroads 0:4a5d4b4a40c4 17 * This library uses the Arduino Wire.h to complete I2C transactions.
highroads 0:4a5d4b4a40c4 18 *
highroads 0:4a5d4b4a40c4 19 * Development environment specifics:
highroads 0:4a5d4b4a40c4 20 * IDE: Arduino 1.0.5
highroads 0:4a5d4b4a40c4 21 * Hardware Platform: Arduino Pro 3.3V/8MHz
highroads 0:4a5d4b4a40c4 22 * VL6180x Breakout Version: 1.0
highroads 0:4a5d4b4a40c4 23 *
highroads 0:4a5d4b4a40c4 24 * Some settings and initial values come from code written by Kris Winer
highroads 0:4a5d4b4a40c4 25 * VL6180X_t3 Basic Example Code
highroads 0:4a5d4b4a40c4 26 * by: Kris Winer
highroads 0:4a5d4b4a40c4 27 * date: September 1, 2014
highroads 0:4a5d4b4a40c4 28 * license: Beerware - Use this code however you'd like. If you
highroads 0:4a5d4b4a40c4 29 * find it useful you can buy me a beer some time.
highroads 0:4a5d4b4a40c4 30 *
highroads 0:4a5d4b4a40c4 31 * This code is beerware. If you see me (or any other SparkFun employee) at the
highroads 0:4a5d4b4a40c4 32 * local pub, and you've found our code helpful, please buy us a round!
highroads 0:4a5d4b4a40c4 33 *
highroads 0:4a5d4b4a40c4 34 * Distributed as-is; no warranty is given.
highroads 2:31313127c530 35 */
highroads 0:4a5d4b4a40c4 36 #include "mbed.h"
highroads 0:4a5d4b4a40c4 37 #ifndef VL6180x_h
highroads 0:4a5d4b4a40c4 38 #define VL6180x_h
highroads 0:4a5d4b4a40c4 39
highroads 0:4a5d4b4a40c4 40 #define VL6180x_FAILURE_RESET -1
highroads 0:4a5d4b4a40c4 41
highroads 0:4a5d4b4a40c4 42 #define VL6180X_IDENTIFICATION_MODEL_ID 0x0000
highroads 0:4a5d4b4a40c4 43 #define VL6180X_IDENTIFICATION_MODEL_REV_MAJOR 0x0001
highroads 0:4a5d4b4a40c4 44 #define VL6180X_IDENTIFICATION_MODEL_REV_MINOR 0x0002
highroads 0:4a5d4b4a40c4 45 #define VL6180X_IDENTIFICATION_MODULE_REV_MAJOR 0x0003
highroads 0:4a5d4b4a40c4 46 #define VL6180X_IDENTIFICATION_MODULE_REV_MINOR 0x0004
highroads 0:4a5d4b4a40c4 47 #define VL6180X_IDENTIFICATION_DATE 0x0006 //16bit value
highroads 0:4a5d4b4a40c4 48 #define VL6180X_IDENTIFICATION_TIME 0x0008 //16bit value
highroads 0:4a5d4b4a40c4 49
highroads 0:4a5d4b4a40c4 50 #define VL6180X_SYSTEM_MODE_GPIO0 0x0010
highroads 0:4a5d4b4a40c4 51 #define VL6180X_SYSTEM_MODE_GPIO1 0x0011
highroads 0:4a5d4b4a40c4 52 #define VL6180X_SYSTEM_HISTORY_CTRL 0x0012
highroads 0:4a5d4b4a40c4 53 #define VL6180X_SYSTEM_INTERRUPT_CONFIG_GPIO 0x0014
highroads 0:4a5d4b4a40c4 54 #define VL6180X_SYSTEM_INTERRUPT_CLEAR 0x0015
highroads 0:4a5d4b4a40c4 55 #define VL6180X_SYSTEM_FRESH_OUT_OF_RESET 0x0016
highroads 0:4a5d4b4a40c4 56 #define VL6180X_SYSTEM_GROUPED_PARAMETER_HOLD 0x0017
highroads 0:4a5d4b4a40c4 57
highroads 0:4a5d4b4a40c4 58 #define VL6180X_SYSRANGE_START 0x0018
highroads 0:4a5d4b4a40c4 59 #define VL6180X_SYSRANGE_THRESH_HIGH 0x0019
highroads 0:4a5d4b4a40c4 60 #define VL6180X_SYSRANGE_THRESH_LOW 0x001A
highroads 0:4a5d4b4a40c4 61 #define VL6180X_SYSRANGE_INTERMEASUREMENT_PERIOD 0x001B
highroads 0:4a5d4b4a40c4 62 #define VL6180X_SYSRANGE_MAX_CONVERGENCE_TIME 0x001C
highroads 0:4a5d4b4a40c4 63 #define VL6180X_SYSRANGE_CROSSTALK_COMPENSATION_RATE 0x001E
highroads 0:4a5d4b4a40c4 64 #define VL6180X_SYSRANGE_CROSSTALK_VALID_HEIGHT 0x0021
highroads 0:4a5d4b4a40c4 65 #define VL6180X_SYSRANGE_EARLY_CONVERGENCE_ESTIMATE 0x0022
highroads 0:4a5d4b4a40c4 66 #define VL6180X_SYSRANGE_PART_TO_PART_RANGE_OFFSET 0x0024
highroads 0:4a5d4b4a40c4 67 #define VL6180X_SYSRANGE_RANGE_IGNORE_VALID_HEIGHT 0x0025
highroads 0:4a5d4b4a40c4 68 #define VL6180X_SYSRANGE_RANGE_IGNORE_THRESHOLD 0x0026
highroads 0:4a5d4b4a40c4 69 #define VL6180X_SYSRANGE_MAX_AMBIENT_LEVEL_MULT 0x002C
highroads 0:4a5d4b4a40c4 70 #define VL6180X_SYSRANGE_RANGE_CHECK_ENABLES 0x002D
highroads 0:4a5d4b4a40c4 71 #define VL6180X_SYSRANGE_VHV_RECALIBRATE 0x002E
highroads 0:4a5d4b4a40c4 72 #define VL6180X_SYSRANGE_VHV_REPEAT_RATE 0x0031
highroads 0:4a5d4b4a40c4 73
highroads 0:4a5d4b4a40c4 74 #define VL6180X_SYSALS_START 0x0038
highroads 0:4a5d4b4a40c4 75 #define VL6180X_SYSALS_THRESH_HIGH 0x003A
highroads 0:4a5d4b4a40c4 76 #define VL6180X_SYSALS_THRESH_LOW 0x003C
highroads 0:4a5d4b4a40c4 77 #define VL6180X_SYSALS_INTERMEASUREMENT_PERIOD 0x003E
highroads 0:4a5d4b4a40c4 78 #define VL6180X_SYSALS_ANALOGUE_GAIN 0x003F
highroads 0:4a5d4b4a40c4 79 #define VL6180X_SYSALS_INTEGRATION_PERIOD 0x0040
highroads 0:4a5d4b4a40c4 80
highroads 0:4a5d4b4a40c4 81 #define VL6180X_RESULT_RANGE_STATUS 0x004D
highroads 0:4a5d4b4a40c4 82 #define VL6180X_RESULT_ALS_STATUS 0x004E
highroads 0:4a5d4b4a40c4 83 #define VL6180X_RESULT_INTERRUPT_STATUS_GPIO 0x004F
highroads 0:4a5d4b4a40c4 84 #define VL6180X_RESULT_ALS_VAL 0x0050
highroads 0:4a5d4b4a40c4 85 #define VL6180X_RESULT_HISTORY_BUFFER 0x0052
highroads 0:4a5d4b4a40c4 86 #define VL6180X_RESULT_RANGE_VAL 0x0062
highroads 0:4a5d4b4a40c4 87 #define VL6180X_RESULT_RANGE_RAW 0x0064
highroads 0:4a5d4b4a40c4 88 #define VL6180X_RESULT_RANGE_RETURN_RATE 0x0066
highroads 0:4a5d4b4a40c4 89 #define VL6180X_RESULT_RANGE_REFERENCE_RATE 0x0068
highroads 0:4a5d4b4a40c4 90 #define VL6180X_RESULT_RANGE_RETURN_SIGNAL_COUNT 0x006C
highroads 0:4a5d4b4a40c4 91 #define VL6180X_RESULT_RANGE_REFERENCE_SIGNAL_COUNT 0x0070
highroads 0:4a5d4b4a40c4 92 #define VL6180X_RESULT_RANGE_RETURN_AMB_COUNT 0x0074
highroads 0:4a5d4b4a40c4 93 #define VL6180X_RESULT_RANGE_REFERENCE_AMB_COUNT 0x0078
highroads 0:4a5d4b4a40c4 94 #define VL6180X_RESULT_RANGE_RETURN_CONV_TIME 0x007C
highroads 0:4a5d4b4a40c4 95 #define VL6180X_RESULT_RANGE_REFERENCE_CONV_TIME 0x0080
highroads 0:4a5d4b4a40c4 96
highroads 0:4a5d4b4a40c4 97 #define VL6180X_READOUT_AVERAGING_SAMPLE_PERIOD 0x010A
highroads 0:4a5d4b4a40c4 98 #define VL6180X_FIRMWARE_BOOTUP 0x0119
highroads 0:4a5d4b4a40c4 99 #define VL6180X_FIRMWARE_RESULT_SCALER 0x0120
highroads 0:4a5d4b4a40c4 100 #define VL6180X_I2C_SLAVE_DEVICE_ADDRESS 0x0212
highroads 0:4a5d4b4a40c4 101 #define VL6180X_INTERLEAVED_MODE_ENABLE 0x02A3
highroads 0:4a5d4b4a40c4 102
highroads 2:31313127c530 103 /**
highroads 2:31313127c530 104 * gain settings for ALS
highroads 2:31313127c530 105 *Data sheet shows gain values as binary list
highroads 2:31313127c530 106 */
highroads 2:31313127c530 107 enum vl6180x_als_gain {
highroads 0:4a5d4b4a40c4 108
highroads 0:4a5d4b4a40c4 109 GAIN_20 = 0, // Actual ALS Gain of 20
highroads 0:4a5d4b4a40c4 110 GAIN_10, // Actual ALS Gain of 10.32
highroads 0:4a5d4b4a40c4 111 GAIN_5, // Actual ALS Gain of 5.21
highroads 0:4a5d4b4a40c4 112 GAIN_2_5, // Actual ALS Gain of 2.60
highroads 0:4a5d4b4a40c4 113 GAIN_1_67, // Actual ALS Gain of 1.72
highroads 0:4a5d4b4a40c4 114 GAIN_1_25, // Actual ALS Gain of 1.28
highroads 0:4a5d4b4a40c4 115 GAIN_1 , // Actual ALS Gain of 1.01
highroads 0:4a5d4b4a40c4 116 GAIN_40, // Actual ALS Gain of 40
highroads 0:4a5d4b4a40c4 117
highroads 0:4a5d4b4a40c4 118 };
highroads 2:31313127c530 119 /**
highroads 2:31313127c530 120 * VL6180xIdentification
highroads 2:31313127c530 121 * @brief structure to hold module identification
highroads 2:31313127c530 122 *
highroads 2:31313127c530 123 */
highroads 2:31313127c530 124 struct VL6180xIdentification {
highroads 3:4a20f2102acf 125 /** Model Number */
highroads 0:4a5d4b4a40c4 126 uint8_t idModel;
highroads 3:4a20f2102acf 127 /** Model Number */
highroads 0:4a5d4b4a40c4 128 uint8_t idModelRevMajor;
highroads 3:4a20f2102acf 129 /** Model Number */
highroads 0:4a5d4b4a40c4 130 uint8_t idModelRevMinor;
highroads 3:4a20f2102acf 131 /** Module major revision */
highroads 0:4a5d4b4a40c4 132 uint8_t idModuleRevMajor;
highroads 3:4a20f2102acf 133 /** Module minor revision */
highroads 0:4a5d4b4a40c4 134 uint8_t idModuleRevMinor;
highroads 3:4a20f2102acf 135 /** Manufacture date */
highroads 3:4a20f2102acf 136 uint16_t idDate;
highroads 3:4a20f2102acf 137 /** Manufacture time seconds after midnight */
highroads 3:4a20f2102acf 138 uint16_t idTime;
highroads 3:4a20f2102acf 139 };
highroads 2:31313127c530 140 /**
highroads 2:31313127c530 141 * VL6180x tof/als sensor example
highroads 2:31313127c530 142 *
highroads 2:31313127c530 143 * @code
highroads 2:31313127c530 144 #include "mbed.h"
highroads 2:31313127c530 145 #include <VL6180x.h>
highroads 0:4a5d4b4a40c4 146
highroads 2:31313127c530 147 const float GAIN_1 = 1.01; // Actual ALS Gain of 1.01
highroads 2:31313127c530 148 const float GAIN_1_25 = 1.28; // Actual ALS Gain of 1.28
highroads 2:31313127c530 149 const float GAIN_1_67 = 1.72; // Actual ALS Gain of 1.72
highroads 2:31313127c530 150 const float GAIN_2_5 = 2.6; // Actual ALS Gain of 2.60
highroads 2:31313127c530 151 const float GAIN_5 = 5.21; // Actual ALS Gain of 5.21
highroads 2:31313127c530 152 const float GAIN_10 = 10.32; // Actual ALS Gain of 10.32
highroads 2:31313127c530 153 const float GAIN_20 = 20; // Actual ALS Gain of 20
highroads 2:31313127c530 154 const float GAIN_40 = 40; // Actual ALS Gain of 40
highroads 2:31313127c530 155
highroads 2:31313127c530 156
highroads 2:31313127c530 157 #define VL6180X_ADDRESS 0x29
highroads 2:31313127c530 158
highroads 2:31313127c530 159 VL6180xIdentification identification;
highroads 2:31313127c530 160 // mbed uses 8bit addresses shift address by 1 bit left
highroads 2:31313127c530 161 VL6180x sensor(D14, D15, VL6180X_ADDRESS<<1);
highroads 2:31313127c530 162
highroads 2:31313127c530 163 void printIdentification(struct VL6180xIdentification *temp){
highroads 2:31313127c530 164 printf("Model ID = ");
highroads 2:31313127c530 165 printf("%d\n",temp->idModel);
highroads 2:31313127c530 166
highroads 2:31313127c530 167 printf("Model Rev = ");
highroads 2:31313127c530 168 printf("%d",temp->idModelRevMajor);
highroads 2:31313127c530 169 printf(".");
highroads 2:31313127c530 170 printf("%d\n",temp->idModelRevMinor);
highroads 2:31313127c530 171
highroads 2:31313127c530 172 printf("Module Rev = ");
highroads 2:31313127c530 173 printf("%d",temp->idModuleRevMajor);
highroads 2:31313127c530 174 printf(".");
highroads 2:31313127c530 175 printf("%d\n",temp->idModuleRevMinor);
highroads 2:31313127c530 176
highroads 2:31313127c530 177 printf("Manufacture Date = ");
highroads 2:31313127c530 178 printf("%d",((temp->idDate >> 3) & 0x001F));
highroads 2:31313127c530 179 printf("/");
highroads 2:31313127c530 180 printf("%d",((temp->idDate >> 8) & 0x000F));
highroads 2:31313127c530 181 printf("/1");
highroads 2:31313127c530 182 printf("%d\n",((temp->idDate >> 12) & 0x000F));
highroads 2:31313127c530 183 printf(" Phase: ");
highroads 2:31313127c530 184 printf("%d\n",(temp->idDate & 0x0007));
highroads 2:31313127c530 185
highroads 2:31313127c530 186 printf("Manufacture Time (s)= ");
highroads 2:31313127c530 187 printf("%d\n",(temp->idTime * 2));
highroads 2:31313127c530 188 printf("\n\n");
highroads 2:31313127c530 189 }
highroads 2:31313127c530 190 int main() {
highroads 2:31313127c530 191
highroads 2:31313127c530 192 wait_ms(100); // delay .1s
highroads 2:31313127c530 193
highroads 2:31313127c530 194 sensor.getIdentification(&identification); // Retrieve manufacture info from device memory
highroads 2:31313127c530 195 printIdentification(&identification); // Helper function to print all the Module information
highroads 2:31313127c530 196
highroads 2:31313127c530 197 if(sensor.VL6180xInit() != 0){
highroads 2:31313127c530 198 printf("FAILED TO INITALIZE\n"); //Initialize device and check for errors
highroads 2:31313127c530 199 };
highroads 2:31313127c530 200
highroads 2:31313127c530 201 sensor.VL6180xDefautSettings(); //Load default settings to get started.
highroads 2:31313127c530 202
highroads 2:31313127c530 203 wait_ms(1000); // delay 1s
highroads 2:31313127c530 204
highroads 2:31313127c530 205
highroads 2:31313127c530 206
highroads 2:31313127c530 207 while(1) {
highroads 2:31313127c530 208 //Get Ambient Light level and report in LUX
highroads 2:31313127c530 209 printf("Ambient Light Level (Lux) = ");
highroads 2:31313127c530 210
highroads 2:31313127c530 211 //Input GAIN for light levels,
highroads 2:31313127c530 212 // GAIN_20 // Actual ALS Gain of 20
highroads 2:31313127c530 213 // GAIN_10 // Actual ALS Gain of 10.32
highroads 2:31313127c530 214 // GAIN_5 // Actual ALS Gain of 5.21
highroads 2:31313127c530 215 // GAIN_2_5 // Actual ALS Gain of 2.60
highroads 2:31313127c530 216 // GAIN_1_67 // Actual ALS Gain of 1.72
highroads 2:31313127c530 217 // GAIN_1_25 // Actual ALS Gain of 1.28
highroads 2:31313127c530 218 // GAIN_1 // Actual ALS Gain of 1.01
highroads 2:31313127c530 219 // GAIN_40 // Actual ALS Gain of 40
highroads 2:31313127c530 220
highroads 2:31313127c530 221 printf("%f\n",sensor.getAmbientLight(GAIN_1) );
highroads 2:31313127c530 222
highroads 2:31313127c530 223 //Get Distance and report in mm
highroads 2:31313127c530 224 printf("Distance measured (mm) = ");
highroads 2:31313127c530 225 printf("%d\n", sensor.getDistance() );
highroads 2:31313127c530 226
highroads 2:31313127c530 227 wait_ms(500);
highroads 2:31313127c530 228 }
highroads 2:31313127c530 229 }
highroads 2:31313127c530 230 * @endcode
highroads 2:31313127c530 231 */
highroads 0:4a5d4b4a40c4 232 class VL6180x
highroads 0:4a5d4b4a40c4 233 {
highroads 0:4a5d4b4a40c4 234 public:
highroads 2:31313127c530 235 /**
highroads 2:31313127c530 236 * VL6180x constructor
highroads 2:31313127c530 237 *
highroads 2:31313127c530 238 * @param sda SDA pin
highroads 2:31313127c530 239 * @param sdl SCL pin
highroads 4:ebaf8038c8ed 240 * @param addr (7 bit) address of the I2C peripheral
highroads 2:31313127c530 241 */
highroads 0:4a5d4b4a40c4 242 VL6180x(PinName sda, PinName scl, uint8_t addr);
highroads 2:31313127c530 243 /**
highroads 2:31313127c530 244 * VL6180x destructor
highroads 2:31313127c530 245 */
highroads 0:4a5d4b4a40c4 246 ~VL6180x();
highroads 2:31313127c530 247 /**
highroads 2:31313127c530 248 * Send mandatory settings as stated in ST datasheet.
highroads 2:31313127c530 249 * http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00122600.pdf (Section 1.3)
highroads 2:31313127c530 250 * @returns 0 if ok
highroads 2:31313127c530 251 * @returns -1 on error*/
highroads 2:31313127c530 252 int VL6180xInit(void);
highroads 2:31313127c530 253 /**
highroads 2:31313127c530 254 * Use default settings from ST data sheet section 9.
highroads 2:31313127c530 255 *
highroads 2:31313127c530 256 * http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00122600.pdf
highroads 2:31313127c530 257 */
highroads 0:4a5d4b4a40c4 258 void VL6180xDefautSettings(void);
highroads 2:31313127c530 259 /**
highroads 2:31313127c530 260 * Get Range distance in (mm)
highroads 2:31313127c530 261 * @returns TOF distance in mm
highroads 2:31313127c530 262 */
highroads 0:4a5d4b4a40c4 263 uint8_t getDistance();
highroads 2:31313127c530 264 /**
highroads 5:fa7d17a114d2 265 * Get Range distance in meters
highroads 5:fa7d17a114d2 266 * @returns TOF distance in meters
highroads 5:fa7d17a114d2 267 */
highroads 5:fa7d17a114d2 268 float getDistance_m();
highroads 5:fa7d17a114d2 269 /**
highroads 2:31313127c530 270 * Get ALS level in Lux
highroads 2:31313127c530 271 * @param vl6180x_als_gain gain setting for sensor
highroads 2:31313127c530 272 * @returns light level in Lux
highroads 2:31313127c530 273 */
highroads 0:4a5d4b4a40c4 274 float getAmbientLight(vl6180x_als_gain VL6180X_ALS_GAIN);
highroads 2:31313127c530 275 /**
highroads 2:31313127c530 276 * Load structure provided by the user with identification info
highroads 2:31313127c530 277 * Structure example:
highroads 2:31313127c530 278 * struct VL6180xIdentification
highroads 4:ebaf8038c8ed 279 * @code
highroads 4:ebaf8038c8ed 280 void printIdentification(struct VL6180xIdentification *temp){
highroads 4:ebaf8038c8ed 281 printf("Model ID = ");
highroads 4:ebaf8038c8ed 282 printf("%d\n",temp->idModel);
highroads 4:ebaf8038c8ed 283
highroads 4:ebaf8038c8ed 284 printf("Model Rev = ");
highroads 4:ebaf8038c8ed 285 printf("%d",temp->idModelRevMajor);
highroads 4:ebaf8038c8ed 286 printf(".");
highroads 4:ebaf8038c8ed 287 printf("%d\n",temp->idModelRevMinor);
highroads 4:ebaf8038c8ed 288
highroads 4:ebaf8038c8ed 289 printf("Module Rev = ");
highroads 4:ebaf8038c8ed 290 printf("%d",temp->idModuleRevMajor);
highroads 4:ebaf8038c8ed 291 printf(".");
highroads 4:ebaf8038c8ed 292 printf("%d\n",temp->idModuleRevMinor);
highroads 4:ebaf8038c8ed 293
highroads 4:ebaf8038c8ed 294 printf("Manufacture Date = ");
highroads 4:ebaf8038c8ed 295 printf("%d",((temp->idDate >> 3) & 0x001F));
highroads 4:ebaf8038c8ed 296 printf("/");
highroads 4:ebaf8038c8ed 297 printf("%d",((temp->idDate >> 8) & 0x000F));
highroads 4:ebaf8038c8ed 298 printf("/1");
highroads 4:ebaf8038c8ed 299 printf("%d\n",((temp->idDate >> 12) & 0x000F));
highroads 4:ebaf8038c8ed 300 printf(" Phase: ");
highroads 4:ebaf8038c8ed 301 printf("%d\n",(temp->idDate & 0x0007));
highroads 4:ebaf8038c8ed 302
highroads 4:ebaf8038c8ed 303 printf("Manufacture Time (s)= ");
highroads 4:ebaf8038c8ed 304 printf("%d\n",(temp->idTime * 2));
highroads 4:ebaf8038c8ed 305 printf("\n\n");
highroads 4:ebaf8038c8ed 306 *@endcode
highroads 2:31313127c530 307 */
highroads 0:4a5d4b4a40c4 308 void getIdentification(struct VL6180xIdentification *temp);
highroads 0:4a5d4b4a40c4 309
highroads 2:31313127c530 310 /**
highroads 2:31313127c530 311 * Change the default address of the device to allow multiple
highroads 2:31313127c530 312 * sensors on the bus. Can use up to 127 sensors. New address
highroads 2:31313127c530 313 * is saved in non-volatile device memory.
highroads 2:31313127c530 314 * @param old_address current address
highroads 2:31313127c530 315 * @param new_address desired new address
highroads 2:31313127c530 316 * @returns new address
highroads 2:31313127c530 317 */
highroads 0:4a5d4b4a40c4 318 uint8_t changeAddress(uint8_t old_address, uint8_t new_address);
highroads 0:4a5d4b4a40c4 319
highroads 0:4a5d4b4a40c4 320
highroads 0:4a5d4b4a40c4 321 private:
highroads 0:4a5d4b4a40c4 322 //Store address given when the class is initialized.
highroads 0:4a5d4b4a40c4 323 //This value can be changed by the changeAddress() function
highroads 0:4a5d4b4a40c4 324 I2C m_i2c;
highroads 0:4a5d4b4a40c4 325 int m_addr;
highroads 2:31313127c530 326 /**
highroads 2:31313127c530 327 * read 8 bit register
highroads 2:31313127c530 328 * @param registerAddr address for register
highroads 2:31313127c530 329 * @returns contents of register
highroads 2:31313127c530 330 */
highroads 0:4a5d4b4a40c4 331 uint8_t VL6180x_getRegister(uint16_t registerAddr);
highroads 2:31313127c530 332 /**
highroads 2:31313127c530 333 * read 16 bit register
highroads 2:31313127c530 334 * @param registerAddr address for register
highroads 2:31313127c530 335 * @param returns contents of register
highroads 2:31313127c530 336 */
highroads 2:31313127c530 337 uint16_t VL6180x_getRegister16bit(uint16_t registerAddr);
highroads 2:31313127c530 338 /**
highroads 2:31313127c530 339 * write 8 bit register
highroads 2:31313127c530 340 * @param registerAddr address for register
highroads 2:31313127c530 341 * @returns ERROR
highroads 2:31313127c530 342 */
highroads 0:4a5d4b4a40c4 343 void VL6180x_setRegister(uint16_t registerAddr, uint8_t data);
highroads 2:31313127c530 344 /**
highroads 2:31313127c530 345 * write 16 bit register
highroads 2:31313127c530 346 * @param registerAddr address for register
highroads 2:31313127c530 347 * @returns ERROR
highroads 2:31313127c530 348 */
highroads 0:4a5d4b4a40c4 349 void VL6180x_setRegister16bit(uint16_t registerAddr, uint16_t data);
highroads 0:4a5d4b4a40c4 350 };
highroads 0:4a5d4b4a40c4 351
highroads 0:4a5d4b4a40c4 352 #endif