programme ines avce xbee

Dependencies:   MMA8451Q mbed xbee_lib

Fork of Programme_course by Freescale_Cachan

Revision:
2:ddf9879f0e25
diff -r 4a9196bcf97a -r ddf9879f0e25 xbeemoi.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xbeemoi.cpp	Fri Mar 17 14:18:13 2017 +0000
@@ -0,0 +1,79 @@
+/////////////////////* Fichier des fonctions Xbee adaptées à la course 2017 *//////////////////////////
+
+#include "Mlib.h"
+
+
+void Xbee_init()
+{
+
+    // reset the xbees (at least 200ns)
+    rst1 = 0;
+    wait_ms(1);
+    rst1 = 1;
+    wait_ms(1);
+}
+
+int Xbee_receive()
+{
+    int data3=0;
+    char receiveData[NB_CARAC];
+
+    xbee1.RecieveData(receiveData,NB_CARAC);
+
+    data3=atoi(receiveData);
+    pc.printf("Recu:%s,%d \n",receiveData,data3);
+
+    return data3;
+}
+
+void Xbee_send(int data)
+{
+    char data0=0;
+    data0=char(data);
+
+    xbee1.SendData(&data0);
+}
+
+/* fonction qui permet d'initialiser les valeurs de VIT KP KI et KD via Xbee*/
+
+int Get_values_Xbee()
+{
+    int param =0;
+
+    pc.printf("en attente\n");
+
+    param= Xbee_receive();
+
+    switch(param) {
+
+        case VIT1:
+            pc.printf("en attente de la valeur de VIT\n");
+            if(Xbee_receive()!=0) {
+                VIT=Xbee_receive();
+                pc.printf("OK!!\n");
+            }
+
+        case KP1:
+            pc.printf("en attente de la valeur de KP\n");
+            if(Xbee_receive()!=0) {
+                KP=Xbee_receive();
+                pc.printf("OK!!\n");
+            }
+
+        case KD1:
+            pc.printf("en attente de la valeur de KD\n");
+            if(Xbee_receive()!=0) {
+                KD=Xbee_receive();
+                pc.printf("OK!!\n");
+            }
+
+        case KI1:
+            pc.printf("en attente de la valeur de KI\n");
+            if(Xbee_receive()!=0) {
+                KI=Xbee_receive();
+                pc.printf("OK!!\n");
+            }
+
+    }
+
+}
\ No newline at end of file