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