X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/c1dfa01fb7d5cbaf43375fdba304ab8887bcae3c..f71bec53129472a38453877af44cc3d85acaded2:/irsnd.c diff --git a/irsnd.c b/irsnd.c index 554e264..8420675 100644 --- a/irsnd.c +++ b/irsnd.c @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * @file irsnd.c * - * Copyright (c) 2010-2013 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2010-2015 Frank Meyer - frank(at)fli4l.de * - * Supported mikrocontrollers: + * Supported AVR mikrocontrollers: * * ATtiny87, ATtiny167 * ATtiny45, ATtiny85 @@ -13,7 +13,7 @@ * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284, ATmega1284P * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * - * $Id: irsnd.c,v 1.76 2014/06/23 06:56:00 fm Exp $ + * $Id: irsnd.c,v 1.91 2015/09/20 10:51:37 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 @@ -43,6 +43,7 @@ # else # error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h # endif // IRSND_OCx + #elif defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) // ATtiny45/85 uses OC0A = PB0 or OC0B = PB1 # if IRSND_OCx == IRSND_OC0A // OC0A # define IRSND_PORT_LETTER B @@ -53,6 +54,7 @@ # else # error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h # endif // IRSND_OCx + #elif defined (__AVR_ATtiny87__) || defined (__AVR_ATtiny167__) // ATtiny87/167 uses OC0A = PA2 # if IRSND_OCx == IRSND_OC0A // OC0A # define IRSND_PORT_LETTER A @@ -60,6 +62,7 @@ # else # error Wrong value for IRSND_OCx, choose IRSND_OC0A in irsndconfig.h # endif // IRSND_OCx + #elif defined (__AVR_ATmega8__) // ATmega8 uses only OC2 = PB3 # if IRSND_OCx == IRSND_OC2 // OC0A # define IRSND_PORT_LETTER B @@ -74,6 +77,7 @@ # else # error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h # endif // IRSND_OCx + #elif defined (__AVR_ATmega162__) // ATmega162 uses OC2 = PB1 or OC0 = PB0 # if IRSND_OCx == IRSND_OC2 // OC2 # define IRSND_PORT_LETTER B @@ -84,6 +88,7 @@ # else # error Wrong value for IRSND_OCx, choose IRSND_OC2 or IRSND_OC0 in irsndconfig.h # endif // IRSND_OCx + #elif defined (__AVR_ATmega164__) \ || defined (__AVR_ATmega324__) \ || defined (__AVR_ATmega644__) \ @@ -105,6 +110,7 @@ # else # error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h # endif // IRSND_OCx + #elif defined (__AVR_ATmega48__) \ || defined (__AVR_ATmega88__) \ || defined (__AVR_ATmega88P__) \ @@ -126,6 +132,7 @@ # else # error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h # endif // IRSND_OCx + #elif defined (__AVR_ATmega8515__) // ATmega8515 uses OC0 = PB0 or OC1A = PD5 or OC1B = PE2 # if IRSND_OCx == IRSND_OC0 # define IRSND_PORT_LETTER B @@ -136,9 +143,25 @@ # elif IRSND_OCx == IRSND_OC1B # define IRSND_PORT_LETTER E # define IRSND_BIT_NUMBER 2 +# endif // IRSND_OCx + +#elif defined (__AVR_XMEGA__) // ATxmega +# if IRSND_OCx == IRSND_XMEGA_OC0A +# define IRSND_BIT_NUMBER 0 +# elif IRSND_OCx == IRSND_XMEGA_OC0B +# define IRSND_BIT_NUMBER 1 +# elif IRSND_OCx == IRSND_XMEGA_OC0C +# define IRSND_BIT_NUMBER 2 +# elif IRSND_OCx == IRSND_XMEGA_OC0D +# define IRSND_BIT_NUMBER 3 +# elif IRSND_OCx == IRSND_XMEGA_OC1A +# define IRSND_BIT_NUMBER 4 +# elif IRSND_OCx == IRSND_XMEGA_OC1B +# define IRSND_BIT_NUMBER 5 # else -# error Wrong value for IRSND_OCx, choose IRSND_OC0, IRSND_OC1A, or IRSND_OC1B in irsndconfig.h +# error Wrong value for IRSND_OCx, choose IRSND_XMEGA_OC0A, IRSND_XMEGA_OC0B, IRSND_XMEGA_OC0C, IRSND_XMEGA_OC0D, IRSND_XMEGA_OC1A, or IRSND_XMEGA_OC1B in irsndconfig.h # endif // IRSND_OCx + #elif defined (PIC_C18) //Microchip C18 compiler //Nothing here to do here -> See irsndconfig.h #elif defined (ARM_STM32) //STM32 @@ -149,7 +172,14 @@ # endif // unix, WIN32 #endif // __AVR... -#if defined(ATMEL_AVR) +#if defined(__AVR_XMEGA__) +# define _CONCAT(a,b) a##b +# define CONCAT(a,b) _CONCAT(a,b) +# define IRSND_PORT IRSND_PORT_PRE.OUT +# define IRSND_DDR IRSND_PORT_PRE.DIR +# define IRSND_PIN IRSND_PORT_PRE.IN +# define IRSND_BIT IRSND_BIT_NUMBER +#elif defined(ATMEL_AVR) # define _CONCAT(a,b) a##b # define CONCAT(a,b) _CONCAT(a,b) # define IRSND_PORT CONCAT(PORT, IRSND_PORT_LETTER) @@ -193,6 +223,9 @@ #define SAMSUNG32_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! #define SAMSUNG32_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define SAMSUNG48_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG48_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define SAMSUNG48_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG48_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + #define MATSUSHITA_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME + 0.5) #define MATSUSHITA_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME + 0.5) #define MATSUSHITA_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME + 0.5) @@ -261,6 +294,15 @@ #define NUBERT_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! #define NUBERT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define FAN_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * FAN_START_BIT_PULSE_TIME + 0.5) +#define FAN_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FAN_START_BIT_PAUSE_TIME + 0.5) +#define FAN_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * FAN_1_PULSE_TIME + 0.5) +#define FAN_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FAN_1_PAUSE_TIME + 0.5) +#define FAN_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * FAN_0_PULSE_TIME + 0.5) +#define FAN_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FAN_0_PAUSE_TIME + 0.5) +#define FAN_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * FAN_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define FAN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * FAN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + #define SPEAKER_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PULSE_TIME + 0.5) #define SPEAKER_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PAUSE_TIME + 0.5) #define SPEAKER_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * SPEAKER_1_PULSE_TIME + 0.5) @@ -388,9 +430,25 @@ #define ROOMBA_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * ROOMBA_0_PAUSE_TIME + 0.5) #define ROOMBA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * ROOMBA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define PENTAX_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * PENTAX_START_BIT_PULSE_TIME + 0.5) +#define PENTAX_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PENTAX_START_BIT_PAUSE_TIME + 0.5) +#define PENTAX_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PENTAX_REPEAT_START_BIT_PAUSE_TIME + 0.5) +#define PENTAX_PULSE_LEN (uint8_t)(F_INTERRUPTS * PENTAX_PULSE_TIME + 0.5) +#define PENTAX_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PENTAX_1_PAUSE_TIME + 0.5) +#define PENTAX_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PENTAX_0_PAUSE_TIME + 0.5) +#define PENTAX_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * PENTAX_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + +#define ACP24_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * ACP24_START_BIT_PULSE_TIME + 0.5) +#define ACP24_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * ACP24_START_BIT_PAUSE_TIME + 0.5) +#define ACP24_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * ACP24_REPEAT_START_BIT_PAUSE_TIME + 0.5) +#define ACP24_PULSE_LEN (uint8_t)(F_INTERRUPTS * ACP24_PULSE_TIME + 0.5) +#define ACP24_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * ACP24_1_PAUSE_TIME + 0.5) +#define ACP24_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * ACP24_0_PAUSE_TIME + 0.5) +#define ACP24_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * ACP24_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + static volatile uint8_t irsnd_busy = 0; static volatile uint8_t irsnd_protocol = 0; -static volatile uint8_t irsnd_buffer[6] = {0}; +static volatile uint8_t irsnd_buffer[9] = {0}; static volatile uint8_t irsnd_repeat = 0; static volatile uint8_t irsnd_is_on = FALSE; @@ -411,10 +469,29 @@ irsnd_on (void) # if defined(PIC_C18) // PIC C18 PWMon(); // 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 + +# elif defined (__AVR_XMEGA__) +# if (IRSND_OCx == IRSND_XMEGA_OC0A) // use OC0A + XMEGA_Timer.CTRLB |= (1< 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 + +# elif defined (__AVR_XMEGA__) +# if (IRSND_OCx == IRSND_XMEGA_OC0A) // use OC0A + XMEGA_Timer.CTRLB &= ~(1< +#endif + static void irsnd_set_freq (IRSND_FREQ_TYPE freq) { #ifndef ANALYZE -# if defined(PIC_C18) // PIC C18 - OpenPWM(freq); - SetDCPWM( (uint16_t) (freq * 2) + 1); // freq*2 = Duty cycles 50% - PWMoff(); +# if defined(PIC_C18) // PIC C18 or XC8 +# if defined(__12F1840) // XC8 + TRISA2=0; + PR2=freq; + CCP1M0=1; + CCP1M1=1; + CCP1M2=1; + CCP1M3=1; + DC1B0=1; + DC1B1=0; + CCPR1L = 0b01101001; + TMR2IF = 0; + TMR2ON=1; + CCP1CON &=(~0b0011); // p 197 "active high" +# else // PIC C18 + OpenPWM(freq); + SetDCPWM( (uint16_t) (freq * 2) + 1); // freq*2 = Duty cycles 50% +# endif + PWMoff(); # elif defined (ARM_STM32) // STM32 static uint32_t TimeBaseFreq = 0; @@ -545,6 +661,10 @@ irsnd_set_freq (IRSND_FREQ_TYPE freq) TIM_SetAutoreload(IRSND_TIMER, freq - 1); /* Set duty cycle */ TIM_SetCompare1(IRSND_TIMER, (freq + 1) / 2); + +# elif defined (__AVR_XMEGA__) + XMEGA_Timer.CCA = freq; + # else // AVR # if IRSND_OCx == IRSND_OC2 @@ -575,8 +695,10 @@ void irsnd_init (void) { #ifndef ANALYZE -# if defined(PIC_C18) // PIC C18 +# if defined(PIC_C18) // PIC C18 or XC8 compiler +# if ! defined(__12F1840) // only C18: OpenTimer; +# endif irsnd_set_freq (IRSND_FREQ_36_KHZ); // default frequency IRSND_PIN = 0; // set IO to outout PWMoff(); @@ -590,6 +712,7 @@ irsnd_init (void) RCC_AHBPeriphClockCmd(IRSND_PORT_RCC, ENABLE); # elif defined (ARM_STM32F10X) RCC_APB2PeriphClockCmd(IRSND_PORT_RCC, ENABLE); + // RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); // only in case of remapping, not necessary for default port-timer mapping # elif defined (ARM_STM32F4XX) RCC_AHB1PeriphClockCmd(IRSND_PORT_RCC, ENABLE); # endif @@ -607,7 +730,7 @@ irsnd_init (void) 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_PinRemapConfig(GPIO_*Remap*_TIM[IRSND_TIMER_NUMBER], ENABLE); // only in case of remapping, not necessary for default port-timer mapping # endif /* TIMx clock enable */ @@ -636,7 +759,21 @@ irsnd_init (void) TIM_OC1PreloadConfig(IRSND_TIMER, TIM_OCPreload_Enable); irsnd_set_freq (IRSND_FREQ_36_KHZ); // set default frequency -# else // AVR + +# elif defined (__AVR_XMEGA__) + IRSND_PORT &= ~(1<address, SAMSUNG_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, 16); + + 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_buffer[4] = (command & 0x00FF); // CCCCCCCC + irsnd_buffer[5] = ~(command & 0x00FF); // cccccccc + irsnd_busy = TRUE; + break; + } +#endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 case IRMP_MATSUSHITA_PROTOCOL: { @@ -901,6 +1054,18 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) break; } #endif +#if IRSND_SUPPORT_TECHNICS_PROTOCOL == 1 + case IRMP_TECHNICS_PROTOCOL: + { + command = bitsrevervse (irmp_data_p->command, TECHNICS_COMMAND_LEN); + + irsnd_buffer[0] = (command & 0x07FC) >> 3; // CCCCCCCC + irsnd_buffer[1] = ((command & 0x0007) << 5) | ((~command & 0x07C0) >> 6); // CCCccccc + irsnd_buffer[2] = (~command & 0x003F) << 2; // cccccc + irsnd_busy = TRUE; + break; + } +#endif #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 case IRMP_KASEIKYO_PROTOCOL: { @@ -1019,6 +1184,15 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) break; } #endif +#if IRSND_SUPPORT_FAN_PROTOCOL == 1 + case IRMP_FAN_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 3; // CCCCCCCC + irsnd_buffer[1] = (irmp_data_p->command & 0x0007) << 5; // CCC00000 + irsnd_busy = TRUE; + break; + } +#endif #if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 case IRMP_SPEAKER_PROTOCOL: { @@ -1190,12 +1364,73 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) #if IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 case IRMP_ROOMBA_PROTOCOL: { - irsnd_buffer[0] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC. irsnd_busy = TRUE; break; } #endif +#if IRSND_SUPPORT_PENTAX_PROTOCOL == 1 + case IRMP_PENTAX_PROTOCOL: + { + irsnd_buffer[0] = (irmp_data_p->command & 0x3F) << 2; // CCCCCC.. + irsnd_busy = TRUE; + break; + } +#endif +#if IRSND_SUPPORT_ACP24_PROTOCOL == 1 +# define ACP_SET_BIT(acp24_bitno, c, irmp_bitno) \ + do \ + { \ + if ((c) & (1<<(irmp_bitno))) \ + { \ + irsnd_buffer[((acp24_bitno)>>3)] |= 1 << (((7 - (acp24_bitno)) & 0x07)); \ + } \ + } while (0) + + case IRMP_ACP24_PROTOCOL: + { + uint16_t cmd = irmp_data_p->command; + uint8_t i; + + address = bitsrevervse (irmp_data_p->address, ACP24_ADDRESS_LEN); + + for (i = 0; i < 8; i++) + { + irsnd_buffer[i] = 0x00; // CCCCCCCC + } + + // ACP24-Frame: + // 1 2 3 4 5 6 + // 0123456789012345678901234567890123456789012345678901234567890123456789 + // N VVMMM ? ??? t vmA x y TTTT + // + // irmp_data_p->command: + // + // 5432109876543210 + // NAVVvMMMmtxyTTTT + + ACP_SET_BIT( 0, cmd, 15); + ACP_SET_BIT(24, cmd, 14); + ACP_SET_BIT( 2, cmd, 13); + ACP_SET_BIT( 3, cmd, 12); + ACP_SET_BIT(22, cmd, 11); + ACP_SET_BIT( 4, cmd, 10); + ACP_SET_BIT( 5, cmd, 9); + ACP_SET_BIT( 6, cmd, 8); + ACP_SET_BIT(23, cmd, 7); + ACP_SET_BIT(20, cmd, 6); + ACP_SET_BIT(26, cmd, 5); + ACP_SET_BIT(44, cmd, 4); + ACP_SET_BIT(66, cmd, 3); + ACP_SET_BIT(67, cmd, 2); + ACP_SET_BIT(68, cmd, 1); + ACP_SET_BIT(69, cmd, 0); + + irsnd_busy = TRUE; + break; + } +#endif + default: { break; @@ -1489,13 +1724,31 @@ irsnd_ISR (void) 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 + n_auto_repetitions = SAMSUNG32_FRAMES; // 1 frame 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_SAMSUNG48_PROTOCOL == 1 + case IRMP_SAMSUNG48_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 = SAMSUNG48_COMPLETE_DATA_LEN; + n_auto_repetitions = SAMSUNG48_FRAMES; // 1 frame + auto_repetition_pause_len = SAMSUNG48_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause + repeat_frame_pause_len = SAMSUNG48_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 case IRMP_MATSUSHITA_PROTOCOL: { @@ -1514,6 +1767,24 @@ irsnd_ISR (void) break; } #endif +#if IRSND_SUPPORT_TECHNICS_PROTOCOL == 1 + case IRMP_TECHNICS_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 = TECHNICS_COMPLETE_DATA_LEN; // here TECHNICS + 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: { @@ -1688,6 +1959,24 @@ irsnd_ISR (void) break; } #endif +#if IRSND_SUPPORT_FAN_PROTOCOL == 1 + case IRMP_FAN_PROTOCOL: + { + startbit_pulse_len = FAN_START_BIT_PULSE_LEN; + startbit_pause_len = FAN_START_BIT_PAUSE_LEN - 1; + pulse_1_len = FAN_1_PULSE_LEN; + pause_1_len = FAN_1_PAUSE_LEN - 1; + pulse_0_len = FAN_0_PULSE_LEN; + pause_0_len = FAN_0_PAUSE_LEN - 1; + has_stop_bit = FAN_STOP_BIT; + complete_data_len = FAN_COMPLETE_DATA_LEN; + n_auto_repetitions = FAN_FRAMES; // only 1 frame + auto_repetition_pause_len = FAN_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause + repeat_frame_pause_len = FAN_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } +#endif #if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 case IRMP_SPEAKER_PROTOCOL: { @@ -1933,6 +2222,42 @@ irsnd_ISR (void) irsnd_set_freq (IRSND_FREQ_38_KHZ); break; } +#endif +#if IRSND_SUPPORT_PENTAX_PROTOCOL == 1 + case IRMP_PENTAX_PROTOCOL: + { + startbit_pulse_len = PENTAX_START_BIT_PULSE_LEN; + startbit_pause_len = PENTAX_START_BIT_PAUSE_LEN; + complete_data_len = PENTAX_COMPLETE_DATA_LEN; + pulse_1_len = PENTAX_PULSE_LEN; + pause_1_len = PENTAX_1_PAUSE_LEN - 1; + pulse_0_len = PENTAX_PULSE_LEN; + pause_0_len = PENTAX_0_PAUSE_LEN - 1; + has_stop_bit = PENTAX_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = PENTAX_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif +#if IRSND_SUPPORT_ACP24_PROTOCOL == 1 + case IRMP_ACP24_PROTOCOL: + { + startbit_pulse_len = ACP24_START_BIT_PULSE_LEN; + startbit_pause_len = ACP24_START_BIT_PAUSE_LEN - 1; + complete_data_len = ACP24_COMPLETE_DATA_LEN; + pulse_1_len = ACP24_PULSE_LEN; + pause_1_len = ACP24_1_PAUSE_LEN - 1; + pulse_0_len = ACP24_PULSE_LEN; + pause_0_len = ACP24_0_PAUSE_LEN - 1; + has_stop_bit = ACP24_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = ACP24_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif default: { @@ -1968,9 +2293,15 @@ irsnd_ISR (void) case IRMP_SAMSUNG_PROTOCOL: case IRMP_SAMSUNG32_PROTOCOL: #endif +#if IRSND_SUPPORT_SAMSUNG48_PROTOCOL == 1 + case IRMP_SAMSUNG48_PROTOCOL: +#endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 case IRMP_MATSUSHITA_PROTOCOL: #endif +#if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 + case IRMP_TECHNICS_PROTOCOL: +#endif #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 case IRMP_KASEIKYO_PROTOCOL: #endif @@ -1989,6 +2320,9 @@ irsnd_ISR (void) #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 case IRMP_NUBERT_PROTOCOL: #endif +#if IRSND_SUPPORT_FAN_PROTOCOL == 1 + case IRMP_FAN_PROTOCOL: +#endif #if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 case IRMP_SPEAKER_PROTOCOL: #endif @@ -2016,13 +2350,20 @@ irsnd_ISR (void) #if IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 case IRMP_ROOMBA_PROTOCOL: #endif +#if IRSND_SUPPORT_PENTAX_PROTOCOL == 1 + case IRMP_PENTAX_PROTOCOL: +#endif +#if IRSND_SUPPORT_ACP24_PROTOCOL == 1 + case IRMP_ACP24_PROTOCOL: +#endif #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_NEC16_PROTOCOL == 1 || IRSND_SUPPORT_NEC42_PROTOCOL == 1 || \ - IRSND_SUPPORT_LGAIR_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \ + IRSND_SUPPORT_LGAIR_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || IRSND_SUPPORT_TECHNICS_PROTOCOL == 1 || \ 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_SPEAKER_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 || \ - IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 || IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 + IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_FAN_PROTOCOL == 1 || IRSND_SUPPORT_SPEAKER_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 || IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 || IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 || \ + IRSND_SUPPORT_PENTAX_PROTOCOL == 1 || IRSND_SUPPORT_ACP24_PROTOCOL == 1 { #if IRSND_SUPPORT_DENON_PROTOCOL == 1 if (irsnd_protocol == IRMP_DENON_PROTOCOL) @@ -2054,7 +2395,7 @@ irsnd_ISR (void) 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)))) ? + pause_len = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); } else if (current_bit == SAMSUNG_ADDRESS_LEN) // send SYNC bit (16th bit) @@ -2067,7 +2408,7 @@ irsnd_ISR (void) 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)))) ? + pause_len = (irsnd_buffer[cur_bit >> 3] & (1<<(7-(cur_bit & 7)))) ? (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); } } @@ -2080,7 +2421,7 @@ irsnd_ISR (void) 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)))) ? + pause_len = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); } else if (current_bit == NEC16_ADDRESS_LEN) // send SYNC bit (8th bit) @@ -2093,7 +2434,7 @@ irsnd_ISR (void) 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)))) ? + pause_len = (irsnd_buffer[cur_bit >> 3] & (1<<(7-(cur_bit & 7)))) ? (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); } } @@ -2125,7 +2466,7 @@ irsnd_ISR (void) } 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; + uint8_t cur_bit_value = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? 1 : 0; pulse_len = BANG_OLUFSEN_PULSE_LEN; if (cur_bit_value == last_bit_value) @@ -2141,7 +2482,7 @@ irsnd_ISR (void) } else #endif - if (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) + if (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) { pulse_len = pulse_1_len; pause_len = pause_1_len; @@ -2308,7 +2649,7 @@ irsnd_ISR (void) { 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; + first_pulse = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? TRUE : FALSE; } } else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL || @@ -2368,7 +2709,7 @@ irsnd_ISR (void) } } #endif - first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE; + first_pulse = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? TRUE : FALSE; } if (irsnd_protocol == IRMP_RC5_PROTOCOL)