Paul Sainrat / Mbed 2 deprecated App4_Projet

Dependencies:   mbed-rtos mbed

Revision:
0:703249a56b9d
Child:
1:5c0ca9bdf810
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DO/DO.cpp	Mon Oct 23 13:13:33 2017 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "DO.h"
+#include "config.h"
+
+
+char calcCRC16(char* trame)
+{
+    char length = trame[2];
+    int CRC16 = 0xFFFF;
+    for(char i =0x00; i<length; i++) {
+        CRC16 = CRC16 ^ trame[3+i];
+        for(int j = 0 ; j<8 ; j++) {
+            if((CRC16 & 0x1)==0x01) {
+                CRC16 = CRC16/2 ^ 0xA001;
+            } else {
+                CRC16 = CRC16/2;
+            }
+        }
+    }
+    return CRC16 & 0x00FF ; 
+}
+
+
+void recieveData(char* data){
+  if(calcCRC16(data)){
+    
+  }
+  else{
+    printf("Erreur : Checksum incorect \n");
+  }
+
+}