Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of 2015robot_main by
Diff: communicate.h
- Revision:
- 51:cb430192b28b
- Parent:
- 44:315d5960f18c
- Child:
- 57:3fbd487e055e
--- a/communicate.h Sat Sep 26 08:43:21 2015 +0000 +++ b/communicate.h Sun Sep 27 05:02:15 2015 +0000 @@ -13,17 +13,20 @@ } /***IM920 Communication.***/ -/*char rcvBUFF_IM920[40], rcvBUFF_SBDBT[40]; +char rcvBUFF_IM920[40], rcvBUFF_SBDBT[40]; int rcvCOUNT_IM920 = 0, rcvCOUNT_SBDBT = 0; int rcvFLAG = 0; int sendFLAG = 0; int deadCOUNT = 0; +int deadflag = 0; int oldDATA; unsigned int cm, a2, b, X, Y; -unsigned int sdDATA = 0; +unsigned int sendDATA = 0; int LED = 0; +unsigned long outDATA[4]; Serial IM920_USART(p9, p10); +Serial SBDBT_USART(p28, p27); DigitalIn BUSY(p8); Ticker DTimer; @@ -47,7 +50,7 @@ } } -int cv(int Buzzer, int LED) { +int cvsendDATA(int Buzzer, int LED) { if (Buzzer > 1) Buzzer = 1; else if (Buzzer < 0) @@ -119,17 +122,17 @@ void deadCheck() { if (rcvFLAG == 0 && deadCOUNT >= 5) { - PC.printf("DEAD\r\n"); + deadflag = 1; deadCOUNT = 0; } else if (rcvFLAG == 0 && deadCOUNT >= 2) { deadCOUNT++; - DEVICE_TX(); + DEVICE_TX(sendDATA); } else if (rcvFLAG == 0) { deadCOUNT++; } - sdDATA = cvsendDATA(0, LED); + sendDATA = cvsendDATA(0, LED); } inline void initializeIM920(){ @@ -140,8 +143,7 @@ SBDBT_USART.format(8, Serial::None, 1); SBDBT_USART.attach(SBDBT_RX, Serial::RxIrq); DTimer.attach(deadCheck, 0.3); - sdDATA = cvsendDATA(0, 0); - unsigned long outDATA[4]; + sendDATA = cvsendDATA(0, 0); } inline void readIM920(){ @@ -149,9 +151,9 @@ if (strlen(rcvBUFF_IM920) > 8) { cvrecvDATA(rcvBUFF_IM920, outDATA); readDATA(outDATA); - PC.printf("A2 = %d, X = %d, Y = %d, B = %d \r\n", a2, X, Y, b); deadCOUNT = 0; - DEVICE_TX(sdDATA, 1); + deadflag = 0; + DEVICE_TX(sendDATA, 1); } memset(rcvBUFF_IM920, '\0', 40); rcvFLAG = 0; @@ -160,17 +162,17 @@ if (strlen(rcvBUFF_SBDBT) > 4) { cvrecvDATAsbdbt(rcvBUFF_SBDBT, outDATA); readDATA(outDATA); - PC.printf("A2 = %d, X = %d, Y = %d, B = %d \r\n", a2, X, Y, b); deadCOUNT = 0; - DEVICE_TX(sdDATA, 2); + deadflag = 0; + DEVICE_TX(sendDATA, 2); } memset(rcvBUFF_SBDBT, '\0', 40); rcvFLAG = 0; } -}*/ +} /***Get state ps3con.***/ -#define SBDBT_TX p28 +/*#define SBDBT_TX p28 #define SBDBT_RX p27 Serial SBDBT(SBDBT_TX, SBDBT_RX); #define ps3_start 0x80 @@ -264,4 +266,4 @@ SBDBT.baud(2400); SBDBT.format(8, Serial::None, 1); SBDBT.attach(SBDBT_interrupt, Serial::RxIrq); -} \ No newline at end of file +}*/ \ No newline at end of file