WS2812

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Mon Nov 12 05:05:50 2018 +0000
Parent:
2:6e647820f587
Commit message:
Support GCC_ARM compiler

Changed in this revision

WS2812.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6e647820f587 -r 6e60574091dd WS2812.cpp
--- a/WS2812.cpp	Thu Feb 12 20:24:15 2015 +0000
+++ b/WS2812.cpp	Mon Nov 12 05:05:50 2018 +0000
@@ -1,5 +1,11 @@
 #include "WS2812.h"
 
+#if defined ( __GNUC__ )    /* GCC Compiler */
+#define NOP __asm __volatile("nop\n")
+#else
+#define NOP __nop()
+#endif
+
 WS2812::WS2812(PinName pin, int size, int zeroHigh, int zeroLow, int oneHigh, int oneLow) : __gpo(pin)
 {
     __size = size;
@@ -92,20 +98,20 @@
         if (__transmitBuf[i]){
             __gpo = 1;
             for (; j < __oneHigh; j++) {
-                __nop();
+                NOP;
             }
             __gpo = 0;
             for (; j < __oneLow; j++) {
-                __nop();
+                NOP;
             }
         } else {
             __gpo = 1;
             for (; j < __zeroHigh; j++) {
-                __nop();
+                NOP;
             }
             __gpo = 0;
             for (; j < __zeroLow; j++) {
-                __nop();
+                NOP;
             }
         }
     }