mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-13 09:56:16 +00:00
Added ESP32 IR receive support (IRsend not implemented yet).
- disable a lot of defines not relevant to ESP32, set them to 1 (no-op) - change default IR pin to 35 from 11 - changed serial speed to 115200 (9600 is too slow to keep up with IR input) - irSend disables code that will not compile on ESP32. It won't work, but it won't break compilation either.
This commit is contained in:
15
irRecv.cpp
15
irRecv.cpp
@@ -1,5 +1,10 @@
|
||||
#include "IRremote.h"
|
||||
#include "IRremoteInt.h"
|
||||
|
||||
#ifdef ESP32
|
||||
hw_timer_t *timer;
|
||||
void onTimer(); // defined in IRremote.cpp
|
||||
#endif
|
||||
|
||||
//+=============================================================================
|
||||
// Decodes the received IR message
|
||||
@@ -117,6 +122,15 @@ IRrecv::IRrecv (int recvpin, int blinkpin)
|
||||
//
|
||||
void IRrecv::enableIRIn ( )
|
||||
{
|
||||
// Interrupt Service Routine - Fires every 50uS
|
||||
#ifdef ESP32
|
||||
// 3 timers, choose #1, 80 divider nanosecond precision, 1 to count up
|
||||
timer = timerBegin(1, 80, 1);
|
||||
timerAttachInterrupt(timer, &onTimer, 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)
|
||||
@@ -130,6 +144,7 @@ void IRrecv::enableIRIn ( )
|
||||
TIMER_RESET;
|
||||
|
||||
sei(); // enable interrupts
|
||||
#endif
|
||||
|
||||
// Initialize state machine variables
|
||||
irparams.rcvstate = STATE_IDLE;
|
||||
|
||||
Reference in New Issue
Block a user