hello world LIDAR
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Fork of X_NUCLEO_53L0A1 by
Revision 4:4e1576541eed, committed 2016-12-05
- Comitter:
- johnAlexander
- Date:
- Mon Dec 05 11:03:50 2016 +0000
- Parent:
- 1:01b8004bc0a7
- Child:
- 7:35ecf3e060c3
- Commit message:
- Minor code tidy-up.
Changed in this revision
--- a/Components/Interfaces/GenericSensor.h Mon Nov 28 14:52:49 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/**
- ******************************************************************************
- * @file GenericSensor.h
- * @author AST / EST
- * @version V0.0.1
- * @date 13-April-2015
- * @brief This file contains the abstract class describing in general
- * the interfaces of a generic sensor
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-/* Define to prevent from recursive inclusion --------------------------------*/
-#ifndef __GENERIC_SENSOR_CLASS_H
-#define __GENERIC_SENSOR_CLASS_H
-
-/* Includes ------------------------------------------------------------------*/
-#include <stdint.h>
-
-/* Classes ------------------------------------------------------------------*/
-/** An abstract class for Generic sensors
- */
-class GenericSensor
-{
- public:
- /**
- * @brief Initialization of sensor
- * @param[out] ptr Pointer to device specific initalization structure
- * @return 0 in case of success, an error code otherwise
- */
- virtual int Init() = 0;
-
- /**
- * @brief Get ID of sensor
- * @param[out] id Pointer to where to store the ID to
- * @return 0 in case of success, an error code otherwise
- */
- virtual int ReadID() = 0;
-};
-
-#endif /* __GENERIC_SENSOR_CLASS_H */
-
--- a/Components/Interfaces/RangeSensor.h Mon Nov 28 14:52:49 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/**
- ******************************************************************************
- * @file RangeSensor.h
- * @author AST / EST
- * @version V0.0.1
- * @date 13-April-2015
- * @brief This file contains the abstract class describing in general
- * the interfaces of a range sensor
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-/* Define to prevent from recursive inclusion --------------------------------*/
-#ifndef __RANGE_SENSOR_CLASS_H
-#define __RANGE_SENSOR_CLASS_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "GenericSensor.h"
-
-/* Classes ------------------------------------------------------------------*/
-/** An abstract class for range sensors
- */
-class RangeSensor : public GenericSensor
-{
- public:
- /**
- * @brief Get current range [mm]
- * @param[out] piData Pointer to where to store range to
- * @return 0 in case of success, an error code otherwise
- */
- virtual int GetRange(int32_t *piData) = 0;
-};
-
-#endif /* __RANGE_SENSOR_CLASS_H */
-
--- a/Components/VL53L0X/vl53l0x_class.cpp Mon Nov 28 14:52:49 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.cpp Mon Dec 05 11:03:50 2016 +0000
@@ -5031,7 +5031,7 @@
}
-int VL53L0X::ReadID()
+int VL53L0X::ReadID(uint8_t *id)
{
int status = 0;
uint16_t rl_id=0;
@@ -5113,7 +5113,7 @@
status=IsPresent();
if(!status)
{
- status=Init();
+ status=Init((void *)NULL);
if(status != VL53L0X_ERROR_NONE)
{
printf("Failed to init VL53L0X sensor!\n\r");
--- a/Components/VL53L0X/vl53l0x_class.h Mon Nov 28 14:52:49 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h Mon Dec 05 11:03:50 2016 +0000
@@ -42,6 +42,7 @@
/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
#include "RangeSensor.h"
#include "DevI2C.h"
@@ -372,10 +373,10 @@
*/
int InitSensor(uint8_t NewAddr);
- int RawInitSensor(void);
- int initDevice(VL53L0X_DEV Dev);
- int setLongRangePresets(VL53L0X_DEV Dev);
- int DoRanging(VL53L0X_Dev_t *pMyDevice);
+// int RawInitSensor(void);
+// int initDevice(VL53L0X_DEV Dev);
+// int setLongRangePresets(VL53L0X_DEV Dev);
+// int DoRanging(VL53L0X_Dev_t *pMyDevice);
@@ -491,10 +492,11 @@
* @param void
* @return 0 on success, @a #CALIBRATION_WARNING if failed
*/
- virtual int Init()
+// virtual int Init()
+ virtual int Init(void *NewAddr)
{
- return VL53L0X_DataInit(&MyDevice);
-// return VL53L0X_DataInit(Device);
+// return VL53L0X_DataInit(&MyDevice);
+ return VL53L0X_DataInit(Device);
// return 1;
}
@@ -687,10 +689,25 @@
* @param pRange_mm Pointer to range distance
* @return 0 on success
*/
- virtual int GetRange(int32_t *piData)
+ virtual int GetDistance(uint32_t *piData)
{
-// return VL6180x_RangeGetResult(Device, piData);
- return 1;
+ 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;
}
/**
@@ -1325,7 +1342,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);
VL53L0X_Error WaitStopCompleted(VL53L0X_DEV Dev);
@@ -1352,7 +1369,7 @@
{
int status;
- status=ReadID();
+ status=ReadID((uint8_t *)MyDevice.I2cDevAddr);
if(status)
VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r");
return status;
--- a/x_nucleo_53l0a1.h Mon Nov 28 14:52:49 2016 +0000 +++ b/x_nucleo_53l0a1.h Mon Dec 05 11:03:50 2016 +0000 @@ -1,4 +1,4 @@ -/** +//** ****************************************************************************** * @file x_nucleo_53L0A1.h * @author IMG @@ -41,7 +41,7 @@ #define __X_NUCLEO_53L0A1_H /* Includes ------------------------------------------------------------------*/ -#include "mbed.h" +//#include "mbed.h" #include "vl53l0x_class.h" #include "Display_class.h" #include "stmpe1600_class.h"
