programme tdc502

Dependencies:   TDC502 mbed

Files at this revision

API Documentation at this revision

Comitter:
khalidel
Date:
Sun Jun 11 18:38:11 2017 +0000
Parent:
0:893cddb940f0
Commit message:
pour lucas

Changed in this revision

TDC502.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
diff -r 893cddb940f0 -r 346b69769c2e TDC502.lib
--- a/TDC502.lib	Tue May 16 09:56:45 2017 +0000
+++ b/TDC502.lib	Sun Jun 11 18:38:11 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/schnf30/code/TDC502_for_student/#03d9a0c443f6
+https://developer.mbed.org/teams/xCrocoDiffusion/code/TDC502/#fab1adb9c5b5
diff -r 893cddb940f0 -r 346b69769c2e main.cpp
--- a/main.cpp	Tue May 16 09:56:45 2017 +0000
+++ b/main.cpp	Sun Jun 11 18:38:11 2017 +0000
@@ -1,26 +1,55 @@
 #include "mbed.h"
 #include "TDC502.h"
 Serial pc(USBTX,USBRX);
-
-DigitalOut ale(PE_0,1);
+//Serial envoi();
+DigitalOut ale(PE_0,1); //ALE=1
 TDC502 tdc502(PortD, 0x00FF, //PD_7, PD_6, PD_5, PD_4, PD_3, PD_2, PD_1, PD_0,  DataD7 - D0
               PortA, 0x00F0, //PA_7,PA_6,PA_5,PA_4,   adresse AD3 à AD0
+              PD_11,PD_12,PD_13, // rdn wrn csn
+              PE_2, PA_0); // INTFLAG TDC_READY
+//déclaration broche rx tx serial envoi
 
-              PD_11,PD_12,PD_13, // rdn wrn csn
-              PE_2, PA_0 ); // INTFLAG TDC_READY
 int main()
 {
+    pc.baud(115200); //vitesse de transmission
+//   tdc502.TestPerformanceWrite();
+//   tdc502.TestPerformanceRead();
 
-    pc.baud(115200);
-    tdc502.TestPerformanceWrite();
-    tdc502.TestPerformanceRead();
-    tdc502.init();
-    tdc502.ReadAllRegister();
-    tdc502.StartMesure();
-    while(1)
-        if (tdc502.data_ready()) {
-            tdc502.ReadData();
-            wait(10.0);
+    tdc502.init(); //Initialisation du TDC502
+
+//   tdc502.ReadAllRegister(); //lecture des registres
+   //tdc502.StartMesure();
+    while(1) {
+            pc.printf("Debut mesure 11.06\r\n");
+
             tdc502.StartMesure();
-        }
+            wait_ms(10);
+            tdc502.StopMesure();
+            pc.printf("Fin mesure\r\n");
+            // faire envoi vers carte IHM envoi==tdc502.StartMesure();
+            //                              envoi==tdc502.StopMesure();
+// Affichage des donnees acquises pour verifier.
+
+            for (unsigned i = 0; i < tdc502.NbreDataAcquise; i++) {
+
+                unsigned result;
+                float tempsns;
+                result = tdc502.DataTdc502[i];
+                i++;
+                result = (result << 8) + tdc502.DataTdc502[i];
+                i++;
+                result = (result << 8) + tdc502.DataTdc502[i];
+                i++;
+                result = (result << 8) + tdc502.DataTdc502[i];
+
+                tempsns = result;
+                tempsns = tempsns * 500.0 / 65536.0; // vient config du tdc502
+                printf("Data %u --> %.3fns\r\n",result,tempsns);
+
+            }
+            printf("Nombre de mseure %u %u\r\n",tdc502.NbreDataAcquise,tdc502.NbreDataAcquise/4);
+            pc.printf("Appuyer sur une touche");
+            pc.getc();
+            pc.printf("\r\n");
+    }
 }
\ No newline at end of file