Library for use with VL53L0X, cut 1.1, based on mass-market API v1.1.
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Dependents: ConcorsoFinal HelloWorld_IHM01A1 m3pi_BT m3pi_LIDAR ... more
Fork of X_NUCLEO_53L0A1 by
X-NUCLEO-53L0A1 Proximity Sensor Expansion Board Firmware Package
Introduction
This firmware package includes Component Device Drivers and the Board Support Package for STMicroelectronics' X-NUCLEO-53L0A1 Proximity sensor expansion board based on VL53L0X.
Firmware Library
Class X_NUCLEO_53L0A1 is intended to represent the Proximity sensor expansion board with the same name.
The expansion board provides support for the following components:
- on-board VL53L0X proximity sensor,
- up to two additional VL53L0X Satellites,
- on-board 4-digit display
It is intentionally implemented as a singleton because only one X-NUCLEO-VL53L0A1 may be deployed at a time in a HW component stack. In order to get the singleton instance you have to call class method `Instance()`, e.g.:
// Sensors expansion board singleton instance static X_NUCLEO_53L0A1 *board = X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);
Example Applications
- Hello World 53L0
- Display 53L0A1
- Display 53L0A1 Interrupts
- Display 53L0A1 with satellites
- 53L0A1 Satellites with Interrupts
- 53L0A1_HandGestureRecognition
The library and sample application code were tested against mbed revision 143, dated 26th May 2017.
Diff: Components/VL53L0X/vl53l0x_class.h
- Revision:
- 9:367d1f390cb2
- Parent:
- 8:8d27ebb4e1eb
- Child:
- 10:faf8d62ce6d1
--- a/Components/VL53L0X/vl53l0x_class.h Wed Dec 07 14:49:50 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h Wed Jun 07 12:53:53 2017 +0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- Copyright © 2016, STMicroelectronics International N.V.
+ Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,6 @@
/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
#include "RangeSensor.h"
#include "DevI2C.h"
@@ -61,7 +60,7 @@
#define STATUS_FAIL 0x01
-#define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int)
+#define VL53L0X_OsDelay(...) HAL_Delay(2)
#ifdef USE_EMPTY_STRING
#define VL53L0X_STRING_DEVICE_INFO_NAME ""
@@ -328,7 +327,7 @@
Device=&MyDevice;
gpio0=NULL;
if (pin_gpio1 != NC) { gpio1Int = new InterruptIn(pin_gpio1); }
- else { gpio1Int = NULL; }
+ else { gpio1Int = NULL; }
}
/** Destructor
@@ -352,7 +351,7 @@
*gpio0 = 1;
else if (expgpio0)
*expgpio0 = 1;
- wait_ms(1);
+ wait_ms(10);
}
/**
@@ -366,14 +365,22 @@
*gpio0 = 0;
else if (expgpio0)
*expgpio0 = 0;
- wait_ms(1);
+ wait_ms(10);
}
/**
* @brief Initialize the sensor with default values
* @return 0 on Success
- */
+ */
int InitSensor(uint8_t NewAddr);
+
+ int RawInitSensor(void);
+ int initDevice(VL53L0X_DEV Dev);
+ int setLongRangePresets(VL53L0X_DEV Dev);
+ int DoRanging(VL53L0X_Dev_t *pMyDevice);
+
+
+
/**
* @brief Start the measure indicated by operating mode
@@ -486,9 +493,12 @@
* @param void
* @return 0 on success, @a #CALIBRATION_WARNING if failed
*/
- virtual int Init(void * NewAddr)
+ virtual int Init(void *init)
+// virtual int Init()
{
- return VL53L0X_DataInit(Device);
+ return VL53L0X_DataInit(&MyDevice);
+// return VL53L0X_DataInit(Device);
+// return 1;
}
/**
@@ -529,6 +539,7 @@
*/
int Prepare()
{
+// return VL6180x_Prepare(Device);
// taken from rangingTest() in vl53l0x_SingleRanging_Example.c
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
uint32_t refSpadCount;
@@ -680,24 +691,10 @@
* @return 0 on success
*/
virtual int GetDistance(uint32_t *piData)
+// virtual int GetRange(int32_t *piData)
{
- int status=0;
- VL53L0X_RangingMeasurementData_t pRangingMeasurementData;
-
- status=StartMeasurement(range_single_shot_polling, NULL);
- if (!status) {
- status=GetMeasurement(range_single_shot_polling, &pRangingMeasurementData);
- }
- if (pRangingMeasurementData.RangeStatus == 0) {
- // we have a valid range.
- *piData = pRangingMeasurementData.RangeMilliMeter;
- }
- else {
- *piData = 0;
- status = VL53L0X_ERROR_RANGE_ERROR;
- }
- StopMeasurement(range_single_shot_polling);
- return status;
+// return VL6180x_RangeGetResult(Device, piData);
+ return 1;
}
/**
@@ -1332,6 +1329,7 @@
VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo);
/* Read function of the ID device */
+// virtual int ReadID();
virtual int ReadID(uint8_t *id);
VL53L0X_Error WaitMeasurementDataReady(VL53L0X_DEV Dev);
@@ -1358,8 +1356,9 @@
int IsPresent()
{
int status;
+ uint8_t id=0;
- status=ReadID((uint8_t *)MyDevice.I2cDevAddr);
+ status=ReadID(&id);
if(status)
VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r");
return status;
@@ -1378,6 +1377,9 @@
/* IO Device */
DevI2C &dev_i2c;
+ /* GPIO expander */
+// STMPE1600 &io_expander;
+// ExpGpioPinName xshutdown;
/* Digital out pin */
DigitalOut *gpio0;
/* GPIO expander */
@@ -1393,3 +1395,5 @@
#endif /* _VL53L0X_CLASS_H_ */
+
+

X-NUCLEO-53L0A1 Ranging Sensor Expansion Board