@@ -243,7 +243,7 @@ static void USE_IRAM_ATTR gpio_intr() {
243
243
timer->dev ->config .alarm_en = 1 ;
244
244
#else // _ESP32_IRRECV_TIMER_HACK
245
245
timerWrite (timer, 0 );
246
- timerAlarmEnable (timer);
246
+ timerAlarm (timer, MS_TO_USEC (params. timeout ), 0 , 1 );
247
247
#endif // _ESP32_IRRECV_TIMER_HACK
248
248
#endif // ESP32
249
249
}
@@ -356,10 +356,22 @@ void IRrecv::enableIRIn(const bool pullup) {
356
356
pinMode (params.recvpin , INPUT);
357
357
#endif // UNIT_TEST
358
358
}
359
+
360
+ #ifndef UNIT_TEST
361
+ #if defined(ESP8266)
362
+ // Initialise ESP8266 timer.
363
+ os_timer_disarm (&timer);
364
+ os_timer_setfn (&timer, reinterpret_cast <os_timer_func_t *>(read_timeout),
365
+ NULL );
366
+ #endif // ESP8266
367
+ // Attach Interrupt
368
+ attachInterrupt (params.recvpin , gpio_intr, CHANGE);
369
+ #endif // UNIT_TEST
370
+
359
371
#if defined(ESP32)
360
372
// Initialise the ESP32 timer.
361
373
// 80MHz / 80 = 1 uSec granularity.
362
- timer = timerBegin (_timer_num, 80 , true );
374
+ timer = timerBegin (1000000 );
363
375
#ifdef DEBUG
364
376
if (timer == NULL ) {
365
377
DPRINT (" FATAL: Unable enable system timer: " );
@@ -368,26 +380,17 @@ void IRrecv::enableIRIn(const bool pullup) {
368
380
#endif // DEBUG
369
381
assert (timer != NULL ); // Check we actually got the timer.
370
382
// Set the timer so it only fires once, and set it's trigger in uSeconds.
371
- timerAlarmWrite (timer, MS_TO_USEC (params.timeout ), ONCE );
383
+ timerAlarm (timer, MS_TO_USEC (params.timeout ), 0 , 1 );
372
384
// Note: Interrupt needs to be attached before it can be enabled or disabled.
373
385
// Note: EDGE (true) is not supported, use LEVEL (false). Ref: #1713
374
386
// See: https://github.com/espressif/arduino-esp32/blob/caef4006af491130136b219c1205bdcf8f08bf2b/cores/esp32/esp32-hal-timer.c#L224-L227
375
- timerAttachInterrupt (timer, &read_timeout, false );
387
+ timerAttachInterrupt (timer, &read_timeout);
376
388
#endif // ESP32
377
389
378
390
// Initialise state machine variables
379
391
resume ();
380
392
381
- #ifndef UNIT_TEST
382
- #if defined(ESP8266)
383
- // Initialise ESP8266 timer.
384
- os_timer_disarm (&timer);
385
- os_timer_setfn (&timer, reinterpret_cast <os_timer_func_t *>(read_timeout),
386
- NULL );
387
- #endif // ESP8266
388
- // Attach Interrupt
389
- attachInterrupt (params.recvpin , gpio_intr, CHANGE);
390
- #endif // UNIT_TEST
393
+
391
394
}
392
395
393
396
// / Stop collection of any received IR data.
@@ -398,7 +401,7 @@ void IRrecv::disableIRIn(void) {
398
401
os_timer_disarm (&timer);
399
402
#endif // ESP8266
400
403
#if defined(ESP32)
401
- timerAlarmDisable (timer);
404
+ // timerAlarmDisable(timer);
402
405
timerDetachInterrupt (timer);
403
406
timerEnd (timer);
404
407
#endif // ESP32
@@ -413,7 +416,8 @@ void IRrecv::pause(void) {
413
416
params.rawlen = 0 ;
414
417
params.overflow = false ;
415
418
#if defined(ESP32)
416
- gpio_intr_disable ((gpio_num_t )params.recvpin );
419
+ // gpio_intr_disable((gpio_num_t)params.recvpin);
420
+ detachInterrupt ((gpio_num_t )params.recvpin );
417
421
#endif // ESP32
418
422
}
419
423
@@ -426,8 +430,9 @@ void IRrecv::resume(void) {
426
430
params.rawlen = 0 ;
427
431
params.overflow = false ;
428
432
#if defined(ESP32)
429
- timerAlarmDisable (timer);
430
- gpio_intr_enable ((gpio_num_t )params.recvpin );
433
+ // timerAlarmDisable(timer);
434
+ // gpio_intr_enable((gpio_num_t)params.recvpin);
435
+ attachInterrupt (params.recvpin , gpio_intr, CHANGE);
431
436
#endif // ESP32
432
437
}
433
438
@@ -1185,10 +1190,6 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
1185
1190
DPRINTLN (" Attempting York decode" );
1186
1191
if (decodeYork (results, offset, kYorkBits )) return true ;
1187
1192
#endif // DECODE_YORK
1188
- #if DECODE_BLUESTARHEAVY
1189
- DPRINTLN (" Attempting BluestarHeavy decode" );
1190
- if (decodeBluestarHeavy (results, offset, kBluestarHeavyBits )) return true ;
1191
- #endif // DECODE_BLUESTARHEAVY
1192
1193
// Typically new protocols are added above this line.
1193
1194
}
1194
1195
#if DECODE_HASH
0 commit comments