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
Diff: main.cpp
- Revision:
- 1:43a9bc2f05b5
- Parent:
- 0:d96995e87b29
--- 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****/