36 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 44 #elif defined(__AVR_AT90USB162__) 48 #elif defined(__AVR_ATmega32U4__) 51 #define IR_USE_TIMER4_HS 54 #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) 60 #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) 65 #elif defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__) 71 #elif defined(__SAM3X8E__) || defined(__SAM3X8H__) 94 #elif defined( __AVR_ATtinyX4__ ) 100 #define IR_USE_TIMER2 105 #define SYSCLOCK F_CPU 107 #define SYSCLOCK 16000000
116 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 119 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 125 #define NEC_HDR_MARK 9000
126 #define NEC_HDR_SPACE 4500
127 #define NEC_BIT_MARK 560
128 #define NEC_ONE_SPACE 1600
129 #define NEC_ZERO_SPACE 560
130 #define NEC_RPT_SPACE 2250
132 #define SONY_HDR_MARK 2400
133 #define SONY_HDR_SPACE 600
134 #define SONY_ONE_MARK 1200
135 #define SONY_ZERO_MARK 600
136 #define SONY_RPT_LENGTH 45000
137 #define SONY_DOUBLE_SPACE_USECS 500
140 #define SANYO_HDR_MARK 3500
141 #define SANYO_HDR_SPACE 950
142 #define SANYO_ONE_MARK 2400
143 #define SANYO_ZERO_MARK 700
144 #define SANYO_DOUBLE_SPACE_USECS 800
145 #define SANYO_RPT_LENGTH 45000
151 #define MITSUBISHI_HDR_SPACE 350
152 #define MITSUBISHI_ONE_MARK 1950
153 #define MITSUBISHI_ZERO_MARK 750
159 #define RC5_RPT_LENGTH 46000
161 #define RC6_HDR_MARK 2666
162 #define RC6_HDR_SPACE 889
164 #define RC6_RPT_LENGTH 46000
166 #define SHARP_BIT_MARK 245
167 #define SHARP_ONE_SPACE 1805
168 #define SHARP_ZERO_SPACE 795
169 #define SHARP_GAP 600000
170 #define SHARP_TOGGLE_MASK 0x3FF
171 #define SHARP_RPT_SPACE 3000
173 #define DISH_HDR_MARK 400
174 #define DISH_HDR_SPACE 6100
175 #define DISH_BIT_MARK 400
176 #define DISH_ONE_SPACE 1700
177 #define DISH_ZERO_SPACE 2800
178 #define DISH_RPT_SPACE 6200
179 #define DISH_TOP_BIT 0x8000
182 #define PANASONIC_HDR_MARK 3502
183 #define PANASONIC_HDR_SPACE 1750
184 #define PANASONIC_BIT_MARK 502
185 #define PANASONIC_ONE_SPACE 1244
186 #define PANASONIC_ZERO_SPACE 400
188 #define JVC_HDR_MARK 8000
189 #define JVC_HDR_SPACE 4000
190 #define JVC_BIT_MARK 600
191 #define JVC_ONE_SPACE 1600
192 #define JVC_ZERO_SPACE 550
193 #define JVC_RPT_LENGTH 60000
196 #define SAMSUNG_HDR_MARK 4500
197 #define SAMSUNG_BITS 32
198 #define SAMSUNG_HDR_SPACE 4500
199 #define SAMSUNG_BIT_MARK 560
200 #define SAMSUNG_ONE_SPACE 1600
201 #define SAMSUNG_ZERO_SPACE 600
204 #define DAIKIN_MARK 450
205 #define DAIKIN_ONE_SPACE 1270
208 #define DAIKIN_ZERO_SPACE 425
210 #define DAIKIN_POST_SPACE 1670
212 #define DAIKIN_LONG_MARK 3490
213 #define DAIKIN_LONG_SPACE 24870
214 #define DAIKIN_VERY_LONG_SPACE 35150
244 #define SHARP_BITS 15
250 #ifdef USE_DAIKIN_FTX 270 #define STATE_SPACE 4
285 extern volatile irparams_t
irparams;
291 #define TOPBIT 0x80000000
295 #define SANYO_BITS 12
296 #define MITSUBISHI_BITS 16
297 #define MIN_RC5_SAMPLES 11
298 #define MIN_RC6_SAMPLES 1
299 #define PANASONIC_BITS 48
301 #define DAIKIN_BITS 290
308 #define TIMER_ENABLE_PWM (TCCR2A |= _BV(COM2B1)) 309 #define TIMER_DISABLE_PWM (TCCR2A &= ~(_BV(COM2B1))) 310 #define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A)) 311 #define TIMER_DISABLE_INTR (TIMSK2 = 0
) 312 #define TIMER_INTR_NAME TIMER2_COMPA_vect 313 #define TIMER_CONFIG_KHZ(val) ({ 314 const uint8_t pwmval = SYSCLOCK / 2000
/ (val); 316 TCCR2B = _BV(WGM22) | _BV(CS20); 318 OCR2B = pwmval / 3
; \ 322 #define TIMER_CONFIG_NORMAL() ({ 325 OCR2A = TIMER_COUNT_TOP; 329 #define TIMER_CONFIG_NORMAL() ({ 336 #if defined(CORE_OC2B_PIN) 337 #define TIMER_PWM_PIN CORE_OC2B_PIN 338 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 339 #define TIMER_PWM_PIN 9
340 #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) 341 #define TIMER_PWM_PIN 14
343 #define TIMER_PWM_PIN 3
348 #elif defined(IR_USE_TIMER1) 350 #define TIMER_ENABLE_PWM (TCCR1A |= _BV(COM1A1)) 351 #define TIMER_DISABLE_PWM (TCCR1A &= ~(_BV(COM1A1))) 352 #if defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__) 353 #define TIMER_ENABLE_INTR (TIMSK = _BV(OCIE1A)) 354 #define TIMER_DISABLE_INTR (TIMSK = 0
) 356 #define TIMER_ENABLE_INTR (TIMSK1 = _BV(OCIE1A)) 357 #define TIMER_DISABLE_INTR (TIMSK1 = 0
) 360 #if defined(__AVR_ATtinyX4__) 361 #define TIMER_INTR_NAME TIM1_COMPA_vect 363 #define TIMER_INTR_NAME TIMER1_COMPA_vect 366 #define TIMER_CONFIG_KHZ(val) ({ 367 const uint16_t pwmval = SYSCLOCK / 2000
/ (val); 369 TCCR1B = _BV(WGM13) | _BV(CS10); 371 OCR1A = pwmval / 3
; \ 373 #define TIMER_CONFIG_NORMAL() ({ 375 TCCR1B = _BV(WGM12) | _BV(CS10); 376 OCR1A = SYSCLOCK * USECPERTICK / 1000000
; 379 #if defined(CORE_OC1A_PIN) 380 #define TIMER_PWM_PIN CORE_OC1A_PIN 381 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 382 #define TIMER_PWM_PIN 11
383 #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) 384 #define TIMER_PWM_PIN 13
385 #elif defined(__AVR_ATtinyX4__) 386 #define TIMER_PWM_PIN 6
388 #define TIMER_PWM_PIN 9
393 #elif defined(IR_USE_TIMER3) 395 #define TIMER_ENABLE_PWM (TCCR3A |= _BV(COM3A1)) 396 #define TIMER_DISABLE_PWM (TCCR3A &= ~(_BV(COM3A1))) 397 #define TIMER_ENABLE_INTR (TIMSK3 = _BV(OCIE3A)) 398 #define TIMER_DISABLE_INTR (TIMSK3 = 0
) 399 #define TIMER_INTR_NAME TIMER3_COMPA_vect 400 #define TIMER_CONFIG_KHZ(val) ({ 401 const uint16_t pwmval = SYSCLOCK / 2000
/ (val); 403 TCCR3B = _BV(WGM33) | _BV(CS30); 405 OCR3A = pwmval / 3
; \ 407 #define TIMER_CONFIG_NORMAL() ({ 409 TCCR3B = _BV(WGM32) | _BV(CS30); 410 OCR3A = SYSCLOCK * USECPERTICK / 1000000
; 413 #if defined(CORE_OC3A_PIN) 414 #define TIMER_PWM_PIN CORE_OC3A_PIN 415 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 416 #define TIMER_PWM_PIN 5
418 #error "Please add OC3A pin number here\n" 423 #elif defined(IR_USE_TIMER4_HS) 425 #define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1)) 426 #define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1))) 427 #define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4)) 428 #define TIMER_DISABLE_INTR (TIMSK4 = 0
) 429 #define TIMER_INTR_NAME TIMER4_OVF_vect 430 #define TIMER_CONFIG_KHZ(val) ({ 431 const uint16_t pwmval = SYSCLOCK / 2000
/ (val); 439 TC4H = (pwmval / 3
) >> 8
; 440 OCR4A = (pwmval / 3
) & 255
; \ 442 #define TIMER_CONFIG_NORMAL() ({ 448 TC4H = (SYSCLOCK * USECPERTICK / 1000000
) >> 8
; 449 OCR4C = (SYSCLOCK * USECPERTICK / 1000000
) & 255
; 453 #if defined(CORE_OC4A_PIN) 454 #define TIMER_PWM_PIN CORE_OC4A_PIN 455 #elif defined(__AVR_ATmega32U4__) 456 #define TIMER_PWM_PIN 13
458 #error "Please add OC4A pin number here\n" 463 #elif defined(IR_USE_TIMER4) 465 #define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1)) 466 #define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1))) 467 #define TIMER_ENABLE_INTR (TIMSK4 = _BV(OCIE4A)) 468 #define TIMER_DISABLE_INTR (TIMSK4 = 0
) 469 #define TIMER_INTR_NAME TIMER4_COMPA_vect 470 #define TIMER_CONFIG_KHZ(val) ({ 471 const uint16_t pwmval = SYSCLOCK / 2000
/ (val); 473 TCCR4B = _BV(WGM43) | _BV(CS40); 475 OCR4A = pwmval / 3
; \ 477 #define TIMER_CONFIG_NORMAL() ({ 479 TCCR4B = _BV(WGM42) | _BV(CS40); 480 OCR4A = SYSCLOCK * USECPERTICK / 1000000
; 483 #if defined(CORE_OC4A_PIN) 484 #define TIMER_PWM_PIN CORE_OC4A_PIN 485 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 486 #define TIMER_PWM_PIN 6
488 #error "Please add OC4A pin number here\n" 493 #elif defined(IR_USE_TIMER5) 495 #define TIMER_ENABLE_PWM (TCCR5A |= _BV(COM5A1)) 496 #define TIMER_DISABLE_PWM (TCCR5A &= ~(_BV(COM5A1))) 497 #define TIMER_ENABLE_INTR (TIMSK5 = _BV(OCIE5A)) 498 #define TIMER_DISABLE_INTR (TIMSK5 = 0
) 499 #define TIMER_INTR_NAME TIMER5_COMPA_vect 500 #define TIMER_CONFIG_KHZ(val) ({ 501 const uint16_t pwmval = SYSCLOCK / 2000
/ (val); 503 TCCR5B = _BV(WGM53) | _BV(CS50); 505 OCR5A = pwmval / 3
; \ 507 #define TIMER_CONFIG_NORMAL() ({ 509 TCCR5B = _BV(WGM52) | _BV(CS50); 510 OCR5A = SYSCLOCK * USECPERTICK / 1000000
; 513 #if defined(CORE_OC5A_PIN) 514 #define TIMER_PWM_PIN CORE_OC5A_PIN 515 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 516 #define TIMER_PWM_PIN 46
518 #error "Please add OC5A pin number here\n" 523 #error "Internal code configuration error, no known IR_USE_TIMER# defined\n" 528 #if defined(CORE_LED0_PIN) 529 #define BLINKLED CORE_LED0_PIN 530 #define BLINKLED_ON() (digitalWrite(CORE_LED0_PIN, HIGH)) 531 #define BLINKLED_OFF() (digitalWrite(CORE_LED0_PIN, LOW)) 532 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 534 #define BLINKLED_ON() (PORTB |= B10000000) 535 #define BLINKLED_OFF() (PORTB &= B01111111) 536 #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) 538 #define BLINKLED_ON() (PORTD |= B00000001) 539 #define BLINKLED_OFF() (PORTD &= B11111110) 542 #define BLINKLED_ON() (PORTB |= B00100000) 543 #define BLINKLED_OFF() (PORTB &= B11011111)
volatile irparams_t irparams
unsigned int rawbuf[RAWBUF]