Roman Ciesarík / Mbed 2 deprecated Semestralna_praca_Roman_Ciesarik

Dependencies:   MMA8451Q mbed

Revision:
5:c1952cbf8111
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/headre.cpp	Thu Jan 04 23:04:53 2018 +0000
@@ -0,0 +1,101 @@
+/*#include "mbed.h"
+#include "headre.h"
+#include "definicie.h"
+
+char crc=0x00;
+//Serial pc(USBTX, USBRX, 57600);
+int i;
+
+char prijemSpravy[30];
+
+
+void prijmemSpravu()
+{
+    //pc.attach(&prijmemSpravu);
+    for (int j=0;j<4;j++)
+    {
+        while(true)
+        {
+            if(pc.readable()==1)
+            {
+                prijemSpravy[j]=pc.getc(); 
+                break;                                 
+            }
+        }    
+    }
+    
+    int pom= prijemSpravy[3] + 1;
+    
+    for (int j=0;j<pom;j++)
+    {
+        while(true)
+        {
+            if(pc.readable()==1)
+            {
+                prijemSpravy[j+4]=pc.getc();
+                break;                                  
+            }
+        }    
+    }
+   pc.attach(&prijmemSpravu);
+}
+
+
+void poslemSpravu(char adrRX, char adrTX, int velkost, char DATA[] )
+{
+    crc=0x00;
+    char odosli[5+velkost];
+    odosli[0]=0xA0;
+    odosli[1]=adrRX;
+    odosli[2]=adrTX;
+    odosli[3]=velkost;
+
+    crc=crc8table[crc^adrRX];
+    crc=crc8table[crc^adrTX];
+
+    for (i=0; i<velkost; i++) {
+        odosli[4+i]=DATA[i];
+    }
+
+    for (i=0; i<velkost; i++) {
+        crc=crc8table[crc^DATA[i]];
+    }
+
+    odosli[velkost+4]=crc;
+
+    for (i=0; i<velkost+5; i++) {
+        pc.putc(odosli[i]);
+    }
+
+}
+
+
+void zamkni()
+{
+    char DATA[]= {0x01};
+    poslemSpravu(VYTAH,0xcc,sizeof(DATA),DATA);
+}
+
+void odomkni()
+{
+    char DATA[]= {0x00};
+    poslemSpravu(VYTAH,0xcc,sizeof(DATA),DATA);
+}
+
+void stop()
+{
+    char DATA[]= {0x01};
+    poslemSpravu(MOTOR,0xcc,sizeof(DATA),DATA);
+}
+
+void hore()
+{
+    char DATA[]= {0x02,0x64,0x00,0x00,0x00};
+    poslemSpravu(MOTOR,0xcc,sizeof(DATA),DATA);   
+}
+
+void dole()
+{
+    char DATA[]= {0x02,0x9c,0xff,0xff,0xff};
+    poslemSpravu(MOTOR,0xcc,sizeof(DATA),DATA);
+}*/
\ No newline at end of file