asdf

Dependencies:   NokiaLCD XMIT_IR mbed

Fork of 4180_mP_WirelessPong_revC by Curtis Mulady

Revision:
19:5a4be4519de5
Parent:
18:98839f78fc01
Child:
20:a74fe4d43ec0
--- a/main.cpp	Sat Oct 06 17:36:47 2012 +0000
+++ b/main.cpp	Sat Oct 06 17:45:32 2012 +0000
@@ -3,7 +3,8 @@
 #include "NokiaLCD.h"
 #include "XMIT_IR.h"
 
-#define FPS 10
+#define FPS 15
+#define PKT_RATE 15
 
 /****************************************
 |=======================================|
@@ -23,7 +24,6 @@
 void UpdateLCD(void const* arguments);
 void IRStuff(void const* arguments);
 void ISR_UARTRX(void);
-void ISR_UARTTX(void);
 char CheckPacket(char new_data, char* packet_buffer, char* data, int data_len);
 void MakePacket2(char* data,int len);
 
@@ -39,7 +39,7 @@
 Serial pc(USBTX,USBRX);
 PwmOut IRLED_mod(p21);
 
-IRTransmitter ir_tx(p13,p21,p14,4,&ISR_UARTRX,&ISR_UARTTX); //tx,pwm,size
+IRTransmitter ir_tx(p13,p21,p14,4,&ISR_UARTRX); //tx,pwm,size
 
 //Global Vars
 char text_buffer[32];
@@ -49,7 +49,6 @@
 char error_code=0;
 Thread* threadptr_irstuff;
 char packet_buff[10];
-Mail<char,64> rx_data_mailbox;
 Mutex data_update_mutex;
 
 
@@ -84,6 +83,7 @@
 
         //Use main loop to set LCD framerate
         thread_updatelcd.signal_set(0x1);
+        thread_blinkalive.signal_set(0x1);
         Thread::wait(1000/FPS);
 
     }
@@ -141,7 +141,7 @@
         result = ir_tx.ReadPacket(temp_buff,4);
 
         if(result == 0x1) {
-            //pc.printf("\n");
+            pc.printf("\n");
             //update data - mutex
             data_update_mutex.lock();
             for(int i=0; i<4; i++) {
@@ -149,7 +149,7 @@
             }
             data_update_mutex.unlock();
             for(int i=0; i<4; i++) {
-                //pc.printf("0x%02X.",irdatIN[i]);
+                pc.printf("0x%02X.",irdatIN[i]);
             }
         }
 
@@ -162,37 +162,8 @@
 
 }
 
-char CheckPacket(char new_data, char* packet_buffer, char* data, int data_len)
-{
-    //Requires a packet buffer of length 'data_len'+3.
-    //Shifts data and checks each 'set' for a valid packet.
-    //Once a valid packet is receievd, the data buffer is updated with new values.
-    //returns success(0) or failure(error code)
 
 
-    char check=0x0;
-    //Shift All data 1 cell over
-    for(int i=0; i<data_len+2; i++) {
-        packet_buffer[i] = packet_buffer[i+1];
-    }
-    packet_buffer[data_len+2] = new_data;
-
-    //check for valid packet
-    if(packet_buffer[0]!=ASCII_STX)
-        return 0x1; //bad start byte
-    if(packet_buffer[data_len+2]!=ASCII_ETX)
-        return 0x2; //bad end byte
-
-    for(int i=1; i<data_len+1; i++) {
-        check^=packet_buffer[i];
-    }
-    if(check!=packet_buffer[data_len+1]) {
-        return 0x3; //bad checksum
-    }
-
-    return 0;
-}
-
 void BlinkAlive(void const* arguments)
 {
     while(true) {
@@ -205,11 +176,11 @@
         irdatOUT[1] = ++irdata_out;
         irdatOUT[2] = ~(irdata_out*2);
         irdatOUT[3] = irdata_out*7+13;
-        //MakePacket2(irdatOUT,4);
         ir_tx.MakePacket(irdatOUT,4);
 
         //Roughly use to set rate of data packets per second
-        Thread::wait(1000);
+        //Thread::wait(100);
+        Thread::signal_wait(0x1);
     }
 }
 
@@ -225,15 +196,5 @@
 
 }
 
-//Handle Transmission of TX data (mail it to appropriate thread)
-void ISR_UARTTX()
-{
-    //get RX data (and prevent ISR from looping forever
-    //uint32_t RBR = LPC_UART1->RBR;
 
-    char data = ir_tx.isr_tx();
-    LPC_UART1->THR = (uint32_t)data;
-    //LPC_UART1->THR = '?';
 
-}
-