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: Ultrasound_And_IMU
Fork of X_NUCLEO_6180XA1 by
Diff: Components/VL6180X/vl6180x_class.h
- Revision:
- 46:116dadbc80f1
- Parent:
- 44:36d12d319078
- Child:
- 48:e799ad44dab7
--- a/Components/VL6180X/vl6180x_class.h Tue Mar 15 16:26:36 2016 +0000
+++ b/Components/VL6180X/vl6180x_class.h Thu May 19 14:11:25 2016 +0000
@@ -165,11 +165,6 @@
*expgpio0=0;
}
- /**
- * @brief Initialize the sensor with default values
- * @return 0 on Success
- */
- int InitSensor(uint8_t NewAddr);
/**
* @brief Start the measure indicated by operating mode
@@ -281,11 +276,51 @@
*
* @param void
* @return 0 on success, @a #CALIBRATION_WARNING if failed
- */
- virtual int Init()
- {
- return VL6180x_InitData(Device);
- }
+*/
+virtual int Init(void * NewAddr)
+{
+ int status;
+
+ VL6180x_Off();
+ VL6180x_On();
+ status=VL6180x_WaitDeviceBooted(Device);
+ if(status)
+ VL6180x_ErrLog("WaitDeviceBooted fail\n\r");
+ status=IsPresent();
+ if(!status)
+ {
+ Device->Present=1;
+ VL6180x_InitData(Device);
+ if(status)
+ {
+ printf("Failed to init VL6180X sensor!\n\r");
+ return status;
+ }
+ status=Prepare();
+ if(status)
+ {
+ printf("Failed to prepare VL6180X!\n\r");
+ return status;
+ }
+ if(*(uint8_t*)NewAddr!=DEFAULT_DEVICE_ADDRESS)
+ {
+ status=SetI2CAddress(*(uint8_t*)NewAddr);
+ if(status)
+ {
+ printf("Failed to change I2C address!\n\r");
+ return status;
+ }
+ }
+ else
+ {
+ printf("Invalid new address!\n\r");
+ return INVALID_PARAMS;
+ }
+ Device->Ready=1;
+ }
+ return status;
+}
+
/**
* @brief Configure GPIO1 function and set polarity.
@@ -1138,7 +1173,7 @@
int _DMax_InitData(VL6180xDev_t dev);
/* Read function of the ID device */
- virtual int ReadID();
+ virtual int ReadID(uint8_t *id);
/* Write and read functions from I2C */
int VL6180x_WrByte(VL6180xDev_t dev, uint16_t index, uint8_t data);
@@ -1154,9 +1189,9 @@
int IsPresent()
{
- int status;
+ int status; uint8_t id;
- status=ReadID();
+ status=ReadID(&id);
if(status)
VL6180x_ErrLog("Failed to read ID device. Device not present!\n\r");
return status;
