Projet S5 info - Advanced version

Dependencies:   XBeeLib mbed-rtos mbed

Fork of Capteurs-Beginner by Vincent Belanger

Revision:
8:096edc8e8679
Parent:
7:e11d6545731a
Child:
9:6959e3ebe7f2
--- a/main.cpp	Wed Apr 06 20:16:07 2016 +0000
+++ b/main.cpp	Mon Apr 11 20:37:39 2016 +0000
@@ -1,34 +1,34 @@
 #include "mbed.h"
 #include "rtos.h"
 #include "XBeeLib.h"
-
+ 
 using namespace XBeeLib;
-
+ 
 Serial pc(USBTX, USBRX);
-
+ 
 XBeeZB* xbee;
-
+ 
 AnalogIn GP2D12(p15);
-DigitalIn capteur_1(p16);
-DigitalIn capteur_2(p17);
-DigitalIn capteur_3(p18);
-DigitalIn capteur_4(p19);
-DigitalIn capteur_5(p20);
-DigitalIn capteur_6(p21);
-
+DigitalIn capteur_1(p23);
+DigitalIn capteur_2(p24);
+DigitalIn capteur_3(p25);
+DigitalIn capteur_4(p26);
+DigitalIn capteur_5(p27);
+DigitalIn capteur_6(p28);
+ 
 Mutex capt_lock;
-
+ 
 bool capt_1;
 bool capt_2;
 bool capt_3;
 bool capt_4;
 bool capt_5;
 bool capt_6;
-
+ 
 uint16_t GP2D12_value;
  
 /* lecture des capteurs à partir des broches du mbed : p15, p16, p17, 19, 20 21*/
-
+ 
 void lecture_capteurs (void const *args){
     capt_lock.lock();
     
@@ -41,36 +41,36 @@
     
     GP2D12_value = GP2D12.read_u16();
     
-    
     capt_lock.unlock();
 }
-
+ 
 void send_data_to_coordinator(const uint8_t* data)
 { 
     const TxStatus txStatus = xbee->send_data_to_coordinator(data, 2);
 }
-
+ 
 void envoi_donnees (void const *args) {
     capt_lock.lock();
     uint8_t data[3];
     data[0] = (capt_1 << 7) | (capt_2 << 6) | (capt_3 << 5) | (capt_4 << 4) | (capt_5 << 3) | (capt_6 << 2);
     data[1] = (GP2D12_value & 0xFF00) >> 8;
-    
+
+    capt_lock.unlock();
     pc.printf("%x \n\r", GP2D12_value);
     pc.printf("%02x %02x %02x\n\r", data[0], data[1], data[2]);
-    capt_lock.unlock();
  
     send_data_to_coordinator(data);
 } 
-
+ 
 int main (void) {
     xbee = new XBeeZB(p13, p14, NC, NC, NC, 9600);
     
     RtosTimer readTimer(lecture_capteurs, osTimerPeriodic);
     RtosTimer sendTimer(envoi_donnees, osTimerPeriodic);
     
-    readTimer.start(50);
-    sendTimer.start(50);
+    readTimer.start(10);
+    sendTimer.start(10);
     
     wait(osWaitForever);
-}
\ No newline at end of file
+}
+            
\ No newline at end of file