Skip to content

Commit

Permalink
Fix #478 -- don't use a generic name for NOP in case other platforms …
Browse files Browse the repository at this point in the history
…mess with it.
  • Loading branch information
focalintent committed Aug 16, 2017
1 parent 074794d commit 7637a25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
26 changes: 10 additions & 16 deletions fastled_delay.h
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions fastspi_bitbang.h
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 7637a25

Please sign in to comment.