Richard Huckaby / 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 //VIN -- VOUT
00015 //GND -- GND
00016 //SDA -- p27
00017 //SCA -- p28
00018 
00019 /*=================================== Main ==================================
00020 =============================================================================*/
00021 int main()
00022 {   
00023    int status;
00024    uint32_t distance;
00025 
00026    DevI2C *device_i2c =new DevI2C(p27, p28);     
00027         
00028    /* creates the 53L0A1 expansion board singleton obj */
00029    board=X_NUCLEO_53L0A1::Instance(device_i2c,p21,p21,p21);
00030 
00031    /* init the 53L0A1 expansion board with default values */
00032    status=board->InitBoard();
00033    if(status) { printf("Failed to init board!\n\r"); return 0; }
00034 
00035    while(1)
00036    {
00037        status = board->sensor_centre->GetDistance(&distance);
00038        if (status == VL53L0X_ERROR_NONE)
00039            printf("Distance : %ldmm\n", distance);
00040    }
00041 
00042 }
00043