programme ines avce xbee
Dependencies: MMA8451Q mbed xbee_lib
Fork of Programme_course by
xbeemoi.cpp
- Committer:
- inesmas3
- Date:
- 2017-03-17
- Revision:
- 2:ddf9879f0e25
File content as of revision 2:ddf9879f0e25:
/////////////////////* 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"); } } }