library for implementing ir transmission

Revision:
7:01243fe65940
Parent:
6:281167565d6d
--- a/XMIT_IR.cpp	Sat Oct 06 17:36:37 2012 +0000
+++ b/XMIT_IR.cpp	Sat Oct 06 17:45:20 2012 +0000
@@ -2,7 +2,7 @@
 #include "XMIT_IR.h"
 
 
-IRTransmitter::IRTransmitter(PinName TX, PinName PWM, PinName RX, int data_buff_len, void (*fptr_isr_rx)(void), void (*fptr_isr_tx)(void))
+IRTransmitter::IRTransmitter(PinName TX, PinName PWM, PinName RX, int data_buff_len, void (*fptr_isr_rx)(void))
 {
     ir_serial = new Serial(TX,RX);
     ir_pwm = new PwmOut(PWM);
@@ -14,11 +14,6 @@
     (*ir_pwm) = 0.5;                //pulse width = 50%
     (*ir_serial).baud(2400);
     (*ir_serial).attach(fptr_isr_rx,Serial::RxIrq);
-    (*ir_serial).attach(fptr_isr_tx,Serial::TxIrq);
-
-//    uint_32 tmp = LPC_UART1->IER;
-
-//    LPC_UART1->IER = tmp;
 
     //Initialize Variables
     for(int i=0; i<data_buff_len+3; i++)
@@ -42,38 +37,15 @@
 void IRTransmitter::MakePacket(char* data,int len)
 {
     char check =0x0;
-    Timer t;
-    t.reset();
-    t.start();
-
-    //(*ir_serial).putc(ASCII_STX);
-    mail_tx_packet(ASCII_STX);
+    
+    (*ir_serial).putc(ASCII_STX);
     for(int i=0; i<len; i++) {
         check^=data[i];
-        //(*ir_serial).putc(data[i]);
-        mail_tx_packet(data[i]);
+        (*ir_serial).putc(data[i]);
     }
-    //(*ir_serial).putc(check);
-    mail_tx_packet(check);
-    //(*ir_serial).putc(ASCII_ETX);
-    mail_tx_packet(ASCII_ETX);
-
-    t.stop();
-    int time = t.read_ms();
-    (*debug_port).printf("\nms=%d\n",time);
+    (*ir_serial).putc(check);
+    (*ir_serial).putc(ASCII_ETX);
 
-    char tmp = isr_tx();
-    LPC_UART1->THR = (uint32_t)data;
-
-
-
-}
-
-void IRTransmitter::mail_tx_packet(char data)
-{
-    char* mail = ir_txdata_mailbox.alloc();
-    mail[0] = data;
-    ir_txdata_mailbox.put(mail);
 }
 
 
@@ -102,10 +74,6 @@
         }
         (*debug_port).printf("  PKT_VALID=0x%02X.",packet_is_valid(len));*/
 
-        if((*data)=='?') {
-            (*debug_port).putc('*');
-        }
-
 
 
         if(packet_is_valid(len)==0) {
@@ -163,22 +131,4 @@
     ir_rxdata_mailbox.put(mail);
 }
 
-char IRTransmitter::isr_tx(void)
-{
-    //char* mail = ir_rxdata_mailbox.alloc();
-    //mail[0] = (char)data;
-    //ir_rxdata_mailbox.put(mail);
 
-    char data = 0xF1;
-    osEvent evt = ir_txdata_mailbox.get();
-    if(evt.status == osEventMail) {
-        char* mail = (char*)evt.value.p;
-        data = (*mail);
-
-        //(*ir_serial).putc(data);
-        ir_rxdata_mailbox.free(mail);
-    }
-    //(*debug_port).printf("TX=0x%02X.",data);
-    return data;
-}
-