Serial Interrupt Library with mbed RTOS for multi-threading
Dependencies: buffered-serial1 mbed-rtos mbed
Fork of Serial_interrupts by
Diff: main.cpp
- Revision:
- 2:3d959c9fc9d7
- Parent:
- 1:2f1e54d137c7
- Child:
- 4:b6e538868312
--- a/main.cpp Mon Dec 10 00:32:22 2012 +0000 +++ b/main.cpp Mon Dec 10 22:33:57 2012 +0000 @@ -8,35 +8,11 @@ // LED1 and LED2 indicate RX and TX interrupt routine activity // LED3 changing indicate main loop running +BufferedSerial device(p13,p14); // tx, rx -BufferedSerial device(p13,p14); // tx, rx -//IRQn device_irqn = UART1_IRQn; -// Can also use USB and type back in the number printed out in a terminal window -// Serial monitor_device(USBTX, USBRX); -DigitalOut led1(LED1); -DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); -/* -void Tx_interrupt(); -void Rx_interrupt(); -void send_line(); -void read_line(); - - -// Circular buffers for serial TX and RX data - used by interrupt routines -const int buffer_size = 255; -// might need to increase buffer size for high baud rates -char tx_buffer[buffer_size]; -char rx_buffer[buffer_size]; -// Circular buffer pointers -// volatile makes read-modify-write atomic -volatile int tx_in=0; -volatile int tx_out=0; -volatile int rx_in=0; -volatile int rx_out=0; -*/ // Line buffers for sprintf and sscanf char tx_line[80]; char rx_line[80]; @@ -47,12 +23,7 @@ int i=0; int rx_i=0; device.baud(9600); -/* -// Setup a serial interrupt function to receive data - device.attach(&Rx_interrupt, Serial::RxIrq); -// Setup a serial interrupt function to transmit data - device.attach(&Tx_interrupt, Serial::TxIrq); -*/ + // Formatted IO test using send and receive serial interrupts // with sprintf and sscanf while (1) {