MODSERIAL with support for KL25Z + RTOS (beta, putc + puts currently)

Dependents:   kl25z_USB_4

Fork of MODSERIAL by Erik -

Files at this revision

API Documentation at this revision

Comitter:
AjK
Date:
Thu Apr 19 20:47:46 2012 +0000
Parent:
21:af2af4c61c2f
Child:
23:5c45c21f36b7
Commit message:
1.22 Buffer pointer fix by Anthony Wieser

Changed in this revision

ChangeLog.c Show annotated file Show diff for this revision Revisions of this file
GETC.cpp Show annotated file Show diff for this revision Revisions of this file
PUTC.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ChangeLog.c	Tue May 10 08:07:27 2011 +0000
+++ b/ChangeLog.c	Thu Apr 19 20:47:46 2012 +0000
@@ -1,5 +1,13 @@
 /* $Id:$
 
+1.22    19th April 2012
+
+    * http://mbed.org/forum/bugs-suggestions/topic/2936/
+    * Bug fix, protect important buffer pointers from IRQ corruption.
+      Credits: 
+        Anthony Wieser  http://mbed.org/users/WieserSoftwareLtd/ for the fix.
+        BlazeX http://mbed.org/users/BlazeX/ for the alert that a fix was needed!
+
 1.21    10 May 2011
     
     * http://mbed.org/forum/mbed/topic/2264
--- a/GETC.cpp	Tue May 10 08:07:27 2011 +0000
+++ b/GETC.cpp	Thu Apr 19 20:47:46 2012 +0000
@@ -56,7 +56,9 @@
         _IER = ier;
     }
     
+    __disable_irq();
     buffer_count[RxIrq]--;   
+    __enable_irq();
     return c;
 }
 
--- a/PUTC.cpp	Tue May 10 08:07:27 2011 +0000
+++ b/PUTC.cpp	Thu Apr 19 20:47:46 2012 +0000
@@ -65,7 +65,9 @@
         }
         _IER &= ~2;
         buffer[TxIrq][buffer_in[TxIrq]] = c;
+        __disable_irq();
         buffer_count[TxIrq]++;
+        __enable_irq();
         buffer_in[TxIrq]++;
         if (buffer_in[TxIrq] >= buffer_size[TxIrq]) {
             buffer_in[TxIrq] = 0;