Skip to content

Revert "Added ESP32 IR receive support (IRsend not implemented yet)." #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ These are the active contributors of this project that you may contact if there
- [ElectricRCAircraftGuy](https://github.com/electricrcaircraftguy): Active Contributor
- [philipphenkel](https://github.com/philipphenkel): Active Contributor
- [MCUdude](https://github.com/MCUdude): Contributor
- [marcmerlin](https://github.com/marcmerlin): Contributor (ESP32 port)

Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed.
11 changes: 2 additions & 9 deletions IRremote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
// Whynter A/C ARC-110WD added by Francesco Meschia
//******************************************************************************

#include <avr/interrupt.h>

// Defining IR_GLOBAL here allows us to declare the instantiation of global variables
#define IR_GLOBAL
# include "IRremote.h"
# include "IRremoteInt.h"
#undef IR_GLOBAL

#ifndef IR_TIMER_USE_ESP32
#include <avr/interrupt.h>
#endif


//+=============================================================================
// The match functions were (apparently) originally MACROs to improve code speed
// (although this would have bloated the code) hence the names being CAPS
Expand Down Expand Up @@ -123,11 +120,7 @@ int MATCH_SPACE (int measured_ticks, int desired_us)
// As soon as first MARK arrives:
// Gap width is recorded; Ready is cleared; New logging starts
//
#ifdef IR_TIMER_USE_ESP32
void IRTimer()
#else
ISR (TIMER_INTR_NAME)
#endif
{
TIMER_RESET;

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Tutorials and more information will be made available on [the official homepage]
- ATmega8535, 16, 32, 164, 324, 644, 1284,
- ATmega64, 128
- ATtiny 84 / 85
- ESP32 (receive only)

We are open to suggestions for adding support to new boards, however we highly recommend you contact your supplier first and ask them to provide support from their side.

Expand All @@ -43,7 +42,6 @@ We are open to suggestions for adding support to new boards, however we highly r
| [ATmega8535 ATmega16, ATmega32](https://github.com/MCUdude/MightyCore) | **13** | **1** |
| [ATmega64, ATmega128](https://github.com/MCUdude/MegaCore) | **13** | **1** |
| ATmega1280, ATmega2560 | 5, 6, **9**, 11, 46 | 1, **2**, 3, 4, 5 |
| [ESP32](http://esp32.net/) | N/A (not supported) | **1** |
| [Teensy 1.0](https://www.pjrc.com/teensy/) | **17** | **1** |
| [Teensy 2.0](https://www.pjrc.com/teensy/) | 9, **10**, 14 | 1, 3, **4_HS** |
| [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/) | **1**, 16, 25 | 1, **2**, 3 |
Expand Down
37 changes: 4 additions & 33 deletions boarddefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,9 @@
# define BLINKLED_ON() (PORTD |= B00000001)
# define BLINKLED_OFF() (PORTD &= B11111110)

// No system LED on ESP32, disable blinking
#elif defined(ESP32)
# define BLINKLED 255
# define BLINKLED_ON() 1
# define BLINKLED_OFF() 1
#else
# define BLINKLED 13
# define BLINKLED_ON() (PORTB |= B00100000)
#define BLINKLED_ON() (PORTB |= B00100000)
# define BLINKLED_OFF() (PORTB &= B11011111)
#endif

Expand Down Expand Up @@ -130,17 +125,15 @@

// ATtiny84
#elif defined(__AVR_ATtiny84__)
#define IR_USE_TIMER1 // tx = pin 6
#define IR_USE_TIMER1 // tx = pin 6

//ATtiny85
#elif defined(__AVR_ATtiny85__)
#define IR_USE_TIMER_TINY0 // tx = pin 1
#define IR_USE_TIMER_TINY0 // tx = pin 1

#elif defined(ESP32)
#define IR_TIMER_USE_ESP32
#else
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
// ATmega48, ATmega88, ATmega168, ATmega328
#else
//#define IR_USE_TIMER1 // tx = pin 9
#define IR_USE_TIMER2 // tx = pin 3

Expand Down Expand Up @@ -545,28 +538,6 @@

#define TIMER_PWM_PIN 1 /* ATtiny85 */

//---------------------------------------------------------
// ESP32 (ESP8266 should likely be added here too)
//

// ESP32 has it own timer API and does not use these macros, but to avoid ifdef'ing
// them out in the common code, they are defined to no-op. This allows the code to compile
// (which it wouldn't otherwise) but irsend will not work until ESP32 specific code is written
// for that -- merlin
// As a warning, sending timing specific code from an ESP32 can be challenging if you need 100%
// reliability because the arduino code may be interrupted and cause your sent waveform to be the
// wrong length. This is specifically an issue for neopixels which require 800Khz resolution.
// IR may just work as is with the common code since it's lower frequency, but if not, the other
// way to do this on ESP32 is using the RMT built in driver like in this incomplete library below
// https://github.com/ExploreEmbedded/ESP32_RMT
#elif defined(IR_TIMER_USE_ESP32)
#define TIMER_RESET
#define TIMER_ENABLE_PWM
#define TIMER_DISABLE_PWM Serial.println("IRsend not implemented for ESP32 yet");
#define TIMER_ENABLE_INTR
#define TIMER_DISABLE_INTR
#define TIMER_INTR_NAME

//---------------------------------------------------------
// Unknown Timer
//
Expand Down
3 changes: 0 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
## 2.3.3 - 2017/03/31
- Added ESP32 IR receive support [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/425)

## 2.2.3 - 2017/03/27
- Fix calculation of pause length in LEGO PF protocol [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/427)

Expand Down
4 changes: 0 additions & 4 deletions examples/IRrecvDemo/IRrecvDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ decode_results results;
void setup()
{
Serial.begin(9600);
// In case the interrupt driver crashes on setup, give a clue
// to the user what's going on.
Serial.println("Enabling IRin");
irrecv.enableIRIn(); // Start the receiver
Serial.println("Enabled IRin");
}

void loop() {
Expand Down
2 changes: 1 addition & 1 deletion examples/IRrecvDump/IRrecvDump.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* You can change this to another available Arduino Pin.
* Your IR receiver should be connected to the pin defined here
*/
int RECV_PIN = 11;
int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

Expand Down
17 changes: 0 additions & 17 deletions irRecv.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#include "IRremote.h"
#include "IRremoteInt.h"

#ifdef IR_TIMER_USE_ESP32
hw_timer_t *timer;
void IRTimer(); // defined in IRremote.cpp
#endif

//+=============================================================================
// Decodes the received IR message
Expand Down Expand Up @@ -122,17 +117,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)
Expand All @@ -146,7 +130,6 @@ void IRrecv::enableIRIn ( )
TIMER_RESET;

sei(); // enable interrupts
#endif

// Initialize state machine variables
irparams.rcvstate = STATE_IDLE;
Expand Down
3 changes: 0 additions & 3 deletions irSend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ void IRsend::space (unsigned int time)
//
void IRsend::enableIROut (int khz)
{
// FIXME: implement ESP32 support, see IR_TIMER_USE_ESP32 in boarddefs.h
#ifndef ESP32
// Disable the Timer2 Interrupt (which is used for receiving IR)
TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt

Expand All @@ -68,7 +66,6 @@ void IRsend::enableIROut (int khz)
// CS2 = 000: no prescaling
// The top value for the timer. The modulation frequency will be SYSCLOCK / 2 / OCR2A.
TIMER_CONFIG_KHZ(khz);
#endif
}

//+=============================================================================
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/z3t0/Arduino-IRremote.git"
},
"version": "2.3.3",
"version": "2.2.3",
"frameworks": "arduino",
"platforms": "atmelavr",
"authors" :
Expand Down