Files at this revision

API Documentation at this revision

Comitter:
mbed714
Date:
Sat Feb 20 11:26:16 2010 +0000
Commit message:

Changed in this revision

main.cpp 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
diff -r 000000000000 -r 90e9a34552d3 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 20 11:26:16 2010 +0000
@@ -0,0 +1,50 @@
+#include "mbed.h"
+
+// Test app to cause program to suddently terminate when using serial interrupt...
+// Line 24 seems to be the important bit, but I don't really understand why?
+// Is it perhaps the putc is peroperly clearing the interrupt flag instead of the getc?
+
+
+// usb serial device defaults to 9600 baud, 8N1 on /dev/ttyACM0 (in Linux!)
+Serial pc(USBTX, USBRX); // tx, rx
+
+// debugging LEDs
+DigitalOut interrupt(LED1);
+DigitalOut tx(LED4);
+
+// one byte receive buffer
+char rx_byte;
+
+void handle()
+{
+  interrupt = 1;
+  //if(pc.readable()) // <--- this line doesn't matter either way...
+  {
+    rx_byte = pc.getc();
+    //pc.putc(rx_byte);  // <--- WITHOUT THIS LINE, THE APPLICATION WILL HANG IF IT RECEIVES WHILE SENDING!
+  }
+  interrupt = 0;
+  return;
+}
+
+int main()
+{
+  interrupt = 0;
+  tx = 0;
+  pc.attach(handle);
+  
+  while(1) 
+  {
+    // send a long string of bytes 
+    tx = 1;
+    for(int i=0;i<20;i++)
+    {
+      NVIC_DisableIRQ(UART0_IRQn);
+      pc.printf("If I receive while transmitting this I *won't* crash...\r\n");
+      NVIC_EnableIRQ(UART0_IRQn);
+    }
+    tx = 0;
+    
+    wait(1.0);
+  }
+}
\ No newline at end of file
diff -r 000000000000 -r 90e9a34552d3 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 20 11:26:16 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0