X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/31c1f035d79f12406325e9c0b1f680cdb5bae435..4a7dc859e27ad629f32a77237b6e6af4fb714603:/irsnd.c diff --git a/irsnd.c b/irsnd.c index fb7e449..554e264 100644 --- a/irsnd.c +++ b/irsnd.c @@ -1,9 +1,19 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * @file irsnd.c * - * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2010-2013 Frank Meyer - frank(at)fli4l.de * - * $Id: irsnd.c,v 1.36 2011/04/20 09:09:48 fm Exp $ + * Supported mikrocontrollers: + * + * ATtiny87, ATtiny167 + * ATtiny45, ATtiny85 + * ATtiny44 ATtiny84 + * ATmega8, ATmega16, ATmega32 + * ATmega162 + * 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 $ * * 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,119 +22,145 @@ *--------------------------------------------------------------------------------------------------------------------------------------------------- */ -#ifdef unix // test/debug on linux/unix -#include -#include -#include -#include -#include - -#define DEBUG -#define F_CPU 8000000L - -#else // not unix: - -#ifdef WIN32 // test/debug on windows -#include -#include -#include - -#define F_CPU 8000000L -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -#define DEBUG - -#else - -#ifdef CODEVISION - #define COM2A0 6 - #define WGM21 1 - #define CS20 0 -#else - #include - #include - #include - #include -#endif // CODEVISION - -#endif // WIN32 -#endif // unix - -#include "irmp.h" -#include "irsndconfig.h" #include "irsnd.h" +#ifndef F_CPU +# error F_CPU unkown +#endif + /*--------------------------------------------------------------------------------------------------------------------------------------------------- - * ATmega pin definition of OC2 / OC2A / OC2B + * ATtiny pin definition of OC0A / OC0B + * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B *--------------------------------------------------------------------------------------------------------------------------------------------------- */ -#if defined (__AVR_ATmega8__) // ATmega8 uses OC2 = PB3 -#undef IRSND_OC2 // has no OC2A / OC2B -#define IRSND_OC2 0 // magic: use OC2 -#define IRSND_PORT PORTB // port B -#define IRSND_DDR DDRB // ddr B -#define IRSND_BIT 3 // OC2A - -#elif defined (__AVR_ATmega16__) \ - || defined (__AVR_ATmega32__) // ATmega16|32 uses OC2 = PD7 -#undef IRSND_OC2 // has no OC2A / OC2B -#define IRSND_OC2 0 // magic: use OC2 -#define IRSND_PORT PORTD // port D -#define IRSND_DDR DDRD // ddr D -#define IRSND_BIT 7 // OC2 - -#elif defined (__AVR_ATmega162__) // ATmega162 uses OC2 = PB1 -#undef IRSND_OC2 // has no OC2A / OC2B -#define IRSND_OC2 0 // magic: use OC2 -#define IRSND_PORT PORTB // port B -#define IRSND_DDR DDRB // ddr B -#define IRSND_BIT 1 // OC2 - +#if defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny84__) // ATtiny44/84 uses OC0A = PB2 or OC0B = PA7 +# if IRSND_OCx == IRSND_OC0A // OC0A +# define IRSND_PORT_LETTER B +# define IRSND_BIT_NUMBER 2 +# elif IRSND_OCx == IRSND_OC0B // OC0B +# define IRSND_PORT_LETTER A +# define IRSND_BIT_NUMBER 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 +# define IRSND_BIT_NUMBER 0 +# elif IRSND_OCx == IRSND_OC0B // OC0B +# define IRSND_PORT_LETTER B +# define IRSND_BIT_NUMBER 1 +# 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 +# define IRSND_BIT_NUMBER 2 +# 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 +# define IRSND_BIT_NUMBER 3 +# 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_LETTER D +# define IRSND_BIT_NUMBER 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 +# define IRSND_BIT_NUMBER 1 +# elif IRSND_OCx == IRSND_OC0 // OC0 +# define IRSND_PORT_LETTER B +# define IRSND_BIT_NUMBER 0 +# 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__) // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 -#if IRSND_OC2 == 1 // OC2A -#define IRSND_PORT PORTD // port D -#define IRSND_DDR DDRD // ddr D -#define IRSND_BIT 7 // OC2A -#elif IRSND_OC2 == 2 // OC2B -#define IRSND_PORT PORTD // port D -#define IRSND_DDR DDRD // ddr D -#define IRSND_BIT 6 // OC2B -#else -#error Wrong value for IRSND_OC2, choose 1 or 2 in irsndconfig.h -#endif // IRSND_OC2 - + || 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_LETTER D +# define IRSND_BIT_NUMBER 7 +# elif IRSND_OCx == IRSND_OC2B // OC2B +# define IRSND_PORT_LETTER D +# define IRSND_BIT_NUMBER 6 +# elif IRSND_OCx == IRSND_OC0A // OC0A +# define IRSND_PORT_LETTER B +# define IRSND_BIT_NUMBER 3 +# elif IRSND_OCx == IRSND_OC0B // OC0B +# define IRSND_PORT_LETTER B +# define IRSND_BIT_NUMBER 4 +# 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_ATmega168__) \ - || defined (__AVR_ATmega328__) \ - || defined (__AVR_ATmega328P__) // ATmega48|88|168|328P uses OC2A = PB3 or OC2B = PD3 -#if IRSND_OC2 == 1 // OC2A -#define IRSND_PORT PORTB // port B -#define IRSND_DDR DDRB // ddr B -#define IRSND_BIT 3 // OC2A -#elif IRSND_OC2 == 2 // OC2B -#define IRSND_PORT PORTD // port D -#define IRSND_DDR DDRD // ddr D -#define IRSND_BIT 3 // OC2B + || 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_LETTER B +# define IRSND_BIT_NUMBER 3 +# elif IRSND_OCx == IRSND_OC2B // OC2B +# define IRSND_PORT_LETTER D +# define IRSND_BIT_NUMBER 3 +# elif IRSND_OCx == IRSND_OC0A // OC0A +# define IRSND_PORT_LETTER D +# define IRSND_BIT_NUMBER 6 +# elif IRSND_OCx == IRSND_OC0B // OC0B +# define IRSND_PORT_LETTER D +# define IRSND_BIT_NUMBER 5 +# 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 +# define IRSND_BIT_NUMBER 0 +# elif IRSND_OCx == IRSND_OC1A +# define IRSND_PORT_LETTER D +# define IRSND_BIT_NUMBER 5 +# elif IRSND_OCx == IRSND_OC1B +# define IRSND_PORT_LETTER E +# define IRSND_BIT_NUMBER 2 +# else +# 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 +#elif defined (ARM_STM32) //STM32 + //Nothing here to do here -> See irsndconfig.h #else -#error Wrong value for IRSND_OC2, choose 1 or 2 in irsndconfig.h -#endif // IRSND_OC2 - -#else -#if !defined (unix) && !defined (WIN32) -#error OC2A/OC2B not defined, please fill in definitions here. -#endif // unix, WIN32 +# if !defined (unix) && !defined (WIN32) +# error mikrocontroller not defined, please fill in definitions here. +# endif // unix, WIN32 #endif // __AVR... +#if defined(ATMEL_AVR) +# define _CONCAT(a,b) a##b +# define CONCAT(a,b) _CONCAT(a,b) +# define IRSND_PORT CONCAT(PORT, IRSND_PORT_LETTER) +# define IRSND_DDR CONCAT(DDR, IRSND_PORT_LETTER) +# define IRSND_BIT IRSND_BIT_NUMBER +#endif + #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 /*--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -136,8 +172,8 @@ typedef uint8_t IRSND_PAUSE_LEN; #define SIRCS_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME + 0.5) #define SIRCS_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME + 0.5) #define SIRCS_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME + 0.5) -#define SIRCS_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! -#define SIRCS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define SIRCS_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define SIRCS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define NEC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME + 0.5) #define NEC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME + 0.5) @@ -145,62 +181,76 @@ typedef uint8_t IRSND_PAUSE_LEN; #define NEC_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME + 0.5) #define NEC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME + 0.5) #define NEC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME + 0.5) -#define NEC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define NEC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define SAMSUNG_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME + 0.5) #define SAMSUNG_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME + 0.5) #define SAMSUNG_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME + 0.5) #define SAMSUNG_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME + 0.5) #define SAMSUNG_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME + 0.5) -#define SAMSUNG_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define SAMSUNG_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! -#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 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 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) #define MATSUSHITA_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME + 0.5) #define MATSUSHITA_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME + 0.5) -#define MATSUSHITA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * MATSUSHITA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define MATSUSHITA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * MATSUSHITA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define KASEIKYO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME + 0.5) #define KASEIKYO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME + 0.5) #define KASEIKYO_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME + 0.5) #define KASEIKYO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME + 0.5) #define KASEIKYO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME + 0.5) -#define KASEIKYO_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! -#define KASEIKYO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define KASEIKYO_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define KASEIKYO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define RECS80_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME + 0.5) #define RECS80_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME + 0.5) #define RECS80_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME + 0.5) #define RECS80_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME + 0.5) #define RECS80_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME + 0.5) -#define RECS80_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define RECS80_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define RC5_START_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5) #define RC5_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5) -#define RC5_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC5_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define RC5_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC5_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define RC6_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME + 0.5) #define RC6_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME + 0.5) #define RC6_TOGGLE_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME + 0.5) #define RC6_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_BIT_TIME + 0.5) -#define RC6_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC6_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define RC6_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC6_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define DENON_PULSE_LEN (uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME + 0.5) #define DENON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME + 0.5) #define DENON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME + 0.5) -#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 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) #define RECS80EXT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME + 0.5) #define RECS80EXT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME + 0.5) -#define RECS80EXT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80EXT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define RECS80EXT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80EXT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + +#define TELEFUNKEN_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * TELEFUNKEN_START_BIT_PULSE_TIME + 0.5) +#define TELEFUNKEN_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * TELEFUNKEN_START_BIT_PAUSE_TIME + 0.5) +#define TELEFUNKEN_PULSE_LEN (uint8_t)(F_INTERRUPTS * TELEFUNKEN_PULSE_TIME + 0.5) +#define TELEFUNKEN_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * TELEFUNKEN_1_PAUSE_TIME + 0.5) +#define TELEFUNKEN_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * TELEFUNKEN_0_PAUSE_TIME + 0.5) +#define TELEFUNKEN_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * TELEFUNKEN_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define TELEFUNKEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * TELEFUNKEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define NUBERT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME + 0.5) #define NUBERT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME + 0.5) @@ -208,8 +258,17 @@ typedef uint8_t IRSND_PAUSE_LEN; #define NUBERT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME + 0.5) #define NUBERT_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME + 0.5) #define NUBERT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME + 0.5) -#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 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 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) +#define SPEAKER_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SPEAKER_1_PAUSE_TIME + 0.5) +#define SPEAKER_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * SPEAKER_0_PULSE_TIME + 0.5) +#define SPEAKER_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SPEAKER_0_PAUSE_TIME + 0.5) +#define SPEAKER_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SPEAKER_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define SPEAKER_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SPEAKER_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define BANG_OLUFSEN_START_BIT1_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME + 0.5) #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME + 0.5) @@ -222,24 +281,59 @@ typedef uint8_t IRSND_PAUSE_LEN; #define BANG_OLUFSEN_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME + 0.5) #define BANG_OLUFSEN_R_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME + 0.5) #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 BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BANG_OLUFSEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! -#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_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_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_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! - -#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) +#define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + +#define RUWIDO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME + 0.5) +#define RUWIDO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME + 0.5) +#define RUWIDO_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME + 0.5) +#define RUWIDO_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME + 0.5) +#define RUWIDO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + +#ifdef PIC_C18 // PIC C18 +# define IRSND_FREQ_TYPE uint8_t +# define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 30000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +# define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 32000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +# define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 36000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +# define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 38000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +# define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 40000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +# define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 56000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +# define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 455000 / 2 / Pre_Scaler / PIC_Scaler) - 1) +#elif defined (ARM_STM32) // STM32 +# define IRSND_FREQ_TYPE uint32_t +# define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) (30000) +# define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) (32000) +# define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) (36000) +# define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) (38000) +# define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) (40000) +# define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) (56000) +# define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) (455000) +#else // AVR +# if F_CPU >= 16000000L +# define AVR_PRESCALER 8 +# else +# define AVR_PRESCALER 1 +# endif +# define IRSND_FREQ_TYPE uint8_t +# define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 30000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 32000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 36000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 38000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 40000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 56000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 455000 / AVR_PRESCALER / 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) @@ -279,10 +373,25 @@ typedef uint8_t IRSND_PAUSE_LEN; #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; -static volatile uint8_t irsnd_protocol; -static volatile uint8_t irsnd_buffer[6]; -static volatile uint8_t irsnd_repeat; +#define A1TVBOX_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PULSE_TIME + 0.5) +#define A1TVBOX_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PAUSE_TIME + 0.5) +#define A1TVBOX_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PULSE_TIME + 0.5) +#define A1TVBOX_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PAUSE_TIME + 0.5) +#define A1TVBOX_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * A1TVBOX_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define A1TVBOX_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * A1TVBOX_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + +#define ROOMBA_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PULSE_TIME + 0.5) +#define ROOMBA_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PAUSE_TIME + 0.5) +#define ROOMBA_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * ROOMBA_1_PULSE_TIME + 0.5) +#define ROOMBA_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * ROOMBA_0_PULSE_TIME + 0.5) +#define ROOMBA_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * ROOMBA_1_PAUSE_TIME + 0.5) +#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! + +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 @@ -291,7 +400,6 @@ static void (*irsnd_callback_ptr) (uint8_t); /*--------------------------------------------------------------------------------------------------------------------------------------------------- * Switch PWM on - * @details Switches PWM on with a narrow spike on all 3 channels -> leds glowing *--------------------------------------------------------------------------------------------------------------------------------------------------- */ static void @@ -299,15 +407,32 @@ irsnd_on (void) { if (! irsnd_is_on) { -#ifndef DEBUG -#if IRSND_OC2 == 0 // use OC2 - TCCR2 |= (1< 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 +# else // AVR +# if IRSND_OCx == IRSND_OC2 // use OC2 + TCCR2 |= (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 +# 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; + } +# else + 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; + + /* 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 +# elif IRSND_OCx == IRSND_OC2A // use OC2A + 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! +# elif IRSND_OCx == IRSND_OC0 // use OC0 + OCR0 = freq; // use register OCR2 for OC2 +# elif IRSND_OCx == IRSND_OC0A // use OC0A + 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! +# else +# error wrong value of IRSND_OCx +# endif +# endif //PIC_C18 +#endif // ANALYZE } /*--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -377,20 +574,106 @@ irsnd_set_freq (uint8_t freq) void irsnd_init (void) { -#ifndef DEBUG - IRSND_PORT &= ~(1<= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14)) + RCC_APB1PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); +# else + 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 +# else // AVR + IRSND_PORT &= ~(1<protocol; - irsnd_repeat = irmp_data_p->flags; + irsnd_repeat = irmp_data_p->flags & IRSND_REPETITION_MASK; switch (irsnd_protocol) { #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 case IRMP_SIRCS_PROTOCOL: { - uint8_t sircs_additional_command_len; + // 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_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_command_len = sircs_additional_bitlen; sircs_additional_address_len = 0; } @@ -510,11 +796,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; } @@ -526,13 +811,52 @@ 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; + } +#endif +#if IRSND_SUPPORT_LGAIR_PROTOCOL == 1 + case IRMP_LGAIR_PROTOCOL: + { + address = irmp_data_p->address; + command = irmp_data_p->command; + + irsnd_buffer[0] = ( (address & 0x00FF)); // AAAAAAAA + irsnd_buffer[1] = ( (command & 0xFF00) >> 8); // CCCCCCCC + irsnd_buffer[2] = ( (command & 0x00FF)); // CCCCCCCC + irsnd_buffer[3] = (( ((command & 0xF000) >> 12) + // checksum + ((command & 0x0F00) >> 8) + + ((command & 0x00F0) >>4 ) + + ((command & 0x000F))) & 0x000F) << 4; irsnd_busy = TRUE; break; } @@ -580,22 +904,24 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 case IRMP_KASEIKYO_PROTOCOL: { - uint8_t xor; + 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); - xor = ((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 << 4 | (command & 0x000F); // XXXXCCCC - irsnd_buffer[3] = 0 | (command & 0xF000) >> 12; // 0000CCCC + 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 = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; + xor_value = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; - irsnd_buffer[5] = xor; + irsnd_buffer[5] = xor_value; irsnd_busy = TRUE; break; } @@ -667,8 +993,19 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) { 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_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; + + 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; } @@ -682,6 +1019,15 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) break; } #endif +#if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 + case IRMP_SPEAKER_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: { @@ -695,7 +1041,7 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 case IRMP_GRUNDIG_PROTOCOL: { - command = bitsrevervse (irmp_data_p->command, GRUNDIG_COMMAND_LEN); + command = bitsrevervse (irmp_data_p->command, TELEFUNKEN_COMMAND_LEN); irsnd_buffer[0] = 0xFF; // S1111111 (1st frame) irsnd_buffer[1] = 0xC0; // 11 @@ -706,6 +1052,32 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) break; } #endif +#if IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 + case IRMP_TELEFUNKEN_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 7; // CCCCCCCC + irsnd_buffer[1] = (irmp_data_p->command << 1) & 0xff; // CCCCCCC + + 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); +#if 0 + 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) +#endif + + irsnd_busy = TRUE; + break; + } +#endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 case IRMP_NOKIA_PROTOCOL: { @@ -726,14 +1098,24 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) #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 + irsnd_buffer[0] = ((irmp_data_p->address & 0x07FF) >> 3); // AAAAAAAA + irsnd_buffer[1] = ((irmp_data_p->address & 0x0007) << 5) | ((irmp_data_p->command >> 5) & 0x1F); // AAACCCCC + irsnd_buffer[2] = ((irmp_data_p->command & 0x001F) << 3) | ((~irmp_data_p->command & 0x01) << 2); // CCCCCc irsnd_busy = TRUE; break; } #endif +#if IRSND_SUPPORT_RUWIDO_PROTOCOL == 1 + case IRMP_RUWIDO_PROTOCOL: + { + irsnd_buffer[0] = ((irmp_data_p->address & 0x01FF) >> 1); // AAAAAAAA + irsnd_buffer[1] = ((irmp_data_p->address & 0x0001) << 7) | ((irmp_data_p->command & 0x7F)); // ACCCCCCC + irsnd_buffer[2] = ((~irmp_data_p->command & 0x01) << 7); // c + irsnd_busy = TRUE; + break; + } +#endif #if IRSND_SUPPORT_FDC_PROTOCOL == 1 case IRMP_FDC_PROTOCOL: { @@ -790,8 +1172,26 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) 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 +#if IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 + case IRMP_ROOMBA_PROTOCOL: + { - irsnd_protocol = IRMP_LEGO_PROTOCOL; + irsnd_buffer[0] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC. irsnd_busy = TRUE; break; } @@ -805,6 +1205,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 @@ -813,31 +1219,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) { @@ -847,21 +1254,43 @@ irsnd_ISR (void) { 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--; + } +#endif + if (auto_repetition_pause_counter >= auto_repetition_pause_len) { auto_repetition_pause_counter = 0; - if (irsnd_protocol == IRMP_DENON_PROTOCOL) +#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_GRUNDIG_PROTOCOL) // n'th grundig info frame + 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_NOKIA_PROTOCOL) // n'th nokia info frame + 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 +#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) { @@ -874,10 +1303,15 @@ irsnd_ISR (void) complete_data_len = NOKIA_COMPLETE_DATA_LEN; } } + else +#endif + { + ; + } } else { -#ifdef DEBUG +#ifdef ANALYZE if (irsnd_is_on) { putchar ('0'); @@ -890,11 +1324,10 @@ irsnd_ISR (void) return irsnd_busy; } } - else if (repeat_counter > 0 && packet_repeat_pause_counter < repeat_frame_pause_len) + else if (packet_repeat_pause_counter < repeat_frame_pause_len) { packet_repeat_pause_counter++; - -#ifdef DEBUG +#ifdef ANALYZE if (irsnd_is_on) { putchar ('0'); @@ -908,7 +1341,20 @@ 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; @@ -961,6 +1407,60 @@ 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_LGAIR_PROTOCOL == 1 + case IRMP_LGAIR_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 = LGAIR_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: { @@ -1068,6 +1568,24 @@ irsnd_ISR (void) break; } #endif +#if IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 + case IRMP_TELEFUNKEN_PROTOCOL: + { + startbit_pulse_len = TELEFUNKEN_START_BIT_PULSE_LEN; + startbit_pause_len = TELEFUNKEN_START_BIT_PAUSE_LEN - 1; + pulse_1_len = TELEFUNKEN_PULSE_LEN; + pause_1_len = TELEFUNKEN_1_PAUSE_LEN - 1; + pulse_0_len = TELEFUNKEN_PULSE_LEN; + pause_0_len = TELEFUNKEN_0_PAUSE_LEN - 1; + has_stop_bit = TELEFUNKEN_STOP_BIT; + complete_data_len = TELEFUNKEN_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frames + auto_repetition_pause_len = 0; // TELEFUNKEN_AUTO_REPETITION_PAUSE_LEN; // xx ms pause + repeat_frame_pause_len = TELEFUNKEN_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 case IRMP_RC5_PROTOCOL: { @@ -1134,6 +1652,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: { @@ -1152,6 +1688,24 @@ irsnd_ISR (void) break; } #endif +#if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 + case IRMP_SPEAKER_PROTOCOL: + { + startbit_pulse_len = SPEAKER_START_BIT_PULSE_LEN; + startbit_pause_len = SPEAKER_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SPEAKER_1_PULSE_LEN; + pause_1_len = SPEAKER_1_PAUSE_LEN - 1; + pulse_0_len = SPEAKER_0_PULSE_LEN; + pause_0_len = SPEAKER_0_PAUSE_LEN - 1; + has_stop_bit = SPEAKER_STOP_BIT; + complete_data_len = SPEAKER_COMPLETE_DATA_LEN; + n_auto_repetitions = SPEAKER_FRAMES; // 2 frames + auto_repetition_pause_len = SPEAKER_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause + repeat_frame_pause_len = SPEAKER_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 case IRMP_BANG_OLUFSEN_PROTOCOL: { @@ -1182,9 +1736,24 @@ irsnd_ISR (void) 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 + 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 @@ -1197,9 +1766,9 @@ irsnd_ISR (void) 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 + 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; } @@ -1212,7 +1781,7 @@ irsnd_ISR (void) 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; + complete_data_len = SIEMENS_COMPLETE_DATA_LEN; n_auto_repetitions = 1; // 1 frame auto_repetition_pause_len = 0; repeat_frame_pause_len = SIEMENS_FRAME_REPEAT_PAUSE_LEN; @@ -1220,6 +1789,22 @@ irsnd_ISR (void) break; } #endif +#if IRSND_SUPPORT_RUWIDO_PROTOCOL == 1 + case IRMP_RUWIDO_PROTOCOL: + { + startbit_pulse_len = RUWIDO_START_BIT_PULSE_LEN; + startbit_pause_len = RUWIDO_START_BIT_PAUSE_LEN; + pulse_len = RUWIDO_BIT_PULSE_LEN; + pause_len = RUWIDO_BIT_PAUSE_LEN; + has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT; + complete_data_len = RUWIDO_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RUWIDO_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } +#endif #if IRSND_SUPPORT_FDC_PROTOCOL == 1 case IRMP_FDC_PROTOCOL: { @@ -1276,7 +1861,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 @@ -1284,7 +1868,7 @@ irsnd_ISR (void) case IRMP_NIKON_PROTOCOL: { startbit_pulse_len = NIKON_START_BIT_PULSE_LEN; - startbit_pause_len = 271 - 1; // NIKON_START_BIT_PAUSE_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; @@ -1295,7 +1879,6 @@ 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 @@ -1316,6 +1899,40 @@ irsnd_ISR (void) 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 +#if IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 + case IRMP_ROOMBA_PROTOCOL: + { + startbit_pulse_len = ROOMBA_START_BIT_PULSE_LEN; + startbit_pause_len = ROOMBA_START_BIT_PAUSE_LEN; + pulse_1_len = ROOMBA_1_PULSE_LEN; + pause_1_len = ROOMBA_1_PAUSE_LEN - 1; + pulse_0_len = ROOMBA_0_PULSE_LEN; + pause_0_len = ROOMBA_0_PAUSE_LEN - 1; + has_stop_bit = ROOMBA_STOP_BIT; + complete_data_len = ROOMBA_COMPLETE_DATA_LEN; + n_auto_repetitions = ROOMBA_FRAMES; // 8 frames + auto_repetition_pause_len = ROOMBA_FRAME_REPEAT_PAUSE_LEN; + repeat_frame_pause_len = ROOMBA_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif default: { @@ -1338,6 +1955,15 @@ 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_LGAIR_PROTOCOL == 1 + case IRMP_LGAIR_PROTOCOL: +#endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 case IRMP_SAMSUNG_PROTOCOL: case IRMP_SAMSUNG32_PROTOCOL: @@ -1354,12 +1980,18 @@ irsnd_ISR (void) #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 case IRMP_RECS80EXT_PROTOCOL: #endif +#if IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 + case IRMP_TELEFUNKEN_PROTOCOL: +#endif #if IRSND_SUPPORT_DENON_PROTOCOL == 1 case IRMP_DENON_PROTOCOL: #endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 case IRMP_NUBERT_PROTOCOL: #endif +#if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 + case IRMP_SPEAKER_PROTOCOL: +#endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 case IRMP_BANG_OLUFSEN_PROTOCOL: #endif @@ -1378,13 +2010,35 @@ irsnd_ISR (void) #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 case IRMP_LEGO_PROTOCOL: #endif +#if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 + case IRMP_THOMSON_PROTOCOL: +#endif +#if IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 + case IRMP_ROOMBA_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_LGAIR_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_LEGO_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 { +#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 @@ -1420,6 +2074,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) { @@ -1539,15 +2219,31 @@ irsnd_ISR (void) #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 case IRMP_SIEMENS_PROTOCOL: #endif +#if IRSND_SUPPORT_RUWIDO_PROTOCOL == 1 + case IRMP_RUWIDO_PROTOCOL: +#endif #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_A1TVBOX_PROTOCOL == 1 + 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_NOKIA_PROTOCOL == 1 +#if IRSND_SUPPORT_RC5_PROTOCOL == 1 || \ + IRSND_SUPPORT_RC6_PROTOCOL == 1 || \ + IRSND_SUPPORT_RC6A_PROTOCOL == 1 || \ + IRSND_SUPPORT_RUWIDO_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) { @@ -1557,8 +2253,8 @@ 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++; @@ -1596,11 +2292,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; @@ -1615,7 +2312,7 @@ irsnd_ISR (void) } } else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL || - // irsnd_protocol == IRMP_SIEMENS_PROTOCOL) + // irsnd_protocol == IRMP_SIEMENS_PROTOCOL || irsnd_protocol == IRMP_RUWIDO_PROTOCOL) #endif { if (current_bit == 0xFF) // 1 start bit @@ -1626,7 +2323,19 @@ irsnd_ISR (void) 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 @@ -1670,6 +2379,8 @@ irsnd_ISR (void) 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) @@ -1689,6 +2400,8 @@ irsnd_ISR (void) } 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) @@ -1710,7 +2423,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_RUWIDO_PROTOCOL == 1 || IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 default: { @@ -1735,13 +2448,15 @@ irsnd_ISR (void) } else { + irsnd_busy = TRUE; //Rainer + send_trailer = TRUE; n_repeat_frames = 0; repeat_counter = 0; } } } -#ifdef DEBUG +#ifdef ANALYZE if (irsnd_is_on) { putchar ('0'); @@ -1755,7 +2470,7 @@ irsnd_ISR (void) return irsnd_busy; } -#ifdef DEBUG +#ifdef ANALYZE // main function - for unix/linux + windows only! // AVR: see main.c! @@ -1767,7 +2482,6 @@ irsnd_ISR (void) int main (int argc, char ** argv) { - int idx; int protocol; int address; int command; @@ -1804,12 +2518,19 @@ main (int argc, char ** argv) { irsnd_ISR (); } - for (idx = 0; idx < 20; idx++) + + putchar ('\n'); + +#if 1 // enable here to send twice + (void) irsnd_send_data (&irmp_data, TRUE); + + while (irsnd_busy) { irsnd_ISR (); } putchar ('\n'); +#endif } else { @@ -1819,4 +2540,4 @@ main (int argc, char ** argv) return 0; } -#endif // DEBUG +#endif // ANALYZE