MultiTech / MTS-Utils

Dependents:   mtsas mtsas thermostat_fan_demo--fan mtsas ... more

NOTE: MTS-Utils has moved to GitHub. This version will not be updated. For updates, go to the GitHub version.

Revision:
13:4709c2dfcd11
Parent:
6:fca9bc67b15f
diff -r 7818d55b35c6 -r 4709c2dfcd11 MTSCircularBuffer.cpp
--- a/MTSCircularBuffer.cpp	Mon Mar 23 16:37:56 2015 -0500
+++ b/MTSCircularBuffer.cpp	Mon Jun 08 15:30:12 2015 -0500
@@ -20,8 +20,10 @@
         if (readIndex == bufferSize) {
             readIndex = 0;
         }
+        __disable_irq();
         data[i++] = buffer[readIndex++];
         bytes--;
+        __enable_irq();
         checkThreshold();
     }
     return i;
@@ -35,8 +37,10 @@
     if (readIndex == bufferSize) {
         readIndex = 0;
     }
+    __disable_irq();
     data = buffer[readIndex++];
     bytes--;
+    __enable_irq();
     checkThreshold();
     return 1;
 }
@@ -48,8 +52,10 @@
         if(writeIndex == bufferSize) {
             writeIndex = 0;
         }
+        __disable_irq();
         buffer[writeIndex++] = data[i++];
         bytes++;
+        __enable_irq();
         checkThreshold();
     }
     return i;
@@ -63,8 +69,10 @@
     if(writeIndex == bufferSize) {
         writeIndex = 0;
     }
+    __disable_irq();
     buffer[writeIndex++] = data;
     bytes++;
+    __enable_irq();
     checkThreshold();
     return 1;
 }