X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/779fbc81da759376eaf8eeb8fb0fda639e376c55..a48187fa5b6eeab9fdfbcbc8f09d8e0127bd1e73:/irsnd.c diff --git a/irsnd.c b/irsnd.c index da09960..17e78f5 100644 --- a/irsnd.c +++ b/irsnd.c @@ -1,9 +1,18 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * @file irsnd.c * - * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irsnd.c,v 1.29 2011/01/18 13:02:15 fm Exp $ + * Supported mikrocontrollers: + * + * ATtiny45, ATtiny85 + * ATtiny84 + * ATmega8, ATmega16, ATmega32 + * ATmega162 + * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284 + * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P + * + * $Id: irsnd.c,v 1.48 2012/02/24 14:24:28 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 @@ -12,6 +21,13 @@ *--------------------------------------------------------------------------------------------------------------------------------------------------- */ +#if defined(__18CXX) +#define PIC_C18 // Microchip C18 +#include // basic P18 lib +#include "timers.h" // timer lib +#include "pwm.h" // pwm lib +#endif + #ifdef unix // test/debug on linux/unix #include #include @@ -30,21 +46,23 @@ #include #define F_CPU 8000000L -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; #define DEBUG #else #ifdef CODEVISION - #define COM2A0 6 - #define WGM21 1 - #define CS20 0 +#define COM2A0 6 +#define WGM21 1 +#define CS20 0 +#elif defined(PIC_C18) + //nothing to do here #else - #include - #include - #include - #include +#include +#include +#include +#include #endif // CODEVISION #endif // WIN32 @@ -54,12 +72,157 @@ typedef unsigned short uint16_t; #include "irsndconfig.h" #include "irsnd.h" +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * ATtiny pin definition of OC0A / OC0B + * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#if defined (__AVR_ATtiny84__) // ATtiny84 uses OC0A = PB2 or OC0B = PA7 +#if IRSND_OCx == IRSND_OC0A // OC0A +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 2 // OC0A +#elif IRSND_OCx == IRSND_OC0B // OC0B +#define IRSND_PORT PORTA // port A +#define IRSND_DDR DDRA // ddr A +#define IRSND_BIT 7 // OC0B +#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 PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 0 // OC0A +#elif IRSND_OCx == IRSND_OC0B // OC0B +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 1 // OC0B +#else +#error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h +#endif // IRSND_OCx + +#elif defined (__AVR_ATmega8__) // ATmega8 uses only OC2 = PB3 +#if IRSND_OCx == IRSND_OC2 // OC0A +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 3 // OC0A +#else +#error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h +#endif // IRSND_OCx + + +#elif defined (__AVR_ATmega16__) \ + || defined (__AVR_ATmega32__) // ATmega16|32 uses OC2 = PD7 +#if IRSND_OCx == IRSND_OC2 // OC2 +#define IRSND_PORT PORTD // port D +#define IRSND_DDR DDRD // ddr D +#define IRSND_BIT 7 // OC2 +#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 PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 1 // OC2 + +#elif IRSND_OCx == IRSND_OC0 // OC0 +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 0 // OC0 +#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__) \ + || defined (__AVR_ATmega644P__) \ + || defined (__AVR_ATmega1284__) \ + || defined (__AVR_ATmega1284P__) // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4 +#if IRSND_OCx == IRSND_OC2A // OC2A +#define IRSND_PORT PORTD // port D +#define IRSND_DDR DDRD // ddr D +#define IRSND_BIT 7 // OC2A +#elif IRSND_OCx == IRSND_OC2B // OC2B +#define IRSND_PORT PORTD // port D +#define IRSND_DDR DDRD // ddr D +#define IRSND_BIT 6 // OC2B +#elif IRSND_OCx == IRSND_OC0A // OC0A +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 3 // OC0A +#elif IRSND_OCx == IRSND_OC0B // OC0B +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 4 // OC0B +#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__) \ + || defined (__AVR_ATmega168__) \ + || defined (__AVR_ATmega168P__) \ + || defined (__AVR_ATmega328P__) // ATmega48|88|168|168|328 uses OC2A = PB3 or OC2B = PD3 or OC0A = PD6 or OC0B = PD5 +#if IRSND_OCx == IRSND_OC2A // OC2A +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 3 // OC2A +#elif IRSND_OCx == IRSND_OC2B // OC2B +#define IRSND_PORT PORTD // port D +#define IRSND_DDR DDRD // ddr D +#define IRSND_BIT 3 // OC2B +#elif IRSND_OCx == IRSND_OC0A // OC0A +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 6 // OC0A +#elif IRSND_OCx == IRSND_OC0B // OC0B +#define IRSND_PORT PORTD // port D +#define IRSND_DDR DDRD // ddr D +#define IRSND_BIT 5 // OC0B +#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__) +#if IRSND_OCx == IRSND_OC0 +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 0 // OC0 +#elif IRSND_OCx == IRSND_OC1A +#define IRSND_PORT PORTD // port D +#define IRSND_DDR DDRD // ddr D +#define IRSND_BIT 5 // OC1A +#elif IRSND_OCx == IRSND_OC1B +#define IRSND_PORT PORTE // port E +#define IRSND_DDR DDRE // ddr E +#define IRSND_BIT 2 // OC1E +#error Wrong value for IRSND_OCx, choose IRSND_OC0, IRSND_OC1A, or IRSND_OC1B in irsndconfig.h +#endif // IRSND_OCx + +#elif defined (PIC_C18) //Microchip C18 compiler + //Nothing here to do here -> See irsndconfig.h + +#else +#if !defined (unix) && !defined (WIN32) +#error mikrocontroller not defined, please fill in definitions here. +#endif // unix, WIN32 +#endif // __AVR... + #if IRSND_SUPPORT_NIKON_PROTOCOL == 1 -typedef uint16_t IRSND_PAUSE_LEN; + typedef uint16_t IRSND_PAUSE_LEN; #else -typedef uint8_t IRSND_PAUSE_LEN; + typedef uint8_t IRSND_PAUSE_LEN; #endif +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * IR timings + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ #define SIRCS_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME + 0.5) #define SIRCS_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME + 0.5) #define SIRCS_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME + 0.5) @@ -124,6 +287,12 @@ typedef uint8_t IRSND_PAUSE_LEN; #define DENON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! #define DENON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define THOMSON_PULSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME + 0.5) +#define THOMSON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME + 0.5) +#define THOMSON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME + 0.5) +#define THOMSON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * THOMSON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define THOMSON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * THOMSON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + #define RECS80EXT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME + 0.5) #define RECS80EXT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME + 0.5) #define RECS80EXT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME + 0.5) @@ -153,22 +322,36 @@ typedef uint8_t IRSND_PAUSE_LEN; #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME + 0.5) #define BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BANG_OLUFSEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! -#define GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_PRE_PAUSE_TIME + 0.5) -#define GRUNDIG_OR_NOKIA_BIT_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME + 0.5) +#define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME + 0.5) +#define GRUNDIG_NOKIA_IR60_BIT_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME + 0.5) #define GRUNDIG_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! #define NOKIA_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NOKIA_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! -#define GRUNDIG_OR_NOKIA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! -#define SIEMENS_START_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME + 0.5) -#define SIEMENS_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME + 0.5) -#define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define IR60_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * IR60_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define SIEMENS_START_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME + 0.5) +#define SIEMENS_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME + 0.5) +#define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + + +#ifdef PIC_C18 +#define IRSND_FREQ_30_KHZ (uint8_t) ((F_CPU / 30000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +#define IRSND_FREQ_32_KHZ (uint8_t) ((F_CPU / 32000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +#define IRSND_FREQ_36_KHZ (uint8_t) ((F_CPU / 36000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +#define IRSND_FREQ_38_KHZ (uint8_t) ((F_CPU / 38000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +#define IRSND_FREQ_40_KHZ (uint8_t) ((F_CPU / 40000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +#define IRSND_FREQ_56_KHZ (uint8_t) ((F_CPU / 56000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +#define IRSND_FREQ_455_KHZ (uint8_t) ((F_CPU / 455000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +#else // AVR +#define IRSND_FREQ_30_KHZ (uint8_t) ((F_CPU / 30000 / 2) - 1) #define IRSND_FREQ_32_KHZ (uint8_t) ((F_CPU / 32000 / 2) - 1) #define IRSND_FREQ_36_KHZ (uint8_t) ((F_CPU / 36000 / 2) - 1) #define IRSND_FREQ_38_KHZ (uint8_t) ((F_CPU / 38000 / 2) - 1) #define IRSND_FREQ_40_KHZ (uint8_t) ((F_CPU / 40000 / 2) - 1) #define IRSND_FREQ_56_KHZ (uint8_t) ((F_CPU / 56000 / 2) - 1) #define IRSND_FREQ_455_KHZ (uint8_t) ((F_CPU / 455000 / 2) - 1) +#endif #define FDC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME + 0.5) #define FDC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME + 0.5) @@ -198,14 +381,26 @@ typedef uint8_t IRSND_PAUSE_LEN; #define NIKON_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME + 0.5) #define NIKON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME + 0.5) #define NIKON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME + 0.5) -#define NIKON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! - -static volatile uint8_t irsnd_busy; -static volatile uint8_t irsnd_protocol; -static volatile uint8_t irsnd_buffer[6]; -static volatile uint8_t irsnd_repeat; +#define NIKON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + +#define LEGO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME + 0.5) +#define LEGO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME + 0.5) +#define LEGO_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_REPEAT_START_BIT_PAUSE_TIME + 0.5) +#define LEGO_PULSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_PULSE_TIME + 0.5) +#define LEGO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME + 0.5) +#define LEGO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME + 0.5) +#define LEGO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * LEGO_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_repeat = 0; static volatile uint8_t irsnd_is_on = FALSE; +#if IRSND_USE_CALLBACK == 1 +static void (*irsnd_callback_ptr) (uint8_t); +#endif // IRSND_USE_CALLBACK == 1 + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * Switch PWM on * @details Switches PWM on with a narrow spike on all 3 channels -> leds glowing @@ -217,12 +412,37 @@ irsnd_on (void) if (! irsnd_is_on) { #ifndef DEBUG -#if defined (__AVR_ATmega32__) - TCCR2 |= (1< enable PWM outout pin (0=PWM on, 1=PWM off) #else - TCCR2A |= (1< disbale PWM output pin (0=PWM on, 1=PWM off) +#else //AVR + +#if IRSND_OCx == IRSND_OC2 // use OC2 + TCCR2 &= ~(1<protocol; - irsnd_repeat = irmp_data_p->flags; + irsnd_repeat = irmp_data_p->flags & IRSND_REPETITION_MASK; switch (irsnd_protocol) { @@ -399,11 +684,10 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) 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] = (command & 0x00FF); // CCCCCCCC - + 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; } @@ -415,13 +699,35 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) 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); - irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with fix bitmask instead of inverted command - irsnd_buffer[3] = 0x8B; // 10001011 - { - irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc - } - + 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; } @@ -470,16 +776,18 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) case IRMP_KASEIKYO_PROTOCOL: { uint8_t xor; + 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); xor = ((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 << 4 | (command & 0x000F); // XXXXCCCC - irsnd_buffer[3] = 0 | (command & 0xF000) >> 12; // 0000CCCC + irsnd_buffer[3] = (genre2 << 4) | (command & 0xF000) >> 12; // ggggCCCC irsnd_buffer[4] = (command & 0x0FF0) >> 4; // CCCCCCCC xor = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; @@ -562,6 +870,17 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) break; } #endif +#if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 + 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; + } +#endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 case IRMP_NUBERT_PROTOCOL: { @@ -595,6 +914,17 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) 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); + irsnd_buffer[0] = command >> 6 | 0x01; // 1011111S (start instruction frame) + irsnd_buffer[1] = (command & 0x7F) << 1; // CCCCCCC_ (2nd frame) + + irsnd_busy = TRUE; + break; + } +#endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 case IRMP_NOKIA_PROTOCOL: { @@ -671,6 +1001,19 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) 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); + + irsnd_buffer[0] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC + irsnd_buffer[1] = ((irmp_data_p->command & 0x000F) << 4) | crc; // CCCCcccc + + irsnd_protocol = IRMP_LEGO_PROTOCOL; + irsnd_busy = TRUE; + break; + } #endif default: { @@ -681,6 +1024,12 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) return irsnd_busy; } +void +irsnd_stop (void) +{ + irsnd_repeat = 0; +} + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * ISR routine * @details ISR routine, called 10000 times per second @@ -689,31 +1038,32 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) uint8_t irsnd_ISR (void) { - static uint8_t current_bit = 0xFF; - static uint8_t pulse_counter; - static IRSND_PAUSE_LEN pause_counter; - static uint8_t startbit_pulse_len; - static IRSND_PAUSE_LEN startbit_pause_len; - static uint8_t pulse_1_len; - static uint8_t pause_1_len; - static uint8_t pulse_0_len; - static uint8_t pause_0_len; - static uint8_t has_stop_bit; - static uint8_t new_frame = TRUE; - static uint8_t complete_data_len; - static uint8_t n_auto_repetitions; // number of auto_repetitions - static uint8_t auto_repetition_counter; // auto_repetition counter - static uint16_t auto_repetition_pause_len; // pause before auto_repetition, uint16_t! - static uint16_t auto_repetition_pause_counter; // pause before auto_repetition, uint16_t! - static uint8_t n_repeat_frames; // number of repeat frames - static uint8_t repeat_counter; // repeat counter - static uint16_t repeat_frame_pause_len; // pause before repeat, uint16_t! - static uint16_t packet_repeat_pause_counter; // pause before repeat, uint16_t! + static uint8_t send_trailer = FALSE; + static uint8_t current_bit = 0xFF; + static uint8_t pulse_counter = 0; + static IRSND_PAUSE_LEN pause_counter = 0; + static uint8_t startbit_pulse_len = 0; + static IRSND_PAUSE_LEN startbit_pause_len = 0; + static uint8_t pulse_1_len = 0; + static uint8_t pause_1_len = 0; + static uint8_t pulse_0_len = 0; + static uint8_t pause_0_len = 0; + static uint8_t has_stop_bit = 0; + static uint8_t new_frame = TRUE; + static uint8_t complete_data_len = 0; + static uint8_t n_repeat_frames = 0; // number of repetition frames + static uint8_t n_auto_repetitions = 0; // number of auto_repetitions + static uint8_t auto_repetition_counter = 0; // auto_repetition counter + static uint16_t auto_repetition_pause_len = 0; // pause before auto_repetition, uint16_t! + static uint16_t auto_repetition_pause_counter = 0; // pause before auto_repetition, uint16_t! + static uint8_t repeat_counter = 0; // repeat counter + static uint16_t repeat_frame_pause_len = 0; // pause before repeat, uint16_t! + static uint16_t packet_repeat_pause_counter = 0; // pause before repeat, uint16_t! #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - static uint8_t last_bit_value; + static uint8_t last_bit_value; #endif - static uint8_t pulse_len = 0xFF; - static IRSND_PAUSE_LEN pause_len = 0xFF; + static uint8_t pulse_len = 0xFF; + static IRSND_PAUSE_LEN pause_len = 0xFF; if (irsnd_busy) { @@ -727,17 +1077,22 @@ irsnd_ISR (void) { auto_repetition_pause_counter = 0; - if (irsnd_protocol == IRMP_DENON_PROTOCOL) + 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_GRUNDIG_PROTOCOL) // n'th grundig info frame + else 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_NOKIA_PROTOCOL) // n'th nokia info frame + else 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_NOKIA_PROTOCOL) // n'th nokia frame { if (auto_repetition_counter + 1 < n_auto_repetitions) { @@ -766,7 +1121,11 @@ irsnd_ISR (void) return irsnd_busy; } } +#if 0 else if (repeat_counter > 0 && packet_repeat_pause_counter < repeat_frame_pause_len) +#else + else if (packet_repeat_pause_counter < repeat_frame_pause_len) +#endif { packet_repeat_pause_counter++; @@ -784,7 +1143,21 @@ irsnd_ISR (void) } 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; @@ -837,6 +1210,42 @@ irsnd_ISR (void) 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; + } +#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; + } +#endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 case IRMP_SAMSUNG_PROTOCOL: { @@ -1010,6 +1419,24 @@ irsnd_ISR (void) 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; + } +#endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 case IRMP_NUBERT_PROTOCOL: { @@ -1050,32 +1477,47 @@ irsnd_ISR (void) #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 case IRMP_GRUNDIG_PROTOCOL: { - startbit_pulse_len = GRUNDIG_OR_NOKIA_BIT_LEN; - startbit_pause_len = GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN - 1; - pulse_len = GRUNDIG_OR_NOKIA_BIT_LEN; - pause_len = GRUNDIG_OR_NOKIA_BIT_LEN; - has_stop_bit = GRUNDIG_OR_NOKIA_STOP_BIT; + 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_OR_NOKIA_FRAME_REPEAT_PAUSE_LEN; // 117 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_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; } #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 case IRMP_NOKIA_PROTOCOL: { - startbit_pulse_len = GRUNDIG_OR_NOKIA_BIT_LEN; - startbit_pause_len = GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN - 1; - pulse_len = GRUNDIG_OR_NOKIA_BIT_LEN; - pause_len = GRUNDIG_OR_NOKIA_BIT_LEN; - has_stop_bit = GRUNDIG_OR_NOKIA_STOP_BIT; + 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_OR_NOKIA_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + 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; } @@ -1087,7 +1529,7 @@ irsnd_ISR (void) startbit_pause_len = SIEMENS_BIT_LEN; pulse_len = SIEMENS_BIT_LEN; pause_len = SIEMENS_BIT_LEN; - has_stop_bit = SIEMENS_STOP_BIT; + 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; @@ -1152,7 +1594,6 @@ irsnd_ISR (void) auto_repetition_pause_len = 0; repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN; irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; } #endif @@ -1171,7 +1612,24 @@ irsnd_ISR (void) 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; } #endif @@ -1196,6 +1654,12 @@ irsnd_ISR (void) #if IRSND_SUPPORT_NEC_PROTOCOL == 1 case IRMP_NEC_PROTOCOL: #endif +#if IRSND_SUPPORT_NEC16_PROTOCOL == 1 + case IRMP_NEC16_PROTOCOL: +#endif +#if IRSND_SUPPORT_NEC42_PROTOCOL == 1 + case IRMP_NEC42_PROTOCOL: +#endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 case IRMP_SAMSUNG_PROTOCOL: case IRMP_SAMSUNG32_PROTOCOL: @@ -1215,6 +1679,9 @@ irsnd_ISR (void) #if IRSND_SUPPORT_DENON_PROTOCOL == 1 case IRMP_DENON_PROTOCOL: #endif +#if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 + case IRMP_THOMSON_PROTOCOL: +#endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 case IRMP_NUBERT_PROTOCOL: #endif @@ -1233,12 +1700,16 @@ irsnd_ISR (void) #if IRSND_SUPPORT_NIKON_PROTOCOL == 1 case IRMP_NIKON_PROTOCOL: #endif +#if IRSND_SUPPORT_LEGO_PROTOCOL == 1 + case IRMP_LEGO_PROTOCOL: +#endif -#if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \ +#if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_NEC16_PROTOCOL == 1 || IRSND_SUPPORT_NEC42_PROTOCOL == 1 || \ + IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_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_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_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1 { if (pulse_counter == 0) { @@ -1275,6 +1746,32 @@ irsnd_ISR (void) 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 +#endif + #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL) { @@ -1397,12 +1894,15 @@ irsnd_ISR (void) #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 case IRMP_GRUNDIG_PROTOCOL: #endif +#if IRSND_SUPPORT_IR60_PROTOCOL == 1 + case IRMP_IR60_PROTOCOL: +#endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 case IRMP_NOKIA_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_NOKIA_PROTOCOL == 1 + IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 { if (pulse_counter == pulse_len && pause_counter == pause_len) { @@ -1412,14 +1912,14 @@ irsnd_ISR (void) { current_bit = 0xFF; -#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) +#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_OR_NOKIA_FRAME_REPEAT_PAUSE_LEN; + 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 @@ -1451,11 +1951,12 @@ irsnd_ISR (void) { uint8_t first_pulse; -#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) +#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; @@ -1464,8 +1965,8 @@ irsnd_ISR (void) } else // send n'th bit { - pulse_len = GRUNDIG_OR_NOKIA_BIT_LEN; - pause_len = GRUNDIG_OR_NOKIA_BIT_LEN; + 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; } } @@ -1565,7 +2066,7 @@ irsnd_ISR (void) 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_NOKIA_PROTOCOL == 1 + // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 default: { @@ -1590,6 +2091,8 @@ irsnd_ISR (void) } else { + irsnd_busy = TRUE; //Rainer + send_trailer = TRUE; n_repeat_frames = 0; repeat_counter = 0; } @@ -1622,7 +2125,6 @@ irsnd_ISR (void) int main (int argc, char ** argv) { - int idx; int protocol; int address; int command; @@ -1659,10 +2161,6 @@ main (int argc, char ** argv) { irsnd_ISR (); } - for (idx = 0; idx < 20; idx++) - { - irsnd_ISR (); - } putchar ('\n'); }