diff --git a/FastLED.h b/FastLED.h index c2cd250..ad6ab9a 100644 --- a/FastLED.h +++ b/FastLED.h @@ -16,6 +16,12 @@ #define FASTLED_HAS_PRAGMA_MESSAGE #endif +#if __cplusplus >= 201703L +#define FASTLED_REGISTER +#else +#define FASTLED_REGISTER register +#endif + #if 0 // tired of these warning messages #define FASTLED_VERSION 3003002 #ifndef FASTLED_INTERNAL diff --git a/chipsets.h b/chipsets.h index 8e9051d..9cd4838 100644 --- a/chipsets.h +++ b/chipsets.h @@ -84,7 +84,7 @@ class LPD8806Controller : public CPixelLEDController { class LPD8806_ADJUST { public: // LPD8806 spec wants the high bit of every rgb data byte sent out to be set. - __attribute__((always_inline)) inline static uint8_t adjust(register uint8_t data) { return ((data>>1) | 0x80) + ((data && (data<254)) & 0x01); } + __attribute__((always_inline)) inline static uint8_t adjust(FASTLED_REGISTER uint8_t data) { return ((data>>1) | 0x80) + ((data && (data<254)) & 0x01); } __attribute__((always_inline)) inline static void postBlock(int len) { SPI::writeBytesValueRaw(0, ((len*3+63)>>6)); } @@ -172,7 +172,7 @@ protected: startBoundary(); while(pixels.has(1)) { - register uint16_t command; + FASTLED_REGISTER uint16_t command; command = 0x8000; command |= (pixels.loadAndScale0() & 0xF8) << 7; // red is the high 5 bits command |= (pixels.loadAndScale1() & 0xF8) << 2; // green is the middle 5 bits @@ -348,7 +348,7 @@ class P9813Controller : public CPixelLEDController { void writeBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); } inline void writeLed(uint8_t r, uint8_t g, uint8_t b) __attribute__((always_inline)) { - register uint8_t top = 0xC0 | ((~b & 0xC0) >> 2) | ((~g & 0xC0) >> 4) | ((~r & 0xC0) >> 6); + FASTLED_REGISTER uint8_t top = 0xC0 | ((~b & 0xC0) >> 2) | ((~g & 0xC0) >> 4) | ((~r & 0xC0) >> 6); mSPI.writeByte(top); mSPI.writeByte(b); mSPI.writeByte(g); mSPI.writeByte(r); } diff --git a/fastpin.h b/fastpin.h index ed2b8e7..b253e26 100644 --- a/fastpin.h +++ b/fastpin.h @@ -57,11 +57,11 @@ public: inline void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); } inline void toggle() __attribute__ ((always_inline)) { *mInPort = mPinMask; } - inline void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= mPinMask; } - inline void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~mPinMask; } - inline void set(register port_t val) __attribute__ ((always_inline)) { *mPort = val; } + inline void hi(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port |= mPinMask; } + inline void lo(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~mPinMask; } + inline void set(FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *mPort = val; } - inline void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } + inline void fastset(FASTLED_REGISTER port_ptr_t port, FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *port = val; } port_t hival() __attribute__ ((always_inline)) { return *mPort | mPinMask; } port_t loval() __attribute__ ((always_inline)) { return *mPort & ~mPinMask; } @@ -115,11 +115,11 @@ public: inline void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); } inline void toggle() __attribute__ ((always_inline)) { *mInPort = mPinMask; } - inline void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= mPinMask; } - inline void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~mPinMask; } - inline void set(register port_t val) __attribute__ ((always_inline)) { *mPort = val; } + inline void hi(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port |= mPinMask; } + inline void lo(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~mPinMask; } + inline void set(FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *mPort = val; } - inline void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } + inline void fastset(FASTLED_REGISTER port_ptr_t port, FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *port = val; } port_t hival() __attribute__ ((always_inline)) { return *mPort | mPinMask; } port_t loval() __attribute__ ((always_inline)) { return *mPort & ~mPinMask; } @@ -183,11 +183,11 @@ public: inline static void toggle() __attribute__ ((always_inline)) { *sInPort = sPinMask; } - inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= sPinMask; } - inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~sPinMask; } - inline static void set(register port_t val) __attribute__ ((always_inline)) { *sPort = val; } + inline static void hi(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port |= sPinMask; } + inline static void lo(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~sPinMask; } + inline static void set(FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *sPort = val; } - inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } + inline static void fastset(FASTLED_REGISTER port_ptr_t port, FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *port = val; } static port_t hival() __attribute__ ((always_inline)) { return *sPort | sPinMask; } static port_t loval() __attribute__ ((always_inline)) { return *sPort & ~sPinMask; } @@ -222,11 +222,11 @@ public: inline static void toggle() __attribute__ ((always_inline)) { } - inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { } - inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { } - inline static void set(register port_t val) __attribute__ ((always_inline)) { } + inline static void hi(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { } + inline static void lo(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { } + inline static void set(FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { } - inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { } + inline static void fastset(FASTLED_REGISTER port_ptr_t port, FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { } static port_t hival() __attribute__ ((always_inline)) { return 0; } static port_t loval() __attribute__ ((always_inline)) { return 0;} diff --git a/fastspi_bitbang.h b/fastspi_bitbang.h index 019b6dc..6ebd6da 100644 --- a/fastspi_bitbang.h +++ b/fastspi_bitbang.h @@ -228,26 +228,26 @@ public: writeByte(value); } #else - register data_ptr_t datapin = FastPin::port(); + FASTLED_REGISTER data_ptr_t datapin = FastPin::port(); if(FastPin::port() != FastPin::port()) { // If data and clock are on different ports, then writing a bit will consist of writing the value foor // the bit (hi or low) to the data pin port, and then two writes to the clock port to strobe the clock line - register clock_ptr_t clockpin = FastPin::port(); - register data_t datahi = FastPin::hival(); - register data_t datalo = FastPin::loval(); - register clock_t clockhi = FastPin::hival(); - register clock_t clocklo = FastPin::loval(); + FASTLED_REGISTER clock_ptr_t clockpin = FastPin::port(); + FASTLED_REGISTER data_t datahi = FastPin::hival(); + FASTLED_REGISTER data_t datalo = FastPin::loval(); + FASTLED_REGISTER clock_t clockhi = FastPin::hival(); + FASTLED_REGISTER clock_t clocklo = FastPin::loval(); while(len--) { writeByte(value, clockpin, datapin, datahi, datalo, clockhi, clocklo); } } else { // If data and clock are on the same port then we can combine setting the data and clock pins - register data_t datahi_clockhi = FastPin::hival() | FastPin::mask(); - register data_t datalo_clockhi = FastPin::loval() | FastPin::mask(); - register data_t datahi_clocklo = FastPin::hival() & ~FastPin::mask(); - register data_t datalo_clocklo = FastPin::loval() & ~FastPin::mask(); + FASTLED_REGISTER data_t datahi_clockhi = FastPin::hival() | FastPin::mask(); + FASTLED_REGISTER data_t datalo_clockhi = FastPin::loval() | FastPin::mask(); + FASTLED_REGISTER data_t datahi_clocklo = FastPin::hival() & ~FastPin::mask(); + FASTLED_REGISTER data_t datalo_clocklo = FastPin::loval() & ~FastPin::mask(); while(len--) { writeByte(value, datapin, datahi_clockhi, datalo_clockhi, datahi_clocklo, datalo_clocklo); @@ -258,7 +258,7 @@ public: // write a block of len uint8_ts out. Need to type this better so that explicit casts into the call aren't required. // note that this template version takes a class parameter for a per-byte modifier to the data. - template void writeBytes(register uint8_t *data, int len) { + template void writeBytes(FASTLED_REGISTER uint8_t *data, int len) { select(); #ifdef FAST_SPI_INTERRUPTS_WRITE_PINS uint8_t *end = data + len; @@ -266,16 +266,16 @@ public: writeByte(D::adjust(*data++)); } #else - register clock_ptr_t clockpin = FastPin::port(); - register data_ptr_t datapin = FastPin::port(); + FASTLED_REGISTER clock_ptr_t clockpin = FastPin::port(); + FASTLED_REGISTER data_ptr_t datapin = FastPin::port(); if(FastPin::port() != FastPin::port()) { // If data and clock are on different ports, then writing a bit will consist of writing the value foor // the bit (hi or low) to the data pin port, and then two writes to the clock port to strobe the clock line - register data_t datahi = FastPin::hival(); - register data_t datalo = FastPin::loval(); - register clock_t clockhi = FastPin::hival(); - register clock_t clocklo = FastPin::loval(); + FASTLED_REGISTER data_t datahi = FastPin::hival(); + FASTLED_REGISTER data_t datalo = FastPin::loval(); + FASTLED_REGISTER clock_t clockhi = FastPin::hival(); + FASTLED_REGISTER clock_t clocklo = FastPin::loval(); uint8_t *end = data + len; while(data != end) { @@ -285,10 +285,10 @@ public: } else { // FastPin::hi(); // If data and clock are on the same port then we can combine setting the data and clock pins - register data_t datahi_clockhi = FastPin::hival() | FastPin::mask(); - register data_t datalo_clockhi = FastPin::loval() | FastPin::mask(); - register data_t datahi_clocklo = FastPin::hival() & ~FastPin::mask(); - register data_t datalo_clocklo = FastPin::loval() & ~FastPin::mask(); + FASTLED_REGISTER data_t datahi_clockhi = FastPin::hival() | FastPin::mask(); + FASTLED_REGISTER data_t datalo_clockhi = FastPin::loval() | FastPin::mask(); + FASTLED_REGISTER data_t datahi_clocklo = FastPin::hival() & ~FastPin::mask(); + FASTLED_REGISTER data_t datalo_clocklo = FastPin::loval() & ~FastPin::mask(); uint8_t *end = data + len; @@ -303,7 +303,7 @@ public: } // default version of writing a block of data out to the SPI port, with no data modifications being made - void writeBytes(register uint8_t *data, int len) { writeBytes(data, len); } + void writeBytes(FASTLED_REGISTER uint8_t *data, int len) { writeBytes(data, len); } // write a block of uint8_ts out in groups of three. len is the total number of uint8_ts to write out. The template @@ -329,16 +329,16 @@ public: #else // If we can guaruntee that no one else will be writing data while we are running (namely, changing the values of the PORT/PDOR pins) // then we can use a bunch of optimizations in here - register data_ptr_t datapin = FastPin::port(); + FASTLED_REGISTER data_ptr_t datapin = FastPin::port(); if(FastPin::port() != FastPin::port()) { - register clock_ptr_t clockpin = FastPin::port(); + FASTLED_REGISTER clock_ptr_t clockpin = FastPin::port(); // If data and clock are on different ports, then writing a bit will consist of writing the value foor // the bit (hi or low) to the data pin port, and then two writes to the clock port to strobe the clock line - register data_t datahi = FastPin::hival(); - register data_t datalo = FastPin::loval(); - register clock_t clockhi = FastPin::hival(); - register clock_t clocklo = FastPin::loval(); + FASTLED_REGISTER data_t datahi = FastPin::hival(); + FASTLED_REGISTER data_t datalo = FastPin::loval(); + FASTLED_REGISTER clock_t clockhi = FastPin::hival(); + FASTLED_REGISTER clock_t clocklo = FastPin::loval(); while(pixels.has(1)) { if(FLAGS & FLAG_START_BIT) { @@ -353,10 +353,10 @@ public: } else { // If data and clock are on the same port then we can combine setting the data and clock pins - register data_t datahi_clockhi = FastPin::hival() | FastPin::mask(); - register data_t datalo_clockhi = FastPin::loval() | FastPin::mask(); - register data_t datahi_clocklo = FastPin::hival() & ~FastPin::mask(); - register data_t datalo_clocklo = FastPin::loval() & ~FastPin::mask(); + FASTLED_REGISTER data_t datahi_clockhi = FastPin::hival() | FastPin::mask(); + FASTLED_REGISTER data_t datalo_clockhi = FastPin::loval() | FastPin::mask(); + FASTLED_REGISTER data_t datahi_clocklo = FastPin::hival() & ~FastPin::mask(); + FASTLED_REGISTER data_t datalo_clocklo = FastPin::loval() & ~FastPin::mask(); while(pixels.has(1)) { if(FLAGS & FLAG_START_BIT) { diff --git a/fastspi_ref.h b/fastspi_ref.h index 00c41d3..1acb309 100644 --- a/fastspi_ref.h +++ b/fastspi_ref.h @@ -47,7 +47,7 @@ public: } // A full cycle of writing a value for len bytes, including select, release, and waiting - template void writeBytes(register uint8_t *data, int len) { + template void writeBytes(FASTLED_REGISTER uint8_t *data, int len) { uint8_t *end = data + len; select(); // could be optimized to write 16bit words out instead of 8bit bytes @@ -60,7 +60,7 @@ public: } // A full cycle of writing a value for len bytes, including select, release, and waiting - void writeBytes(register uint8_t *data, int len) { writeBytes(data, len); } + void writeBytes(FASTLED_REGISTER uint8_t *data, int len) { writeBytes(data, len); } // write a single bit out, which bit from the passed in byte is determined by template parameter template inline static void writeBit(uint8_t b) { /* TODO */ } diff --git a/fastspi_types.h b/fastspi_types.h index 5510bba..8a31626 100644 --- a/fastspi_types.h +++ b/fastspi_types.h @@ -19,8 +19,8 @@ FASTLED_NAMESPACE_BEGIN /// TODO: Convinience macro for building these class DATA_NOP { public: - static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data) { return data; } - static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data, register uint8_t scale) { return scale8(data, scale); } + static __attribute__((always_inline)) inline uint8_t adjust(FASTLED_REGISTER uint8_t data) { return data; } + static __attribute__((always_inline)) inline uint8_t adjust(FASTLED_REGISTER uint8_t data, FASTLED_REGISTER uint8_t scale) { return scale8(data, scale); } static __attribute__((always_inline)) inline void postBlock(int /* len */) { } }; diff --git a/platforms/esp/32/clockless_block_esp32.h b/platforms/esp/32/clockless_block_esp32.h index 8ab5807..1c99c5f 100644 --- a/platforms/esp/32/clockless_block_esp32.h +++ b/platforms/esp/32/clockless_block_esp32.h @@ -78,14 +78,14 @@ public: #define ESP_ADJUST 0 // (2*(F_CPU/24000000)) #define ESP_ADJUST2 0 - template __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & last_mark, register Lines & b, PixelController &pixels) { // , register uint32_t & b2) { + template __attribute__ ((always_inline)) inline static void writeBits(FASTLED_REGISTER uint32_t & last_mark, FASTLED_REGISTER Lines & b, PixelController &pixels) { // , register uint32_t & b2) { Lines b2 = b; transpose8x1_noinline(b.bytes,b2.bytes); - register uint8_t d = pixels.template getd(pixels); - register uint8_t scale = pixels.template getscale(pixels); + FASTLED_REGISTER uint8_t d = pixels.template getd(pixels); + FASTLED_REGISTER uint8_t scale = pixels.template getscale(pixels); - for(register uint32_t i = 0; i < USED_LANES; i++) { + for(FASTLED_REGISTER uint32_t i = 0; i < USED_LANES; i++) { while((__clock_cycles() - last_mark) < (T1+T2+T3)); last_mark = __clock_cycles(); *FastPin::sport() = PORT_MASK << REAL_FIRST_PIN; @@ -100,7 +100,7 @@ public: b.bytes[i] = pixels.template loadAndScale(pixels,i,d,scale); } - for(register uint32_t i = USED_LANES; i < 8; i++) { + for(FASTLED_REGISTER uint32_t i = USED_LANES; i < 8; i++) { while((__clock_cycles() - last_mark) < (T1+T2+T3)); last_mark = __clock_cycles(); *FastPin::sport() = PORT_MASK << REAL_FIRST_PIN; diff --git a/platforms/esp/32/clockless_rmt_esp32.cpp b/platforms/esp/32/clockless_rmt_esp32.cpp index 7306085..5cae4b9 100644 --- a/platforms/esp/32/clockless_rmt_esp32.cpp +++ b/platforms/esp/32/clockless_rmt_esp32.cpp @@ -624,11 +624,11 @@ void IRAM_ATTR ESP32RMTController::fillNext() // -- Get the zero and one values into local variables // each one is a "rmt_item_t", which contains two values, which is very convenient - register uint32_t one_val = mOne.val; - register uint32_t zero_val = mZero.val; + FASTLED_REGISTER uint32_t one_val = mOne.val; + FASTLED_REGISTER uint32_t zero_val = mZero.val; // -- Use locals for speed - volatile register uint32_t * pItem = mRMT_mem_ptr; + volatile FASTLED_REGISTER uint32_t * pItem = mRMT_mem_ptr; // set the owner to SW --- current driver does this but its not clear it matters fastled_set_mem_owner(mRMT_channel, RMT_MEM_OWNER_SW); @@ -638,7 +638,7 @@ void IRAM_ATTR ESP32RMTController::fillNext() for (int i=0; i < PULSES_PER_FILL / 32; i++) { if (mCur < mSize) { - register uint32_t thispixel = mPixelData[mCur]; + FASTLED_REGISTER uint32_t thispixel = mPixelData[mCur]; for (int j = 0; j < 32; j++) { *pItem++ = (thispixel & 0x80000000L) ? one_val : zero_val; diff --git a/platforms/esp/32/fastpin_esp32.h b/platforms/esp/32/fastpin_esp32.h index cbb09ff..804ab86 100644 --- a/platforms/esp/32/fastpin_esp32.h +++ b/platforms/esp/32/fastpin_esp32.h @@ -37,7 +37,7 @@ public: else GPIO.out1_w1tc.val = MASK; } - inline static void set(register port_t val) __attribute__ ((always_inline)) { + inline static void set(FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { if (PIN < 32) GPIO.out = val; else GPIO.out1.val = val; } @@ -49,9 +49,9 @@ public: else { GPIO.out1.val ^=MASK; } } - inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { hi(); } - inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { lo(); } - inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } + inline static void hi(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { hi(); } + inline static void lo(FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { lo(); } + inline static void fastset(FASTLED_REGISTER port_ptr_t port, FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *port = val; } inline static port_t hival() __attribute__ ((always_inline)) { if (PIN < 32) return GPIO.out | MASK; diff --git a/platforms/esp/32/fastspi_esp32.h b/platforms/esp/32/fastspi_esp32.h index 33d620f..cb72547 100644 --- a/platforms/esp/32/fastspi_esp32.h +++ b/platforms/esp/32/fastspi_esp32.h @@ -126,7 +126,7 @@ public: // write a block of len uint8_ts out. Need to type this better so that explicit casts into the call aren't required. // note that this template version takes a class parameter for a per-byte modifier to the data. - template void writeBytes(register uint8_t *data, int len) { + template void writeBytes(FASTLED_REGISTER uint8_t *data, int len) { select(); uint8_t *end = data + len; while(data != end) { @@ -137,7 +137,7 @@ public: } // default version of writing a block of data out to the SPI port, with no data modifications being made - void writeBytes(register uint8_t *data, int len) { writeBytes(data, len); } + void writeBytes(FASTLED_REGISTER uint8_t *data, int len) { writeBytes(data, len); } // write a single bit out, which bit from the passed in byte is determined by template parameter template inline void writeBit(uint8_t b) { @@ -165,4 +165,4 @@ public: } }; -FASTLED_NAMESPACE_END \ No newline at end of file +FASTLED_NAMESPACE_END