Added mbed support

This commit is contained in:
Armin 2021-10-02 20:17:30 +02:00
parent 3549fb5ca2
commit 3a471eedfb
5 changed files with 51 additions and 17 deletions

View File

@ -37,7 +37,7 @@ jobs:
# Examples: arduino:avr:uno, arduino:avr:leonardo, arduino:avr:nano, arduino:avr:mega
# arduino:sam:arduino_due_x, arduino:samd:arduino_zero_native"
# ATTinyCore:avr:attinyx5:chip=85,clock=1internal, digistump:avr:digispark-tiny, digistump:avr:digispark-pro
# STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
# STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
# esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80
# You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace
#############################################################################################################
@ -51,20 +51,22 @@ jobs:
- arduino:avr:uno|USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
- arduino:avr:leonardo
- arduino:megaavr:nona4809:mode=off
- megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal
- arduino:samd:arduino_zero_native
- arduino:mbed:nano33ble
- arduino:mbed_rp2040:pico
- digistump:avr:digispark-tiny:clock=clock16
- ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
- ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
- ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
- TinyCore:avr:tiny32
- arduino:samd:arduino_zero_native
- MegaCore:avr:128:bootloader=no_bootloader,eeprom=keep,BOD=2v7,LTO=Os_flto,clock=8MHz_internal # ATmega128
- SparkFun:avr:promicro
- megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal
- esp8266:esp8266:d1_mini:eesz=4M3M,xtal=80
- esp32:esp32:featheresp32:FlashFreq=80
- STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
- STM32:stm32:GenL0:pnum=THUNDERPACK_L072
- STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
- STMicroelectronics:stm32:GenL0:pnum=THUNDERPACK_L072
- stm32duino:STM32F1:genericSTM32F103C
- SparkFun:avr:promicro
- sandeepmistry:nRF5:BBCmicrobit
# Specify parameters for each board.
@ -147,15 +149,15 @@ jobs:
sketches-exclude: MinimalReceiver
- arduino-boards-fqbn: esp32:esp32:featheresp32:FlashFreq=80
platform-url: https://dl.espressif.com/dl/package_esp32_index.json
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
sketches-exclude: MinimalReceiver # undefined reference to `TwoWire::onReceive(void (*)(int))'
- arduino-boards-fqbn: STM32:stm32:GenF1:pnum=BLUEPILL_F103C8 # ST version
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
- arduino-boards-fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # ST version
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json
sketches-exclude: MinimalReceiver
- arduino-boards-fqbn: STM32:stm32:GenL0:pnum=THUNDERPACK_L072 # ST version
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
- arduino-boards-fqbn: STMicroelectronics:stm32:GenL0:pnum=THUNDERPACK_L072 # ST version
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json
sketches-exclude: MinimalReceiver,IRDispatcherDemo
- arduino-boards-fqbn: stm32duino:STM32F1:genericSTM32F103C # Roger Clark version

View File

@ -104,8 +104,10 @@ void dumpTimerPin() {
}
void dumpClock() {
#if defined(F_CPU)
Serial.print(F("MCU Clock: "));
Serial.println(F_CPU);
#endif
}
void dumpPlatform() {

View File

@ -74,7 +74,8 @@ void IRsend::begin(bool aEnableLEDFeedback, uint8_t aLEDFeedbackPin) {
// must exclude cores by MCUdude, MEGATINYCORE, NRF5, SAMD and ESP32 because they do not use the -flto flag for compile
#if (!defined(SEND_PWM_BY_TIMER) || defined(USE_NO_SEND_PWM)) \
&& !defined(SUPPRESS_ERROR_MESSAGE_FOR_BEGIN) \
&& !(defined(NRF5) || defined(ARDUINO_ARCH_NRF52840)) && !defined(ARDUINO_ARCH_SAMD) \
&& !(defined(NRF5) || defined(ARDUINO_ARCH_NRF52840)) \
&& !defined(ARDUINO_ARCH_SAMD) && !defined(ARDUINO_ARCH_RP2040) \
&& !defined(ESP32) && !defined(ESP8266) && !defined(MEGATINYCORE) \
&& !defined(MINICORE) && !defined(MIGHTYCORE) && !defined(MEGACORE) && !defined(MAJORCORE) \
&& !(defined(__STM32F1__) || defined(ARDUINO_ARCH_STM32F1)) && !(defined(STM32F1xx) || defined(ARDUINO_ARCH_STM32))
@ -85,7 +86,7 @@ void IRsend::begin(bool aEnableLEDFeedback, uint8_t aLEDFeedbackPin) {
* I know now way to check for lto flag here.
*/
UsageError(
"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.");
"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.");
#endif
setLEDFeedback(aLEDFeedbackPin, aEnableLEDFeedback);

View File

@ -180,8 +180,12 @@
* Measured value for Nano @16MHz is around 3000, for Bluepill @72MHz is around 700, for Zero 3600
*/
#if !defined(PULSE_CORRECTION_NANOS)
# if defined(F_CPU)
// 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>"
#define PULSE_CORRECTION_NANOS (48000000000L / F_CPU) // 3000 @16MHz, 666 @72MHz
# else
#define PULSE_CORRECTION_NANOS 600
# endif
#endif
#include "IRremoteInt.h"

View File

@ -975,10 +975,6 @@ void timerConfigForReceive() {
#error PWM generation by hardware not implemented for SAMD
# endif
# if defined(SEND_PWM_BY_TIMER)
#define IR_SEND_PIN 9
# endif
// use Timer TC3 here
# if !defined(IR_SAMD_TIMER)
#define IR_SAMD_TIMER TC3
@ -1053,6 +1049,35 @@ void TC3_Handler(void) {
}
}
/***************************************
* Mbed based boards
***************************************/
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE + Sparkfun Apollo3
#include "mbed.h"
# if defined(SEND_PWM_BY_TIMER)
#error PWM generation by hardware not implemented for MBED
# endif
#define TIMER_RESET_INTR_PENDING
#define TIMER_ENABLE_RECEIVE_INTR sMbedTimer.attach(IRTimerInterruptHandler, std::chrono::microseconds(MICROS_PER_TICK));
#define TIMER_DISABLE_RECEIVE_INTR sMbedTimer.detach();
// Redefinition of ISR macro which creates a plain function now
# ifdef ISR
#undef ISR
# endif
#define ISR() void IRTimerInterruptHandler(void)
void IRTimerInterruptHandler();
mbed::Ticker sMbedTimer;
/*
* Set timer for interrupts every MICROS_PER_TICK (50 us)
*/
void timerConfigForReceive() {
sMbedTimer.attach(IRTimerInterruptHandler, std::chrono::microseconds(MICROS_PER_TICK));
}
/***************************************
* NRF5 boards like the BBC:Micro
***************************************/