AAA

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
halusis
Date:
Thu May 24 09:38:18 2018 +0000
Commit message:
AAA

Changed in this revision

COMMs/COMMs.cpp Show annotated file Show diff for this revision Revisions of this file
COMMs/COMMs.h Show annotated file Show diff for this revision Revisions of this file
GCS_MUX_CODE.cpp Show annotated file Show diff for this revision Revisions of this file
Global_Variables/Global_Variables.cpp Show annotated file Show diff for this revision Revisions of this file
Global_Variables/Global_Variables.h Show annotated file Show diff for this revision Revisions of this file
Pin_Assign/Pin_Assign.cpp Show annotated file Show diff for this revision Revisions of this file
Pin_Assign/Pin_Assign.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/COMMs/COMMs.cpp	Thu May 24 09:38:18 2018 +0000
@@ -0,0 +1,84 @@
+#include "mbed.h"
+#include "Pin_Assign.h"
+#include "Global_Variables.h"
+#include "COMMs.h"
+
+void PrsTrk(void)
+{
+    for(char i=0;i<=63;i++) {MuxPck[i]=TrkPck[i];} //C/P -> 63;
+    
+    MuxPck[74]=TrkPck[74];
+    MuxPck[75]=TrkPck[75];
+    MuxPck[76]=TrkPck[76];
+    MuxPck[77]=TrkPck[77];
+    MuxPck[78]=TrkPck[78];
+    MuxPck[79]=TrkPck[79];
+}
+void GetTrk(void)
+{
+    unsigned char Trkbuf;
+    Trkbuf=Trk.getc();
+    
+    if(Trkbuf==0xfe&&TrkCnt==0||Trkbuf==0xfe&&TrkCnt==1)        {TrkPck[TrkCnt]=Trkbuf;TrkCnt++;}
+    else if(TrkCnt>=2&&TrkCnt<=81)                              {TrkPck[TrkCnt]=Trkbuf;TrkCnt++;}
+    else if(Trkbuf==0xff&&TrkCnt==82||Trkbuf==0xff&&TrkCnt==83) {TrkPck[TrkCnt]=Trkbuf;TrkCnt++;}
+    else if(TrkCnt==84)                                         {PrsTrk(); TrkCnt=0;}
+    else TrkCnt=0;
+}
+
+void PrsTrg(void)
+{
+    MuxPck[64]=TrgPck[19]; //lat
+    MuxPck[65]=TrgPck[20];
+    MuxPck[66]=TrgPck[21];
+    MuxPck[67]=TrgPck[22];
+        
+    MuxPck[68]=TrgPck[23]; //lon
+    MuxPck[69]=TrgPck[24];
+    MuxPck[70]=TrgPck[25];
+    MuxPck[71]=TrgPck[26];
+    MuxPck[72]=TrgPck[27]; //al
+    MuxPck[73]=TrgPck[28];
+}
+void GetTrg(void)
+{
+    unsigned char Trgbuf;
+    Trgbuf=Trg.getc();
+    
+    if(Trgbuf==0xfe&&TrgCnt==0||Trgbuf==0xfe&&TrgCnt==1)        {TrgPck[TrgCnt]=Trgbuf;TrgCnt++;}
+    else if(TrgCnt>=2&&TrgCnt<=81)                              {TrgPck[TrgCnt]=Trgbuf;TrgCnt++;}
+    else if(Trgbuf==0xff&&TrgCnt==82||Trgbuf==0xff&&TrgCnt==83) {TrgPck[TrgCnt]=Trgbuf;TrgCnt++;}
+    else if(TrgCnt==84)                                         {PrsTrg(); TrgCnt=0;}
+    else TrgCnt=0;
+}
+
+void PrsPc(void)
+{
+    for(char i=0;i<=26;i++) {Trk.putc(PcPck[i]);}
+}
+void GetPc(void)
+{
+    unsigned char Pcbuf;
+    Pcbuf=Pc.getc();
+    
+    if(Pcbuf==0xfe&&PcCnt==0||Pcbuf==0xfe&&PcCnt==1)            {PcPck[PcCnt]=Pcbuf;PcCnt++;}
+    else if(PcCnt>=2&&PcCnt<=24)                                {PcPck[PcCnt]=Pcbuf;PcCnt++;}
+    else if(Pcbuf==0xff&&PcCnt==25||Pcbuf==0xff&&PcCnt==26)     {PcPck[PcCnt]=Pcbuf;PcCnt++;}
+    else if(PcCnt==27)                                          {PrsPc(); PcCnt=0;}
+    else PcCnt=0;
+}
+
+void Mux2GCS(void)
+{
+    int chksum=0;
+    for(char ChkCnt=1;ChkCnt<=73;ChkCnt++)
+    {
+        chksum+=MuxPck[6+ChkCnt];
+    }
+    MuxPck[80]=chksum/256;
+    MuxPck[81]=chksum%256;
+    MuxPck[82]=0xff;
+    MuxPck[83]=0xff;
+    
+    for(char i=0;i<=83;i++) {Pc.putc(MuxPck[i]);}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/COMMs/COMMs.h	Thu May 24 09:38:18 2018 +0000
@@ -0,0 +1,10 @@
+#ifndef COMMS_H
+#define COMMS_H
+#include "mbed.h"
+
+extern void GetTrk(void);
+extern void GetTrg(void);
+extern void GetPc(void);
+extern void Mux2GCS(void);
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GCS_MUX_CODE.cpp	Thu May 24 09:38:18 2018 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+#include "Pin_Assign.h"
+#include "Global_Variables.h"
+#include "COMMs.h"
+
+Ticker Timer2gcs;
+bool fTimer2gcs=0;
+void Timer2gcs_isr(void);
+
+int main() 
+{
+    Pc.baud(38400);
+    Trk.baud(38400);
+    Trg.baud(38400);
+    
+    Timer2gcs.attach(&Timer2gcs_isr,0.2);
+    
+    while(1) 
+    {
+        if(Pc.readable()) GetPc();
+        if(Trk.readable()) GetTrk();
+        if(Trg.readable()) GetTrg();
+        if(fTimer2gcs==1)
+        {
+            fTimer2gcs=0;
+            Mux2GCS();
+        }
+    }
+}
+
+void Timer2gcs_isr(void)
+{
+    fTimer2gcs=1;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Global_Variables/Global_Variables.cpp	Thu May 24 09:38:18 2018 +0000
@@ -0,0 +1,4 @@
+#include "Global_Variables.h"
+#include "mbed.h"
+
+unsigned char TrkCnt, TrkPck[100], TrgCnt, TrgPck[100], PcCnt,PcPck[100], MuxPck[100];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Global_Variables/Global_Variables.h	Thu May 24 09:38:18 2018 +0000
@@ -0,0 +1,6 @@
+#ifndef GLOBAL_VARIABLES_H
+#define GLOBAL_VARIABLES_H
+#include "mbed.h"
+
+extern unsigned char TrkCnt, TrkPck[100], TrgCnt, TrgPck[100], PcCnt,PcPck[100], MuxPck[100];
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Pin_Assign/Pin_Assign.cpp	Thu May 24 09:38:18 2018 +0000
@@ -0,0 +1,5 @@
+#include "Pin_Assign.h"
+
+Serial Pc(USBTX, USBRX);
+Serial Trk(p9,p10);
+Serial Trg(p13,p14);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Pin_Assign/Pin_Assign.h	Thu May 24 09:38:18 2018 +0000
@@ -0,0 +1,9 @@
+#ifndef PIN_ASSIGN_H
+#define PIN_ASSIGN_H
+#include "mbed.h"
+
+extern Serial Pc;
+extern Serial Trk;
+extern Serial Trg;
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 24 09:38:18 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file