UART1 buffered serial driver, requires RTOS
Dependents: Serial_interrupts_buffered HARP2 HARP3
Buffered serial UART1 - Setup to work with UART1 (p13,p14)
Uses RTOS to block current thread.
Reference: http://mbed.org/users/tylerjw/notebook/buffered-serial-with-rtos/
Revision 3:a4a21e18acd1, committed 2012-12-13
- Comitter:
- tylerjw
- Date:
- Thu Dec 13 06:53:43 2012 +0000
- Parent:
- 2:8ccf9bb8dc65
- Child:
- 4:d3122119f92b
- Commit message:
- commented out debug led code
Changed in this revision
buffered_serial.cpp | Show annotated file Show diff for this revision Revisions of this file |
buffered_serial.h | 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 Thu Dec 13 06:53:43 2012 +0000 @@ -1,6 +1,6 @@ #include "buffered_serial.h" -BufferedSerial::BufferedSerial(PinName tx, PinName rx) : Serial(tx,rx), led1(LED1), led2(LED2), rx_sem(0), tx_sem(0) +BufferedSerial::BufferedSerial(PinName tx, PinName rx) : Serial(tx,rx), /*led1(LED1), led2(LED2),*/ rx_sem(0), tx_sem(0) { tx_in=0; tx_out=0; @@ -90,25 +90,25 @@ void BufferedSerial::Rx_interrupt() { uint32_t IRR1 = LPC_UART1->IIR; - led1=1; + // led1=1; while (readable() && !(IS_RX_FULL)) { rx_buffer[rx_in] = LPC_UART1->RBR; rx_in = NEXT(rx_in); rx_sem.release(); } - led1=0; + // led1=0; } // Interupt Routine to write out data to serial port void BufferedSerial::Tx_interrupt() { uint32_t IRR = LPC_UART1->IIR; - led2=1; + // 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 tx_out = NEXT(tx_out); } if(!IS_TX_FULL) // if not full tx_sem.release(); - led2=0; + // led2=0; } \ No newline at end of file
--- a/buffered_serial.h Tue Dec 11 00:12:45 2012 +0000 +++ b/buffered_serial.h Thu Dec 13 06:53:43 2012 +0000 @@ -44,8 +44,8 @@ char tx_line[LINE_SIZE]; char rx_line[LINE_SIZE]; - DigitalOut led1; - DigitalOut led2; + //DigitalOut led1; // debug + //DigitalOut led2; Semaphore rx_sem; Semaphore tx_sem;