テストモード追加、LED有効化 left -> SerialRX, Data Recieve Complete , Serial Tx , Light Tx
Dependencies: XBee mbed NetServicesMin
main.cpp@2:dec6319cf02c, 2012-04-18 (annotated)
- Committer:
- recotana
- Date:
- Wed Apr 18 07:52:46 2012 +0000
- Revision:
- 2:dec6319cf02c
- Parent:
- 1:36eb173eb52b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
recotana | 0:42adca80439c | 1 | #include "mbed.h" |
recotana | 0:42adca80439c | 2 | |
recotana | 1:36eb173eb52b | 3 | Serial pc(USBTX, USBRX); |
recotana | 1:36eb173eb52b | 4 | |
recotana | 0:42adca80439c | 5 | #include "config.h" |
recotana | 0:42adca80439c | 6 | #include "layer_frame.h" |
recotana | 1:36eb173eb52b | 7 | #include "leds.h" |
recotana | 0:42adca80439c | 8 | #include "serialRecieve.h" |
recotana | 0:42adca80439c | 9 | |
recotana | 0:42adca80439c | 10 | DigitalIn din(p20); |
recotana | 2:dec6319cf02c | 11 | DigitalIn lightButton(p30); |
recotana | 2:dec6319cf02c | 12 | |
recotana | 1:36eb173eb52b | 13 | |
recotana | 0:42adca80439c | 14 | extern Payload sendedPayload; |
recotana | 0:42adca80439c | 15 | |
recotana | 0:42adca80439c | 16 | volatile uint16_t count; |
recotana | 1:36eb173eb52b | 17 | volatile PrefSender spref; |
recotana | 0:42adca80439c | 18 | |
recotana | 2:dec6319cf02c | 19 | volatile int oldBt; |
recotana | 2:dec6319cf02c | 20 | volatile bool isChatterWait; |
recotana | 2:dec6319cf02c | 21 | Timeout chatterWait; |
recotana | 2:dec6319cf02c | 22 | |
recotana | 2:dec6319cf02c | 23 | void ctProcess(void) |
recotana | 2:dec6319cf02c | 24 | { |
recotana | 2:dec6319cf02c | 25 | if(oldBt ^ lightButton) |
recotana | 2:dec6319cf02c | 26 | { |
recotana | 2:dec6319cf02c | 27 | spref.lightsw = lightButton; |
recotana | 2:dec6319cf02c | 28 | oldBt = spref.lightsw; |
recotana | 2:dec6319cf02c | 29 | lightIlluminateChange(lightButton); |
recotana | 2:dec6319cf02c | 30 | } |
recotana | 2:dec6319cf02c | 31 | |
recotana | 2:dec6319cf02c | 32 | isChatterWait = false; |
recotana | 2:dec6319cf02c | 33 | } |
recotana | 2:dec6319cf02c | 34 | |
recotana | 2:dec6319cf02c | 35 | |
recotana | 2:dec6319cf02c | 36 | |
recotana | 0:42adca80439c | 37 | int main(){ |
recotana | 0:42adca80439c | 38 | |
recotana | 1:36eb173eb52b | 39 | serialInit(); |
recotana | 1:36eb173eb52b | 40 | |
recotana | 1:36eb173eb52b | 41 | #ifdef _SERVER_TEST_MODE_ |
recotana | 1:36eb173eb52b | 42 | pc.printf("*.*.*.*.*.*.*. T E S T M O D E *.*.*.*.*.*.*.*.*.*.\n"); |
recotana | 1:36eb173eb52b | 43 | #endif |
recotana | 0:42adca80439c | 44 | |
recotana | 1:36eb173eb52b | 45 | pc.printf("sender start\n"); |
recotana | 1:36eb173eb52b | 46 | din.mode(PullUp); |
recotana | 1:36eb173eb52b | 47 | |
recotana | 2:dec6319cf02c | 48 | lightIlluminateChange(0); |
recotana | 2:dec6319cf02c | 49 | |
recotana | 1:36eb173eb52b | 50 | spref.currentFrameNumber = 0; |
recotana | 1:36eb173eb52b | 51 | spref.gainData.gain = kTxGain; |
recotana | 1:36eb173eb52b | 52 | spref.gainData.middleLevel = kTxMidLevel; |
recotana | 2:dec6319cf02c | 53 | |
recotana | 1:36eb173eb52b | 54 | spref.continueusMode = 0; |
recotana | 1:36eb173eb52b | 55 | spref.isSend = 0; |
recotana | 1:36eb173eb52b | 56 | spref.xbeeAdress = 0; |
recotana | 0:42adca80439c | 57 | |
recotana | 0:42adca80439c | 58 | Payload test; |
recotana | 0:42adca80439c | 59 | initTestPayloadData(&test); |
recotana | 1:36eb173eb52b | 60 | |
recotana | 1:36eb173eb52b | 61 | initCarrierWave(); |
recotana | 0:42adca80439c | 62 | |
recotana | 1:36eb173eb52b | 63 | startLed(); |
recotana | 2:dec6319cf02c | 64 | |
recotana | 2:dec6319cf02c | 65 | isChatterWait = false; |
recotana | 2:dec6319cf02c | 66 | spref.lightsw = lightButton; |
recotana | 2:dec6319cf02c | 67 | oldBt = spref.lightsw; |
recotana | 2:dec6319cf02c | 68 | |
recotana | 2:dec6319cf02c | 69 | lightIlluminateChange(spref.lightsw); |
recotana | 1:36eb173eb52b | 70 | |
recotana | 0:42adca80439c | 71 | while(1){ |
recotana | 0:42adca80439c | 72 | |
recotana | 2:dec6319cf02c | 73 | //light button push or release |
recotana | 2:dec6319cf02c | 74 | if( (oldBt ^ lightButton) && !isChatterWait ){ |
recotana | 2:dec6319cf02c | 75 | |
recotana | 2:dec6319cf02c | 76 | isChatterWait = true; |
recotana | 2:dec6319cf02c | 77 | chatterWait.attach(&ctProcess,0.05); |
recotana | 2:dec6319cf02c | 78 | |
recotana | 2:dec6319cf02c | 79 | |
recotana | 2:dec6319cf02c | 80 | } |
recotana | 2:dec6319cf02c | 81 | |
recotana | 0:42adca80439c | 82 | readProcess(); |
recotana | 0:42adca80439c | 83 | |
recotana | 0:42adca80439c | 84 | |
recotana | 1:36eb173eb52b | 85 | if(spref.continueusMode == 1) sendPayload(&sendedPayload); |
recotana | 1:36eb173eb52b | 86 | |
recotana | 1:36eb173eb52b | 87 | else if(!din) sendPayload(&test); |
recotana | 1:36eb173eb52b | 88 | |
recotana | 0:42adca80439c | 89 | else sendByteData(0x00); |
recotana | 0:42adca80439c | 90 | |
recotana | 2:dec6319cf02c | 91 | |
recotana | 0:42adca80439c | 92 | } |
recotana | 0:42adca80439c | 93 | |
recotana | 0:42adca80439c | 94 | } |
recotana | 2:dec6319cf02c | 95 |