From e664a9f3949ead6acd19b69fce14dfa71e045abc Mon Sep 17 00:00:00 2001 From: ukw Date: Tue, 12 Mar 2013 12:49:53 +0000 Subject: [PATCH] Version 2.3.8: changed timing tolerances for RECS80(EXT) in IRMP, allowed 15kHz for RECS80(EXT) in IRSND. git-svn-id: svn://mikrocontroller.net/irmp@116 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- IR-Data/saa3004-15kHz.txt | 4 + IR-Data/saa3004-20kHz.txt | 4 + IR-Data/test-suite.sh | 70 +- README.txt | 4 +- irmp.c | 24 +- irsnd.c | 2882 ++++++++++++++++++------------------- irsnd.h | 10 +- irsndconfig.h | 6 +- 8 files changed, 1507 insertions(+), 1497 deletions(-) create mode 100644 IR-Data/saa3004-15kHz.txt create mode 100644 IR-Data/saa3004-20kHz.txt diff --git a/IR-Data/saa3004-15kHz.txt b/IR-Data/saa3004-15kHz.txt new file mode 100644 index 0000000..542ccd2 --- /dev/null +++ b/IR-Data/saa3004-15kHz.txt @@ -0,0 +1,4 @@ +# [ 6 (RECS80) 0x0002 0x0008] +00011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110001111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111111111111111111111111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111111111111111111111110001111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111111111111111111111111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111111111111111111111110001111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111 +# [ 6 (RECS80) 0x0002 0x0009] +000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110001111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111111111111111111111111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111111111111111111111110001111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000111111111111111 diff --git a/IR-Data/saa3004-20kHz.txt b/IR-Data/saa3004-20kHz.txt new file mode 100644 index 0000000..acb9d04 --- /dev/null +++ b/IR-Data/saa3004-20kHz.txt @@ -0,0 +1,4 @@ +# [ 6 (RECS80) 0x0002 0x0008] +0000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011111111111111111111 +# [ 6 (RECS80) 0x0002 0x0009] +000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000011111111111111111111 diff --git a/IR-Data/test-suite.sh b/IR-Data/test-suite.sh index a1727d1..1808f09 100644 --- a/IR-Data/test-suite.sh +++ b/IR-Data/test-suite.sh @@ -23,7 +23,7 @@ make -f makefile.lnx all cd .. for j in \ - 3xNEC3xAPPLE.log.txt \ + 3xNEC3xAPPLE.log.txt \ Dbox.txt \ DK_Digital.txt \ Grundig_TP715.txt \ @@ -64,30 +64,30 @@ for j in \ rc5x.txt \ rc6-hold.txt \ rc6.txt \ - sharp_kurz_10khz.txt \ - sharp_lang_10khz.txt \ + sharp_kurz_10khz.txt \ + sharp_lang_10khz.txt \ xbox360-10kHz.txt do echo -n "testing $j ... " if tmpsrc/irmp-10kHz -v < $j | grep -q error then - tmpsrc/irmp-10kHz -v < $j | grep error - echo "test failed" - exit 1 + tmpsrc/irmp-10kHz -v < $j | grep error + echo "test failed" + exit 1 else - if tmpsrc/irmp-10kHz -v < $j | grep -q checked - then - echo "checked!" - else - echo "successful" - fi + if tmpsrc/irmp-10kHz -v < $j | grep -q checked + then + echo "checked!" + else + echo "successful" + fi fi done # t-home-mediareceiver-15kHz.txt (RUWIDO) conflicts with Denon for j in \ - a1tvbox-15kHz.txt \ + a1tvbox-15kHz.txt \ bo_beolink1000-15kHz.txt \ bose_wave_system_15khz.txt \ denon-15kHz.txt \ @@ -96,8 +96,9 @@ for j in \ irc-15kHz.txt \ kathrein-15kHz.txt \ recs80-15kHz.txt \ + saa3004-15kHz.txt \ samsung32-15kHz.txt \ - sharp_15khz.txt \ + sharp_15khz.txt \ Siemens-Gigaset-M740AV-15kHz.txt \ thomson-mb100-15kHz.txt \ tp400vt-15kHz.txt \ @@ -107,38 +108,39 @@ do echo -n "testing $j ... " if tmpsrc/irmp-15kHz -v < $j | grep -q error then - tmpsrc/irmp-15kHz -v < $j | grep error - echo "test failed" - exit 1 + tmpsrc/irmp-15kHz -v < $j | grep error + echo "test failed" + exit 1 else - if tmpsrc/irmp-15kHz -v < $j | grep -q checked - then - echo "checked!" - else - echo "successful" - fi + if tmpsrc/irmp-15kHz -v < $j | grep -q checked + then + echo "checked!" + else + echo "successful" + fi fi done for j in \ - a1tvbox-20kHz.txt \ + a1tvbox-20kHz.txt \ rc-car-20kHz.txt \ fdc-20kHz.txt \ - fdc2-20kHz.txt + fdc2-20kHz.txt \ + saa3004-20kHz.txt do echo -n "testing $j ... " if tmpsrc/irmp-20kHz -v < $j | grep -q error then - tmpsrc/irmp-20kHz -v < $j | grep error - echo "test failed" - exit 1 + tmpsrc/irmp-20kHz -v < $j | grep error + echo "test failed" + exit 1 else - if tmpsrc/irmp-20kHz -v < $j | grep -q checked - then - echo "checked!" - else - echo "successful" - fi + if tmpsrc/irmp-20kHz -v < $j | grep -q checked + then + echo "checked!" + else + echo "successful" + fi fi done diff --git a/README.txt b/README.txt index 47c61cb..4bc758f 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- -Version IRMP: 2.3.7 21.01.2013 -Version IRSND: 2.3.6 17.01.2013 +Version IRMP: 2.3.8 12.03.2013 +Version IRSND: 2.3.8 12.03.2013 Dokumentation: diff --git a/irmp.c b/irmp.c index 2a0d65b..29473eb 100644 --- a/irmp.c +++ b/irmp.c @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2013 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.138 2013/01/21 11:11:54 fm Exp $ + * $Id: irmp.c,v 1.139 2013/03/12 12:49:59 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -14,7 +14,7 @@ * ATtiny44, ATtiny84 * ATmega8, ATmega16, ATmega32 * ATmega162 - * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284 + * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284, ATmega1284P * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * * This program is free software; you can redistribute it and/or modify @@ -155,12 +155,12 @@ #define KASEIKYO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1) #define KASEIKYO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1) -#define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1) -#define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define RECS80_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RECS80_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define RECS80_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RECS80_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define RECS80_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) @@ -205,12 +205,12 @@ #define RC6_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RC6_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) // pauses: 300 - 600 -#define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1) -#define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_00 + 0.5) + 1) -#define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) -#define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) -#define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define RECS80EXT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RECS80EXT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define RECS80EXT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) diff --git a/irsnd.c b/irsnd.c index 2380710..fd01122 100644 --- a/irsnd.c +++ b/irsnd.c @@ -10,10 +10,10 @@ * ATtiny44 ATtiny84 * ATmega8, ATmega16, ATmega32 * ATmega162 - * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284 + * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284, ATmega1284P * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * - * $Id: irsnd.c,v 1.67 2013/01/17 06:46:19 fm Exp $ + * $Id: irsnd.c,v 1.68 2013/03/12 12:49:59 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -378,24 +378,24 @@ irsnd_on (void) { #ifndef DEBUG # if defined(PIC_C18) // PIC C18 - IRSND_PIN = 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off) + IRSND_PIN = 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off) # elif defined (ARM_STM32) // STM32 - TIM_SelectOCxM(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_OCMode_PWM1); // enable PWM as OC-mode - TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable); // enable OC-output (is being disabled in TIM_SelectOCxM()) - TIM_Cmd(IRSND_TIMER, ENABLE); // enable counter + TIM_SelectOCxM(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_OCMode_PWM1); // enable PWM as OC-mode + TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable); // enable OC-output (is being disabled in TIM_SelectOCxM()) + TIM_Cmd(IRSND_TIMER, ENABLE); // enable counter # else // AVR # if IRSND_OCx == IRSND_OC2 // use OC2 - TCCR2 |= (1< disbale PWM output pin (0=PWM on, 1=PWM off) + IRSND_PIN = 1; //input mode -> disbale PWM output pin (0=PWM on, 1=PWM off) # elif defined (ARM_STM32) // STM32 - TIM_Cmd(IRSND_TIMER, DISABLE); // disable counter - TIM_SelectOCxM(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_ForcedAction_InActive); // force output inactive - TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable); // enable OC-output (is being disabled in TIM_SelectOCxM()) - TIM_SetCounter(IRSND_TIMER, 0); // reset counter value + TIM_Cmd(IRSND_TIMER, DISABLE); // disable counter + TIM_SelectOCxM(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_ForcedAction_InActive); // force output inactive + TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable); // enable OC-output (is being disabled in TIM_SelectOCxM()) + TIM_SetCounter(IRSND_TIMER, 0); // reset counter value # else //AVR # if IRSND_OCx == IRSND_OC2 // use OC2 - TCCR2 &= ~(1<= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14)) - if (RCC_ClocksStructure.PCLK1_Frequency == RCC_ClocksStructure.HCLK_Frequency) - { - TimeBaseFreq = RCC_ClocksStructure.PCLK1_Frequency; - } - else - { - TimeBaseFreq = RCC_ClocksStructure.PCLK1_Frequency * 2; - } + if (RCC_ClocksStructure.PCLK1_Frequency == RCC_ClocksStructure.HCLK_Frequency) + { + TimeBaseFreq = RCC_ClocksStructure.PCLK1_Frequency; + } + else + { + TimeBaseFreq = RCC_ClocksStructure.PCLK1_Frequency * 2; + } # else - if (RCC_ClocksStructure.PCLK2_Frequency == RCC_ClocksStructure.HCLK_Frequency) - { - TimeBaseFreq = RCC_ClocksStructure.PCLK2_Frequency; - } - else - { - TimeBaseFreq = RCC_ClocksStructure.PCLK2_Frequency * 2; - } + if (RCC_ClocksStructure.PCLK2_Frequency == RCC_ClocksStructure.HCLK_Frequency) + { + TimeBaseFreq = RCC_ClocksStructure.PCLK2_Frequency; + } + else + { + TimeBaseFreq = RCC_ClocksStructure.PCLK2_Frequency * 2; + } # endif - } + } - freq = TimeBaseFreq/freq; + freq = TimeBaseFreq/freq; - /* Set frequency */ - TIM_SetAutoreload(IRSND_TIMER, freq - 1); - /* Set duty cycle */ - TIM_SetCompare1(IRSND_TIMER, (freq + 1) / 2); + /* Set frequency */ + TIM_SetAutoreload(IRSND_TIMER, freq - 1); + /* Set duty cycle */ + TIM_SetCompare1(IRSND_TIMER, (freq + 1) / 2); # else // AVR # if IRSND_OCx == IRSND_OC2 - OCR2 = freq; // use register OCR2 for OC2 + OCR2 = freq; // use register OCR2 for OC2 # elif IRSND_OCx == IRSND_OC2A // use OC2A - OCR2A = freq; // use register OCR2A for OC2A and OC2B! + OCR2A = freq; // use register OCR2A for OC2A and OC2B! # elif IRSND_OCx == IRSND_OC2B // use OC2B - OCR2A = freq; // use register OCR2A for OC2A and OC2B! + OCR2A = freq; // use register OCR2A for OC2A and OC2B! # elif IRSND_OCx == IRSND_OC0 // use OC0 - OCR0 = freq; // use register OCR2 for OC2 + OCR0 = freq; // use register OCR2 for OC2 # elif IRSND_OCx == IRSND_OC0A // use OC0A - OCR0A = freq; // use register OCR0A for OC0A and OC0B! + OCR0A = freq; // use register OCR0A for OC0A and OC0B! # elif IRSND_OCx == IRSND_OC0B // use OC0B - OCR0A = freq; // use register OCR0A for OC0A and OC0B! + OCR0A = freq; // use register OCR0A for OC0A and OC0B! # else # error wrong value of IRSND_OCx # endif @@ -542,101 +542,101 @@ irsnd_init (void) { #ifndef DEBUG # if defined(PIC_C18) // PIC C18 - OpenTimer; - irsnd_set_freq (IRSND_FREQ_36_KHZ); //default frequency - IRSND_PIN = 1; //default PWM output pin off (0=PWM on, 1=PWM off) + OpenTimer; + irsnd_set_freq (IRSND_FREQ_36_KHZ); //default frequency + IRSND_PIN = 1; //default PWM output pin off (0=PWM on, 1=PWM off) # elif defined (ARM_STM32) // STM32 - GPIO_InitTypeDef GPIO_InitStructure; - TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - TIM_OCInitTypeDef TIM_OCInitStructure; + GPIO_InitTypeDef GPIO_InitStructure; + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + TIM_OCInitTypeDef TIM_OCInitStructure; /* GPIOx clock enable */ # if defined (ARM_STM32L1XX) - RCC_AHBPeriphClockCmd(IRSND_PORT_RCC, ENABLE); + RCC_AHBPeriphClockCmd(IRSND_PORT_RCC, ENABLE); # elif defined (ARM_STM32F10X) - RCC_APB2PeriphClockCmd(IRSND_PORT_RCC, ENABLE); + RCC_APB2PeriphClockCmd(IRSND_PORT_RCC, ENABLE); # elif defined (ARM_STM32F4XX) - RCC_AHB1PeriphClockCmd(IRSND_PORT_RCC, ENABLE); + RCC_AHB1PeriphClockCmd(IRSND_PORT_RCC, ENABLE); # endif - /* GPIO Configuration */ - GPIO_InitStructure.GPIO_Pin = IRSND_BIT; + /* GPIO Configuration */ + GPIO_InitStructure.GPIO_Pin = IRSND_BIT; # if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX) - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(IRSND_PORT, &GPIO_InitStructure); - GPIO_PinAFConfig(IRSND_PORT, (uint8_t)IRSND_BIT_NUMBER, IRSND_GPIO_AF); + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(IRSND_PORT, &GPIO_InitStructure); + GPIO_PinAFConfig(IRSND_PORT, (uint8_t)IRSND_BIT_NUMBER, IRSND_GPIO_AF); # elif defined (ARM_STM32F10X) - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_Init(IRSND_PORT, &GPIO_InitStructure); - GPIO_PinRemapConfig(, ENABLE); // TODO: remapping required + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_Init(IRSND_PORT, &GPIO_InitStructure); + GPIO_PinRemapConfig(, ENABLE); // TODO: remapping required # endif - /* TIMx clock enable */ + /* TIMx clock enable */ # if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14)) - RCC_APB1PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); + RCC_APB1PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); # else - RCC_APB2PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); + RCC_APB2PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); # endif - /* Time base configuration */ - TIM_TimeBaseStructure.TIM_Period = -1; // set dummy value (don't set to 0), will be initialized later - TIM_TimeBaseStructure.TIM_Prescaler = 0; - TIM_TimeBaseStructure.TIM_ClockDivision = 0; - TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - TIM_TimeBaseInit(IRSND_TIMER, &TIM_TimeBaseStructure); - - /* PWM1 Mode configuration */ - TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; - TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; - TIM_OCInitStructure.TIM_Pulse = 0; // will be initialized later - TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; - TIM_OC1Init(IRSND_TIMER, &TIM_OCInitStructure); - - /* Preload configuration */ - TIM_ARRPreloadConfig(IRSND_TIMER, ENABLE); - TIM_OC1PreloadConfig(IRSND_TIMER, TIM_OCPreload_Enable); - - irsnd_set_freq (IRSND_FREQ_36_KHZ); // set default frequency + /* Time base configuration */ + TIM_TimeBaseStructure.TIM_Period = -1; // set dummy value (don't set to 0), will be initialized later + TIM_TimeBaseStructure.TIM_Prescaler = 0; + TIM_TimeBaseStructure.TIM_ClockDivision = 0; + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseInit(IRSND_TIMER, &TIM_TimeBaseStructure); + + /* PWM1 Mode configuration */ + TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; + TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; + TIM_OCInitStructure.TIM_Pulse = 0; // will be initialized later + TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; + TIM_OC1Init(IRSND_TIMER, &TIM_OCInitStructure); + + /* Preload configuration */ + TIM_ARRPreloadConfig(IRSND_TIMER, ENABLE); + TIM_OC1PreloadConfig(IRSND_TIMER, TIM_OCPreload_Enable); + + irsnd_set_freq (IRSND_FREQ_36_KHZ); // set default frequency # else // AVR - IRSND_PORT &= ~(1<>= 1; - len--; + xx <<= 1; + if (x & 1) + { + xx |= 1; + } + x >>= 1; + len--; } return xx; } @@ -701,14 +701,14 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) if (do_wait) { - while (irsnd_busy) - { - // do nothing; - } + while (irsnd_busy) + { + // do nothing; + } } else if (irsnd_busy) { - return (FALSE); + return (FALSE); } irsnd_protocol = irmp_data_p->protocol; @@ -717,399 +717,399 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) switch (irsnd_protocol) { #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 - case IRMP_SIRCS_PROTOCOL: - { - // uint8_t sircs_additional_command_len; - uint8_t sircs_additional_address_len; - - sircs_additional_bitlen = (irmp_data_p->address & 0xFF00) >> 8; // additional bitlen - - if (sircs_additional_bitlen > 15 - SIRCS_MINIMUM_DATA_LEN) - { - // sircs_additional_command_len = 15 - SIRCS_MINIMUM_DATA_LEN; - sircs_additional_address_len = sircs_additional_bitlen - (15 - SIRCS_MINIMUM_DATA_LEN); - } - else - { - // sircs_additional_command_len = sircs_additional_bitlen; - sircs_additional_address_len = 0; - } - - command = bitsrevervse (irmp_data_p->command, 15); - - irsnd_buffer[0] = (command & 0x7F80) >> 7; // CCCCCCCC - irsnd_buffer[1] = (command & 0x007F) << 1; // CCCC**** - - if (sircs_additional_address_len > 0) - { - address = bitsrevervse (irmp_data_p->address, 5); - irsnd_buffer[1] |= (address & 0x0010) >> 4; - irsnd_buffer[2] = (address & 0x000F) << 4; - } - irsnd_busy = TRUE; - break; - } + case IRMP_SIRCS_PROTOCOL: + { + // uint8_t sircs_additional_command_len; + uint8_t sircs_additional_address_len; + + sircs_additional_bitlen = (irmp_data_p->address & 0xFF00) >> 8; // additional bitlen + + if (sircs_additional_bitlen > 15 - SIRCS_MINIMUM_DATA_LEN) + { + // sircs_additional_command_len = 15 - SIRCS_MINIMUM_DATA_LEN; + sircs_additional_address_len = sircs_additional_bitlen - (15 - SIRCS_MINIMUM_DATA_LEN); + } + else + { + // sircs_additional_command_len = sircs_additional_bitlen; + sircs_additional_address_len = 0; + } + + command = bitsrevervse (irmp_data_p->command, 15); + + irsnd_buffer[0] = (command & 0x7F80) >> 7; // CCCCCCCC + irsnd_buffer[1] = (command & 0x007F) << 1; // CCCC**** + + if (sircs_additional_address_len > 0) + { + address = bitsrevervse (irmp_data_p->address, 5); + irsnd_buffer[1] |= (address & 0x0010) >> 4; + irsnd_buffer[2] = (address & 0x000F) << 4; + } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NEC_PROTOCOL == 1 - case IRMP_APPLE_PROTOCOL: - { - command = irmp_data_p->command | (irmp_data_p->address << 8); // store address as ID in upper byte of command - address = 0x87EE; // set fixed NEC-lookalike address (customer ID of apple) - - address = bitsrevervse (address, NEC_ADDRESS_LEN); - command = bitsrevervse (command, NEC_COMMAND_LEN); - - irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with id instead of inverted command - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC - irsnd_buffer[3] = 0x8B; // 10001011 (id) - irsnd_busy = TRUE; - break; - } - case IRMP_NEC_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC - irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc - irsnd_busy = TRUE; - break; - } + case IRMP_APPLE_PROTOCOL: + { + command = irmp_data_p->command | (irmp_data_p->address << 8); // store address as ID in upper byte of command + address = 0x87EE; // set fixed NEC-lookalike address (customer ID of apple) + + address = bitsrevervse (address, NEC_ADDRESS_LEN); + command = bitsrevervse (command, NEC_COMMAND_LEN); + + irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with id instead of inverted command + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = 0x8B; // 10001011 (id) + irsnd_busy = TRUE; + break; + } + case IRMP_NEC_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NEC16_PROTOCOL == 1 - case IRMP_NEC16_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, NEC16_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, NEC16_COMMAND_LEN); + case IRMP_NEC16_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NEC16_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NEC16_COMMAND_LEN); - irsnd_buffer[0] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC - irsnd_busy = TRUE; - break; - } + irsnd_buffer[0] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NEC42_PROTOCOL == 1 - case IRMP_NEC42_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, NEC42_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, NEC42_COMMAND_LEN); - - irsnd_buffer[0] = ( (address & 0x1FE0) >> 5); // AAAAAAAA - irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // AAAAAaaa - irsnd_buffer[2] = ((~address & 0x03FC) >> 2); // aaaaaaaa - irsnd_buffer[3] = ((~address & 0x0003) << 6) | ( (command & 0x00FC) >> 2); // aaCCCCCC - irsnd_buffer[4] = ( (command & 0x0003) << 6) | ((~command & 0x00FC) >> 2); // CCcccccc - irsnd_buffer[5] = ((~command & 0x0003) << 6); // cc - irsnd_busy = TRUE; - break; - } + case IRMP_NEC42_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NEC42_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NEC42_COMMAND_LEN); + + irsnd_buffer[0] = ( (address & 0x1FE0) >> 5); // AAAAAAAA + irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // AAAAAaaa + irsnd_buffer[2] = ((~address & 0x03FC) >> 2); // aaaaaaaa + irsnd_buffer[3] = ((~address & 0x0003) << 6) | ( (command & 0x00FC) >> 2); // aaCCCCCC + irsnd_buffer[4] = ( (command & 0x0003) << 6) | ((~command & 0x00FC) >> 2); // CCcccccc + irsnd_buffer[5] = ((~command & 0x0003) << 6); // cc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 - case IRMP_SAMSUNG_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, SAMSUNG_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0x00F0) | ((command & 0xF000) >> 12); // IIIICCCC - irsnd_buffer[3] = ((command & 0x0F00) >> 4) | ((~(command & 0xF000) >> 12) & 0x0F); // CCCCcccc - irsnd_buffer[4] = (~(command & 0x0F00) >> 4) & 0xF0; // cccc0000 - irsnd_busy = TRUE; - break; - } - case IRMP_SAMSUNG32_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, SAMSUNG32_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC - irsnd_buffer[3] = (command & 0x00FF); // CCCCCCCC - irsnd_busy = TRUE; - break; - } + case IRMP_SAMSUNG_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, SAMSUNG_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0x00F0) | ((command & 0xF000) >> 12); // IIIICCCC + irsnd_buffer[3] = ((command & 0x0F00) >> 4) | ((~(command & 0xF000) >> 12) & 0x0F); // CCCCcccc + irsnd_buffer[4] = (~(command & 0x0F00) >> 4) & 0xF0; // cccc0000 + irsnd_busy = TRUE; + break; + } + case IRMP_SAMSUNG32_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, SAMSUNG32_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = (command & 0x00FF); // CCCCCCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 - case IRMP_MATSUSHITA_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, MATSUSHITA_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, MATSUSHITA_COMMAND_LEN); - - irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC - irsnd_buffer[1] = ((command & 0x000F) << 4) | ((address & 0x0F00) >> 8); // CCCCAAAA - irsnd_buffer[2] = (address & 0x00FF); // AAAAAAAA - irsnd_busy = TRUE; - break; - } + case IRMP_MATSUSHITA_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, MATSUSHITA_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, MATSUSHITA_COMMAND_LEN); + + irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC + irsnd_buffer[1] = ((command & 0x000F) << 4) | ((address & 0x0F00) >> 8); // CCCCAAAA + irsnd_buffer[2] = (address & 0x00FF); // AAAAAAAA + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 - case IRMP_KASEIKYO_PROTOCOL: - { - uint8_t xor_value; - uint16_t genre2; + case IRMP_KASEIKYO_PROTOCOL: + { + uint8_t xor_value; + uint16_t genre2; - address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4); - genre2 = bitsrevervse ((irmp_data_p->flags & ~IRSND_REPETITION_MASK) >> 4, 4); + address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4); + genre2 = bitsrevervse ((irmp_data_p->flags & ~IRSND_REPETITION_MASK) >> 4, 4); - xor_value = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F; + xor_value = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F; - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = xor_value << 4 | (command & 0x000F); // XXXXCCCC - irsnd_buffer[3] = (genre2 << 4) | (command & 0xF000) >> 12; // ggggCCCC - irsnd_buffer[4] = (command & 0x0FF0) >> 4; // CCCCCCCC + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = xor_value << 4 | (command & 0x000F); // XXXXCCCC + irsnd_buffer[3] = (genre2 << 4) | (command & 0xF000) >> 12; // ggggCCCC + irsnd_buffer[4] = (command & 0x0FF0) >> 4; // CCCCCCCC - xor_value = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; + xor_value = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; - irsnd_buffer[5] = xor_value; - irsnd_busy = TRUE; - break; - } + irsnd_buffer[5] = xor_value; + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 - case IRMP_RECS80_PROTOCOL: - { - toggle_bit_recs80 = toggle_bit_recs80 ? 0x00 : 0x40; + case IRMP_RECS80_PROTOCOL: + { + toggle_bit_recs80 = toggle_bit_recs80 ? 0x00 : 0x40; - irsnd_buffer[0] = 0x80 | toggle_bit_recs80 | ((irmp_data_p->address & 0x0007) << 3) | - ((irmp_data_p->command & 0x0038) >> 3); // STAAACCC - irsnd_buffer[1] = (irmp_data_p->command & 0x07) << 5; // CCC00000 - irsnd_busy = TRUE; - break; - } + irsnd_buffer[0] = 0x80 | toggle_bit_recs80 | ((irmp_data_p->address & 0x0007) << 3) | + ((irmp_data_p->command & 0x0038) >> 3); // STAAACCC + irsnd_buffer[1] = (irmp_data_p->command & 0x07) << 5; // CCC00000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 - case IRMP_RECS80EXT_PROTOCOL: - { - toggle_bit_recs80ext = toggle_bit_recs80ext ? 0x00 : 0x40; + case IRMP_RECS80EXT_PROTOCOL: + { + toggle_bit_recs80ext = toggle_bit_recs80ext ? 0x00 : 0x40; - irsnd_buffer[0] = 0x80 | toggle_bit_recs80ext | ((irmp_data_p->address & 0x000F) << 2) | - ((irmp_data_p->command & 0x0030) >> 4); // STAAAACC - irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC0000 - irsnd_busy = TRUE; - break; - } + irsnd_buffer[0] = 0x80 | toggle_bit_recs80ext | ((irmp_data_p->address & 0x000F) << 2) | + ((irmp_data_p->command & 0x0030) >> 4); // STAAAACC + irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC0000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 - case IRMP_RC5_PROTOCOL: - { - toggle_bit_rc5 = toggle_bit_rc5 ? 0x00 : 0x40; + case IRMP_RC5_PROTOCOL: + { + toggle_bit_rc5 = toggle_bit_rc5 ? 0x00 : 0x40; - irsnd_buffer[0] = ((irmp_data_p->command & 0x40) ? 0x00 : 0x80) | toggle_bit_rc5 | - ((irmp_data_p->address & 0x001F) << 1) | ((irmp_data_p->command & 0x20) >> 5); // CTAAAAAC - irsnd_buffer[1] = (irmp_data_p->command & 0x1F) << 3; // CCCCC000 - irsnd_busy = TRUE; - break; - } + irsnd_buffer[0] = ((irmp_data_p->command & 0x40) ? 0x00 : 0x80) | toggle_bit_rc5 | + ((irmp_data_p->address & 0x001F) << 1) | ((irmp_data_p->command & 0x20) >> 5); // CTAAAAAC + irsnd_buffer[1] = (irmp_data_p->command & 0x1F) << 3; // CCCCC000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RC6_PROTOCOL == 1 - case IRMP_RC6_PROTOCOL: - { - toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08; + case IRMP_RC6_PROTOCOL: + { + toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08; - irsnd_buffer[0] = 0x80 | toggle_bit_rc6 | ((irmp_data_p->address & 0x00E0) >> 5); // 1MMMTAAA, MMM = 000 - irsnd_buffer[1] = ((irmp_data_p->address & 0x001F) << 3) | ((irmp_data_p->command & 0xE0) >> 5); // AAAAACCC - irsnd_buffer[2] = (irmp_data_p->command & 0x1F) << 3; // CCCCC - irsnd_busy = TRUE; - break; - } + irsnd_buffer[0] = 0x80 | toggle_bit_rc6 | ((irmp_data_p->address & 0x00E0) >> 5); // 1MMMTAAA, MMM = 000 + irsnd_buffer[1] = ((irmp_data_p->address & 0x001F) << 3) | ((irmp_data_p->command & 0xE0) >> 5); // AAAAACCC + irsnd_buffer[2] = (irmp_data_p->command & 0x1F) << 3; // CCCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RC6A_PROTOCOL == 1 - case IRMP_RC6A_PROTOCOL: - { - toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08; - - irsnd_buffer[0] = 0x80 | 0x60 | ((irmp_data_p->address & 0x3000) >> 12); // 1MMMT0AA, MMM = 110 - irsnd_buffer[1] = ((irmp_data_p->address & 0x0FFF) >> 4) ; // AAAAAAAA - irsnd_buffer[2] = ((irmp_data_p->address & 0x000F) << 4) | ((irmp_data_p->command & 0xF000) >> 12) | toggle_bit_rc6; // AAAACCCC - irsnd_buffer[3] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC - irsnd_buffer[4] = (irmp_data_p->command & 0x000F) << 4; // CCCC - irsnd_busy = TRUE; - break; - } + case IRMP_RC6A_PROTOCOL: + { + toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08; + + irsnd_buffer[0] = 0x80 | 0x60 | ((irmp_data_p->address & 0x3000) >> 12); // 1MMMT0AA, MMM = 110 + irsnd_buffer[1] = ((irmp_data_p->address & 0x0FFF) >> 4) ; // AAAAAAAA + irsnd_buffer[2] = ((irmp_data_p->address & 0x000F) << 4) | ((irmp_data_p->command & 0xF000) >> 12) | toggle_bit_rc6; // AAAACCCC + irsnd_buffer[3] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC + irsnd_buffer[4] = (irmp_data_p->command & 0x000F) << 4; // CCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - case IRMP_DENON_PROTOCOL: - { - irsnd_buffer[0] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x0380) >> 7); // AAAAACCC (1st frame) - irsnd_buffer[1] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC - irsnd_buffer[2] = ((irmp_data_p->address & 0x1F) << 3) | (((~irmp_data_p->command) & 0x0380) >> 7); // AAAAAccc (2nd frame) - irsnd_buffer[3] = (~(irmp_data_p->command) & 0x7F) << 1; // ccccccc - irsnd_busy = TRUE; - break; - } + case IRMP_DENON_PROTOCOL: + { + irsnd_buffer[0] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x0380) >> 7); // AAAAACCC (1st frame) + irsnd_buffer[1] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC + irsnd_buffer[2] = ((irmp_data_p->address & 0x1F) << 3) | (((~irmp_data_p->command) & 0x0380) >> 7); // AAAAAccc (2nd frame) + irsnd_buffer[3] = (~(irmp_data_p->command) & 0x7F) << 1; // ccccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 - case IRMP_THOMSON_PROTOCOL: - { - toggle_bit_thomson = toggle_bit_thomson ? 0x00 : 0x08; + case IRMP_THOMSON_PROTOCOL: + { + toggle_bit_thomson = toggle_bit_thomson ? 0x00 : 0x08; - irsnd_buffer[0] = ((irmp_data_p->address & 0x0F) << 4) | toggle_bit_thomson | ((irmp_data_p->command & 0x0070) >> 4); // AAAATCCC (1st frame) - irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC - irsnd_busy = TRUE; - break; - } + irsnd_buffer[0] = ((irmp_data_p->address & 0x0F) << 4) | toggle_bit_thomson | ((irmp_data_p->command & 0x0070) >> 4); // AAAATCCC (1st frame) + irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 - case IRMP_NUBERT_PROTOCOL: - { - irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC - irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000 - irsnd_busy = TRUE; - break; - } + case IRMP_NUBERT_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC + irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - case IRMP_BANG_OLUFSEN_PROTOCOL: - { - irsnd_buffer[0] = irmp_data_p->command >> 11; // SXSCCCCC - irsnd_buffer[1] = irmp_data_p->command >> 3; // CCCCCCCC - irsnd_buffer[2] = (irmp_data_p->command & 0x0007) << 5; // CCC00000 - irsnd_busy = TRUE; - break; - } + case IRMP_BANG_OLUFSEN_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 11; // SXSCCCCC + irsnd_buffer[1] = irmp_data_p->command >> 3; // CCCCCCCC + irsnd_buffer[2] = (irmp_data_p->command & 0x0007) << 5; // CCC00000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 - case IRMP_GRUNDIG_PROTOCOL: - { - command = bitsrevervse (irmp_data_p->command, GRUNDIG_COMMAND_LEN); + case IRMP_GRUNDIG_PROTOCOL: + { + command = bitsrevervse (irmp_data_p->command, GRUNDIG_COMMAND_LEN); - irsnd_buffer[0] = 0xFF; // S1111111 (1st frame) - irsnd_buffer[1] = 0xC0; // 11 - irsnd_buffer[2] = 0x80 | (command >> 2); // SCCCCCCC (2nd frame) - irsnd_buffer[3] = (command << 6) & 0xC0; // CC + irsnd_buffer[0] = 0xFF; // S1111111 (1st frame) + irsnd_buffer[1] = 0xC0; // 11 + irsnd_buffer[2] = 0x80 | (command >> 2); // SCCCCCCC (2nd frame) + irsnd_buffer[3] = (command << 6) & 0xC0; // CC - irsnd_busy = TRUE; - break; - } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_IR60_PROTOCOL == 1 - case IRMP_IR60_PROTOCOL: - { - command = (bitsrevervse (0x7d, IR60_COMMAND_LEN) << 7) | bitsrevervse (irmp_data_p->command, IR60_COMMAND_LEN); + case IRMP_IR60_PROTOCOL: + { + command = (bitsrevervse (0x7d, IR60_COMMAND_LEN) << 7) | bitsrevervse (irmp_data_p->command, IR60_COMMAND_LEN); #if 0 - irsnd_buffer[0] = command >> 6 | 0x01; // 1011111S (start instruction frame) - irsnd_buffer[1] = (command & 0x7F) << 1; // CCCCCCC_ (2nd frame) + irsnd_buffer[0] = command >> 6 | 0x01; // 1011111S (start instruction frame) + irsnd_buffer[1] = (command & 0x7F) << 1; // CCCCCCC_ (2nd frame) #else - irsnd_buffer[0] = ((command & 0x7F) << 1) | 0x01; // CCCCCCCS (1st frame) - irsnd_buffer[1] = command >> 6; // 1011111_ (start instruction frame) + irsnd_buffer[0] = ((command & 0x7F) << 1) | 0x01; // CCCCCCCS (1st frame) + irsnd_buffer[1] = command >> 6; // 1011111_ (start instruction frame) #endif - irsnd_busy = TRUE; - break; - } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - case IRMP_NOKIA_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, NOKIA_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, NOKIA_COMMAND_LEN); - - irsnd_buffer[0] = 0xBF; // S0111111 (1st + 3rd frame) - irsnd_buffer[1] = 0xFF; // 11111111 - irsnd_buffer[2] = 0x80; // 1 - irsnd_buffer[3] = 0x80 | command >> 1; // SCCCCCCC (2nd frame) - irsnd_buffer[4] = (command << 7) | (address >> 1); // CAAAAAAA - irsnd_buffer[5] = (address << 7); // A - - irsnd_busy = TRUE; - break; - } + case IRMP_NOKIA_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NOKIA_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NOKIA_COMMAND_LEN); + + irsnd_buffer[0] = 0xBF; // S0111111 (1st + 3rd frame) + irsnd_buffer[1] = 0xFF; // 11111111 + irsnd_buffer[2] = 0x80; // 1 + irsnd_buffer[3] = 0x80 | command >> 1; // SCCCCCCC (2nd frame) + irsnd_buffer[4] = (command << 7) | (address >> 1); // CAAAAAAA + irsnd_buffer[5] = (address << 7); // A + + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 - case IRMP_SIEMENS_PROTOCOL: - { - irsnd_buffer[0] = ((irmp_data_p->address & 0x0FFF) >> 5); // SAAAAAAA - irsnd_buffer[1] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x7F) >> 5); // AAAAA0CC - irsnd_buffer[2] = (irmp_data_p->command << 3) | ((~irmp_data_p->command & 0x01) << 2); // CCCCCc + case IRMP_SIEMENS_PROTOCOL: + { + irsnd_buffer[0] = ((irmp_data_p->address & 0x0FFF) >> 5); // SAAAAAAA + irsnd_buffer[1] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x7F) >> 5); // AAAAA0CC + irsnd_buffer[2] = (irmp_data_p->command << 3) | ((~irmp_data_p->command & 0x01) << 2); // CCCCCc - irsnd_busy = TRUE; - break; - } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_FDC_PROTOCOL == 1 - case IRMP_FDC_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0xFF); // AAAAAAAA - irsnd_buffer[1] = 0; // 00000000 - irsnd_buffer[2] = 0; // 0000RRRR - irsnd_buffer[3] = (command & 0xFF); // CCCCCCCC - irsnd_buffer[4] = ~(command & 0xFF); // cccccccc - irsnd_busy = TRUE; - break; - } + case IRMP_FDC_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0xFF); // AAAAAAAA + irsnd_buffer[1] = 0; // 00000000 + irsnd_buffer[2] = 0; // 0000RRRR + irsnd_buffer[3] = (command & 0xFF); // CCCCCCCC + irsnd_buffer[4] = ~(command & 0xFF); // cccccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 - case IRMP_RCCAR_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, 2); // A0 A1 - command = bitsrevervse (irmp_data_p->command, RCCAR_COMMAND_LEN - 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V - - irsnd_buffer[0] = ((command & 0x06) << 5) | ((address & 0x0003) << 4) | ((command & 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3 - irsnd_buffer[1] = ((command & 0x78) << 1) | ((command & 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0 - - irsnd_busy = TRUE; - break; - } + case IRMP_RCCAR_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, 2); // A0 A1 + command = bitsrevervse (irmp_data_p->command, RCCAR_COMMAND_LEN - 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V + + irsnd_buffer[0] = ((command & 0x06) << 5) | ((address & 0x0003) << 4) | ((command & 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3 + irsnd_buffer[1] = ((command & 0x78) << 1) | ((command & 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0 + + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_JVC_PROTOCOL == 1 - case IRMP_JVC_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, JVC_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, JVC_COMMAND_LEN); + case IRMP_JVC_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, JVC_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, JVC_COMMAND_LEN); - irsnd_buffer[0] = ((address & 0x000F) << 4) | (command & 0x0F00) >> 8; // AAAACCCC - irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC + irsnd_buffer[0] = ((address & 0x000F) << 4) | (command & 0x0F00) >> 8; // AAAACCCC + irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC - irsnd_busy = TRUE; - break; - } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NIKON_PROTOCOL == 1 - case IRMP_NIKON_PROTOCOL: - { - irsnd_buffer[0] = (irmp_data_p->command & 0x0003) << 6; // CC - irsnd_busy = TRUE; - break; - } + case IRMP_NIKON_PROTOCOL: + { + irsnd_buffer[0] = (irmp_data_p->command & 0x0003) << 6; // CC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 - case IRMP_LEGO_PROTOCOL: - { - uint8_t crc = 0x0F ^ ((irmp_data_p->command & 0x0F00) >> 8) ^ ((irmp_data_p->command & 0x00F0) >> 4) ^ (irmp_data_p->command & 0x000F); + case IRMP_LEGO_PROTOCOL: + { + uint8_t crc = 0x0F ^ ((irmp_data_p->command & 0x0F00) >> 8) ^ ((irmp_data_p->command & 0x00F0) >> 4) ^ (irmp_data_p->command & 0x000F); - irsnd_buffer[0] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC - irsnd_buffer[1] = ((irmp_data_p->command & 0x000F) << 4) | crc; // CCCCcccc - irsnd_busy = TRUE; - break; - } + irsnd_buffer[0] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC + irsnd_buffer[1] = ((irmp_data_p->command & 0x000F) << 4) | crc; // CCCCcccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - case IRMP_A1TVBOX_PROTOCOL: - { - irsnd_buffer[0] = 0x80 | (irmp_data_p->address >> 2); // 10AAAAAA - irsnd_buffer[1] = (irmp_data_p->address << 6) | (irmp_data_p->command >> 2); // AACCCCCC - irsnd_buffer[2] = (irmp_data_p->command << 6); // CC - - irsnd_busy = TRUE; - break; - } -#endif - default: - { - break; - } + case IRMP_A1TVBOX_PROTOCOL: + { + irsnd_buffer[0] = 0x80 | (irmp_data_p->address >> 2); // 10AAAAAA + irsnd_buffer[1] = (irmp_data_p->address << 6) | (irmp_data_p->command >> 2); // AACCCCCC + irsnd_buffer[2] = (irmp_data_p->command << 6); // CC + + irsnd_busy = TRUE; + break; + } +#endif + default: + { + break; + } } return irsnd_busy; @@ -1158,678 +1158,678 @@ irsnd_ISR (void) if (irsnd_busy) { - if (current_bit == 0xFF && new_frame) // start of transmission... - { - if (auto_repetition_counter > 0) - { - auto_repetition_pause_counter++; + if (current_bit == 0xFF && new_frame) // start of transmission... + { + if (auto_repetition_counter > 0) + { + auto_repetition_pause_counter++; #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - if (repeat_frame_pause_len > 0) // frame repeat distance counts from beginning of 1st frame! - { - repeat_frame_pause_len--; - } + if (repeat_frame_pause_len > 0) // frame repeat distance counts from beginning of 1st frame! + { + repeat_frame_pause_len--; + } #endif - if (auto_repetition_pause_counter >= auto_repetition_pause_len) - { - auto_repetition_pause_counter = 0; + if (auto_repetition_pause_counter >= auto_repetition_pause_len) + { + auto_repetition_pause_counter = 0; #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - if (irsnd_protocol == IRMP_DENON_PROTOCOL) // n'th denon frame - { - current_bit = 16; - complete_data_len = 2 * DENON_COMPLETE_DATA_LEN + 1; - } - else + if (irsnd_protocol == IRMP_DENON_PROTOCOL) // n'th denon frame + { + current_bit = 16; + complete_data_len = 2 * DENON_COMPLETE_DATA_LEN + 1; + } + else #endif #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig frame - { - current_bit = 15; - complete_data_len = 16 + GRUNDIG_COMPLETE_DATA_LEN; - } - else + if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig frame + { + current_bit = 15; + complete_data_len = 16 + GRUNDIG_COMPLETE_DATA_LEN; + } + else #endif #if IRSND_SUPPORT_IR60_PROTOCOL == 1 - if (irsnd_protocol == IRMP_IR60_PROTOCOL) // n'th IR60 frame - { - current_bit = 7; - complete_data_len = 2 * IR60_COMPLETE_DATA_LEN + 1; - } - else + if (irsnd_protocol == IRMP_IR60_PROTOCOL) // n'th IR60 frame + { + current_bit = 7; + complete_data_len = 2 * IR60_COMPLETE_DATA_LEN + 1; + } + else #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia frame - { - if (auto_repetition_counter + 1 < n_auto_repetitions) - { - current_bit = 23; - complete_data_len = 24 + NOKIA_COMPLETE_DATA_LEN; - } - else // nokia stop frame - { - current_bit = 0xFF; - complete_data_len = NOKIA_COMPLETE_DATA_LEN; - } - } - else -#endif - { - ; - } - } - else - { + if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia frame + { + if (auto_repetition_counter + 1 < n_auto_repetitions) + { + current_bit = 23; + complete_data_len = 24 + NOKIA_COMPLETE_DATA_LEN; + } + else // nokia stop frame + { + current_bit = 0xFF; + complete_data_len = NOKIA_COMPLETE_DATA_LEN; + } + } + else +#endif + { + ; + } + } + else + { #ifdef DEBUG - if (irsnd_is_on) - { - putchar ('0'); - } - else - { - putchar ('1'); - } -#endif - return irsnd_busy; - } - } + if (irsnd_is_on) + { + putchar ('0'); + } + else + { + putchar ('1'); + } +#endif + return irsnd_busy; + } + } #if 0 - else if (repeat_counter > 0 && packet_repeat_pause_counter < repeat_frame_pause_len) + else if (repeat_counter > 0 && packet_repeat_pause_counter < repeat_frame_pause_len) #else - else if (packet_repeat_pause_counter < repeat_frame_pause_len) + else if (packet_repeat_pause_counter < repeat_frame_pause_len) #endif - { - packet_repeat_pause_counter++; + { + packet_repeat_pause_counter++; #ifdef DEBUG - if (irsnd_is_on) - { - putchar ('0'); - } - else - { - putchar ('1'); - } -#endif - return irsnd_busy; - } - else - { - if (send_trailer) - { - irsnd_busy = FALSE; - send_trailer = FALSE; - return irsnd_busy; - } - - n_repeat_frames = irsnd_repeat; - - if (n_repeat_frames == IRSND_ENDLESS_REPETITION) - { - n_repeat_frames = 255; - } - - packet_repeat_pause_counter = 0; - pulse_counter = 0; - pause_counter = 0; - - switch (irsnd_protocol) - { + if (irsnd_is_on) + { + putchar ('0'); + } + else + { + putchar ('1'); + } +#endif + return irsnd_busy; + } + else + { + if (send_trailer) + { + irsnd_busy = FALSE; + send_trailer = FALSE; + return irsnd_busy; + } + + n_repeat_frames = irsnd_repeat; + + if (n_repeat_frames == IRSND_ENDLESS_REPETITION) + { + n_repeat_frames = 255; + } + + packet_repeat_pause_counter = 0; + pulse_counter = 0; + pause_counter = 0; + + switch (irsnd_protocol) + { #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 - case IRMP_SIRCS_PROTOCOL: - { - startbit_pulse_len = SIRCS_START_BIT_PULSE_LEN; - startbit_pause_len = SIRCS_START_BIT_PAUSE_LEN - 1; - pulse_1_len = SIRCS_1_PULSE_LEN; - pause_1_len = SIRCS_PAUSE_LEN - 1; - pulse_0_len = SIRCS_0_PULSE_LEN; - pause_0_len = SIRCS_PAUSE_LEN - 1; - has_stop_bit = SIRCS_STOP_BIT; - complete_data_len = SIRCS_MINIMUM_DATA_LEN + sircs_additional_bitlen; - n_auto_repetitions = (repeat_counter == 0) ? SIRCS_FRAMES : 1; // 3 frames auto repetition if first frame - auto_repetition_pause_len = SIRCS_AUTO_REPETITION_PAUSE_LEN; // 25ms pause - repeat_frame_pause_len = SIRCS_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_40_KHZ); - break; - } + case IRMP_SIRCS_PROTOCOL: + { + startbit_pulse_len = SIRCS_START_BIT_PULSE_LEN; + startbit_pause_len = SIRCS_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SIRCS_1_PULSE_LEN; + pause_1_len = SIRCS_PAUSE_LEN - 1; + pulse_0_len = SIRCS_0_PULSE_LEN; + pause_0_len = SIRCS_PAUSE_LEN - 1; + has_stop_bit = SIRCS_STOP_BIT; + complete_data_len = SIRCS_MINIMUM_DATA_LEN + sircs_additional_bitlen; + n_auto_repetitions = (repeat_counter == 0) ? SIRCS_FRAMES : 1; // 3 frames auto repetition if first frame + auto_repetition_pause_len = SIRCS_AUTO_REPETITION_PAUSE_LEN; // 25ms pause + repeat_frame_pause_len = SIRCS_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_40_KHZ); + break; + } #endif #if IRSND_SUPPORT_NEC_PROTOCOL == 1 - case IRMP_NEC_PROTOCOL: - { - startbit_pulse_len = NEC_START_BIT_PULSE_LEN; - - if (repeat_counter > 0) - { - startbit_pause_len = NEC_REPEAT_START_BIT_PAUSE_LEN - 1; - complete_data_len = 0; - } - else - { - startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; - complete_data_len = NEC_COMPLETE_DATA_LEN; - } - - pulse_1_len = NEC_PULSE_LEN; - pause_1_len = NEC_1_PAUSE_LEN - 1; - pulse_0_len = NEC_PULSE_LEN; - pause_0_len = NEC_0_PAUSE_LEN - 1; - has_stop_bit = NEC_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NEC_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + + if (repeat_counter > 0) + { + startbit_pause_len = NEC_REPEAT_START_BIT_PAUSE_LEN - 1; + complete_data_len = 0; + } + else + { + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + complete_data_len = NEC_COMPLETE_DATA_LEN; + } + + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_NEC16_PROTOCOL == 1 - case IRMP_NEC16_PROTOCOL: - { - startbit_pulse_len = NEC_START_BIT_PULSE_LEN; - startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; - pulse_1_len = NEC_PULSE_LEN; - pause_1_len = NEC_1_PAUSE_LEN - 1; - pulse_0_len = NEC_PULSE_LEN; - pause_0_len = NEC_0_PAUSE_LEN - 1; - has_stop_bit = NEC_STOP_BIT; - complete_data_len = NEC16_COMPLETE_DATA_LEN + 1; // 1 more: sync bit - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NEC16_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + complete_data_len = NEC16_COMPLETE_DATA_LEN + 1; // 1 more: sync bit + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_NEC42_PROTOCOL == 1 - case IRMP_NEC42_PROTOCOL: - { - startbit_pulse_len = NEC_START_BIT_PULSE_LEN; - startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; - pulse_1_len = NEC_PULSE_LEN; - pause_1_len = NEC_1_PAUSE_LEN - 1; - pulse_0_len = NEC_PULSE_LEN; - pause_0_len = NEC_0_PAUSE_LEN - 1; - has_stop_bit = NEC_STOP_BIT; - complete_data_len = NEC42_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NEC42_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + complete_data_len = NEC42_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 - case IRMP_SAMSUNG_PROTOCOL: - { - startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; - startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; - pulse_1_len = SAMSUNG_PULSE_LEN; - pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; - pulse_0_len = SAMSUNG_PULSE_LEN; - pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; - has_stop_bit = SAMSUNG_STOP_BIT; - complete_data_len = SAMSUNG_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = SAMSUNG_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } - - case IRMP_SAMSUNG32_PROTOCOL: - { - startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; - startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; - pulse_1_len = SAMSUNG_PULSE_LEN; - pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; - pulse_0_len = SAMSUNG_PULSE_LEN; - pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; - has_stop_bit = SAMSUNG_STOP_BIT; - complete_data_len = SAMSUNG32_COMPLETE_DATA_LEN; - n_auto_repetitions = SAMSUNG32_FRAMES; // 2 frames - auto_repetition_pause_len = SAMSUNG32_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause - repeat_frame_pause_len = SAMSUNG32_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_SAMSUNG_PROTOCOL: + { + startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; + startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SAMSUNG_PULSE_LEN; + pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; + pulse_0_len = SAMSUNG_PULSE_LEN; + pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; + has_stop_bit = SAMSUNG_STOP_BIT; + complete_data_len = SAMSUNG_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = SAMSUNG_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } + + case IRMP_SAMSUNG32_PROTOCOL: + { + startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; + startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SAMSUNG_PULSE_LEN; + pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; + pulse_0_len = SAMSUNG_PULSE_LEN; + pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; + has_stop_bit = SAMSUNG_STOP_BIT; + complete_data_len = SAMSUNG32_COMPLETE_DATA_LEN; + n_auto_repetitions = SAMSUNG32_FRAMES; // 2 frames + auto_repetition_pause_len = SAMSUNG32_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause + repeat_frame_pause_len = SAMSUNG32_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 - case IRMP_MATSUSHITA_PROTOCOL: - { - startbit_pulse_len = MATSUSHITA_START_BIT_PULSE_LEN; - startbit_pause_len = MATSUSHITA_START_BIT_PAUSE_LEN - 1; - pulse_1_len = MATSUSHITA_PULSE_LEN; - pause_1_len = MATSUSHITA_1_PAUSE_LEN - 1; - pulse_0_len = MATSUSHITA_PULSE_LEN; - pause_0_len = MATSUSHITA_0_PAUSE_LEN - 1; - has_stop_bit = MATSUSHITA_STOP_BIT; - complete_data_len = MATSUSHITA_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = MATSUSHITA_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_MATSUSHITA_PROTOCOL: + { + startbit_pulse_len = MATSUSHITA_START_BIT_PULSE_LEN; + startbit_pause_len = MATSUSHITA_START_BIT_PAUSE_LEN - 1; + pulse_1_len = MATSUSHITA_PULSE_LEN; + pause_1_len = MATSUSHITA_1_PAUSE_LEN - 1; + pulse_0_len = MATSUSHITA_PULSE_LEN; + pause_0_len = MATSUSHITA_0_PAUSE_LEN - 1; + has_stop_bit = MATSUSHITA_STOP_BIT; + complete_data_len = MATSUSHITA_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = MATSUSHITA_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 - case IRMP_KASEIKYO_PROTOCOL: - { - startbit_pulse_len = KASEIKYO_START_BIT_PULSE_LEN; - startbit_pause_len = KASEIKYO_START_BIT_PAUSE_LEN - 1; - pulse_1_len = KASEIKYO_PULSE_LEN; - pause_1_len = KASEIKYO_1_PAUSE_LEN - 1; - pulse_0_len = KASEIKYO_PULSE_LEN; - pause_0_len = KASEIKYO_0_PAUSE_LEN - 1; - has_stop_bit = KASEIKYO_STOP_BIT; - complete_data_len = KASEIKYO_COMPLETE_DATA_LEN; - n_auto_repetitions = (repeat_counter == 0) ? KASEIKYO_FRAMES : 1; // 2 frames auto repetition if first frame - auto_repetition_pause_len = KASEIKYO_AUTO_REPETITION_PAUSE_LEN; // 75 ms pause - repeat_frame_pause_len = KASEIKYO_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_KASEIKYO_PROTOCOL: + { + startbit_pulse_len = KASEIKYO_START_BIT_PULSE_LEN; + startbit_pause_len = KASEIKYO_START_BIT_PAUSE_LEN - 1; + pulse_1_len = KASEIKYO_PULSE_LEN; + pause_1_len = KASEIKYO_1_PAUSE_LEN - 1; + pulse_0_len = KASEIKYO_PULSE_LEN; + pause_0_len = KASEIKYO_0_PAUSE_LEN - 1; + has_stop_bit = KASEIKYO_STOP_BIT; + complete_data_len = KASEIKYO_COMPLETE_DATA_LEN; + n_auto_repetitions = (repeat_counter == 0) ? KASEIKYO_FRAMES : 1; // 2 frames auto repetition if first frame + auto_repetition_pause_len = KASEIKYO_AUTO_REPETITION_PAUSE_LEN; // 75 ms pause + repeat_frame_pause_len = KASEIKYO_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 - case IRMP_RECS80_PROTOCOL: - { - startbit_pulse_len = RECS80_START_BIT_PULSE_LEN; - startbit_pause_len = RECS80_START_BIT_PAUSE_LEN - 1; - pulse_1_len = RECS80_PULSE_LEN; - pause_1_len = RECS80_1_PAUSE_LEN - 1; - pulse_0_len = RECS80_PULSE_LEN; - pause_0_len = RECS80_0_PAUSE_LEN - 1; - has_stop_bit = RECS80_STOP_BIT; - complete_data_len = RECS80_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RECS80_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_RECS80_PROTOCOL: + { + startbit_pulse_len = RECS80_START_BIT_PULSE_LEN; + startbit_pause_len = RECS80_START_BIT_PAUSE_LEN - 1; + pulse_1_len = RECS80_PULSE_LEN; + pause_1_len = RECS80_1_PAUSE_LEN - 1; + pulse_0_len = RECS80_PULSE_LEN; + pause_0_len = RECS80_0_PAUSE_LEN - 1; + has_stop_bit = RECS80_STOP_BIT; + complete_data_len = RECS80_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RECS80_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 - case IRMP_RECS80EXT_PROTOCOL: - { - startbit_pulse_len = RECS80EXT_START_BIT_PULSE_LEN; - startbit_pause_len = RECS80EXT_START_BIT_PAUSE_LEN - 1; - pulse_1_len = RECS80EXT_PULSE_LEN; - pause_1_len = RECS80EXT_1_PAUSE_LEN - 1; - pulse_0_len = RECS80EXT_PULSE_LEN; - pause_0_len = RECS80EXT_0_PAUSE_LEN - 1; - has_stop_bit = RECS80EXT_STOP_BIT; - complete_data_len = RECS80EXT_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RECS80EXT_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_RECS80EXT_PROTOCOL: + { + startbit_pulse_len = RECS80EXT_START_BIT_PULSE_LEN; + startbit_pause_len = RECS80EXT_START_BIT_PAUSE_LEN - 1; + pulse_1_len = RECS80EXT_PULSE_LEN; + pause_1_len = RECS80EXT_1_PAUSE_LEN - 1; + pulse_0_len = RECS80EXT_PULSE_LEN; + pause_0_len = RECS80EXT_0_PAUSE_LEN - 1; + has_stop_bit = RECS80EXT_STOP_BIT; + complete_data_len = RECS80EXT_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RECS80EXT_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 - case IRMP_RC5_PROTOCOL: - { - startbit_pulse_len = RC5_BIT_LEN; - startbit_pause_len = RC5_BIT_LEN; - pulse_len = RC5_BIT_LEN; - pause_len = RC5_BIT_LEN; - has_stop_bit = RC5_STOP_BIT; - complete_data_len = RC5_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RC5_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_RC5_PROTOCOL: + { + startbit_pulse_len = RC5_BIT_LEN; + startbit_pause_len = RC5_BIT_LEN; + pulse_len = RC5_BIT_LEN; + pause_len = RC5_BIT_LEN; + has_stop_bit = RC5_STOP_BIT; + complete_data_len = RC5_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RC5_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_RC6_PROTOCOL == 1 - case IRMP_RC6_PROTOCOL: - { - startbit_pulse_len = RC6_START_BIT_PULSE_LEN; - startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1; - pulse_len = RC6_BIT_LEN; - pause_len = RC6_BIT_LEN; - has_stop_bit = RC6_STOP_BIT; - complete_data_len = RC6_COMPLETE_DATA_LEN_SHORT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_RC6_PROTOCOL: + { + startbit_pulse_len = RC6_START_BIT_PULSE_LEN; + startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1; + pulse_len = RC6_BIT_LEN; + pause_len = RC6_BIT_LEN; + has_stop_bit = RC6_STOP_BIT; + complete_data_len = RC6_COMPLETE_DATA_LEN_SHORT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_RC6A_PROTOCOL == 1 - case IRMP_RC6A_PROTOCOL: - { - startbit_pulse_len = RC6_START_BIT_PULSE_LEN; - startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1; - pulse_len = RC6_BIT_LEN; - pause_len = RC6_BIT_LEN; - has_stop_bit = RC6_STOP_BIT; - complete_data_len = RC6_COMPLETE_DATA_LEN_LONG; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_RC6A_PROTOCOL: + { + startbit_pulse_len = RC6_START_BIT_PULSE_LEN; + startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1; + pulse_len = RC6_BIT_LEN; + pause_len = RC6_BIT_LEN; + has_stop_bit = RC6_STOP_BIT; + complete_data_len = RC6_COMPLETE_DATA_LEN_LONG; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - case IRMP_DENON_PROTOCOL: - { - startbit_pulse_len = 0x00; - startbit_pause_len = 0x00; - pulse_1_len = DENON_PULSE_LEN; - pause_1_len = DENON_1_PAUSE_LEN - 1; - pulse_0_len = DENON_PULSE_LEN; - pause_0_len = DENON_0_PAUSE_LEN - 1; - has_stop_bit = DENON_STOP_BIT; - complete_data_len = DENON_COMPLETE_DATA_LEN; - n_auto_repetitions = DENON_FRAMES; // 2 frames, 2nd with inverted command - auto_repetition_pause_len = DENON_AUTO_REPETITION_PAUSE_LEN; // 65 ms pause after 1st frame - repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); // in theory 32kHz, in practice 36kHz is better - break; - } + case IRMP_DENON_PROTOCOL: + { + startbit_pulse_len = 0x00; + startbit_pause_len = 0x00; + pulse_1_len = DENON_PULSE_LEN; + pause_1_len = DENON_1_PAUSE_LEN - 1; + pulse_0_len = DENON_PULSE_LEN; + pause_0_len = DENON_0_PAUSE_LEN - 1; + has_stop_bit = DENON_STOP_BIT; + complete_data_len = DENON_COMPLETE_DATA_LEN; + n_auto_repetitions = DENON_FRAMES; // 2 frames, 2nd with inverted command + auto_repetition_pause_len = DENON_AUTO_REPETITION_PAUSE_LEN; // 65 ms pause after 1st frame + repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); // in theory 32kHz, in practice 36kHz is better + break; + } #endif #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 - case IRMP_THOMSON_PROTOCOL: - { - startbit_pulse_len = 0x00; - startbit_pause_len = 0x00; - pulse_1_len = THOMSON_PULSE_LEN; - pause_1_len = THOMSON_1_PAUSE_LEN - 1; - pulse_0_len = THOMSON_PULSE_LEN; - pause_0_len = THOMSON_0_PAUSE_LEN - 1; - has_stop_bit = THOMSON_STOP_BIT; - complete_data_len = THOMSON_COMPLETE_DATA_LEN; - n_auto_repetitions = THOMSON_FRAMES; // only 1 frame - auto_repetition_pause_len = THOMSON_AUTO_REPETITION_PAUSE_LEN; - repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_THOMSON_PROTOCOL: + { + startbit_pulse_len = 0x00; + startbit_pause_len = 0x00; + pulse_1_len = THOMSON_PULSE_LEN; + pause_1_len = THOMSON_1_PAUSE_LEN - 1; + pulse_0_len = THOMSON_PULSE_LEN; + pause_0_len = THOMSON_0_PAUSE_LEN - 1; + has_stop_bit = THOMSON_STOP_BIT; + complete_data_len = THOMSON_COMPLETE_DATA_LEN; + n_auto_repetitions = THOMSON_FRAMES; // only 1 frame + auto_repetition_pause_len = THOMSON_AUTO_REPETITION_PAUSE_LEN; + repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 - case IRMP_NUBERT_PROTOCOL: - { - startbit_pulse_len = NUBERT_START_BIT_PULSE_LEN; - startbit_pause_len = NUBERT_START_BIT_PAUSE_LEN - 1; - pulse_1_len = NUBERT_1_PULSE_LEN; - pause_1_len = NUBERT_1_PAUSE_LEN - 1; - pulse_0_len = NUBERT_0_PULSE_LEN; - pause_0_len = NUBERT_0_PAUSE_LEN - 1; - has_stop_bit = NUBERT_STOP_BIT; - complete_data_len = NUBERT_COMPLETE_DATA_LEN; - n_auto_repetitions = NUBERT_FRAMES; // 2 frames - auto_repetition_pause_len = NUBERT_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause - repeat_frame_pause_len = NUBERT_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_NUBERT_PROTOCOL: + { + startbit_pulse_len = NUBERT_START_BIT_PULSE_LEN; + startbit_pause_len = NUBERT_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NUBERT_1_PULSE_LEN; + pause_1_len = NUBERT_1_PAUSE_LEN - 1; + pulse_0_len = NUBERT_0_PULSE_LEN; + pause_0_len = NUBERT_0_PAUSE_LEN - 1; + has_stop_bit = NUBERT_STOP_BIT; + complete_data_len = NUBERT_COMPLETE_DATA_LEN; + n_auto_repetitions = NUBERT_FRAMES; // 2 frames + auto_repetition_pause_len = NUBERT_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause + repeat_frame_pause_len = NUBERT_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - case IRMP_BANG_OLUFSEN_PROTOCOL: - { - startbit_pulse_len = BANG_OLUFSEN_START_BIT1_PULSE_LEN; - startbit_pause_len = BANG_OLUFSEN_START_BIT1_PAUSE_LEN - 1; - pulse_1_len = BANG_OLUFSEN_PULSE_LEN; - pause_1_len = BANG_OLUFSEN_1_PAUSE_LEN - 1; - pulse_0_len = BANG_OLUFSEN_PULSE_LEN; - pause_0_len = BANG_OLUFSEN_0_PAUSE_LEN - 1; - has_stop_bit = BANG_OLUFSEN_STOP_BIT; - complete_data_len = BANG_OLUFSEN_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN; - last_bit_value = 0; - irsnd_set_freq (IRSND_FREQ_455_KHZ); - break; - } + case IRMP_BANG_OLUFSEN_PROTOCOL: + { + startbit_pulse_len = BANG_OLUFSEN_START_BIT1_PULSE_LEN; + startbit_pause_len = BANG_OLUFSEN_START_BIT1_PAUSE_LEN - 1; + pulse_1_len = BANG_OLUFSEN_PULSE_LEN; + pause_1_len = BANG_OLUFSEN_1_PAUSE_LEN - 1; + pulse_0_len = BANG_OLUFSEN_PULSE_LEN; + pause_0_len = BANG_OLUFSEN_0_PAUSE_LEN - 1; + has_stop_bit = BANG_OLUFSEN_STOP_BIT; + complete_data_len = BANG_OLUFSEN_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN; + last_bit_value = 0; + irsnd_set_freq (IRSND_FREQ_455_KHZ); + break; + } #endif #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 - case IRMP_GRUNDIG_PROTOCOL: - { - startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; - pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; - complete_data_len = GRUNDIG_COMPLETE_DATA_LEN; - n_auto_repetitions = GRUNDIG_FRAMES; // 2 frames - auto_repetition_pause_len = GRUNDIG_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause - repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_GRUNDIG_PROTOCOL: + { + startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; + complete_data_len = GRUNDIG_COMPLETE_DATA_LEN; + n_auto_repetitions = GRUNDIG_FRAMES; // 2 frames + auto_repetition_pause_len = GRUNDIG_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause + repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_IR60_PROTOCOL == 1 - case IRMP_IR60_PROTOCOL: - { - startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; - pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; - complete_data_len = IR60_COMPLETE_DATA_LEN; - n_auto_repetitions = IR60_FRAMES; // 2 frames - auto_repetition_pause_len = IR60_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause - repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause - irsnd_set_freq (IRSND_FREQ_30_KHZ); - break; - } + case IRMP_IR60_PROTOCOL: + { + startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; + complete_data_len = IR60_COMPLETE_DATA_LEN; + n_auto_repetitions = IR60_FRAMES; // 2 frames + auto_repetition_pause_len = IR60_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause + repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_30_KHZ); + break; + } #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - case IRMP_NOKIA_PROTOCOL: - { - startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; - pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; - complete_data_len = NOKIA_COMPLETE_DATA_LEN; - n_auto_repetitions = NOKIA_FRAMES; // 2 frames - auto_repetition_pause_len = NOKIA_AUTO_REPETITION_PAUSE_LEN; // 20 msec pause - repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NOKIA_PROTOCOL: + { + startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; + complete_data_len = NOKIA_COMPLETE_DATA_LEN; + n_auto_repetitions = NOKIA_FRAMES; // 2 frames + auto_repetition_pause_len = NOKIA_AUTO_REPETITION_PAUSE_LEN; // 20 msec pause + repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 - case IRMP_SIEMENS_PROTOCOL: - { - startbit_pulse_len = SIEMENS_BIT_LEN; - startbit_pause_len = SIEMENS_BIT_LEN; - pulse_len = SIEMENS_BIT_LEN; - pause_len = SIEMENS_BIT_LEN; - has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT; - complete_data_len = SIEMENS_COMPLETE_DATA_LEN - 1; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = SIEMENS_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_SIEMENS_PROTOCOL: + { + startbit_pulse_len = SIEMENS_BIT_LEN; + startbit_pause_len = SIEMENS_BIT_LEN; + pulse_len = SIEMENS_BIT_LEN; + pause_len = SIEMENS_BIT_LEN; + has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT; + complete_data_len = SIEMENS_COMPLETE_DATA_LEN - 1; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = SIEMENS_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_FDC_PROTOCOL == 1 - case IRMP_FDC_PROTOCOL: - { - startbit_pulse_len = FDC_START_BIT_PULSE_LEN; - startbit_pause_len = FDC_START_BIT_PAUSE_LEN - 1; - complete_data_len = FDC_COMPLETE_DATA_LEN; - pulse_1_len = FDC_PULSE_LEN; - pause_1_len = FDC_1_PAUSE_LEN - 1; - pulse_0_len = FDC_PULSE_LEN; - pause_0_len = FDC_0_PAUSE_LEN - 1; - has_stop_bit = FDC_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = FDC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_FDC_PROTOCOL: + { + startbit_pulse_len = FDC_START_BIT_PULSE_LEN; + startbit_pause_len = FDC_START_BIT_PAUSE_LEN - 1; + complete_data_len = FDC_COMPLETE_DATA_LEN; + pulse_1_len = FDC_PULSE_LEN; + pause_1_len = FDC_1_PAUSE_LEN - 1; + pulse_0_len = FDC_PULSE_LEN; + pause_0_len = FDC_0_PAUSE_LEN - 1; + has_stop_bit = FDC_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = FDC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 - case IRMP_RCCAR_PROTOCOL: - { - startbit_pulse_len = RCCAR_START_BIT_PULSE_LEN; - startbit_pause_len = RCCAR_START_BIT_PAUSE_LEN - 1; - complete_data_len = RCCAR_COMPLETE_DATA_LEN; - pulse_1_len = RCCAR_PULSE_LEN; - pause_1_len = RCCAR_1_PAUSE_LEN - 1; - pulse_0_len = RCCAR_PULSE_LEN; - pause_0_len = RCCAR_0_PAUSE_LEN - 1; - has_stop_bit = RCCAR_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RCCAR_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_RCCAR_PROTOCOL: + { + startbit_pulse_len = RCCAR_START_BIT_PULSE_LEN; + startbit_pause_len = RCCAR_START_BIT_PAUSE_LEN - 1; + complete_data_len = RCCAR_COMPLETE_DATA_LEN; + pulse_1_len = RCCAR_PULSE_LEN; + pause_1_len = RCCAR_1_PAUSE_LEN - 1; + pulse_0_len = RCCAR_PULSE_LEN; + pause_0_len = RCCAR_0_PAUSE_LEN - 1; + has_stop_bit = RCCAR_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RCCAR_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_JVC_PROTOCOL == 1 - case IRMP_JVC_PROTOCOL: - { - if (repeat_counter != 0) // skip start bit if repetition frame - { - current_bit = 0; - } - - startbit_pulse_len = JVC_START_BIT_PULSE_LEN; - startbit_pause_len = JVC_START_BIT_PAUSE_LEN - 1; - complete_data_len = JVC_COMPLETE_DATA_LEN; - pulse_1_len = JVC_PULSE_LEN; - pause_1_len = JVC_1_PAUSE_LEN - 1; - pulse_0_len = JVC_PULSE_LEN; - pause_0_len = JVC_0_PAUSE_LEN - 1; - has_stop_bit = JVC_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_JVC_PROTOCOL: + { + if (repeat_counter != 0) // skip start bit if repetition frame + { + current_bit = 0; + } + + startbit_pulse_len = JVC_START_BIT_PULSE_LEN; + startbit_pause_len = JVC_START_BIT_PAUSE_LEN - 1; + complete_data_len = JVC_COMPLETE_DATA_LEN; + pulse_1_len = JVC_PULSE_LEN; + pause_1_len = JVC_1_PAUSE_LEN - 1; + pulse_0_len = JVC_PULSE_LEN; + pause_0_len = JVC_0_PAUSE_LEN - 1; + has_stop_bit = JVC_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_NIKON_PROTOCOL == 1 - case IRMP_NIKON_PROTOCOL: - { - startbit_pulse_len = NIKON_START_BIT_PULSE_LEN; - startbit_pause_len = NIKON_START_BIT_PAUSE_LEN; - complete_data_len = NIKON_COMPLETE_DATA_LEN; - pulse_1_len = NIKON_PULSE_LEN; - pause_1_len = NIKON_1_PAUSE_LEN - 1; - pulse_0_len = NIKON_PULSE_LEN; - pause_0_len = NIKON_0_PAUSE_LEN - 1; - has_stop_bit = NIKON_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NIKON_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NIKON_PROTOCOL: + { + startbit_pulse_len = NIKON_START_BIT_PULSE_LEN; + startbit_pause_len = NIKON_START_BIT_PAUSE_LEN; + complete_data_len = NIKON_COMPLETE_DATA_LEN; + pulse_1_len = NIKON_PULSE_LEN; + pause_1_len = NIKON_1_PAUSE_LEN - 1; + pulse_0_len = NIKON_PULSE_LEN; + pause_0_len = NIKON_0_PAUSE_LEN - 1; + has_stop_bit = NIKON_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NIKON_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 - case IRMP_LEGO_PROTOCOL: - { - startbit_pulse_len = LEGO_START_BIT_PULSE_LEN; - startbit_pause_len = LEGO_START_BIT_PAUSE_LEN - 1; - complete_data_len = LEGO_COMPLETE_DATA_LEN; - pulse_1_len = LEGO_PULSE_LEN; - pause_1_len = LEGO_1_PAUSE_LEN - 1; - pulse_0_len = LEGO_PULSE_LEN; - pause_0_len = LEGO_0_PAUSE_LEN - 1; - has_stop_bit = LEGO_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = LEGO_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_LEGO_PROTOCOL: + { + startbit_pulse_len = LEGO_START_BIT_PULSE_LEN; + startbit_pause_len = LEGO_START_BIT_PAUSE_LEN - 1; + complete_data_len = LEGO_COMPLETE_DATA_LEN; + pulse_1_len = LEGO_PULSE_LEN; + pause_1_len = LEGO_1_PAUSE_LEN - 1; + pulse_0_len = LEGO_PULSE_LEN; + pause_0_len = LEGO_0_PAUSE_LEN - 1; + has_stop_bit = LEGO_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = LEGO_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - case IRMP_A1TVBOX_PROTOCOL: - { - startbit_pulse_len = A1TVBOX_BIT_PULSE_LEN; // don't use A1TVBOX_START_BIT_PULSE_LEN - startbit_pause_len = A1TVBOX_BIT_PAUSE_LEN; // don't use A1TVBOX_START_BIT_PAUSE_LEN - pulse_len = A1TVBOX_BIT_PULSE_LEN; - pause_len = A1TVBOX_BIT_PAUSE_LEN; - has_stop_bit = A1TVBOX_STOP_BIT; - complete_data_len = A1TVBOX_COMPLETE_DATA_LEN + 1; // we send stop bit as data - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = A1TVBOX_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } -#endif - default: - { - irsnd_busy = FALSE; - break; - } - } - } - } - - if (irsnd_busy) - { - new_frame = FALSE; - - switch (irsnd_protocol) - { + case IRMP_A1TVBOX_PROTOCOL: + { + startbit_pulse_len = A1TVBOX_BIT_PULSE_LEN; // don't use A1TVBOX_START_BIT_PULSE_LEN + startbit_pause_len = A1TVBOX_BIT_PAUSE_LEN; // don't use A1TVBOX_START_BIT_PAUSE_LEN + pulse_len = A1TVBOX_BIT_PULSE_LEN; + pause_len = A1TVBOX_BIT_PAUSE_LEN; + has_stop_bit = A1TVBOX_STOP_BIT; + complete_data_len = A1TVBOX_COMPLETE_DATA_LEN + 1; // we send stop bit as data + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = A1TVBOX_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif + default: + { + irsnd_busy = FALSE; + break; + } + } + } + } + + if (irsnd_busy) + { + new_frame = FALSE; + + switch (irsnd_protocol) + { #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 - case IRMP_SIRCS_PROTOCOL: + case IRMP_SIRCS_PROTOCOL: #endif #if IRSND_SUPPORT_NEC_PROTOCOL == 1 - case IRMP_NEC_PROTOCOL: + case IRMP_NEC_PROTOCOL: #endif #if IRSND_SUPPORT_NEC16_PROTOCOL == 1 - case IRMP_NEC16_PROTOCOL: + case IRMP_NEC16_PROTOCOL: #endif #if IRSND_SUPPORT_NEC42_PROTOCOL == 1 - case IRMP_NEC42_PROTOCOL: + case IRMP_NEC42_PROTOCOL: #endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 - case IRMP_SAMSUNG_PROTOCOL: - case IRMP_SAMSUNG32_PROTOCOL: + case IRMP_SAMSUNG_PROTOCOL: + case IRMP_SAMSUNG32_PROTOCOL: #endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 - case IRMP_MATSUSHITA_PROTOCOL: + case IRMP_MATSUSHITA_PROTOCOL: #endif #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 - case IRMP_KASEIKYO_PROTOCOL: + case IRMP_KASEIKYO_PROTOCOL: #endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 - case IRMP_RECS80_PROTOCOL: + case IRMP_RECS80_PROTOCOL: #endif #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 - case IRMP_RECS80EXT_PROTOCOL: + case IRMP_RECS80EXT_PROTOCOL: #endif #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - case IRMP_DENON_PROTOCOL: + case IRMP_DENON_PROTOCOL: #endif #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 - case IRMP_THOMSON_PROTOCOL: + case IRMP_THOMSON_PROTOCOL: #endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 - case IRMP_NUBERT_PROTOCOL: + case IRMP_NUBERT_PROTOCOL: #endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - case IRMP_BANG_OLUFSEN_PROTOCOL: + case IRMP_BANG_OLUFSEN_PROTOCOL: #endif #if IRSND_SUPPORT_FDC_PROTOCOL == 1 - case IRMP_FDC_PROTOCOL: + case IRMP_FDC_PROTOCOL: #endif #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 - case IRMP_RCCAR_PROTOCOL: + case IRMP_RCCAR_PROTOCOL: #endif #if IRSND_SUPPORT_JVC_PROTOCOL == 1 - case IRMP_JVC_PROTOCOL: + case IRMP_JVC_PROTOCOL: #endif #if IRSND_SUPPORT_NIKON_PROTOCOL == 1 - case IRMP_NIKON_PROTOCOL: + case IRMP_NIKON_PROTOCOL: #endif #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 - case IRMP_LEGO_PROTOCOL: + case IRMP_LEGO_PROTOCOL: #endif #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_NEC16_PROTOCOL == 1 || IRSND_SUPPORT_NEC42_PROTOCOL == 1 || \ @@ -1837,437 +1837,437 @@ irsnd_ISR (void) IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \ IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || \ IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1 - { + { #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - if (irsnd_protocol == IRMP_DENON_PROTOCOL) - { - if (auto_repetition_pause_len > 0) // 2nd frame distance counts from beginning of 1st frame! - { - auto_repetition_pause_len--; - } - - if (repeat_frame_pause_len > 0) // frame repeat distance counts from beginning of 1st frame! - { - repeat_frame_pause_len--; - } - } -#endif - - if (pulse_counter == 0) - { - if (current_bit == 0xFF) // send start bit - { - pulse_len = startbit_pulse_len; - pause_len = startbit_pause_len; - } - else if (current_bit < complete_data_len) // send n'th bit - { + if (irsnd_protocol == IRMP_DENON_PROTOCOL) + { + if (auto_repetition_pause_len > 0) // 2nd frame distance counts from beginning of 1st frame! + { + auto_repetition_pause_len--; + } + + if (repeat_frame_pause_len > 0) // frame repeat distance counts from beginning of 1st frame! + { + repeat_frame_pause_len--; + } + } +#endif + + if (pulse_counter == 0) + { + if (current_bit == 0xFF) // send start bit + { + pulse_len = startbit_pulse_len; + pause_len = startbit_pause_len; + } + else if (current_bit < complete_data_len) // send n'th bit + { #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 - if (irsnd_protocol == IRMP_SAMSUNG_PROTOCOL) - { - if (current_bit < SAMSUNG_ADDRESS_LEN) // send address bits - { - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? - (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); - } - else if (current_bit == SAMSUNG_ADDRESS_LEN) // send SYNC bit (16th bit) - { - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; - } - else if (current_bit < SAMSUNG_COMPLETE_DATA_LEN) // send n'th bit - { - uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! - - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ? - (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); - } - } - else + if (irsnd_protocol == IRMP_SAMSUNG_PROTOCOL) + { + if (current_bit < SAMSUNG_ADDRESS_LEN) // send address bits + { + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? + (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); + } + else if (current_bit == SAMSUNG_ADDRESS_LEN) // send SYNC bit (16th bit) + { + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; + } + else if (current_bit < SAMSUNG_COMPLETE_DATA_LEN) // send n'th bit + { + uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! + + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ? + (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); + } + } + else #endif #if IRSND_SUPPORT_NEC16_PROTOCOL == 1 - if (irsnd_protocol == IRMP_NEC16_PROTOCOL) - { - if (current_bit < NEC16_ADDRESS_LEN) // send address bits - { - pulse_len = NEC_PULSE_LEN; - pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? - (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); - } - else if (current_bit == NEC16_ADDRESS_LEN) // send SYNC bit (8th bit) - { - pulse_len = NEC_PULSE_LEN; - pause_len = NEC_START_BIT_PAUSE_LEN - 1; - } - else if (current_bit < NEC16_COMPLETE_DATA_LEN + 1) // send n'th bit - { - uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! - - pulse_len = NEC_PULSE_LEN; - pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ? - (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); - } - } - else + if (irsnd_protocol == IRMP_NEC16_PROTOCOL) + { + if (current_bit < NEC16_ADDRESS_LEN) // send address bits + { + pulse_len = NEC_PULSE_LEN; + pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? + (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); + } + else if (current_bit == NEC16_ADDRESS_LEN) // send SYNC bit (8th bit) + { + pulse_len = NEC_PULSE_LEN; + pause_len = NEC_START_BIT_PAUSE_LEN - 1; + } + else if (current_bit < NEC16_COMPLETE_DATA_LEN + 1) // send n'th bit + { + uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! + + pulse_len = NEC_PULSE_LEN; + pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ? + (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); + } + } + else #endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL) - { - if (current_bit == 0) // send 2nd start bit - { - pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; - pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1; - } - else if (current_bit == 1) // send 3rd start bit - { - pulse_len = BANG_OLUFSEN_START_BIT3_PULSE_LEN; - pause_len = BANG_OLUFSEN_START_BIT3_PAUSE_LEN - 1; - } - else if (current_bit == 2) // send 4th start bit - { - pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; - pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1; - } - else if (current_bit == 19) // send trailer bit - { - pulse_len = BANG_OLUFSEN_PULSE_LEN; - pause_len = BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN - 1; - } - else if (current_bit < BANG_OLUFSEN_COMPLETE_DATA_LEN) // send n'th bit - { - uint8_t cur_bit_value = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? 1 : 0; - pulse_len = BANG_OLUFSEN_PULSE_LEN; - - if (cur_bit_value == last_bit_value) - { - pause_len = BANG_OLUFSEN_R_PAUSE_LEN - 1; - } - else - { - pause_len = cur_bit_value ? (BANG_OLUFSEN_1_PAUSE_LEN - 1) : (BANG_OLUFSEN_0_PAUSE_LEN - 1); - last_bit_value = cur_bit_value; - } - } - } - else -#endif - if (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) - { - pulse_len = pulse_1_len; - pause_len = pause_1_len; - } - else - { - pulse_len = pulse_0_len; - pause_len = pause_0_len; - } - } - else if (has_stop_bit) // send stop bit - { - pulse_len = pulse_0_len; - - if (auto_repetition_counter < n_auto_repetitions) - { - pause_len = pause_0_len; - } - else - { - pause_len = 255; // last frame: pause of 255 - } - } - } - - if (pulse_counter < pulse_len) - { - if (pulse_counter == 0) - { - irsnd_on (); - } - pulse_counter++; - } - else if (pause_counter < pause_len) - { - if (pause_counter == 0) - { - irsnd_off (); - } - pause_counter++; - } - else - { - current_bit++; - - if (current_bit >= complete_data_len + has_stop_bit) - { - current_bit = 0xFF; - auto_repetition_counter++; - - if (auto_repetition_counter == n_auto_repetitions) - { - irsnd_busy = FALSE; - auto_repetition_counter = 0; - } - new_frame = TRUE; - } - - pulse_counter = 0; - pause_counter = 0; - } - break; - } + if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL) + { + if (current_bit == 0) // send 2nd start bit + { + pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1; + } + else if (current_bit == 1) // send 3rd start bit + { + pulse_len = BANG_OLUFSEN_START_BIT3_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT3_PAUSE_LEN - 1; + } + else if (current_bit == 2) // send 4th start bit + { + pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1; + } + else if (current_bit == 19) // send trailer bit + { + pulse_len = BANG_OLUFSEN_PULSE_LEN; + pause_len = BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN - 1; + } + else if (current_bit < BANG_OLUFSEN_COMPLETE_DATA_LEN) // send n'th bit + { + uint8_t cur_bit_value = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? 1 : 0; + pulse_len = BANG_OLUFSEN_PULSE_LEN; + + if (cur_bit_value == last_bit_value) + { + pause_len = BANG_OLUFSEN_R_PAUSE_LEN - 1; + } + else + { + pause_len = cur_bit_value ? (BANG_OLUFSEN_1_PAUSE_LEN - 1) : (BANG_OLUFSEN_0_PAUSE_LEN - 1); + last_bit_value = cur_bit_value; + } + } + } + else +#endif + if (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) + { + pulse_len = pulse_1_len; + pause_len = pause_1_len; + } + else + { + pulse_len = pulse_0_len; + pause_len = pause_0_len; + } + } + else if (has_stop_bit) // send stop bit + { + pulse_len = pulse_0_len; + + if (auto_repetition_counter < n_auto_repetitions) + { + pause_len = pause_0_len; + } + else + { + pause_len = 255; // last frame: pause of 255 + } + } + } + + if (pulse_counter < pulse_len) + { + if (pulse_counter == 0) + { + irsnd_on (); + } + pulse_counter++; + } + else if (pause_counter < pause_len) + { + if (pause_counter == 0) + { + irsnd_off (); + } + pause_counter++; + } + else + { + current_bit++; + + if (current_bit >= complete_data_len + has_stop_bit) + { + current_bit = 0xFF; + auto_repetition_counter++; + + if (auto_repetition_counter == n_auto_repetitions) + { + irsnd_busy = FALSE; + auto_repetition_counter = 0; + } + new_frame = TRUE; + } + + pulse_counter = 0; + pause_counter = 0; + } + break; + } #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 - case IRMP_RC5_PROTOCOL: + case IRMP_RC5_PROTOCOL: #endif #if IRSND_SUPPORT_RC6_PROTOCOL == 1 - case IRMP_RC6_PROTOCOL: + case IRMP_RC6_PROTOCOL: #endif #if IRSND_SUPPORT_RC6A_PROTOCOL == 1 - case IRMP_RC6A_PROTOCOL: + case IRMP_RC6A_PROTOCOL: #endif #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 - case IRMP_SIEMENS_PROTOCOL: + case IRMP_SIEMENS_PROTOCOL: #endif #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 - case IRMP_GRUNDIG_PROTOCOL: + case IRMP_GRUNDIG_PROTOCOL: #endif #if IRSND_SUPPORT_IR60_PROTOCOL == 1 - case IRMP_IR60_PROTOCOL: + case IRMP_IR60_PROTOCOL: #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - case IRMP_NOKIA_PROTOCOL: + case IRMP_NOKIA_PROTOCOL: #endif #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - case IRMP_A1TVBOX_PROTOCOL: + case IRMP_A1TVBOX_PROTOCOL: #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || \ IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 || IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - { - if (pulse_counter == pulse_len && pause_counter == pause_len) - { - current_bit++; + { + if (pulse_counter == pulse_len && pause_counter == pause_len) + { + current_bit++; - if (current_bit >= complete_data_len) - { - current_bit = 0xFF; + if (current_bit >= complete_data_len) + { + current_bit = 0xFF; #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) - { - auto_repetition_counter++; - - if (repeat_counter > 0) - { // set 117 msec pause time - auto_repetition_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; - } - - if (repeat_counter < n_repeat_frames) // tricky: repeat n info frames per auto repetition before sending last stop frame - { - n_auto_repetitions++; // increment number of auto repetitions - repeat_counter++; - } - else if (auto_repetition_counter == n_auto_repetitions) - { - irsnd_busy = FALSE; - auto_repetition_counter = 0; - } - } - else -#endif - { - irsnd_busy = FALSE; - } - - new_frame = TRUE; - irsnd_off (); - } - - pulse_counter = 0; - pause_counter = 0; - } - - if (! new_frame) - { - uint8_t first_pulse; + if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) + { + auto_repetition_counter++; + + if (repeat_counter > 0) + { // set 117 msec pause time + auto_repetition_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; + } + + if (repeat_counter < n_repeat_frames) // tricky: repeat n info frames per auto repetition before sending last stop frame + { + n_auto_repetitions++; // increment number of auto repetitions + repeat_counter++; + } + else if (auto_repetition_counter == n_auto_repetitions) + { + irsnd_busy = FALSE; + auto_repetition_counter = 0; + } + } + else +#endif + { + irsnd_busy = FALSE; + } + + new_frame = TRUE; + irsnd_off (); + } + + pulse_counter = 0; + pause_counter = 0; + } + + if (! new_frame) + { + uint8_t first_pulse; #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) - { - if (current_bit == 0xFF || // start bit of start-frame - (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL && current_bit == 15) || // start bit of info-frame (Grundig) - (irsnd_protocol == IRMP_IR60_PROTOCOL && current_bit == 7) || // start bit of data frame (IR60) - (irsnd_protocol == IRMP_NOKIA_PROTOCOL && (current_bit == 23 || current_bit == 47))) // start bit of info- or stop-frame (Nokia) - { - pulse_len = startbit_pulse_len; - pause_len = startbit_pause_len; - first_pulse = TRUE; - } - else // send n'th bit - { - pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE; - } - } - else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL || - // irsnd_protocol == IRMP_SIEMENS_PROTOCOL) -#endif - { - if (current_bit == 0xFF) // 1 start bit - { + if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) + { + if (current_bit == 0xFF || // start bit of start-frame + (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL && current_bit == 15) || // start bit of info-frame (Grundig) + (irsnd_protocol == IRMP_IR60_PROTOCOL && current_bit == 7) || // start bit of data frame (IR60) + (irsnd_protocol == IRMP_NOKIA_PROTOCOL && (current_bit == 23 || current_bit == 47))) // start bit of info- or stop-frame (Nokia) + { + pulse_len = startbit_pulse_len; + pause_len = startbit_pause_len; + first_pulse = TRUE; + } + else // send n'th bit + { + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE; + } + } + else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL || + // irsnd_protocol == IRMP_SIEMENS_PROTOCOL) +#endif + { + if (current_bit == 0xFF) // 1 start bit + { #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 - if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL) - { - pulse_len = startbit_pulse_len; - pause_len = startbit_pause_len; - } - else + if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL) + { + pulse_len = startbit_pulse_len; + pause_len = startbit_pause_len; + } + else #endif #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - if (irsnd_protocol == IRMP_A1TVBOX_PROTOCOL) - { - current_bit = 0; - } - else -#endif - { - ; - } - - first_pulse = TRUE; - } - else // send n'th bit - { + if (irsnd_protocol == IRMP_A1TVBOX_PROTOCOL) + { + current_bit = 0; + } + else +#endif + { + ; + } + + first_pulse = TRUE; + } + else // send n'th bit + { #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 - if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL) - { - pulse_len = RC6_BIT_LEN; - pause_len = RC6_BIT_LEN; - - if (irsnd_protocol == IRMP_RC6_PROTOCOL) - { - if (current_bit == 4) // toggle bit (double len) - { - pulse_len = 2 * RC6_BIT_LEN; - pause_len = 2 * RC6_BIT_LEN; - } - } - else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL) - { - if (current_bit == 4) // toggle bit (double len) - { - pulse_len = 2 * RC6_BIT_LEN + RC6_BIT_LEN; // hack! - pause_len = 2 * RC6_BIT_LEN; - } - else if (current_bit == 5) // toggle bit (double len) - { - pause_len = 2 * RC6_BIT_LEN; - } - } - } -#endif - first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE; - } - - if (irsnd_protocol == IRMP_RC5_PROTOCOL) - { - first_pulse = first_pulse ? FALSE : TRUE; - } - } - - if (first_pulse) - { - // printf ("first_pulse: current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); - - if (pulse_counter < pulse_len) - { - if (pulse_counter == 0) - { - irsnd_on (); - } - pulse_counter++; - } - else // if (pause_counter < pause_len) - { - if (pause_counter == 0) - { - irsnd_off (); - } - pause_counter++; - } - } - else - { - // printf ("first_pause: current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); - - if (pause_counter < pause_len) - { - if (pause_counter == 0) - { - irsnd_off (); - } - pause_counter++; - } - else // if (pulse_counter < pulse_len) - { - if (pulse_counter == 0) - { - irsnd_on (); - } - pulse_counter++; - } - } - } - break; - } + if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL) + { + pulse_len = RC6_BIT_LEN; + pause_len = RC6_BIT_LEN; + + if (irsnd_protocol == IRMP_RC6_PROTOCOL) + { + if (current_bit == 4) // toggle bit (double len) + { + pulse_len = 2 * RC6_BIT_LEN; + pause_len = 2 * RC6_BIT_LEN; + } + } + else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL) + { + if (current_bit == 4) // toggle bit (double len) + { + pulse_len = 2 * RC6_BIT_LEN + RC6_BIT_LEN; // hack! + pause_len = 2 * RC6_BIT_LEN; + } + else if (current_bit == 5) // toggle bit (double len) + { + pause_len = 2 * RC6_BIT_LEN; + } + } + } +#endif + first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE; + } + + if (irsnd_protocol == IRMP_RC5_PROTOCOL) + { + first_pulse = first_pulse ? FALSE : TRUE; + } + } + + if (first_pulse) + { + // printf ("first_pulse: current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); + + if (pulse_counter < pulse_len) + { + if (pulse_counter == 0) + { + irsnd_on (); + } + pulse_counter++; + } + else // if (pause_counter < pause_len) + { + if (pause_counter == 0) + { + irsnd_off (); + } + pause_counter++; + } + } + else + { + // printf ("first_pause: current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); + + if (pause_counter < pause_len) + { + if (pause_counter == 0) + { + irsnd_off (); + } + pause_counter++; + } + else // if (pulse_counter < pulse_len) + { + if (pulse_counter == 0) + { + irsnd_on (); + } + pulse_counter++; + } + } + } + break; + } #endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - default: - { - irsnd_busy = FALSE; - break; - } - } - } - - if (! irsnd_busy) - { - if (repeat_counter < n_repeat_frames) - { + default: + { + irsnd_busy = FALSE; + break; + } + } + } + + if (! irsnd_busy) + { + if (repeat_counter < n_repeat_frames) + { #if IRSND_SUPPORT_FDC_PROTOCOL == 1 - if (irsnd_protocol == IRMP_FDC_PROTOCOL) - { - irsnd_buffer[2] |= 0x0F; - } -#endif - repeat_counter++; - irsnd_busy = TRUE; - } - else - { - irsnd_busy = TRUE; //Rainer - send_trailer = TRUE; - n_repeat_frames = 0; - repeat_counter = 0; - } - } + if (irsnd_protocol == IRMP_FDC_PROTOCOL) + { + irsnd_buffer[2] |= 0x0F; + } +#endif + repeat_counter++; + irsnd_busy = TRUE; + } + else + { + irsnd_busy = TRUE; //Rainer + send_trailer = TRUE; + n_repeat_frames = 0; + repeat_counter = 0; + } + } } #ifdef DEBUG if (irsnd_is_on) { - putchar ('0'); + putchar ('0'); } else { - putchar ('1'); + putchar ('1'); } #endif @@ -2293,53 +2293,53 @@ main (int argc, char ** argv) if (argc != 4 && argc != 5) { - fprintf (stderr, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv[0]); - return 1; + fprintf (stderr, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv[0]); + return 1; } if (sscanf (argv[1], "%d", &protocol) == 1 && - sscanf (argv[2], "%x", &address) == 1 && - sscanf (argv[3], "%x", &command) == 1) + sscanf (argv[2], "%x", &address) == 1 && + sscanf (argv[3], "%x", &command) == 1) { - irmp_data.protocol = protocol; - irmp_data.address = address; - irmp_data.command = command; + irmp_data.protocol = protocol; + irmp_data.address = address; + irmp_data.command = command; - if (argc == 5) - { - irmp_data.flags = atoi (argv[4]); - } - else - { - irmp_data.flags = 0; - } + if (argc == 5) + { + irmp_data.flags = atoi (argv[4]); + } + else + { + irmp_data.flags = 0; + } - irsnd_init (); + irsnd_init (); - (void) irsnd_send_data (&irmp_data, TRUE); + (void) irsnd_send_data (&irmp_data, TRUE); - while (irsnd_busy) - { - irsnd_ISR (); - } + while (irsnd_busy) + { + irsnd_ISR (); + } - putchar ('\n'); + putchar ('\n'); #if 1 // enable here to send twice - (void) irsnd_send_data (&irmp_data, TRUE); + (void) irsnd_send_data (&irmp_data, TRUE); - while (irsnd_busy) - { - irsnd_ISR (); - } + while (irsnd_busy) + { + irsnd_ISR (); + } - putchar ('\n'); + putchar ('\n'); #endif } else { - fprintf (stderr, "%s: wrong arguments\n", argv[0]); - return 1; + fprintf (stderr, "%s: wrong arguments\n", argv[0]); + return 1; } return 0; } diff --git a/irsnd.h b/irsnd.h index 304bc85..77a5d5e 100644 --- a/irsnd.h +++ b/irsnd.h @@ -3,7 +3,7 @@ * * Copyright (c) 2010-2013 Frank Meyer - frank(at)fli4l.de * - * $Id: irsnd.h,v 1.15 2013/01/17 07:33:13 fm Exp $ + * $Id: irsnd.h,v 1.16 2013/03/12 12:49:59 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -88,14 +88,14 @@ # define IRSND_SUPPORT_A1TVBOX_PROTOCOL 0 #endif -#if IRSND_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 20000 -# warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 20000) +#if IRSND_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 15000 +# warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 15000) # undef IRSND_SUPPORT_RECS80_PROTOCOL # define IRSND_SUPPORT_RECS80_PROTOCOL 0 #endif -#if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 20000 -# warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 20000) +#if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 15000 +# warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 15000) # undef IRSND_SUPPORT_RECS80EXT_PROTOCOL # define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0 #endif diff --git a/irsndconfig.h b/irsndconfig.h index b119779..3d278bc 100644 --- a/irsndconfig.h +++ b/irsndconfig.h @@ -5,7 +5,7 @@ * * Copyright (c) 2010-2013 Frank Meyer - frank(at)fli4l.de * - * $Id: irsndconfig.h,v 1.47 2013/01/17 07:33:13 fm Exp $ + * $Id: irsndconfig.h,v 1.48 2013/03/12 12:49:59 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -63,8 +63,8 @@ #define IRSND_SUPPORT_KATHREIN_PROTOCOL 0 // Kathrein >= 10000 DON'T CHANGE, NOT SUPPORTED YET! #define IRSND_SUPPORT_NUBERT_PROTOCOL 0 // NUBERT >= 10000 ~100 bytes #define IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL 0 // Bang&Olufsen >= 10000 ~250 bytes -#define IRSND_SUPPORT_RECS80_PROTOCOL 0 // RECS80 >= 20000 ~100 bytes -#define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0 // RECS80EXT >= 20000 ~100 bytes +#define IRSND_SUPPORT_RECS80_PROTOCOL 0 // RECS80 >= 15000 ~100 bytes +#define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0 // RECS80EXT >= 15000 ~100 bytes #define IRSND_SUPPORT_THOMSON_PROTOCOL 0 // Thomson >= 10000 ~250 bytes #define IRSND_SUPPORT_NIKON_PROTOCOL 0 // NIKON >= 10000 ~150 bytes #define IRSND_SUPPORT_NETBOX_PROTOCOL 0 // Netbox keyboard >= 10000 DON'T CHANGE, NOT SUPPORTED YET! -- 2.39.2