test ok de l'IUT GEII NICE

Dependencies:   mbed LIDARLite_v3HP_IUT_GEII

Files at this revision

API Documentation at this revision

Comitter:
vermaelen
Date:
Wed Feb 09 15:17:50 2022 +0000
Commit message:
ca marche

Changed in this revision

LIDARLite_v3HP_copy.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LIDARLite_v3HP_copy.lib	Wed Feb 09 15:17:50 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/vermaelen/code/LIDARLite_v3HP_IUT_GEII/#d6e45ac03963
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 09 15:17:50 2022 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+#include "LIDARLite_v3HP.h"
+DigitalOut myled(LED1);
+I2C i2c(p9,p10);
+LIDARLite_v3HP capteur(&i2c);
+int main()
+{
+
+
+//   capteur.configure(2,0x62);
+    while(1) {
+        capteur.takeRange();
+        //capteur.waitForBusy();
+        uint16_t val=capteur.readDistance();
+        printf("d=%dcm\n\r",val);
+        wait(0.1);
+    }
+}
+
+
+
+//le main qui fonctionne sans bibliothèque
+
+/*
+int main(){
+ char wait;
+ char start[2]={0,4};
+  char reset[2]={0,0};
+ char read=1;
+ char read_measureh=0xf;
+  char read_measurel=0x10;
+ char measureh,measurel;
+ char measure[2];
+  i2c.write(0xC4,reset,2); //juste pour RESET le circuit , pas obligé
+    while(1){
+       i2c.write(0xC4,start,2); //on lance la mesure
+              wait_us(100);
+                            i2c.write(0xC4,&read,1); // on attend la réponse
+       do{
+
+       int rep=i2c.read(0xC4,&wait,1);
+       if(rep==1)
+            printf("c'est le bordel\n\r");
+       else
+            //printf("wait=%x\n\r",wait);
+            putchar('.'); // pour voir le nombre de wait
+       }while((wait&1)!=0);
+       //on récup la mesure, obligé de faire la mesure octet par octet ????
+        i2c.write(0xC4,&read_measureh,1);
+        i2c.read(0xC4,&measureh,1);
+        i2c.write(0xC4,&read_measurel,1);
+        i2c.read(0xC4,&measurel,1);
+       int value=(measureh<<8)+measurel;
+       printf("%x %x :val=%d cm\n\r",measureh,measurel,value);
+
+       //ne fonctionne pas si on fait la mesure sur 2 octets, pas d'auto-incrément ?????
+       //i2c.write(0xC4,&read_measureh,1);
+       //i2c.read(0xC4,measure,2);
+       //int value=(measure[0]<<8)+measure[1];
+       //printf("%x %x :val=%d cm\n\r",measure[0],measure[1],value);
+       wait_ms(50);
+
+    }
+}*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 09 15:17:50 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file