asdf

Dependencies:   NokiaLCD XMIT_IR mbed

Fork of 4180_mP_WirelessPong_revC by Curtis Mulady

Revision:
18:98839f78fc01
Parent:
17:f92e4a384637
Child:
19:5a4be4519de5
--- a/main.cpp	Sat Oct 06 13:40:39 2012 +0000
+++ b/main.cpp	Sat Oct 06 17:36:47 2012 +0000
@@ -3,7 +3,7 @@
 #include "NokiaLCD.h"
 #include "XMIT_IR.h"
 
-#define FPS 5
+#define FPS 10
 
 /****************************************
 |=======================================|
@@ -23,6 +23,7 @@
 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);
 
@@ -38,7 +39,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,&ISR_UARTTX); //tx,pwm,size
 
 //Global Vars
 char text_buffer[32];
@@ -140,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++) {
@@ -148,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]);
             }
         }
 
@@ -208,21 +209,10 @@
         ir_tx.MakePacket(irdatOUT,4);
 
         //Roughly use to set rate of data packets per second
-        Thread::wait(200);
+        Thread::wait(1000);
     }
 }
 
-void MakePacket2(char* data,int len)
-{
-    /*char check =0x0;
-    (*devicerx).putc(ASCII_STX);
-    for(int i=0; i<len; i++) {
-        check^=data[i];
-        (*devicerx).putc(data[i]);
-    }
-    (*devicerx).putc(check);
-    (*devicerx).putc(ASCII_ETX);*/
-}
 
 
 
@@ -231,20 +221,19 @@
 {
     //get RX data (and prevent ISR from looping forever
     uint32_t RBR = LPC_UART1->RBR;
-
-    //write letter and put in mailbox
-    /*char* mail = rx_data_mailbox.alloc();
-    mail[0] = (char)RBR;
-    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);
+    ir_tx.isr_rx(RBR);
 
 }
 
+//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 = '?';
+
+}
+