Skip to content

Commit 9618631

Browse files
authored
Merge pull request Arduino-IRremote#542 from use-sparingly/master
Sparkfun Pro Micro Support
2 parents 20a4d97 + 5a2ded8 commit 9618631

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Whether you use the Adafruit Neopixel lib, or FastLED, interrupts get disabled o
3333
- ATtiny 84 / 85
3434
- ESP32 (receive only)
3535
- ESP8266 is supported in a fork based on an old codebase that isn't as recent, but it works reasonably well given that perfectly timed sub millisecond interrupts are different on that chip. See https://github.com/markszabo/IRremoteESP8266
36+
- Sparkfun Pro Micro
3637

3738
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.
3839

@@ -51,6 +52,7 @@ We are open to suggestions for adding support to new boards, however we highly r
5152
| [ATmega64, ATmega128](https://github.com/MCUdude/MegaCore) | **13** | **1** |
5253
| ATmega1280, ATmega2560 | 5, 6, **9**, 11, 46 | 1, **2**, 3, 4, 5 |
5354
| [ESP32](http://esp32.net/) | N/A (not supported) | **1** |
55+
| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 9, **5**, 5 | 1, **3**, 4_HS |
5456
| [Teensy 1.0](https://www.pjrc.com/teensy/) | **17** | **1** |
5557
| [Teensy 2.0](https://www.pjrc.com/teensy/) | 9, **10**, 14 | 1, 3, **4_HS** |
5658
| [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/) | **1**, 16, 25 | 1, **2**, 3 |

boarddefs.h

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
//
1616
// JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
1717
// Whynter A/C ARC-110WD added by Francesco Meschia
18+
19+
// Sparkfun Pro Micro support by Alastair McCormack
1820
//******************************************************************************
1921

2022
#ifndef boarddefs_h
@@ -70,8 +72,14 @@
7072
// switch IRremote to use a different timer.
7173
//
7274

75+
// Sparkfun Pro Micro
76+
#if defined(ARDUINO_AVR_PROMICRO)
77+
//#define IR_USE_TIMER1 // tx = pin 9
78+
#define IR_USE_TIMER3 // tx = pin 5
79+
//#define IR_USE_TIMER4_HS // tx = pin 5
80+
7381
// Arduino Mega
74-
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
82+
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
7583
//#define IR_USE_TIMER1 // tx = pin 11
7684
#define IR_USE_TIMER2 // tx = pin 9
7785
//#define IR_USE_TIMER3 // tx = pin 5
@@ -246,19 +254,18 @@
246254
# define TIMER_PWM_PIN CORE_OC1A_PIN // Teensy
247255
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
248256
# define TIMER_PWM_PIN 11 // Arduino Mega
249-
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
250-
# define TIMER_PWM_PIN 13 // MegaCore
251257
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
252258
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
253259
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
254260
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
255261
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
256-
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__)
257-
# define TIMER_PWM_PIN 13 // MightyCore
262+
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
263+
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
264+
# define TIMER_PWM_PIN 13 // MightyCore, MegaCore
258265
#elif defined(__AVR_ATtiny84__)
259266
# define TIMER_PWM_PIN 6
260267
#else
261-
# define TIMER_PWM_PIN 9 // Arduino Duemilanove, Diecimila, LilyPad, etc
268+
# define TIMER_PWM_PIN 9 // Arduino Duemilanove, Diecimila, LilyPad, Sparkfun Pro Micro etc
262269
#endif // ATmega48, ATmega88, ATmega168, ATmega328
263270

264271
//---------------------------------------------------------
@@ -291,8 +298,8 @@
291298
//-----------------
292299
#if defined(CORE_OC3A_PIN)
293300
# define TIMER_PWM_PIN CORE_OC3A_PIN // Teensy
294-
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
295-
# define TIMER_PWM_PIN 5 // Arduino Mega
301+
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(ARDUINO_AVR_PROMICRO)
302+
# define TIMER_PWM_PIN 5 // Arduino Mega, Sparkfun Pro Micro
296303
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
297304
# define TIMER_PWM_PIN 6 // MightyCore
298305
#else
@@ -305,12 +312,21 @@
305312
#elif defined(IR_USE_TIMER4_HS)
306313

307314
#define TIMER_RESET
308-
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
309-
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
315+
316+
#if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro
317+
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A0)) // Use complimentary O̅C̅4̅A̅ output on pin 5
318+
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A0))) // (Pro Micro does not map PC7 (32/ICP3/CLK0/OC4A)
319+
// of ATmega32U4 )
320+
#else
321+
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
322+
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
323+
#endif
324+
310325
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4))
311326
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
312327
#define TIMER_INTR_NAME TIMER4_OVF_vect
313328

329+
314330
#define TIMER_CONFIG_KHZ(val) ({ \
315331
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
316332
TCCR4A = (1<<PWM4A); \
@@ -339,6 +355,8 @@
339355
//-----------------
340356
#if defined(CORE_OC4A_PIN)
341357
# define TIMER_PWM_PIN CORE_OC4A_PIN // Teensy
358+
#elif defined(ARDUINO_AVR_PROMICRO)
359+
# define TIMER_PWM_PIN 5 // Sparkfun Pro Micro
342360
#elif defined(__AVR_ATmega32U4__)
343361
# define TIMER_PWM_PIN 13 // Leonardo
344362
#else

0 commit comments

Comments
 (0)