Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bengtmartensson/3c0834ad369d5f6cdec2d7d332058fcb to your computer and use it in GitHub Desktop.
Save bengtmartensson/3c0834ad369d5f6cdec2d7d332058fcb to your computer and use it in GitHub Desktop.
0002-Delete-dead-code.-Add-idiot-test-to-esp32.cpp.patch
From 2076da6c4897d68e3dbf11faa809bdcd79a7e585 Mon Sep 17 00:00:00 2001
From: Bengt Martensson <barf@bengt-martensson.de>
Date: Fri, 7 Apr 2017 11:48:49 +0200
Subject: [PATCH 2/2] Delete dead code. Add idiot test to esp32.cpp.
---
esp32.cpp | 5 +++++
irRecv.cpp | 11 -----------
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/esp32.cpp b/esp32.cpp
index 5f2e9bb..ef4d794 100644
--- a/esp32.cpp
+++ b/esp32.cpp
@@ -5,6 +5,11 @@
#include "IRremote.h"
#include "IRremoteInt.h"
+// "Idiot check"
+#ifdef USE_DEFAULT_ENABLE_IR_IN
+#error Must undef USE_DEFAULT_ENABLE_IR_IN
+#endif
+
hw_timer_t *timer;
void IRTimer(); // defined in IRremote.cpp, masqueraded as ISR(TIMER_INTR_NAME)
diff --git a/irRecv.cpp b/irRecv.cpp
index 2a68897..b549dac 100644
--- a/irRecv.cpp
+++ b/irRecv.cpp
@@ -119,16 +119,6 @@ IRrecv::IRrecv (int recvpin, int blinkpin)
void IRrecv::enableIRIn ( )
{
// Interrupt Service Routine - Fires every 50uS
-#ifdef ESP32
- // ESP32 has a proper API to setup timers, no weird chip macros needed
- // simply call the readable API versions :)
- // 3 timers, choose #1, 80 divider nanosecond precision, 1 to count up
- timer = timerBegin(1, 80, 1);
- timerAttachInterrupt(timer, &IRTimer, 1);
- // every 50ns, autoreload = true
- timerAlarmWrite(timer, 50, true);
- timerAlarmEnable(timer);
-#else
cli();
// Setup pulse clock timer interrupt
// Prescale /8 (16M/8 = 0.5 microseconds per tick)
@@ -142,7 +132,6 @@ void IRrecv::enableIRIn ( )
TIMER_RESET;
sei(); // enable interrupts
-#endif
// Initialize state machine variables
irparams.rcvstate = STATE_IDLE;
--
2.9.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment