Skip to content

Add receiving support for Arduino 101 #481

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
4 changes: 2 additions & 2 deletions IRremote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# include "IRremoteInt.h"
#undef IR_GLOBAL

#ifndef IR_TIMER_USE_ESP32
#if (!defined(IR_TIMER_USE_ESP32) && !defined(IR_TIMER_USE_CURIE))
#include <avr/interrupt.h>
#endif

Expand Down Expand Up @@ -123,7 +123,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
#if (defined(IR_TIMER_USE_ESP32) || defined(IR_TIMER_USE_CURIE))
void IRTimer()
#else
ISR (TIMER_INTR_NAME)
Expand Down
20 changes: 19 additions & 1 deletion boarddefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
# define BLINKLED 255
# define BLINKLED_ON() 1
# define BLINKLED_OFF() 1

#elif defined(CURIE_IDE) || defined(__ARDUINO_ARC__) || defined(ARDUINO_ARCH_ARC32)
# define BLINKLED 13
# define BLINKLED_ON() (digitalWrite(13, HIGH))
# define BLINKLED_OFF() (digitalWrite(13, LOW))

#else
# define BLINKLED 13
# define BLINKLED_ON() (PORTB |= B00100000)
Expand Down Expand Up @@ -138,6 +144,10 @@

#elif defined(ESP32)
#define IR_TIMER_USE_ESP32

#elif defined(CURIE_IDE) || defined(__ARDUINO_ARC__) || defined(ARDUINO_ARCH_ARC32)
#define IR_TIMER_USE_CURIE

#else
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
// ATmega48, ATmega88, ATmega168, ATmega328
Expand Down Expand Up @@ -562,11 +572,19 @@
#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_DISABLE_PWM Serial.println(F("IRsend not implemented for ESP32 yet"));
#define TIMER_ENABLE_INTR
#define TIMER_DISABLE_INTR
#define TIMER_INTR_NAME

#elif defined(IR_TIMER_USE_CURIE)

#define TIMER_RESET
#define TIMER_ENABLE_PWM
#define TIMER_DISABLE_PWM Serial.println(F("IRsend not implemented for curie yet"));
#define TIMER_ENABLE_INTR
#define TIMER_DISABLE_INTR
#define TIMER_INTR_NAME
//---------------------------------------------------------
// Unknown Timer
//
Expand Down
41 changes: 24 additions & 17 deletions irRecv.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#include "IRremote.h"
#include "IRremoteInt.h"

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

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

#ifdef IR_TIMER_USE_CURIE
#include "CurieTimerOne.h"
void IRTimer(); // defined in IRremote.cpp
#endif

//+=============================================================================
// Decodes the received IR message
Expand Down Expand Up @@ -122,17 +127,19 @@ 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
// Interrupt Service Routine - Fires every 50uS
#ifdef IR_TIMER_USE_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);
#elif defined(IR_TIMER_USE_CURIE)
CurieTimerOne.start(50, &IRTimer);
#else
cli();
// Setup pulse clock timer interrupt
// Prescale /8 (16M/8 = 0.5 microseconds per tick)
Expand All @@ -146,7 +153,7 @@ void IRrecv::enableIRIn ( )
TIMER_RESET;

sei(); // enable interrupts
#endif
#endif

// Initialize state machine variables
irparams.rcvstate = STATE_IDLE;
Expand Down
2 changes: 1 addition & 1 deletion irSend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ 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
#if (!defined(IR_TIMER_USE_ESP32) && !defined(IR_TIMER_USE_CURIE))
// Disable the Timer2 Interrupt (which is used for receiving IR)
TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt

Expand Down