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.
Fork of X_NUCLEO_53L0A1 by
Revision 9:367d1f390cb2, committed 2017-06-07
- Comitter:
- johnAlexander
- Date:
- Wed Jun 07 12:53:53 2017 +0000
- Parent:
- 8:8d27ebb4e1eb
- Child:
- 10:faf8d62ce6d1
- Commit message:
- Enable support for left and right sensors. Tested with mbed_143.
Changed in this revision
--- a/Components/Display/Display_class.h Wed Dec 07 14:49:50 2016 +0000
+++ b/Components/Display/Display_class.h Wed Jun 07 12:53:53 2017 +0000
@@ -382,6 +382,7 @@
// stmpe1600_exp1.write16bitReg(GPSR, (uint16_t *)&CurIOVal.bytes[2]);
// ordered low-byte/high-byte!
+ CurIOVal.bytes[1] |= 0xC0; // ensure highest bits are high, as these are xshutdown pins for left & right sensors!
ExpanderData = (CurIOVal.bytes[1] << 8) + CurIOVal.bytes[0];
stmpe1600_exp0.write16bitReg(GPSR, &ExpanderData);
CurIOVal.bytes[3] |= 0x80; // ensure highest bit is high, as this is xshutdown pin on central sensor!
--- a/Components/STMPE1600/stmpe1600_class.h Wed Dec 07 14:49:50 2016 +0000
+++ b/Components/STMPE1600/stmpe1600_class.h Wed Jun 07 12:53:53 2017 +0000
@@ -220,7 +220,7 @@
*/
void writeSYS_CTRL (uint8_t data) // data = SOFT_RESET reset the device
{
- dev_i2c.i2c_write((uint8_t*)data, expdevaddr, SYS_CTRL, 1);
+ dev_i2c.i2c_write(&data, expdevaddr, SYS_CTRL, 1);
}
/**
--- a/Components/VL53L0X/vl53l0x_class.cpp Wed Dec 07 14:49:50 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.cpp Wed Jun 07 12:53:53 2017 +0000
@@ -5113,7 +5113,7 @@
status=IsPresent();
if(!status)
{
- VL53L0X_DataInit(Device);
+ status=Init(&MyDevice);
if(status != VL53L0X_ERROR_NONE)
{
printf("Failed to init VL53L0X sensor!\n\r");
@@ -5131,7 +5131,6 @@
return status;
}
-/*
if(NewAddr!=DEFAULT_DEVICE_ADDRESS)
{
status=SetDeviceAddress(NewAddr);
@@ -5146,8 +5145,6 @@
printf("Invalid new address!\n\r");
return VL53L0X_ERROR_INVALID_PARAMS;
}
-*/
-// Device->Ready=1;
}
return status;
}
@@ -5347,3 +5344,5 @@
+
+
--- 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_ */
+
+
--- a/x_nucleo_53l0a1.cpp Wed Dec 07 14:49:50 2016 +0000
+++ b/x_nucleo_53l0a1.cpp Wed Jun 07 12:53:53 2017 +0000
@@ -84,7 +84,7 @@
printf("Sensor centre present\n\r");
n_dev++;
}
-/* status=sensor_left->InitSensor(NEW_SENSOR_LEFT_ADDRESS);
+ status=sensor_left->InitSensor(NEW_SENSOR_LEFT_ADDRESS);
if(status)
{
delete sensor_left;
@@ -98,8 +98,8 @@
printf("Sensor left present\n\r");
n_dev++;
}
-*/
-/* status=sensor_right->InitSensor(NEW_SENSOR_RIGHT_ADDRESS);
+
+ status=sensor_right->InitSensor(NEW_SENSOR_RIGHT_ADDRESS);
if(status)
{
delete sensor_right;
@@ -113,7 +113,7 @@
printf("Sensor right present\n\r");
n_dev++;
}
-*/
+
if(n_dev==0)
return 1;
else
--- a/x_nucleo_53l0a1.h Wed Dec 07 14:49:50 2016 +0000
+++ b/x_nucleo_53l0a1.h Wed Jun 07 12:53:53 2017 +0000
@@ -47,8 +47,7 @@
#include "DevI2C.h"
/** New device addresses */
-//#define NEW_SENSOR_CENTRE_ADDRESS 0x54
-#define NEW_SENSOR_CENTRE_ADDRESS 0x52
+#define NEW_SENSOR_CENTRE_ADDRESS 0x54
#define NEW_SENSOR_LEFT_ADDRESS 0x56
#define NEW_SENSOR_RIGHT_ADDRESS 0x58
@@ -66,10 +65,8 @@
X_NUCLEO_53L0A1(DevI2C *ext_i2c) : dev_i2c(ext_i2c)
{
stmpe1600_exp0 = new STMPE1600(*ext_i2c, (0x43 * 2)); // U21
- stmpe1600_exp0->writeSYS_CTRL (SOFT_RESET);
stmpe1600_exp1 = new STMPE1600(*ext_i2c, (0x42 * 2)); // U19
- stmpe1600_exp1->writeSYS_CTRL (SOFT_RESET);
display = new Display(*stmpe1600_exp0, *stmpe1600_exp1);
@@ -93,10 +90,8 @@
X_NUCLEO_53L0A1(DevI2C *ext_i2c, PinName gpio1_centre,
PinName gpio1_left, PinName gpio1_right) : dev_i2c(ext_i2c) {
stmpe1600_exp0 = new STMPE1600(*ext_i2c, (0x43 * 2)); // U21
- stmpe1600_exp0->writeSYS_CTRL(SOFT_RESET);
stmpe1600_exp1 = new STMPE1600(*ext_i2c, (0x42 * 2)); // U19
- stmpe1600_exp1->writeSYS_CTRL(SOFT_RESET);
display = new Display(*stmpe1600_exp0, *stmpe1600_exp1);
