![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
UDPversion
Dependencies: XBee mbed NetServicesMin
common/disp_led/leds.cpp@0:84a3b029656e, 2012-04-14 (annotated)
- Committer:
- recotana
- Date:
- Sat Apr 14 03:53:45 2012 +0000
- Revision:
- 0:84a3b029656e
- Child:
- 1:3a46d2725374
UDPversion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
recotana | 0:84a3b029656e | 1 | #include "mbed.h" |
recotana | 0:84a3b029656e | 2 | #include "leds.h" |
recotana | 0:84a3b029656e | 3 | |
recotana | 0:84a3b029656e | 4 | #define kLedOnTime 0.05 |
recotana | 0:84a3b029656e | 5 | |
recotana | 0:84a3b029656e | 6 | #define kTcpConnect p30 |
recotana | 0:84a3b029656e | 7 | #define kTcpRx p29 |
recotana | 0:84a3b029656e | 8 | #define kTcpTx p28 |
recotana | 0:84a3b029656e | 9 | |
recotana | 0:84a3b029656e | 10 | #define kXBeeRx p27 |
recotana | 0:84a3b029656e | 11 | #define kXBeeTx p26 |
recotana | 0:84a3b029656e | 12 | |
recotana | 0:84a3b029656e | 13 | Timeout led_tcp_rx; |
recotana | 0:84a3b029656e | 14 | Timeout led_tcp_tx; |
recotana | 0:84a3b029656e | 15 | Timeout led_xbee_snd; |
recotana | 0:84a3b029656e | 16 | Timeout led_xbee_rec; |
recotana | 0:84a3b029656e | 17 | |
recotana | 0:84a3b029656e | 18 | DigitalOut ledTcpCon(kTcpConnect); |
recotana | 0:84a3b029656e | 19 | DigitalOut ledTcpRec(kTcpRx); |
recotana | 0:84a3b029656e | 20 | DigitalOut ledTcpSend(kTcpTx); |
recotana | 0:84a3b029656e | 21 | |
recotana | 0:84a3b029656e | 22 | DigitalOut ledXBeeRec(kXBeeRx); |
recotana | 0:84a3b029656e | 23 | DigitalOut ledXBeeSend(kXBeeTx); |
recotana | 0:84a3b029656e | 24 | |
recotana | 0:84a3b029656e | 25 | |
recotana | 0:84a3b029656e | 26 | void offTcpRx(void){ |
recotana | 0:84a3b029656e | 27 | ledTcpRec=0; |
recotana | 0:84a3b029656e | 28 | } |
recotana | 0:84a3b029656e | 29 | void offTcpTx(void){ |
recotana | 0:84a3b029656e | 30 | ledTcpSend=0; |
recotana | 0:84a3b029656e | 31 | } |
recotana | 0:84a3b029656e | 32 | void offXBeeRx(void){ |
recotana | 0:84a3b029656e | 33 | ledXBeeRec=0; |
recotana | 0:84a3b029656e | 34 | } |
recotana | 0:84a3b029656e | 35 | void offXBeeTx(void){ |
recotana | 0:84a3b029656e | 36 | ledXBeeSend=0; |
recotana | 0:84a3b029656e | 37 | } |
recotana | 0:84a3b029656e | 38 | |
recotana | 0:84a3b029656e | 39 | void ledTcpRx(void) |
recotana | 0:84a3b029656e | 40 | { |
recotana | 0:84a3b029656e | 41 | if(ledTcpRec == 1) return; |
recotana | 0:84a3b029656e | 42 | ledTcpRec=1; |
recotana | 0:84a3b029656e | 43 | led_tcp_rx.attach(&offTcpRx,kLedOnTime); |
recotana | 0:84a3b029656e | 44 | } |
recotana | 0:84a3b029656e | 45 | void ledTcpTx(void) |
recotana | 0:84a3b029656e | 46 | { |
recotana | 0:84a3b029656e | 47 | if(ledTcpSend == 1) return; |
recotana | 0:84a3b029656e | 48 | ledTcpSend=1; |
recotana | 0:84a3b029656e | 49 | led_tcp_tx.attach(&offTcpTx,kLedOnTime); |
recotana | 0:84a3b029656e | 50 | } |
recotana | 0:84a3b029656e | 51 | void ledXBeeRx(void) |
recotana | 0:84a3b029656e | 52 | { |
recotana | 0:84a3b029656e | 53 | if(ledXBeeRec == 1) return; |
recotana | 0:84a3b029656e | 54 | ledXBeeRec=1; |
recotana | 0:84a3b029656e | 55 | led_xbee_rec.attach(&offXBeeRx,kLedOnTime); |
recotana | 0:84a3b029656e | 56 | } |
recotana | 0:84a3b029656e | 57 | void ledXBeeTx(void) |
recotana | 0:84a3b029656e | 58 | { |
recotana | 0:84a3b029656e | 59 | if(ledXBeeSend == 1) return; |
recotana | 0:84a3b029656e | 60 | ledXBeeSend=1; |
recotana | 0:84a3b029656e | 61 | led_xbee_snd.attach(&offXBeeTx,kLedOnTime); |
recotana | 0:84a3b029656e | 62 | } |
recotana | 0:84a3b029656e | 63 | |
recotana | 0:84a3b029656e | 64 | |
recotana | 0:84a3b029656e | 65 | void ledTcpConnect(bool isConnect) |
recotana | 0:84a3b029656e | 66 | { |
recotana | 0:84a3b029656e | 67 | if(isConnect) ledTcpCon=1; |
recotana | 0:84a3b029656e | 68 | else ledTcpCon=0; |
recotana | 0:84a3b029656e | 69 | } |
recotana | 0:84a3b029656e | 70 | |
recotana | 0:84a3b029656e | 71 | |
recotana | 0:84a3b029656e | 72 | void startLed(void){ |
recotana | 0:84a3b029656e | 73 | ledTcpCon=1; |
recotana | 0:84a3b029656e | 74 | wait(0.2); |
recotana | 0:84a3b029656e | 75 | ledTcpCon=0; |
recotana | 0:84a3b029656e | 76 | |
recotana | 0:84a3b029656e | 77 | ledTcpRec=1; |
recotana | 0:84a3b029656e | 78 | wait(0.2); |
recotana | 0:84a3b029656e | 79 | ledTcpRec=0; |
recotana | 0:84a3b029656e | 80 | |
recotana | 0:84a3b029656e | 81 | ledTcpSend=1; |
recotana | 0:84a3b029656e | 82 | wait(0.2); |
recotana | 0:84a3b029656e | 83 | ledTcpSend=0; |
recotana | 0:84a3b029656e | 84 | |
recotana | 0:84a3b029656e | 85 | ledXBeeRec=1; |
recotana | 0:84a3b029656e | 86 | wait(0.2); |
recotana | 0:84a3b029656e | 87 | ledXBeeRec=0; |
recotana | 0:84a3b029656e | 88 | |
recotana | 0:84a3b029656e | 89 | ledXBeeSend=1; |
recotana | 0:84a3b029656e | 90 | wait(0.2); |
recotana | 0:84a3b029656e | 91 | ledXBeeSend=0; |
recotana | 0:84a3b029656e | 92 | |
recotana | 0:84a3b029656e | 93 | |
recotana | 0:84a3b029656e | 94 | wait(0.4); |
recotana | 0:84a3b029656e | 95 | |
recotana | 0:84a3b029656e | 96 | for(uint8_t i=0; i<2 ;i++){ |
recotana | 0:84a3b029656e | 97 | |
recotana | 0:84a3b029656e | 98 | ledTcpCon=1; |
recotana | 0:84a3b029656e | 99 | ledTcpRec=1; |
recotana | 0:84a3b029656e | 100 | ledTcpSend=1; |
recotana | 0:84a3b029656e | 101 | ledXBeeRec=1; |
recotana | 0:84a3b029656e | 102 | ledXBeeSend=1; |
recotana | 0:84a3b029656e | 103 | wait(0.05); |
recotana | 0:84a3b029656e | 104 | |
recotana | 0:84a3b029656e | 105 | ledTcpCon=0; |
recotana | 0:84a3b029656e | 106 | ledTcpRec=0; |
recotana | 0:84a3b029656e | 107 | ledTcpSend=0; |
recotana | 0:84a3b029656e | 108 | ledXBeeRec=0; |
recotana | 0:84a3b029656e | 109 | ledXBeeSend=0; |
recotana | 0:84a3b029656e | 110 | wait(0.1); |
recotana | 0:84a3b029656e | 111 | |
recotana | 0:84a3b029656e | 112 | } |
recotana | 0:84a3b029656e | 113 | |
recotana | 0:84a3b029656e | 114 | } |