V1 test

Dependencies:   mbed X_NUCLEO_53L0A1

Committer:
lcouturier
Date:
Thu Nov 29 13:38:20 2018 +0000
Revision:
1:b594314c402b
Parent:
0:7fa8f6402b51
V2; ; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lcouturier 0:7fa8f6402b51 1 #include "mbed.h"
lcouturier 0:7fa8f6402b51 2 #include "XNucleo53L0A1.h"
lcouturier 0:7fa8f6402b51 3 #include <stdio.h>
lcouturier 0:7fa8f6402b51 4
lcouturier 0:7fa8f6402b51 5 #define VL53L0_I2C_SDA D14
lcouturier 0:7fa8f6402b51 6 #define VL53L0_I2C_SCL D15
lcouturier 0:7fa8f6402b51 7
lcouturier 0:7fa8f6402b51 8 static XNucleo53L0A1 *board=NULL;
lcouturier 0:7fa8f6402b51 9
lcouturier 0:7fa8f6402b51 10
lcouturier 0:7fa8f6402b51 11 int main()
lcouturier 0:7fa8f6402b51 12 {
lcouturier 0:7fa8f6402b51 13
lcouturier 0:7fa8f6402b51 14 DevI2C *device_i2c = new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);
lcouturier 0:7fa8f6402b51 15
lcouturier 0:7fa8f6402b51 16 /* creates the 53L0A1 expansion board singleton obj */
lcouturier 0:7fa8f6402b51 17 board = XNucleo53L0A1::instance(device_i2c, A2, D8, D2);
lcouturier 0:7fa8f6402b51 18
lcouturier 0:7fa8f6402b51 19 /* init the 53L0A1 expansion board with default values */
lcouturier 0:7fa8f6402b51 20 status = board->init_board();
lcouturier 0:7fa8f6402b51 21 if (status) {
lcouturier 0:7fa8f6402b51 22 printf("Failed to init board!\r\n");
lcouturier 0:7fa8f6402b51 23 return 0;
lcouturier 0:7fa8f6402b51 24 }
lcouturier 0:7fa8f6402b51 25
lcouturier 0:7fa8f6402b51 26 while (1) {
lcouturier 0:7fa8f6402b51 27 status = board->sensor_centre->get_distance(&distance);
lcouturier 0:7fa8f6402b51 28 if (status == VL53L0X_ERROR_NONE) {
lcouturier 0:7fa8f6402b51 29 printf("Distance : %ld\r\n", distance);
lcouturier 0:7fa8f6402b51 30 }
lcouturier 0:7fa8f6402b51 31 }
lcouturier 0:7fa8f6402b51 32 }