asdf
Dependencies: NokiaLCD XMIT_IR mbed
Fork of 4180_mP_WirelessPong_revC by
Diff: main.cpp
- Revision:
- 15:21c512907cf6
- Parent:
- 14:68f7cefd7359
- Child:
- 16:bc0e213ba52d
diff -r 68f7cefd7359 -r 21c512907cf6 main.cpp --- a/main.cpp Sat Oct 06 02:46:01 2012 +0000 +++ b/main.cpp Sat Oct 06 11:34:40 2012 +0000 @@ -38,7 +38,7 @@ Serial pc(USBTX,USBRX); PwmOut IRLED_mod(p21); -IRTransmitter ir_tx(p13,p21,p14,4,&ISR_UARTRX); //tx,pwm,size +//IRTransmitter ir_tx(p13,p21,p14,4,&ISR_UARTRX); //tx,pwm,size //Global Vars char text_buffer[32]; @@ -63,14 +63,6 @@ pc.baud(19200); pc.printf("Starting...\n\n"); - //Serial init - /*devicerx = new Serial(p13, p14); // tx, rx - (*devicerx).baud(2400); - //devicetx.baud(2400); - (*devicerx).attach(&ISR_UARTRX,Serial::RxIrq); - IRLED_mod.period(1.0/38000.0); //38kHz Modulation Freq - IRLED_mod = 0.5; */ - //Variable Init for(int i=0; i<10; i++) packet_buff[i]=0; @@ -125,7 +117,7 @@ while(true) { //If data available - Print data directly to USB port (for debug) - osEvent evt = rx_data_mailbox.get(); + /*osEvent evt = rx_data_mailbox.get(); while(evt.status == osEventMail) { char* mail = (char*)evt.value.p; //if((*mail)==0x02) pc.printf("\n"); @@ -135,12 +127,25 @@ rx_data_mailbox.free(mail); evt = rx_data_mailbox.get(); - } + }*/ + + /*osEvent evt = ir_tx.ir_data_mailbox.get(); + while(evt.status == osEventMail) { + char* mail = (char*)evt.value.p; + //if((*mail)==0x02) pc.printf("\n"); + //pc.printf("0x%02X.",*mail); + //error_code = CheckPacket(*mail,packet_buff,irdatIN,4); + //pc.printf(" ERROR=0x%02X.\n",error_code); + + ir_tx.ir_data_mailbox.free(mail); + evt = ir_tx.ir_data_mailbox.get(); + }*/ - /*char* data; - while(ir_tx.ReadPacket(data)==0) - pc.printf("0x%02X.",*data); - */ + char error_code; + //error_code = ir_tx.ReadPacket(irdatIN,4); + pc.printf("0x%02X.",error_code); + + //Do not return until we have more data //Thread::signal_wait(0x1); @@ -173,8 +178,8 @@ for(int i=1; i<data_len+1; i++) { check^=packet_buffer[i]; } - if(check==packet_buffer[data_len+1]) { - return 0; + if(check!=packet_buffer[data_len+1]) { + return 0x3; //bad checksum } return 0; @@ -193,7 +198,7 @@ irdatOUT[2] = ~(irdata_out*2); irdatOUT[3] = irdata_out*7+13; //MakePacket2(irdatOUT,4); - ir_tx.MakePacket(irdatOUT,4); + //ir_tx.MakePacket(irdatOUT,4); //Roughly use to set rate of data packets per second Thread::wait(50); @@ -221,13 +226,18 @@ uint32_t RBR = LPC_UART1->RBR; //write letter and put in mailbox - char* mail = rx_data_mailbox.alloc(); + /*char* mail = rx_data_mailbox.alloc(); mail[0] = (char)RBR; - rx_data_mailbox.put(mail); + rx_data_mailbox.put(mail);*/ + + /*char* mail = ir_tx.ir_data_mailbox.alloc(); + mail[0] = (char)RBR; + ir_tx.ir_data_mailbox.put(mail);*/ + //ir_tx.isr(RBR); //Let message handler run - (*threadptr_irstuff).signal_set(0x1); + //(*threadptr_irstuff).signal_set(0x1); }