|
39 | 39 | # define BLINKLED_ON() (PORTD |= B00000001) |
40 | 40 | # define BLINKLED_OFF() (PORTD &= B11111110) |
41 | 41 |
|
| 42 | +// No system LED on ESP32, disable blinking |
42 | 43 | #elif defined(ESP32) |
43 | 44 | # define BLINKLED 255 |
44 | 45 | # define BLINKLED_ON() 1 |
45 | 46 | # define BLINKLED_OFF() 1 |
46 | 47 | #else |
47 | 48 | # define BLINKLED 13 |
48 | | - #define BLINKLED_ON() (PORTB |= B00100000) |
| 49 | +# define BLINKLED_ON() (PORTB |= B00100000) |
49 | 50 | # define BLINKLED_OFF() (PORTB &= B11011111) |
50 | 51 | #endif |
51 | 52 |
|
|
129 | 130 |
|
130 | 131 | // ATtiny84 |
131 | 132 | #elif defined(__AVR_ATtiny84__) |
132 | | - #define IR_USE_TIMER1 // tx = pin 6 |
| 133 | + #define IR_USE_TIMER1 // tx = pin 6 |
133 | 134 |
|
134 | 135 | //ATtiny85 |
135 | 136 | #elif defined(__AVR_ATtiny85__) |
136 | | - #define IR_USE_TIMER_TINY0 // tx = pin 1 |
| 137 | + #define IR_USE_TIMER_TINY0 // tx = pin 1 |
137 | 138 |
|
138 | 139 | // Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc |
139 | 140 | // ATmega48, ATmega88, ATmega168, ATmega328 |
| 141 | +#elif defined(ESP32) |
| 142 | + #define IR_TIMER_USE_ESP32 |
140 | 143 | #else |
141 | 144 | //#define IR_USE_TIMER1 // tx = pin 9 |
142 | 145 | #define IR_USE_TIMER2 // tx = pin 3 |
|
151 | 154 | // |
152 | 155 | #if defined(IR_USE_TIMER2) |
153 | 156 |
|
154 | | -#ifdef ESP32 // Used in irSend, not implemented yet (FIXME) |
155 | | -#define TIMER_RESET 1 |
156 | | -#define TIMER_ENABLE_PWM 1 |
157 | | -#define TIMER_DISABLE_PWM Serial.println("IRsend not implemented for ESP32 yet"); |
158 | | -#define TIMER_ENABLE_INTR 1 |
159 | | -#define TIMER_DISABLE_INTR 1 |
160 | | -#define TIMER_INTR_NAME 1 |
161 | | -#else |
162 | 157 | #define TIMER_RESET |
163 | 158 | #define TIMER_ENABLE_PWM (TCCR2A |= _BV(COM2B1)) |
164 | 159 | #define TIMER_DISABLE_PWM (TCCR2A &= ~(_BV(COM2B1))) |
165 | 160 | #define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A)) |
166 | 161 | #define TIMER_DISABLE_INTR (TIMSK2 = 0) |
167 | 162 | #define TIMER_INTR_NAME TIMER2_COMPA_vect |
168 | | -#endif |
169 | 163 |
|
170 | 164 | #define TIMER_CONFIG_KHZ(val) ({ \ |
171 | 165 | const uint8_t pwmval = SYSCLOCK / 2000 / (val); \ |
|
551 | 545 |
|
552 | 546 | #define TIMER_PWM_PIN 1 /* ATtiny85 */ |
553 | 547 |
|
| 548 | +//--------------------------------------------------------- |
| 549 | +// ESP32 (ESP8266 should likely be added here too) |
| 550 | +// |
| 551 | + |
| 552 | +// ESP32 has it own timer API and does not use these macros, but to avoid ifdef'ing |
| 553 | +// them out in the common code, they are defined to no-op. This allows the code to compile |
| 554 | +// (which it wouldn't otherwise) but irsend will not work until ESP32 specific code is written |
| 555 | +// for that -- merlin |
| 556 | +// As a warning, sending timing specific code from an ESP32 can be challenging if you need 100% |
| 557 | +// reliability because the arduino code may be interrupted and cause your sent waveform to be the |
| 558 | +// wrong length. This is specifically an issue for neopixels which require 800Khz resolution. |
| 559 | +// IR may just work as is with the common code since it's lower frequency, but if not, the other |
| 560 | +// way to do this on ESP32 is using the RMT built in driver like in this incomplete library below |
| 561 | +// https://github.com/ExploreEmbedded/ESP32_RMT |
| 562 | +#elif defined(IR_TIMER_USE_ESP32) |
| 563 | +#define TIMER_RESET 1 |
| 564 | +#define TIMER_ENABLE_PWM 1 |
| 565 | +#define TIMER_DISABLE_PWM Serial.println("IRsend not implemented for ESP32 yet"); |
| 566 | +#define TIMER_ENABLE_INTR 1 |
| 567 | +#define TIMER_DISABLE_INTR 1 |
| 568 | +#define TIMER_INTR_NAME 1 |
| 569 | + |
554 | 570 | //--------------------------------------------------------- |
555 | 571 | // Unknown Timer |
556 | 572 | // |
|
0 commit comments