Skip to content

Commit 3a471ee

Browse files
committed
Added mbed support
1 parent 3549fb5 commit 3a471ee

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
# Examples: arduino:avr:uno, arduino:avr:leonardo, arduino:avr:nano, arduino:avr:mega
3838
# arduino:sam:arduino_due_x, arduino:samd:arduino_zero_native"
3939
# ATTinyCore:avr:attinyx5:chip=85,clock=1internal, digistump:avr:digispark-tiny, digistump:avr:digispark-pro
40-
# STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
40+
# STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
4141
# esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80
4242
# You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace
4343
#############################################################################################################
@@ -51,20 +51,22 @@ jobs:
5151
- arduino:avr:uno|USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
5252
- arduino:avr:leonardo
5353
- arduino:megaavr:nona4809:mode=off
54-
- megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal
54+
- arduino:samd:arduino_zero_native
55+
- arduino:mbed:nano33ble
56+
- arduino:mbed_rp2040:pico
5557
- digistump:avr:digispark-tiny:clock=clock16
5658
- ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
5759
- ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
5860
- ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
5961
- TinyCore:avr:tiny32
60-
- arduino:samd:arduino_zero_native
6162
- MegaCore:avr:128:bootloader=no_bootloader,eeprom=keep,BOD=2v7,LTO=Os_flto,clock=8MHz_internal # ATmega128
63+
- SparkFun:avr:promicro
64+
- megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal
6265
- esp8266:esp8266:d1_mini:eesz=4M3M,xtal=80
6366
- esp32:esp32:featheresp32:FlashFreq=80
64-
- STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
65-
- STM32:stm32:GenL0:pnum=THUNDERPACK_L072
67+
- STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
68+
- STMicroelectronics:stm32:GenL0:pnum=THUNDERPACK_L072
6669
- stm32duino:STM32F1:genericSTM32F103C
67-
- SparkFun:avr:promicro
6870
- sandeepmistry:nRF5:BBCmicrobit
6971

7072
# Specify parameters for each board.
@@ -147,15 +149,15 @@ jobs:
147149
sketches-exclude: MinimalReceiver
148150

149151
- arduino-boards-fqbn: esp32:esp32:featheresp32:FlashFreq=80
150-
platform-url: https://dl.espressif.com/dl/package_esp32_index.json
152+
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
151153
sketches-exclude: MinimalReceiver # undefined reference to `TwoWire::onReceive(void (*)(int))'
152154

153-
- arduino-boards-fqbn: STM32:stm32:GenF1:pnum=BLUEPILL_F103C8 # ST version
154-
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
155+
- arduino-boards-fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # ST version
156+
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json
155157
sketches-exclude: MinimalReceiver
156158

157-
- arduino-boards-fqbn: STM32:stm32:GenL0:pnum=THUNDERPACK_L072 # ST version
158-
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
159+
- arduino-boards-fqbn: STMicroelectronics:stm32:GenL0:pnum=THUNDERPACK_L072 # ST version
160+
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json
159161
sketches-exclude: MinimalReceiver,IRDispatcherDemo
160162

161163
- arduino-boards-fqbn: stm32duino:STM32F1:genericSTM32F103C # Roger Clark version

examples/IRremoteInfo/IRremoteInfo.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ void dumpTimerPin() {
104104
}
105105

106106
void dumpClock() {
107+
#if defined(F_CPU)
107108
Serial.print(F("MCU Clock: "));
108109
Serial.println(F_CPU);
110+
#endif
109111
}
110112

111113
void dumpPlatform() {

src/IRSend.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ void IRsend::begin(bool aEnableLEDFeedback, uint8_t aLEDFeedbackPin) {
7474
// must exclude cores by MCUdude, MEGATINYCORE, NRF5, SAMD and ESP32 because they do not use the -flto flag for compile
7575
#if (!defined(SEND_PWM_BY_TIMER) || defined(USE_NO_SEND_PWM)) \
7676
&& !defined(SUPPRESS_ERROR_MESSAGE_FOR_BEGIN) \
77-
&& !(defined(NRF5) || defined(ARDUINO_ARCH_NRF52840)) && !defined(ARDUINO_ARCH_SAMD) \
77+
&& !(defined(NRF5) || defined(ARDUINO_ARCH_NRF52840)) \
78+
&& !defined(ARDUINO_ARCH_SAMD) && !defined(ARDUINO_ARCH_RP2040) \
7879
&& !defined(ESP32) && !defined(ESP8266) && !defined(MEGATINYCORE) \
7980
&& !defined(MINICORE) && !defined(MIGHTYCORE) && !defined(MEGACORE) && !defined(MAJORCORE) \
8081
&& !(defined(__STM32F1__) || defined(ARDUINO_ARCH_STM32F1)) && !(defined(STM32F1xx) || defined(ARDUINO_ARCH_STM32))
@@ -85,7 +86,7 @@ void IRsend::begin(bool aEnableLEDFeedback, uint8_t aLEDFeedbackPin) {
8586
* I know now way to check for lto flag here.
8687
*/
8788
UsageError(
88-
"Error: You must use begin(<sendPin>, <EnableLEDFeedback>, <LEDFeedbackPin>) if SEND_PWM_BY_TIMER is not defined or USE_NO_SEND_PWM is defined or enable lto or activate the line #define SUPPRESS_ERROR_MESSAGE_FOR_BEGIN in IRremote.h.");
89+
"Error: You must use begin(<sendPin>, <EnableLEDFeedback>, <LEDFeedbackPin>) if SEND_PWM_BY_TIMER is not defined or USE_NO_SEND_PWM is defined, OR enable lto or activate the line #define SUPPRESS_ERROR_MESSAGE_FOR_BEGIN in IRremote.h.");
8990
#endif
9091

9192
setLEDFeedback(aLEDFeedbackPin, aEnableLEDFeedback);

src/IRremote.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,12 @@
180180
* Measured value for Nano @16MHz is around 3000, for Bluepill @72MHz is around 700, for Zero 3600
181181
*/
182182
#if !defined(PULSE_CORRECTION_NANOS)
183+
# if defined(F_CPU)
183184
// To change this value, you simply can add a line #define "PULSE_CORRECTION_NANOS <My_new_value>" in your ino file before the line "#include <IRremote.h>"
184185
#define PULSE_CORRECTION_NANOS (48000000000L / F_CPU) // 3000 @16MHz, 666 @72MHz
186+
# else
187+
#define PULSE_CORRECTION_NANOS 600
188+
# endif
185189
#endif
186190

187191
#include "IRremoteInt.h"

src/private/IRTimer.hpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,6 @@ void timerConfigForReceive() {
975975
#error PWM generation by hardware not implemented for SAMD
976976
# endif
977977

978-
# if defined(SEND_PWM_BY_TIMER)
979-
#define IR_SEND_PIN 9
980-
# endif
981-
982978
// use Timer TC3 here
983979
# if !defined(IR_SAMD_TIMER)
984980
#define IR_SAMD_TIMER TC3
@@ -1053,6 +1049,35 @@ void TC3_Handler(void) {
10531049
}
10541050
}
10551051

1052+
/***************************************
1053+
* Mbed based boards
1054+
***************************************/
1055+
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE + Sparkfun Apollo3
1056+
#include "mbed.h"
1057+
# if defined(SEND_PWM_BY_TIMER)
1058+
#error PWM generation by hardware not implemented for MBED
1059+
# endif
1060+
1061+
#define TIMER_RESET_INTR_PENDING
1062+
#define TIMER_ENABLE_RECEIVE_INTR sMbedTimer.attach(IRTimerInterruptHandler, std::chrono::microseconds(MICROS_PER_TICK));
1063+
#define TIMER_DISABLE_RECEIVE_INTR sMbedTimer.detach();
1064+
1065+
// Redefinition of ISR macro which creates a plain function now
1066+
# ifdef ISR
1067+
#undef ISR
1068+
# endif
1069+
#define ISR() void IRTimerInterruptHandler(void)
1070+
void IRTimerInterruptHandler();
1071+
1072+
mbed::Ticker sMbedTimer;
1073+
1074+
/*
1075+
* Set timer for interrupts every MICROS_PER_TICK (50 us)
1076+
*/
1077+
void timerConfigForReceive() {
1078+
sMbedTimer.attach(IRTimerInterruptHandler, std::chrono::microseconds(MICROS_PER_TICK));
1079+
}
1080+
10561081
/***************************************
10571082
* NRF5 boards like the BBC:Micro
10581083
***************************************/

0 commit comments

Comments
 (0)