Mike Fiore / Mbed 2 deprecated HelloWorld_53L0A1

Dependencies:   X_NUCLEO_53L0A1 mbed

Fork of HelloWorld_53L0A1 by ST

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "x_nucleo_53l0a1.h"
00003 #include <stdio.h>
00004 
00005 /* This VL53L0X Expansion board test application performs a range measurement in polling mode
00006    on the onboard embedded top sensor. */
00007 
00008 #define VL53L0_I2C_SDA   D14 
00009 #define VL53L0_I2C_SCL   D15 
00010 
00011 static X_NUCLEO_53L0A1 *board=NULL;
00012 
00013 
00014 /*=================================== Main ==================================
00015 =============================================================================*/
00016 int main()
00017 {   
00018    int status;
00019    uint32_t distance;
00020 
00021    DevI2C *device_i2c =new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);     
00022         
00023    /* creates the 53L0A1 expansion board singleton obj */
00024    //board=X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);
00025    board=X_NUCLEO_53L0A1::Instance(device_i2c, A2, D7, D2);
00026 
00027    /* init the 53L0A1 expansion board with default values */
00028    status=board->InitBoard();
00029    if(status) { printf("Failed to init board!\n\r"); return 0; }
00030 
00031    while(1)
00032    {
00033        status = board->sensor_centre->GetDistance(&distance);
00034        if (status == VL53L0X_ERROR_NONE)
00035            printf("Distance : %ld\n", distance);
00036    }
00037 
00038 }
00039