Grenade Drone Controller
Dependencies: mbed
GranadeCtrl.cpp@1:903bcc4d9628, 2018-08-20 (annotated)
- Committer:
- halusis
- Date:
- Mon Aug 20 03:06:52 2018 +0000
- Revision:
- 1:903bcc4d9628
- Parent:
- 0:4194aba3f887
Grenade Drone Controller
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
halusis | 0:4194aba3f887 | 1 | #include "mbed.h" |
halusis | 0:4194aba3f887 | 2 | #include "PinAssign.h" |
halusis | 0:4194aba3f887 | 3 | #include "GlobalVars.h" |
halusis | 0:4194aba3f887 | 4 | #include "Functions.h" |
halusis | 0:4194aba3f887 | 5 | |
halusis | 1:903bcc4d9628 | 6 | bool fSndTimer=1; |
halusis | 1:903bcc4d9628 | 7 | bool fDebugTimer=1; |
halusis | 0:4194aba3f887 | 8 | |
halusis | 0:4194aba3f887 | 9 | Timeout SndTimer; |
halusis | 1:903bcc4d9628 | 10 | Ticker DebugTimer; |
halusis | 0:4194aba3f887 | 11 | void SndTimer_isr(void) {fSndTimer=1;} |
halusis | 1:903bcc4d9628 | 12 | void DebugTimer_isr(void) {fDebugTimer=1;} |
halusis | 0:4194aba3f887 | 13 | |
halusis | 0:4194aba3f887 | 14 | int main() |
halusis | 0:4194aba3f887 | 15 | { |
halusis | 0:4194aba3f887 | 16 | pc.baud(115200); |
halusis | 0:4194aba3f887 | 17 | Switch.baud(9600); |
halusis | 0:4194aba3f887 | 18 | |
halusis | 1:903bcc4d9628 | 19 | InitPWM(); |
halusis | 1:903bcc4d9628 | 20 | |
halusis | 1:903bcc4d9628 | 21 | pc.printf("Start\n"); |
halusis | 1:903bcc4d9628 | 22 | |
halusis | 1:903bcc4d9628 | 23 | DebugTimer.attach(&DebugTimer_isr,1); |
halusis | 1:903bcc4d9628 | 24 | |
halusis | 0:4194aba3f887 | 25 | while(1) |
halusis | 1:903bcc4d9628 | 26 | { |
halusis | 1:903bcc4d9628 | 27 | if(Switch.readable()) RcvProc(); |
halusis | 1:903bcc4d9628 | 28 | |
halusis | 0:4194aba3f887 | 29 | if(fSndTimer==1) |
halusis | 0:4194aba3f887 | 30 | { |
halusis | 0:4194aba3f887 | 31 | fSndTimer=0; |
halusis | 0:4194aba3f887 | 32 | |
halusis | 0:4194aba3f887 | 33 | SndPWM(); |
halusis | 0:4194aba3f887 | 34 | SigBit=RcvBit; |
halusis | 0:4194aba3f887 | 35 | Switch.putc(SigBit); |
halusis | 0:4194aba3f887 | 36 | |
halusis | 1:903bcc4d9628 | 37 | SndTimer.attach(&SndTimer_isr,0.02); |
halusis | 0:4194aba3f887 | 38 | } |
halusis | 0:4194aba3f887 | 39 | |
halusis | 1:903bcc4d9628 | 40 | if(fDebugTimer==1) |
halusis | 1:903bcc4d9628 | 41 | { |
halusis | 1:903bcc4d9628 | 42 | fDebugTimer=0; |
halusis | 1:903bcc4d9628 | 43 | pc.printf("%d %d %d %d %d %d %d %d\n",(int)var1,(int)var2,(int)var3,(int)var4,(int)var5,(int)var6,(int)var7,(int)var8); |
halusis | 1:903bcc4d9628 | 44 | } |
halusis | 1:903bcc4d9628 | 45 | |
halusis | 1:903bcc4d9628 | 46 | |
halusis | 0:4194aba3f887 | 47 | } |
halusis | 0:4194aba3f887 | 48 | } |