Skip to content

Commit 2077fd1

Browse files
tfry-gitArminJo
andauthored
Add pi pico support (Arduino-IRremote#955)
* Documentation * Add support for Pi Pico and other RP2040 boards (non-mbed core) Only receive was tested. Co-authored-by: Armin <[email protected]> Co-authored-by: Thomas Friedrichsmeier <[email protected]>
1 parent 37a05fa commit 2077fd1

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ ATtiny and Digispark boards are only tested with the recommended [ATTinyCore](ht
382382
- Sparkfun Pro Micro
383383
- Nano Every, Uno WiFi Rev2, nRF5 BBC MicroBit, Nano33_BLE
384384
- BluePill with STM32
385+
- RP2040 based boards (Raspberry Pi Pico, etc.)
385386
386387
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.<br/>
387388
If you can provide **examples of using a periodic timer for interrupts** for the new board, and the board name for selection in the Arduino IDE, then you have way better chances to get your board supported by IRremote.
@@ -458,6 +459,7 @@ The timer and the pin usage can be adjusted in [private/IRTimer.hpp](https://git
458459
| [Teensy 4.0 - 4.1](https://www.pjrc.com/teensy/pinout.html) | **FlexPWM1.3** | **8** | 7, 25 |
459460
| [BluePill / STM32F103C8T6](https://github.com/rogerclarkmelbourne/Arduino_STM32) | **3** | % | **PA6 & PA7 & PB0 & PB1** |
460461
| [BluePill / STM32F103C8T6](https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill) | **TIM4** | % | **PB6 & PB7 & PB8 & PB9** |
462+
| [RP2040 / Pi Pico](https://github.com/earlephilhower/arduino-pico) | [default alarm pool](https://raspberrypi.github.io/pico-sdk-doxygen/group__repeating__timer.html) | % | |
461463

462464
### Why do we use 33% duty cycle for sending
463465
We do it according to the statement in the [Vishay datasheet](https://www.vishay.com/docs/80069/circuit.pdf):

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ sentence=Send and receive infrared signals with multiple protocols
66
paragraph=Currently included protocols: Denon / Sharp, JVC, LG / LG2, NEC / Onkyo / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sony, (Pronto), BoseWave, Lego, Whynter, MagiQuest.<br/><br/><b>New: </b><a href="https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-program-to-the-31-version">3.x upgrade instructions</a><br/>Added LG2 protocol.<br/>For all 3.x: Generation of PWM is now done by software by default, thus saving the hardware timer and enabling abitrary output pins. Removed decode_results results. Renamed most irparams_struct values. Support for more CPU's.<br/><b>New: </b>Improved support for Teensy boards by Paul Stoffregen.<br/><a href="https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/changelog.md">Release notes</a><br/>
77
category=Communication
88
url=https://github.com/Arduino-IRremote/Arduino-IRremote
9-
architectures=avr,megaavr,samd,esp8266,esp32,stm32,STM32F1,mbed,mbed_nano
9+
architectures=avr,megaavr,samd,esp8266,esp32,stm32,STM32F1,mbed,mbed_nano,rp2040
1010
includes=IRremote.hpp

src/private/IRTimer.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,34 @@ void timerConfigForReceive() {
11491149
sMbedTimer.attach(IRTimerInterruptHandler, std::chrono::microseconds(MICROS_PER_TICK));
11501150
}
11511151

1152+
/***************************************
1153+
* RP2040 based boards
1154+
***************************************/
1155+
#elif defined(ARDUINO_ARCH_RP2040) // Raspberry Pi Pico, Adafruit Feather RP2040, etc.
1156+
#include "pico/time.h"
1157+
# if defined(SEND_PWM_BY_TIMER)
1158+
#error PWM generation by hardware not implemented for RP2040
1159+
# endif
1160+
1161+
#define TIMER_RESET_INTR_PENDING
1162+
#define TIMER_ENABLE_RECEIVE_INTR add_repeating_timer_us(MICROS_PER_TICK, IRTimerInterruptHandlerHelper, NULL, &sRP2040Timer);
1163+
#define TIMER_DISABLE_RECEIVE_INTR cancel_repeating_timer(&sRP2040Timer);
1164+
1165+
// Redefinition of ISR macro which creates a plain function now
1166+
# ifdef ISR
1167+
#undef ISR
1168+
# endif
1169+
#define ISR() void IRTimerInterruptHandler(void)
1170+
void IRTimerInterruptHandler();
1171+
bool IRTimerInterruptHandlerHelper(repeating_timer_t *) {
1172+
IRTimerInterruptHandler();
1173+
return true;
1174+
}
1175+
1176+
repeating_timer_t sRP2040Timer;
1177+
1178+
void timerConfigForReceive() {}
1179+
11521180
/***************************************
11531181
* NRF5 boards like the BBC:Micro
11541182
***************************************/

0 commit comments

Comments
 (0)