Permalink
Browse files

Fix #478 -- don't use a generic name for NOP in case other platforms …

…mess with it.
  • Loading branch information...
focalintent committed Aug 16, 2017
1 parent 074794d commit 7637a251e878f09febc8dcf836644e0468f37231
Showing with 12 additions and 18 deletions.
  1. +10 −16 fastled_delay.h
  2. +2 −2 fastspi_bitbang.h
View
@@ -34,18 +34,12 @@ template<int WAIT> class CMinWait {
// Default is now just 'nop', with special case for AVR
// ESP32 core has it's own definition of NOP, so undef it first
#ifdef ESP32
#undef NOP
#undef NOP2
#endif
#if defined(__AVR__)
# define NOP __asm__ __volatile__ ("cp r0,r0\n");
# define NOP2 __asm__ __volatile__ ("rjmp .+0");
# define FL_NOP __asm__ __volatile__ ("cp r0,r0\n");
# define FL_NOP2 __asm__ __volatile__ ("rjmp .+0");
#else
# define NOP __asm__ __volatile__ ("nop\n");
# define NOP2 __asm__ __volatile__ ("nop\n\t nop\n");
# define FL_NOP __asm__ __volatile__ ("nop\n");
# define FL_NOP2 __asm__ __volatile__ ("nop\n\t nop\n");
#endif
// predeclaration to not upset the compiler
@@ -98,7 +92,7 @@ template<int CYCLES> __attribute__((always_inline)) inline void delaycycles() {
template<int CYCLES> __attribute__((always_inline)) inline void delaycycles() {
// _delaycycles_ARM<CYCLES / 3, CYCLES % 3>();
NOP; delaycycles<CYCLES-1>();
FL_NOP; delaycycles<CYCLES-1>();
}
#endif
@@ -115,11 +109,11 @@ template<> __attribute__((always_inline)) inline void delaycycles<-3>() {}
template<> __attribute__((always_inline)) inline void delaycycles<-2>() {}
template<> __attribute__((always_inline)) inline void delaycycles<-1>() {}
template<> __attribute__((always_inline)) inline void delaycycles<0>() {}
template<> __attribute__((always_inline)) inline void delaycycles<1>() {NOP;}
template<> __attribute__((always_inline)) inline void delaycycles<2>() {NOP2;}
template<> __attribute__((always_inline)) inline void delaycycles<3>() {NOP;NOP2;}
template<> __attribute__((always_inline)) inline void delaycycles<4>() {NOP2;NOP2;}
template<> __attribute__((always_inline)) inline void delaycycles<5>() {NOP2;NOP2;NOP;}
template<> __attribute__((always_inline)) inline void delaycycles<1>() {FL_NOP;}
template<> __attribute__((always_inline)) inline void delaycycles<2>() {FL_NOP2;}
template<> __attribute__((always_inline)) inline void delaycycles<3>() {FL_NOP;FL_NOP2;}
template<> __attribute__((always_inline)) inline void delaycycles<4>() {FL_NOP2;FL_NOP2;}
template<> __attribute__((always_inline)) inline void delaycycles<5>() {FL_NOP2;FL_NOP2;FL_NOP;}
// Some timing related macros/definitions
View
@@ -158,7 +158,7 @@ class AVRSoftwareSPIOutput {
FastPin<CLOCK_PIN>::fastset(clockpin, hiclock); CLOCK_HI_DELAY;
FastPin<CLOCK_PIN>::fastset(clockpin, loclock); CLOCK_LO_DELAY;
} else {
// NOP;
// FL_NOP;
FastPin<DATA_PIN>::fastset(datapin, loval);
FastPin<CLOCK_PIN>::fastset(clockpin, hiclock); CLOCK_HI_DELAY;
FastPin<CLOCK_PIN>::fastset(clockpin, loclock); CLOCK_LO_DELAY;
@@ -178,7 +178,7 @@ class AVRSoftwareSPIOutput {
FastPin<DATA_PIN>::fastset(clockdatapin, datahiclockhi); CLOCK_HI_DELAY;
FastPin<DATA_PIN>::fastset(clockdatapin, datahiclocklo); CLOCK_LO_DELAY;
} else {
// NOP;
// FL_NOP;
FastPin<DATA_PIN>::fastset(clockdatapin, dataloclocklo);
FastPin<DATA_PIN>::fastset(clockdatapin, dataloclockhi); CLOCK_HI_DELAY;
FastPin<DATA_PIN>::fastset(clockdatapin, dataloclocklo); CLOCK_LO_DELAY;

0 comments on commit 7637a25

Please sign in to comment.