MODSERIAL with support for more devices

Dependents:   1D-Pong BMT-K9_encoder BMT-K9-Regelaar programma_filter ... more

Check the cookbook page for more information: https://mbed.org/cookbook/MODSERIAL

Did you add a device? Please send a pull request so we can keep everything in one library instead of many copies. In that case also send a PM, since currently mbed does not inform of new pull requests. I will then also add you to the developers of this library so you can do other changes directly.

Revision:
28:76793a84f9e5
Parent:
27:9c93ce7cb9d8
--- a/example1.cpp	Thu Jul 11 13:34:53 2013 +0000
+++ b/example1.cpp	Fri Jul 12 15:27:07 2013 +0000
@@ -10,7 +10,7 @@
 
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
-DigitalOut led3(LED2);
+DigitalOut led3(LED3);
 DigitalOut led4(LED4);
 
 MODSERIAL pc(USBTX, USBRX);
@@ -57,7 +57,7 @@
     pc.baud(PC_BAUD);
     
     // Use a deliberatly slow baud to fill up the TX buffer
-    uart.baud(300);
+    uart.baud(1200);
     
     uart.attach(&txCallback, MODSERIAL::TxIrq);
     uart.attach(&rxCallback, MODSERIAL::RxIrq);
@@ -68,19 +68,18 @@
     
     led1 = 1; // Show start of sending with LED1.
     
-    for (int loop = 0; loop < 2; loop++) {
+    for (int loop = 0; loop < 512; loop++) {
         uart.printf("%c", c);        
         c++;
         if (c > 'Z') c = 'A';
     }
-    pc.printf("%c", '!');
+    
     led1 = 0; // Show the end of sending by switching off LED1.
     
     // End program. Flash LED4. Notice how LED 2 and 3 continue
     // to flash for a short period while the interrupt system 
     // continues to send the characters left in the TX buffer.
-    wait(2);
-    pc.printf("\n\n\r%02X", UART2->C2);
+    
     while(1) {
         led4 = !led4;
         wait(0.25);