![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
KEIS
main.cpp@0:e1f99f01bf67, 2013-10-01 (annotated)
- Committer:
- khayakawa
- Date:
- Tue Oct 01 00:11:57 2013 +0000
- Revision:
- 0:e1f99f01bf67
KEIS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
khayakawa | 0:e1f99f01bf67 | 1 | /* PC=router divce, mbed=cordinator */ |
khayakawa | 0:e1f99f01bf67 | 2 | /* */ |
khayakawa | 0:e1f99f01bf67 | 3 | /* */ |
khayakawa | 0:e1f99f01bf67 | 4 | |
khayakawa | 0:e1f99f01bf67 | 5 | #include "mbed.h" |
khayakawa | 0:e1f99f01bf67 | 6 | #include "C12832_lcd.h" |
khayakawa | 0:e1f99f01bf67 | 7 | |
khayakawa | 0:e1f99f01bf67 | 8 | Serial pc(USBTX, USBRX); // tx, rx |
khayakawa | 0:e1f99f01bf67 | 9 | Serial device(p9, p10); // tx, rx |
khayakawa | 0:e1f99f01bf67 | 10 | C12832_LCD lcd; |
khayakawa | 0:e1f99f01bf67 | 11 | DigitalOut myled(LED1); |
khayakawa | 0:e1f99f01bf67 | 12 | DigitalIn fire(p14); |
khayakawa | 0:e1f99f01bf67 | 13 | |
khayakawa | 0:e1f99f01bf67 | 14 | char* ch[16]={"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"}; |
khayakawa | 0:e1f99f01bf67 | 15 | |
khayakawa | 0:e1f99f01bf67 | 16 | void dev_rx () { |
khayakawa | 0:e1f99f01bf67 | 17 | char val; |
khayakawa | 0:e1f99f01bf67 | 18 | int tmp1,tmp2; |
khayakawa | 0:e1f99f01bf67 | 19 | |
khayakawa | 0:e1f99f01bf67 | 20 | myled=1; |
khayakawa | 0:e1f99f01bf67 | 21 | val=device.getc(); |
khayakawa | 0:e1f99f01bf67 | 22 | //lcd.printf("%x ",val); |
khayakawa | 0:e1f99f01bf67 | 23 | tmp1 = val/16; |
khayakawa | 0:e1f99f01bf67 | 24 | tmp2 = val%16; |
khayakawa | 0:e1f99f01bf67 | 25 | pc.printf("%s%s",ch[tmp1],ch[tmp2]); |
khayakawa | 0:e1f99f01bf67 | 26 | //wait(.2); |
khayakawa | 0:e1f99f01bf67 | 27 | myled=0; |
khayakawa | 0:e1f99f01bf67 | 28 | |
khayakawa | 0:e1f99f01bf67 | 29 | |
khayakawa | 0:e1f99f01bf67 | 30 | } |
khayakawa | 0:e1f99f01bf67 | 31 | |
khayakawa | 0:e1f99f01bf67 | 32 | int main() { |
khayakawa | 0:e1f99f01bf67 | 33 | |
khayakawa | 0:e1f99f01bf67 | 34 | lcd.cls(); |
khayakawa | 0:e1f99f01bf67 | 35 | lcd.locate(0,0); |
khayakawa | 0:e1f99f01bf67 | 36 | myled=0; |
khayakawa | 0:e1f99f01bf67 | 37 | int i,tmp1,tmp2,tgl; |
khayakawa | 0:e1f99f01bf67 | 38 | int sd_data_on[20]={0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x92,0xFF,0x77,0xFF,0xFE,0x02,0x44,0x32,0x05,0x70}; |
khayakawa | 0:e1f99f01bf67 | 39 | int sd_data_off[20]={0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x92,0xFF,0x77,0xFF,0xFE,0x02,0x44,0x32,0x04,0x71}; |
khayakawa | 0:e1f99f01bf67 | 40 | |
khayakawa | 0:e1f99f01bf67 | 41 | device.attach(&dev_rx, Serial::RxIrq); |
khayakawa | 0:e1f99f01bf67 | 42 | |
khayakawa | 0:e1f99f01bf67 | 43 | tgl=0; |
khayakawa | 0:e1f99f01bf67 | 44 | while(1) { |
khayakawa | 0:e1f99f01bf67 | 45 | if (fire) { |
khayakawa | 0:e1f99f01bf67 | 46 | for(i=0 ; i<20 ; i++){ |
khayakawa | 0:e1f99f01bf67 | 47 | if(tgl==0){ |
khayakawa | 0:e1f99f01bf67 | 48 | device.putc(sd_data_on[i]); |
khayakawa | 0:e1f99f01bf67 | 49 | tmp1 = sd_data_on[i]/16; |
khayakawa | 0:e1f99f01bf67 | 50 | tmp2 = sd_data_on[i]%16; |
khayakawa | 0:e1f99f01bf67 | 51 | }else{ |
khayakawa | 0:e1f99f01bf67 | 52 | device.putc(sd_data_off[i]); |
khayakawa | 0:e1f99f01bf67 | 53 | tmp1 = sd_data_off[i]/16; |
khayakawa | 0:e1f99f01bf67 | 54 | tmp2 = sd_data_off[i]%16; |
khayakawa | 0:e1f99f01bf67 | 55 | } |
khayakawa | 0:e1f99f01bf67 | 56 | lcd.printf("%s%s",ch[tmp1],ch[tmp2]); |
khayakawa | 0:e1f99f01bf67 | 57 | pc.printf("%s%s",ch[tmp1],ch[tmp2]); |
khayakawa | 0:e1f99f01bf67 | 58 | } |
khayakawa | 0:e1f99f01bf67 | 59 | if(tgl==0) |
khayakawa | 0:e1f99f01bf67 | 60 | tgl=1; |
khayakawa | 0:e1f99f01bf67 | 61 | else |
khayakawa | 0:e1f99f01bf67 | 62 | tgl=0; |
khayakawa | 0:e1f99f01bf67 | 63 | } |
khayakawa | 0:e1f99f01bf67 | 64 | wait(0.2); |
khayakawa | 0:e1f99f01bf67 | 65 | } |
khayakawa | 0:e1f99f01bf67 | 66 | |
khayakawa | 0:e1f99f01bf67 | 67 | //device.attach(dev_rx, RxIrq); |
khayakawa | 0:e1f99f01bf67 | 68 | |
khayakawa | 0:e1f99f01bf67 | 69 | |
khayakawa | 0:e1f99f01bf67 | 70 | } |