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: X_NUCLEO_6180
Revision 1:43a9bc2f05b5, committed 2021-05-03
- Comitter:
- charlesmn
- Date:
- Mon May 03 10:59:47 2021 +0000
- Parent:
- 0:d96995e87b29
- Commit message:
- Sample program for the VL6180 ToF sensor. Runs 1 sensor. Uses singleshot poll mode. MBed V6
Changed in this revision
--- a/VL6180ExpansionBoard.lib Thu Oct 29 09:23:00 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/users/charlesmn/code/VL6180ExpansionBoard/#2abe142876a5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_6180.lib Mon May 03 10:59:47 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_6180/#862286610dfd
--- a/main.cpp Thu Oct 29 09:23:00 2020 +0000
+++ b/main.cpp Mon May 03 10:59:47 2021 +0000
@@ -106,7 +106,13 @@
static XNucleo53L1A1 *board=NULL;
+// MBed V6.4 has renamed wait_ms and UnbufferedSerial replaces Serial
+#if (MBED_VERSION > 60300)
+UnbufferedSerial pc(SERIAL_TX, SERIAL_RX);
+extern "C" void wait_ms(int ms);
+#else
Serial pc(SERIAL_TX, SERIAL_RX);
+#endif
vl6180_DevI2C *dev_I2C = new vl6180_DevI2C(VL6180_I2C_SDA, VL6180_I2C_SCL);
@@ -115,43 +121,38 @@
#define i2c_bus (&hi2c1)
#define def_i2c_time_out 100
-
-void XNUCLEO6180XA1_WaitMilliSec(int n){
- wait_ms(n);
-}
-
+// Define interrupt pins
+// The interrupt pins depend on solder blobs on the back of the shield.
+// Each interupt can have two possible pins, this allows all interrupts to be on the same gpio or different gpio
+// The first values are those an unmodified board has
+// see ST document UM2657 for more details
+PinName CentreIntPin = A3;
+PinName LeftIntPin = D13;
+PinName RightIntPin = D2;
+PinName BottomIntPin = A2;
+// alternate set
+//PinName CentreIntPin = A5;
+//PinName LeftIntPin = D8;
+//PinName RightIntPin = D4;
+//PinName BottomIntPin = A4;
-/**
- * DISPLAY public
- */
-/*************** DISPLAY PUBLIC *********************/
-/*************** DISPLAY PRIVATE *********************/
static char DISP_CurString[10]; // the strin g to be displayed on the screen
-char buffer[10];
-
-
-uint32_t TimeStarted; /* various display and mode delay starting time */
VL6180_RangeData_t Range; /* Range measurmeent */
uint16_t range; /* range average distance */
-
-/* USER CODE END 0 */
-
-/* Private function prototypes -----------------------------------------------*/
-
int main(void)
{
+ int status;
+
pc.baud(115200); // baud rate is important as printf statements take a lot of time
devCentre.i2c_addr = theVL6180Dev; // set to default adress for now
- printf("vl6180_ss_and_poll_ranging \n");
-
- int status;
+ printf("vl6180_ss_and_poll_ranging mbed = %d \r\n",MBED_VERSION);
// create instances for the sensors
- board = XNucleo53L1A1::instance(dev_I2C, A2, D8, D2 ,D2);
+ board = XNucleo53L1A1::instance(dev_I2C, CentreIntPin, LeftIntPin, RightIntPin ,BottomIntPin);
// find the sensors we have and initialise
status = board->init_board();
@@ -225,5 +226,14 @@
}
+ // wait_ms was removed in MBed V6.4
+#if (MBED_VERSION > 60300)
+void wait_ms(int ms)
+ {
+ thread_sleep_for(ms);
+ }
+#endif
+
+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/mbed-os.lib Thu Oct 29 09:23:00 2020 +0000 +++ b/mbed-os.lib Mon May 03 10:59:47 2021 +0000 @@ -1,1 +1,1 @@ -https://github.com/armmbed/mbed-os/#aa70f680bb5755e8fea3f93fc6e04d9b3de235bb +https://github.com/armmbed/mbed-os/#8ef0a435b2356f8159dea8e427b2935d177309f8