A test program to see why the RTOS doesn't like to play with the serial interrupt.

Dependencies:   mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
the_programmer
Date:
Fri Dec 28 19:27:23 2012 +0000
Child:
1:54099c52b7dc
Commit message:
Initial commit (stripped version of full code)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 28 19:27:23 2012 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+
+#define DEBUG
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+Serial probe(p9,p10);
+
+#ifdef DEBUG
+Serial pc(USBTX,USBRX);
+#endif
+
+char serialBuffer[256];
+unsigned char serialBufferLoc = 0;
+
+void rxInterrupt(void){
+    NVIC_DisableIRQ(UART3_IRQn);
+    uint32_t IRR3 = LPC_UART3->IIR;
+    led2=!led2;
+    serialBuffer[serialBufferLoc] = LPC_UART3->RBR;
+
+#ifdef DEBUG
+    pc.putc(serialBuffer[serialBufferLoc]);
+#endif
+
+    if (serialBuffer[serialBufferLoc] == 0x0A) {
+        pc.printf("cr found\r\n");
+    }
+
+    serialBufferLoc++;
+    NVIC_EnableIRQ(UART3_IRQn);
+}
+
+void serialProbeInit(void){
+    probe.baud(9600);
+    probe.format(8,Serial::None,1);
+    probe.attach(&rxInterrupt,Serial::RxIrq);
+}
+
+#ifdef DEBUG
+void serialPcInit(void){
+    pc.baud(115200);
+    pc.format(8,Serial::None,1);
+}
+#endif
+
+int main(){
+    serialProbeInit();
+#ifdef DEBUG
+    serialPcInit();
+    pc.printf("Comtest, MBED started\r\n");
+#endif    
+    while(1){
+        led1 = 1;
+        wait(0.2);
+        led1 = 0;
+        led2 = 0;
+        wait(0.2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Dec 28 19:27:23 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#88a1a9c26ae3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Dec 28 19:27:23 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63cdd78b2dc1
\ No newline at end of file