1#define FASTLED_INTERNAL
11#if defined(FASTLED_AVR) && !defined(FL_IS_TEENSY) && !defined(FL_IS_AVR_ATTINY)
15#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
17typedef union {
unsigned long _long;
fl::u8 raw[4]; } tBytesForLong;
19volatile unsigned long FastLED_timer0_overflow_count=0;
20volatile unsigned long FastLED_timer0_millis = 0;
22LIB8STATIC void __attribute__((always_inline)) fastinc32 (
volatile u32 & _long) {
23 fl::u8 b = ++((tBytesForLong&)_long).raw[0];
25 b = ++((tBytesForLong&)_long).raw[1];
27 b = ++((tBytesForLong&)_long).raw[2];
29 ++((tBytesForLong&)_long).raw[3];
35#if defined(FL_IS_AVR_ATTINY)
41 fastinc32(FastLED_timer0_overflow_count);
54 m = FastLED_timer0_overflow_count;
57 return (m*(MICROSECONDS_PER_TIMER0_OVERFLOW/8))/(1000/8);
60unsigned long micros() {
65 m = FastLED_timer0_overflow_count;
71 #error TIMER 0 not defined
76 if ((TIFR0 & _BV(TOV0)) && (
t < 255))
79 if ((TIFR & _BV(TOV0)) && (
t < 255))
85 return ((m << 8) +
t) * (64 / clockCyclesPerMicrosecond());
88void delay(
unsigned long ms)
90 fl::u16 start = (fl::u16)micros();
93 if (((fl::u16)micros() - start) >= 1000) {
100#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
110#if defined(TCCR0A) && defined(WGM01)
116#if defined(FL_IS_AVR_ATMEGA)
119#elif defined(TCCR0) && defined(CS01) && defined(CS00)
123#elif defined(TCCR0B) && defined(CS01) && defined(CS00)
127#elif defined(TCCR0A) && defined(CS01) && defined(CS00)
132 #error Timer 0 prescale factor 64 not set correctly
136#if defined(TIMSK) && defined(TOIE0)
138#elif defined(TIMSK0) && defined(TOIE0)
141 #error Timer 0 overflow interrupt not set correctly
149#if defined(TCCR1B) && defined(CS11) && defined(CS10)
157#elif defined(TCCR1) && defined(CS11) && defined(CS10)
164#if defined(TCCR1A) && defined(WGM10)
167 #warning this needs to be finished
171#if defined(TCCR2) && defined(CS22)
173#elif defined(TCCR2B) && defined(CS22)
176 #warning Timer 2 not finished (may not be present on this CPU)
180#if defined(TCCR2) && defined(WGM20)
182#elif defined(TCCR2A) && defined(WGM20)
185 #warning Timer 2 not finished (may not be present on this CPU)
188#if defined(TCCR3B) && defined(CS31) && defined(WGM30)
194#if defined(TCCR4A) && defined(TCCR4B) && defined(TCCR4D)
202#if defined(TCCR4B) && defined(CS41) && defined(WGM40)
209#if defined(TCCR5B) && defined(CS51) && defined(WGM50)
Internal FastLED header for implementation files.
#define LIB8STATIC
Define a LIB8TION member function as static inline with an "unused" attribute.