Skip to content

Commit 36ad7da

Browse files
committed
Replaced macros TIMER_EN/DISABLE_RECEIVE_INTR and EN/DISABLE_SEND_PWM_BY_TIMER by functions.
1 parent 7c42691 commit 36ad7da

File tree

6 files changed

+524
-263
lines changed

6 files changed

+524
-263
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ jobs:
106106
sketches-exclude: IR2Keyboard
107107
build-properties: # the flags were put in compiler.cpp.extra_flags
108108
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DIR_SEND_PIN=3 -DUSE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
109+
SimpleSender: -DSEND_PWM_BY_TIMER
109110
All: -DUSE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
110111

111112
- arduino-boards-fqbn: arduino:avr:mega:cpu=atmega2560
112113
sketches-exclude: IR2Keyboard
113114
build-properties: # the flags were put in compiler.cpp.extra_flags
114115
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
116+
SimpleSender: -DSEND_PWM_BY_TIMER
115117

116118
- arduino-boards-fqbn: arduino:avr:leonardo
117119
build-properties: # the flags were put in compiler.cpp.extra_flags
@@ -122,6 +124,7 @@ jobs:
122124
sketches-exclude: MinimalReceiver,IRDispatcherDemo
123125
build-properties: # the flags were put in compiler.cpp.extra_flags
124126
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
127+
SimpleSender: -DSEND_PWM_BY_TIMER
125128

126129
- arduino-boards-fqbn: arduino:samd:arduino_zero_native
127130
sketches-exclude: MinimalReceiver,IRDispatcherDemo
@@ -131,19 +134,24 @@ jobs:
131134
- arduino-boards-fqbn: adafruit:samd:adafruit_metro_m4:cache=on,speed=120,opt=small,maxqspi=50,usbstack=arduino,debug=off
132135
platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
133136
sketches-exclude: MinimalReceiver,IRDispatcherDemo
137+
build-properties: # the flags were put in compiler.cpp.extra_flags
138+
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
134139

135140
- arduino-boards-fqbn: arduino:mbed:nano33ble
136141
build-properties: # the flags were put in compiler.cpp.extra_flags
137142
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
143+
SimpleSender: -DSEND_PWM_BY_TIMER
138144

139145
- arduino-boards-fqbn: arduino:mbed_rp2040:pico
140146
build-properties: # the flags were put in compiler.cpp.extra_flags
141147
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100
148+
SimpleSender: -DSEND_PWM_BY_TIMER
142149

143150
- arduino-boards-fqbn: rp2040:rp2040:arduino_nano_connect
144151
platform-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
145152
build-properties: # the flags were put in compiler.cpp.extra_flags
146153
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DSEND_PWM_BY_TIMER
154+
SimpleSender: -DSEND_PWM_BY_TIMER
147155
All: -DRAW_BUFFER_LENGTH=700
148156

149157
- arduino-boards-fqbn: megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal
@@ -164,27 +172,36 @@ jobs:
164172
platform-url: https://raw.githubusercontent.com/ArminJo/DigistumpArduino/master/package_digistump_index.json
165173
required-libraries: ATtinySerialOut
166174
sketch-names: MinimalReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
175+
build-properties: # the flags were put in compiler.cpp.extra_flags
176+
SimpleSender: -DSEND_PWM_BY_TIMER
167177

168178
- arduino-boards-fqbn: ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
169179
platform-url: http://drazzy.com/package_drazzy.com_index.json
170180
required-libraries: ATtinySerialOut
171181
sketch-names: MinimalReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
182+
build-properties: # the flags were put in compiler.cpp.extra_flags
183+
SimpleSender: -DSEND_PWM_BY_TIMER
172184

173185
- arduino-boards-fqbn: ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
174186
platform-url: http://drazzy.com/package_drazzy.com_index.json
175187
required-libraries: ATtinySerialOut
176188
sketch-names: MinimalReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
189+
build-properties: # the flags were put in compiler.cpp.extra_flags
190+
SimpleSender: -DSEND_PWM_BY_TIMER
177191

178192
- arduino-boards-fqbn: ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
179193
platform-url: http://drazzy.com/package_drazzy.com_index.json
180194
required-libraries: ATtinySerialOut
181195
sketch-names: MinimalReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
196+
build-properties: # the flags were put in compiler.cpp.extra_flags
197+
SimpleSender: -DSEND_PWM_BY_TIMER
182198

183199
- arduino-boards-fqbn: MegaCore:avr:128:bootloader=no_bootloader,eeprom=keep,BOD=2v7,LTO=Os_flto,clock=8MHz_internal
184200
platform-url: https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json
185201
arduino-platform: arduino:avr,MegaCore:avr # gcc is taken from arduino:avr
186202
build-properties: # the flags were put in compiler.cpp.extra_flags
187203
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=300
204+
SimpleSender: -DSEND_PWM_BY_TIMER
188205
All: -DRAW_BUFFER_LENGTH=700
189206

190207
- arduino-boards-fqbn: esp8266:esp8266:d1_mini:eesz=4M3M,xtal=80
@@ -197,7 +214,7 @@ jobs:
197214
- arduino-boards-fqbn: esp32:esp32:featheresp32:FlashFreq=80
198215
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
199216
sketches-exclude: MinimalReceiver # undefined reference to `TwoWire::onReceive(void (*)(int))'
200-
build-properties: # the flags were put in compiler.cpp.extra_flags
217+
build-properties: # the flags were put in compiler.cpp.extra_flags. SEND_PWM_BY_TIMER is always enabled!
201218
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=500 -Wno-error=maybe-uninitialized
202219
All: -DRAW_BUFFER_LENGTH=300 -Wno-error=maybe-uninitialized # https://github.com/espressif/arduino-esp32/issues/7024
203220

@@ -225,7 +242,7 @@ jobs:
225242
- arduino-boards-fqbn: SparkFun:avr:promicro
226243
arduino-platform: arduino:avr,SparkFun:avr
227244
platform-url: https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json # Arduino URL is not required here
228-
build-properties: # the flags were put in compiler.cpp.extra_flags
245+
build-properties: # the flags were put in compiler.cpp.extra_flags. SEND_PWM_BY_TIMER is always enabled!
229246
IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=700
230247
All: -DRAW_BUFFER_LENGTH=300
231248

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-I
3232
- Added support for attiny1614 by Joe Ostrander.
3333
- Fixed SEND_PWM_BY_TIMER for ATtiny167 thanks to freskpe.
3434
- Improved SHARP repeat decoding.
35+
- Replaced macros TIMER_EN/DISABLE_RECEIVE_INTR and EN/DISABLE_SEND_PWM_BY_TIMER by functions.
3536

3637
## 3.9.0
3738
- Improved documentation with the help of [ElectronicsArchiver}(https://github.com/ElectronicsArchiver).

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), BangOlufsen, BoseWave, Lego, Whynter, MagiQuest.<br/><br/><b>New: </b>Introduced common structure PulseDistanceWidthProtocolConstants. Improved Magiquest protocol.<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,rp2040
9+
architectures=avr,megaavr,samd,esp8266,esp32,stm32,STM32F1,mbed,mbed_nano,rp2040,mbed_rp2040
1010
includes=IRremote.hpp

src/IRReceive.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ IRrecv::IRrecv(uint_fast8_t aReceivePin, uint_fast8_t aFeedbackLEDPin) {
119119
//#define _IR_MEASURE_TIMING
120120
//#define _IR_TIMING_TEST_PIN 10 // "pinModeFast(_IR_TIMING_TEST_PIN, OUTPUT);" is executed at start()
121121
#if defined(TIMER_INTR_NAME)
122-
ISR (TIMER_INTR_NAME) // for ISR definitions
122+
ISR (TIMER_INTR_NAME) // for ISR definitions
123123
#else
124124
ISR()
125125
// for functions definitions which are called by separate (board specific) ISR
@@ -130,7 +130,9 @@ ISR()
130130
#endif
131131
// 7 - 8.5 us for ISR body (without pushes and pops) for ATmega328 @16MHz
132132

133-
TIMER_RESET_INTR_PENDING;// reset TickCounterForISR interrupt flag if required (currently only for Teensy and ATmega4809)
133+
#if defined(TIMER_REQUIRES_RESET_INTR_PENDING)
134+
timerResetInterruptPending(); // reset TickCounterForISR interrupt flag if required (currently only for Teensy and ATmega4809)
135+
#endif
134136

135137
// Read if IR Receiver -> SPACE [xmt LED off] or a MARK [xmt LED on]
136138
#if defined(__AVR__)
@@ -310,7 +312,7 @@ void IRrecv::start() {
310312
resume();
311313

312314
// Timer interrupt is enabled after state machine reset
313-
TIMER_ENABLE_RECEIVE_INTR;
315+
timerEnableReceiveInterrupt();
314316
#ifdef _IR_MEASURE_TIMING
315317
pinModeFast(_IR_TIMING_TEST_PIN, OUTPUT);
316318
#endif
@@ -349,7 +351,7 @@ void IRrecv::restartAfterSend() {
349351
* Disables the timer for IR reception.
350352
*/
351353
void IRrecv::stop() {
352-
TIMER_DISABLE_RECEIVE_INTR;
354+
timerDisableReceiveInterrupt();
353355
}
354356
/**
355357
* Alias for stop().

src/IRSend.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ void IRsend::mark(unsigned int aMarkMicros) {
755755
/*
756756
* Generate hardware PWM signal
757757
*/
758-
ENABLE_SEND_PWM_BY_TIMER; // Enable timer or ledcWrite() generated PWM output
758+
enableSendPWMByTimer(); // Enable timer or ledcWrite() generated PWM output
759759
customDelayMicroseconds(aMarkMicros);
760760
IRLedOff();// disables hardware PWM and manages feedback LED
761761
return;
@@ -880,20 +880,20 @@ void IRsend::mark(unsigned int aMarkMicros) {
880880
*/
881881
void IRsend::IRLedOff() {
882882
#if defined(SEND_PWM_BY_TIMER)
883-
DISABLE_SEND_PWM_BY_TIMER; // Disable PWM output
883+
disableSendPWMByTimer(); // Disable PWM output
884884
#elif defined(USE_NO_SEND_PWM)
885885
# if defined(USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN) && !defined(OUTPUT_OPEN_DRAIN)
886-
digitalWriteFast(sendPin, LOW); // prepare for all next active states.
887-
pinModeFast(sendPin, INPUT);// inactive state for open drain
886+
digitalWriteFast(sendPin, LOW); // prepare for all next active states.
887+
pinModeFast(sendPin, INPUT);// inactive state for open drain
888888
# else
889-
digitalWriteFast(sendPin, HIGH); // Set output to inactive high.
889+
digitalWriteFast(sendPin, HIGH); // Set output to inactive high.
890890
# endif
891891
#else
892892
# if defined(USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN)
893893
# if defined(OUTPUT_OPEN_DRAIN)
894-
digitalWriteFast(sendPin, HIGH); // Set output to inactive high.
894+
digitalWriteFast(sendPin, HIGH); // Set output to inactive high.
895895
# else
896-
pinModeFast(sendPin, INPUT); // inactive state to mimic open drain
896+
pinModeFast(sendPin, INPUT); // inactive state to mimic open drain
897897
# endif
898898
# else
899899
digitalWriteFast(sendPin, LOW);

0 commit comments

Comments
 (0)