Add in a new common Delay_MS() function, which provides a blocking delay for all...
[pub/lufa.git] / LUFA / Drivers / Misc / RingBuffer.h
index 1a825ac..5c8c840 100644 (file)
                {\r
                        GCC_FORCE_POINTER_ACCESS(Buffer);\r
 \r
-                       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {       \r
-                               Buffer->In     = DataPtr;\r
-                               Buffer->Out    = DataPtr;\r
-                               Buffer->Start  = &DataPtr[0];\r
-                               Buffer->End    = &DataPtr[Size];\r
-                               Buffer->Size   = Size;\r
-                               Buffer->Count  = 0;\r
-                       }\r
+                       uint_reg_t CurrentGlobalInt = USB_INT_GetGlobalEnableState();\r
+                       USB_INT_GlobalDisable();\r
+       \r
+                       Buffer->In     = DataPtr;\r
+                       Buffer->Out    = DataPtr;\r
+                       Buffer->Start  = &DataPtr[0];\r
+                       Buffer->End    = &DataPtr[Size];\r
+                       Buffer->Size   = Size;\r
+                       Buffer->Count  = 0;\r
+\r
+                       USB_INT_SetGlobalEnableState(CurrentGlobalInt);\r
                }\r
 \r
                /** Retrieves the minimum number of bytes stored in a particular buffer. This value is computed\r
                {\r
                        uint16_t Count;\r
 \r
-                       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {\r
-                               Count = Buffer->Count;\r
-                       }\r
+                       uint_reg_t CurrentGlobalInt = USB_INT_GetGlobalEnableState();\r
+                       USB_INT_GlobalDisable();\r
+                       \r
+                       Count = Buffer->Count;\r
 \r
+                       USB_INT_SetGlobalEnableState(CurrentGlobalInt);\r
                        return Count;\r
                }\r
 \r
                        if (++Buffer->In == Buffer->End)\r
                          Buffer->In = Buffer->Start;\r
 \r
-                       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {\r
-                               Buffer->Count++;\r
-                       }\r
+                       uint_reg_t CurrentGlobalInt = USB_INT_GetGlobalEnableState();\r
+                       USB_INT_GlobalDisable();\r
+                       \r
+                       Buffer->Count++;\r
+\r
+                       USB_INT_SetGlobalEnableState(CurrentGlobalInt);\r
                }\r
 \r
                /** Removes an element from the ring buffer.\r
                        if (++Buffer->Out == Buffer->End)\r
                          Buffer->Out = Buffer->Start;\r
 \r
-                       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {\r
-                               Buffer->Count--;\r
-                       }\r
+                       uint_reg_t CurrentGlobalInt = USB_INT_GetGlobalEnableState();\r
+                       USB_INT_GlobalDisable();\r
+                       \r
+                       Buffer->Count--;\r
+\r
+                       USB_INT_SetGlobalEnableState(CurrentGlobalInt);\r
 \r
                        return Data;\r
                }\r