2323#ifndef IRremoteBoardDefs_h
2424#define IRremoteBoardDefs_h
2525
26+ #ifdef ARDUINO_ARCH_AVR
27+ #include <avr/pgmspace.h>
28+ #define HAS_FLASH_READ 1
29+ #define STRCPY_PF_CAST (x ) (x)
30+ #else
31+ #define HAS_FLASH_READ 0
32+ #endif
33+
2634// Define some defaults, that some boards may like to override
2735// (This is to avoid negative logic, ! DONT_... is just awkward.)
2836
4755/**
4856 * Duty cycle in percent for sent signals.
4957 */
50- #if ! defined(DUTY_CYCLE )
51- #define DUTY_CYCLE 30 // 30 saves power and is compatible to the old existing code
58+ #if ! defined(IR_SEND_DUTY_CYCLE )
59+ #define IR_SEND_DUTY_CYCLE 30 // 30 saves power and is compatible to the old existing code
5260#endif
5361
54- /**
55- * If USE_SOFT_SEND_PWM or USE_NO_SEND_PWM, this amount (in micro seconds) is subtracted from the
56- * on-time of the pulses.
57- */
58- #define PULSE_CORRECTION 3
59-
6062//------------------------------------------------------------------------------
6163// This first #ifdef statement contains defines for blinking the LED,
6264// as well as all other board specific information, with the exception of
154156
155157//------------------------------------------------------------------------------
156158// microseconds per clock interrupt tick
159+ #if ! defined(MICROS_PER_TICK )
157160#define MICROS_PER_TICK 50
161+ #endif
158162
159163//------------------------------------------------------------------------------
160164// Define which timer to use
@@ -439,7 +443,7 @@ static void timerConfigForSend(uint16_t frequency) {
439443 TCCR2A = _BV (WGM20 );
440444 TCCR2B = _BV (WGM22 ) | _BV (CS20 );
441445 OCR2A = pwmval ;
442- OCR2B = pwmval * DUTY_CYCLE / 100 ;
446+ OCR2B = pwmval * IR_SEND_DUTY_CYCLE / 100 ;
443447}
444448
445449#define TIMER_COUNT_TOP (SYSCLOCK * MICROS_PER_TICK / 1000000)
@@ -508,7 +512,7 @@ static void timerConfigForSend(uint16_t frequency) {
508512 TCCR1A = _BV (WGM11 );
509513 TCCR1B = _BV (WGM13 ) | _BV (CS10 );
510514 ICR1 = pwmval ;
511- OCR1A = pwmval * DUTY_CYCLE / 100 ;
515+ OCR1A = pwmval * IR_SEND_DUTY_CYCLE / 100 ;
512516}
513517
514518static void timerConfigForReceive () {
@@ -560,7 +564,7 @@ static void timerConfigForSend(uint16_t frequency) {
560564 TCCR3A = _BV (WGM31 );
561565 TCCR3B = _BV (WGM33 ) | _BV (CS30 );
562566 ICR3 = pwmval ;
563- OCR3A = pwmval * DUTY_CYCLE / 100 ;
567+ OCR3A = pwmval * IR_SEND_DUTY_CYCLE / 100 ;
564568}
565569
566570static void timerConfigForReceive () {
@@ -612,8 +616,8 @@ static void timerConfigForSend(uint16_t frequency) {
612616 TCCR4E = 0 ;
613617 TC4H = pwmval >> 8 ;
614618 OCR4C = pwmval ;
615- TC4H = (pwmval * DUTY_CYCLE / 100 ) >> 8 ;
616- OCR4A = (pwmval * DUTY_CYCLE / 100 ) & 255 ;
619+ TC4H = (pwmval * IR_SEND_DUTY_CYCLE / 100 ) >> 8 ;
620+ OCR4A = (pwmval * IR_SEND_DUTY_CYCLE / 100 ) & 255 ;
617621}
618622
619623static void timerConfigForReceive () {
@@ -656,7 +660,7 @@ static void timerConfigForSend(uint16_t frequency) {
656660 TCCR4A = _BV (WGM41 );
657661 TCCR4B = _BV (WGM43 ) | _BV (CS40 );
658662 ICR4 = pwmval ;
659- OCR4A = pwmval * DUTY_CYCLE / 100 ;
663+ OCR4A = pwmval * IR_SEND_DUTY_CYCLE / 100 ;
660664}
661665
662666static void timerConfigForReceive () {
@@ -692,7 +696,7 @@ static void timerConfigForSend(uint16_t frequency) {
692696 TCCR5A = _BV (WGM51 );
693697 TCCR5B = _BV (WGM53 ) | _BV (CS50 );
694698 ICR5 = pwmval ;
695- OCR5A = pwmval * DUTY_CYCLE / 100 ;
699+ OCR5A = pwmval * IR_SEND_DUTY_CYCLE / 100 ;
696700}
697701
698702static void timerConfigForReceive () {
@@ -820,7 +824,7 @@ static void timerConfigForSend(uint16_t frequency) {
820824 TCCR0A = _BV (WGM00 );
821825 TCCR0B = _BV (WGM02 ) | _BV (CS00 );
822826 OCR0A = pwmval ;
823- OCR0B = pwmval * DUTY_CYCLE / 100 ;
827+ OCR0B = pwmval * IR_SEND_DUTY_CYCLE / 100 ;
824828}
825829
826830#define TIMER_COUNT_TOP (SYSCLOCK * MICROS_PER_TICK / 1000000)
@@ -854,7 +858,7 @@ static void timerConfigForSend(uint16_t frequency) {
854858 TCCR0A = _BV (WGM00 );
855859 TCCR0B = _BV (WGM02 ) | _BV (CS00 );
856860 OCR0A = pwmval ;
857- OCR0B = pwmval * DUTY_CYCLE / 100 ;
861+ OCR0B = pwmval * IR_SEND_DUTY_CYCLE / 100 ;
858862}
859863
860864#define IR_SEND_PIN 1
@@ -872,7 +876,7 @@ static void timerConfigForSend(uint16_t frequency) {
872876 const uint32_t pwmval = (SYSCLOCK / 2000 ) / (frequency );
873877 TCB0 .CTRLB = TCB_CNTMODE_PWM8_gc ;
874878 TCB0 .CCMPL = pwmval ;
875- TCB0 .CCMPH = (pwmval * DUTY_CYCLE ) / 100 ;
879+ TCB0 .CCMPH = (pwmval * IR_SEND_DUTY_CYCLE ) / 100 ;
876880 TCB0 .CTRLA = (TCB_CLKSEL_CLKDIV2_gc ) | (TCB_ENABLE_bm );
877881}
878882
@@ -906,7 +910,7 @@ static void timerConfigForReceive() {
906910#endif
907911
908912#define TIMER_RESET_INTR_PENDING
909- #define TIMER_ENABLE_SEND_PWM ledcWrite(LED_CHANNEL, DUTY_CYCLE ) // we must use channel here not pin number
913+ #define TIMER_ENABLE_SEND_PWM ledcWrite(LED_CHANNEL, IR_SEND_DUTY_CYCLE ) // we must use channel here not pin number
910914#define TIMER_DISABLE_SEND_PWM ledcWrite(LED_CHANNEL, 0)
911915
912916#ifdef ISR
0 commit comments