buffered-serial for use with MBED's main USB serial interface (UART0).

Fork of buffered-serial1 by Tyler Weaver

Files at this revision

API Documentation at this revision

Comitter:
jrj
Date:
Mon Jun 10 14:13:11 2013 +0000
Parent:
2:8ccf9bb8dc65
Commit message:
Adding buffered-serial1 from http://mbed.org/users/tylerjw/code/Serial_interrupts_buffered/docs/e489f1ee71d8/main_8cpp_source.html; ; normal serial interface with callbacks doesn't work when the project includes RTOS.

Changed in this revision

buffered_serial.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/buffered_serial.cpp	Tue Dec 11 00:12:45 2012 +0000
+++ b/buffered_serial.cpp	Mon Jun 10 14:13:11 2013 +0000
@@ -7,7 +7,7 @@
     rx_in=0;
     rx_out=0;
 
-    device_irqn = UART1_IRQn;
+    device_irqn = UART0_IRQn;
 
     // attach the interrupts
     Serial::attach(this, &BufferedSerial::Rx_interrupt, Serial::RxIrq);
@@ -43,7 +43,7 @@
         temp_char = tx_buffer[tx_out];
         tx_out = NEXT(tx_out);
         // Send first character to start tx interrupts, if stopped
-        LPC_UART1->THR = temp_char;
+        LPC_UART0->THR = temp_char;
     }
     // End Critical Section
     NVIC_EnableIRQ(device_irqn);
@@ -89,10 +89,10 @@
 // Interupt Routine to read in data from serial port
 void BufferedSerial::Rx_interrupt()
 {
-    uint32_t IRR1 = LPC_UART1->IIR;
+    uint32_t IRR0= LPC_UART0->IIR;
     led1=1;
     while (readable() && !(IS_RX_FULL)) {
-        rx_buffer[rx_in] = LPC_UART1->RBR;
+        rx_buffer[rx_in] = LPC_UART0->RBR;
         rx_in = NEXT(rx_in);
         rx_sem.release();
     }
@@ -102,10 +102,10 @@
 // Interupt Routine to write out data to serial port
 void BufferedSerial::Tx_interrupt()
 {
-    uint32_t IRR = LPC_UART1->IIR;
+    uint32_t IRR = LPC_UART0->IIR;
     led2=1;
     while ((writeable()) && (tx_in != tx_out)) { // while serial is writeable and there are still characters in the buffer
-        LPC_UART1->THR = tx_buffer[tx_out]; // send the character
+        LPC_UART0->THR = tx_buffer[tx_out]; // send the character
         tx_out = NEXT(tx_out);
     }
     if(!IS_TX_FULL) // if not full