Grenade Drone Controller

Dependencies:   mbed

Committer:
halusis
Date:
Mon Jul 16 02:29:10 2018 +0000
Revision:
0:02ed82ccad9f
Child:
1:d2b6491e52fd
1st complete ver.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
halusis 0:02ed82ccad9f 1 #include "mbed.h"
halusis 0:02ed82ccad9f 2 #include "PinAssign.h"
halusis 0:02ed82ccad9f 3 #include "GlobalVars.h"
halusis 0:02ed82ccad9f 4 #include "SwitchFn.h"
halusis 0:02ed82ccad9f 5
halusis 0:02ed82ccad9f 6 Timeout SndStateReq;
halusis 0:02ed82ccad9f 7
halusis 0:02ed82ccad9f 8 bool fReq=1;
halusis 0:02ed82ccad9f 9
halusis 0:02ed82ccad9f 10 void Req_isr(void) {fReq=1;}
halusis 0:02ed82ccad9f 11
halusis 0:02ed82ccad9f 12 int main()
halusis 0:02ed82ccad9f 13 {
halusis 0:02ed82ccad9f 14 pc.baud(115200);
halusis 0:02ed82ccad9f 15 Snd2Crr.baud(9600);
halusis 0:02ed82ccad9f 16
halusis 0:02ed82ccad9f 17 Sw1.mode(PullUp);
halusis 0:02ed82ccad9f 18 Sw2.mode(PullUp);
halusis 0:02ed82ccad9f 19 Sw3.mode(PullUp);
halusis 0:02ed82ccad9f 20 Sw4.mode(PullUp);
halusis 0:02ed82ccad9f 21 Sw5.mode(PullUp);
halusis 0:02ed82ccad9f 22 Sw6.mode(PullUp);
halusis 0:02ed82ccad9f 23 Sw7.mode(PullUp);
halusis 0:02ed82ccad9f 24 Sw8.mode(PullUp);
halusis 0:02ed82ccad9f 25 Sw14.mode(PullUp);
halusis 0:02ed82ccad9f 26 Sw58.mode(PullUp);
halusis 0:02ed82ccad9f 27 SwAll.mode(PullUp);
halusis 0:02ed82ccad9f 28
halusis 0:02ed82ccad9f 29 myled1=0;
halusis 0:02ed82ccad9f 30 myled2=0;
halusis 0:02ed82ccad9f 31 myled3=0;
halusis 0:02ed82ccad9f 32 myled4=0;
halusis 0:02ed82ccad9f 33
halusis 0:02ed82ccad9f 34 while(1)
halusis 0:02ed82ccad9f 35 {
halusis 0:02ed82ccad9f 36 if(fReq==1)
halusis 0:02ed82ccad9f 37 {
halusis 0:02ed82ccad9f 38 fReq=0;
halusis 0:02ed82ccad9f 39 SndStateReq.attach(&Req_isr, 1);
halusis 0:02ed82ccad9f 40
halusis 0:02ed82ccad9f 41 Send2Crr();
halusis 0:02ed82ccad9f 42
halusis 0:02ed82ccad9f 43 if(SigBit==RcvBit)
halusis 0:02ed82ccad9f 44 {
halusis 0:02ed82ccad9f 45 pc.printf("Good Status\n");
halusis 0:02ed82ccad9f 46 Led9=1;
halusis 0:02ed82ccad9f 47 }
halusis 0:02ed82ccad9f 48 else
halusis 0:02ed82ccad9f 49 {
halusis 0:02ed82ccad9f 50 pc.printf("Signal Lost\n");
halusis 0:02ed82ccad9f 51 Led9=0;
halusis 0:02ed82ccad9f 52 }
halusis 0:02ed82ccad9f 53 RcvStat();
halusis 0:02ed82ccad9f 54 RcvBit=0;
halusis 0:02ed82ccad9f 55
halusis 0:02ed82ccad9f 56 pc.printf("%x\n",SigBit);
halusis 0:02ed82ccad9f 57 }
halusis 0:02ed82ccad9f 58 if(Sw1==0) Sw1Fn();
halusis 0:02ed82ccad9f 59 if(Sw2==0) {Sw2Fn();}
halusis 0:02ed82ccad9f 60 if(Sw3==0) Sw3Fn();
halusis 0:02ed82ccad9f 61 if(Sw4==0) Sw4Fn();
halusis 0:02ed82ccad9f 62 if(Sw5==0) Sw5Fn();
halusis 0:02ed82ccad9f 63 if(Sw6==0) Sw6Fn();
halusis 0:02ed82ccad9f 64 if(Sw7==0) Sw7Fn();
halusis 0:02ed82ccad9f 65 if(Sw8==0) Sw8Fn();
halusis 0:02ed82ccad9f 66 if(Sw14==0) Sw14Fn();
halusis 0:02ed82ccad9f 67 if(Sw58==0) Sw58Fn();
halusis 0:02ed82ccad9f 68 if(SwAll==0) {SwAllFn();}
halusis 0:02ed82ccad9f 69
halusis 0:02ed82ccad9f 70 if(Snd2Crr.readable()) ProcCrr();
halusis 0:02ed82ccad9f 71 }
halusis 0:02ed82ccad9f 72 }