Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:8da34e10e9f8, committed 2019-04-11
- Comitter:
- JVAutran
- Date:
- Thu Apr 11 11:20:38 2019 +0000
- Commit message:
- Programme de mesure de distance avec capteur ToF
Changed in this revision
diff -r 000000000000 -r 8da34e10e9f8 VL53L0X.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VL53L0X.lib Thu Apr 11 11:20:38 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ST/code/VL53L0X/#d25c4fa216af
diff -r 000000000000 -r 8da34e10e9f8 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Apr 11 11:20:38 2019 +0000
@@ -0,0 +1,48 @@
+#include "VL53L0X.h"
+#include "mbed.h"
+
+DevI2C i2C(PB_9, PB_8);
+DigitalOut Pin_Out(PB_9);
+VL53L0X capteur(&i2C, &Pin_Out, PA_8, VL53L0X_DEFAULT_ADDRESS);
+VL53L0X_Dev_t MyDevice;
+VL53L0X_Dev_t *pMyDevice = &MyDevice;
+int distance(uint32_t *p_data);
+
+int main(){
+ uint32_t status = 0;
+ uint32_t *dist;
+
+ printf("\n\r");
+ printf("\n\r");
+ //pMyDevice->comms_type = 1;
+ //pMyDevice->comms_speed_khz = 400;
+
+ capteur.init_sensor(VL53L0X_DEFAULT_ADDRESS);
+ //capteur.disable_interrupt_measure_detection_irq();
+ while(1){
+ status = distance(dist);
+ printf("Distance : %d mm\n\r", *dist);
+ printf("Statut : %d \n\r", status);
+ printf("\n");
+ wait(0.2);
+ }
+ capteur.VL53L0X_off();
+}
+
+int distance(uint32_t *p_data){
+ int status = 0;
+ VL53L0X_RangingMeasurementData_t measurement_data;
+
+ status = capteur.start_measurement(range_single_shot_polling, NULL);
+ if (!status) {
+ status = capteur.get_measurement(range_single_shot_polling, &measurement_data);
+ }
+ if (measurement_data.RangeStatus == 0) {
+ *p_data = measurement_data.RangeMilliMeter;
+ } else {
+ *p_data = 0;
+ status = VL53L0X_ERROR_RANGE_ERROR;
+ }
+ capteur.stop_measurement(range_single_shot_polling);
+ return status;
+}
\ No newline at end of file
diff -r 000000000000 -r 8da34e10e9f8 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Apr 11 11:20:38 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file