test

Dependencies:   mbed

Fork of HelloWorld_53L0A1 by ST

Committer:
zero515
Date:
Wed Feb 01 06:45:54 2017 +0000
Revision:
7:e30d35831e6c
Parent:
6:bc6c3c8c9976
Child:
8:5f1b4151c9e4
test;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
johnAlexander 0:ce8359133ae6 1 #include "mbed.h"
johnAlexander 0:ce8359133ae6 2 #include "x_nucleo_53l0a1.h"
johnAlexander 0:ce8359133ae6 3 #include <stdio.h>
johnAlexander 0:ce8359133ae6 4
zero515 6:bc6c3c8c9976 5 #define VL53L0_I2C_SDA D4
zero515 6:bc6c3c8c9976 6 #define VL53L0_I2C_SCL D5
johnAlexander 0:ce8359133ae6 7
johnAlexander 0:ce8359133ae6 8 static X_NUCLEO_53L0A1 *board=NULL;
zero515 6:bc6c3c8c9976 9 Serial pc(USBTX, USBRX);
johnAlexander 1:3483e701ec59 10
johnAlexander 0:ce8359133ae6 11
johnAlexander 0:ce8359133ae6 12 int main()
johnAlexander 0:ce8359133ae6 13 {
johnAlexander 4:c8932fb926d6 14 int status;
johnAlexander 4:c8932fb926d6 15 uint32_t distance;
zero515 6:bc6c3c8c9976 16 pc.baud(115200);
johnAlexander 3:b3f70617a6b3 17
johnAlexander 4:c8932fb926d6 18 DevI2C *device_i2c =new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);
johnAlexander 4:c8932fb926d6 19
johnAlexander 4:c8932fb926d6 20 board=X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);
johnAlexander 3:b3f70617a6b3 21
johnAlexander 4:c8932fb926d6 22 status=board->InitBoard();
johnAlexander 4:c8932fb926d6 23 if(status) { printf("Failed to init board!\n\r"); return 0; }
johnAlexander 4:c8932fb926d6 24
johnAlexander 4:c8932fb926d6 25 while(1)
johnAlexander 4:c8932fb926d6 26 {
johnAlexander 4:c8932fb926d6 27 status = board->sensor_centre->GetDistance(&distance);
zero515 6:bc6c3c8c9976 28 printf("%ld\n\r", distance);
johnAlexander 4:c8932fb926d6 29 }
johnAlexander 4:c8932fb926d6 30
johnAlexander 0:ce8359133ae6 31 }
johnAlexander 0:ce8359133ae6 32