app4

Dependencies:   mbed-rtos mbed CRC16

Fork of S5info_APP2 by Éric Bisson

Revision:
21:73db1bea19b1
Parent:
13:a436ba0b78e8
diff -r a436ba0b78e8 -r 73db1bea19b1 main.cpp
--- a/main.cpp	Tue Mar 07 04:37:39 2017 +0000
+++ b/main.cpp	Tue Mar 07 05:04:40 2017 +0000
@@ -2,6 +2,7 @@
 #include "rtos.h"
 #include "bit.h"
 #include "uart.h"
+#define CLOCKS_TO_SECOND 96000000 //prout
 
 const float HALF_PERIOD = 0.05; // secondes
 
@@ -80,28 +81,6 @@
     LPC_TIM2->TCR = 1;                      // start Timer
 };
 
-bool codeManchester(bool bit, bool clock)
-{
-    return (bit == clock);
-}
-
-void send_data()
-{
-    out = codeManchester(((trame_sent[byte_sent_pos] >> bit_sent) & 0x01), clockTick);  // Encodage Manchester
-    if(clockTick)
-    {
-        bit_sent--;
-    }
-    clockTick = !clockTick;       //varier entre la 1ere et 2eme partie de demi-periode
-    if (bit_sent < 0) {     //Si l'octet a ete envoye
-        bit_sent = 7;       //remettre la position initiale pour le prochain octet
-        byte_sent_pos++;    //incrementer l'octet
-        if (byte_sent_pos >= trame_length) {  //Si la trame a ete envoyee
-            byte_sent_pos = 0;
-            clockTick = false;
-        }
-    }
-}
 
 //création de la trame
 void create_trame(char message[],int taille)
@@ -145,6 +124,31 @@
     create_trame(text,count);
 }
 
+//Encodage Manchester
+bool codeManchester(bool bit, bool clock)
+{
+    return (bit == clock);
+}
+
+//Envoi des données
+void send_data()
+{
+    out = codeManchester(((trame_sent[byte_sent_pos] >> bit_sent) & 0x01), clockTick);  // Encodage Manchester
+    if(clockTick)
+    {
+        bit_sent--;
+    }
+    clockTick = !clockTick;       //varier entre la 1ere et 2eme partie de demi-periode
+    if (bit_sent < 0) {     //Si l'octet a ete envoye
+        bit_sent = 7;       //remettre la position initiale pour le prochain octet
+        byte_sent_pos++;    //incrementer l'octet
+        if (byte_sent_pos >= trame_length) {  //Si la trame a ete envoyee
+            byte_sent_pos = 0;
+            clockTick = false;
+        }
+    }
+}
+
 void write()
 {
     byte_sent_pos = 0;