![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple HelloWorld program for the VL53L0X LIDAR sensor.
Dependencies: X_NUCLEO_53L0A1 mbed
Fork of HelloWorld_53L0A1 by
main.cpp@6:e59621ce59ea, 2017-04-30 (annotated)
- Committer:
- huck1137
- Date:
- Sun Apr 30 22:47:40 2017 +0000
- Revision:
- 6:e59621ce59ea
- Parent:
- 4:c8932fb926d6
;
Who changed what in which revision?
User | Revision | Line number | New 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 | |
johnAlexander | 1:3483e701ec59 | 5 | /* This VL53L0X Expansion board test application performs a range measurement in polling mode |
johnAlexander | 4:c8932fb926d6 | 6 | on the onboard embedded top sensor. */ |
johnAlexander | 0:ce8359133ae6 | 7 | |
johnAlexander | 0:ce8359133ae6 | 8 | #define VL53L0_I2C_SDA D14 |
johnAlexander | 0:ce8359133ae6 | 9 | #define VL53L0_I2C_SCL D15 |
johnAlexander | 0:ce8359133ae6 | 10 | |
johnAlexander | 0:ce8359133ae6 | 11 | static X_NUCLEO_53L0A1 *board=NULL; |
johnAlexander | 1:3483e701ec59 | 12 | |
johnAlexander | 0:ce8359133ae6 | 13 | |
huck1137 | 6:e59621ce59ea | 14 | //VIN -- VOUT |
huck1137 | 6:e59621ce59ea | 15 | //GND -- GND |
huck1137 | 6:e59621ce59ea | 16 | //SDA -- p27 |
huck1137 | 6:e59621ce59ea | 17 | //SCA -- p28 |
huck1137 | 6:e59621ce59ea | 18 | |
johnAlexander | 0:ce8359133ae6 | 19 | /*=================================== Main ================================== |
johnAlexander | 0:ce8359133ae6 | 20 | =============================================================================*/ |
johnAlexander | 0:ce8359133ae6 | 21 | int main() |
johnAlexander | 0:ce8359133ae6 | 22 | { |
johnAlexander | 4:c8932fb926d6 | 23 | int status; |
johnAlexander | 4:c8932fb926d6 | 24 | uint32_t distance; |
johnAlexander | 3:b3f70617a6b3 | 25 | |
huck1137 | 6:e59621ce59ea | 26 | DevI2C *device_i2c =new DevI2C(p27, p28); |
johnAlexander | 4:c8932fb926d6 | 27 | |
johnAlexander | 4:c8932fb926d6 | 28 | /* creates the 53L0A1 expansion board singleton obj */ |
huck1137 | 6:e59621ce59ea | 29 | board=X_NUCLEO_53L0A1::Instance(device_i2c,p21,p21,p21); |
johnAlexander | 3:b3f70617a6b3 | 30 | |
johnAlexander | 4:c8932fb926d6 | 31 | /* init the 53L0A1 expansion board with default values */ |
johnAlexander | 4:c8932fb926d6 | 32 | status=board->InitBoard(); |
johnAlexander | 4:c8932fb926d6 | 33 | if(status) { printf("Failed to init board!\n\r"); return 0; } |
johnAlexander | 4:c8932fb926d6 | 34 | |
johnAlexander | 4:c8932fb926d6 | 35 | while(1) |
johnAlexander | 4:c8932fb926d6 | 36 | { |
johnAlexander | 4:c8932fb926d6 | 37 | status = board->sensor_centre->GetDistance(&distance); |
johnAlexander | 4:c8932fb926d6 | 38 | if (status == VL53L0X_ERROR_NONE) |
huck1137 | 6:e59621ce59ea | 39 | printf("Distance : %ldmm\n", distance); |
johnAlexander | 4:c8932fb926d6 | 40 | } |
johnAlexander | 4:c8932fb926d6 | 41 | |
johnAlexander | 0:ce8359133ae6 | 42 | } |
johnAlexander | 0:ce8359133ae6 | 43 |