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/
Diff: buffered_serial.cpp
- Revision:
- 2:8ccf9bb8dc65
- Parent:
- 1:eabb26ce183b
- Child:
- 3:a4a21e18acd1
--- a/buffered_serial.cpp Tue Dec 11 00:08:24 2012 +0000 +++ b/buffered_serial.cpp Tue Dec 11 00:12:45 2012 +0000 @@ -56,7 +56,6 @@ i = 0; // Start Critical Section - don't interrupt while changing global buffer variables NVIC_DisableIRQ(device_irqn); - memset(rx_line,LINE_SIZE,0); // Loop reading rx buffer characters until end of line character while ((i==0) || (rx_line[i-1] != '\n')) { // Wait if buffer empty @@ -75,11 +74,11 @@ rx_out = NEXT(rx_out); // prevent overflow on rx_line - /*if(i >= (LINE_SIZE - 1)) // not working!!! + if(i == LINE_SIZE) { i--; break; - }*/ + } } rx_line[i++] = 0; // End Critical Section