X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/1f54e86cd05ee6e47b5da32107d191f0983ccf04..9c86ff1a028fc9f554a74a23e4638179b9e5a1de:/irsnd.c?ds=sidebyside diff --git a/irsnd.c b/irsnd.c index fbd6ded..f08044f 100644 --- a/irsnd.c +++ b/irsnd.c @@ -3,7 +3,16 @@ * * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irsnd.c,v 1.38 2011/05/22 21:40:53 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.45 2012/02/13 11:02:29 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 @@ -37,14 +53,16 @@ typedef unsigned short uint16_t; #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 @@ -59,12 +77,20 @@ typedef unsigned short uint16_t; * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B *--------------------------------------------------------------------------------------------------------------------------------------------------- */ -/*--------------------------------------------------------------------------------------------------------------------------------------------------- - * ATtiny pin definition of OC0A / OC0B - * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B - *--------------------------------------------------------------------------------------------------------------------------------------------------- - */ -#if defined (__AVR_ATtiny85__) // ATtiny85 uses OC0A = PB0 or OC0B = PB1 +#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 @@ -102,6 +128,7 @@ typedef unsigned short uint16_t; #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 @@ -114,7 +141,8 @@ typedef unsigned short uint16_t; || defined (__AVR_ATmega324__) \ || defined (__AVR_ATmega644__) \ || defined (__AVR_ATmega644P__) \ - || defined (__AVR_ATmega1284__) // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4 + || 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 @@ -137,10 +165,10 @@ typedef unsigned short uint16_t; #elif defined (__AVR_ATmega48__) \ || defined (__AVR_ATmega88__) \ + || defined (__AVR_ATmega88P__) \ || defined (__AVR_ATmega168__) \ || defined (__AVR_ATmega168P__) \ - || defined (__AVR_ATmega328__) \ - || defined (__AVR_ATmega328P__) // ATmega48|88|168|168P|328P uses OC2A = PB3 or OC2B = PD3 or OC0A = PD6 or OC0B = PD5 + || 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 @@ -160,6 +188,24 @@ typedef unsigned short uint16_t; #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) @@ -168,9 +214,9 @@ typedef unsigned short uint16_t; #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 /*--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -276,8 +322,8 @@ 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_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_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! @@ -286,12 +332,22 @@ typedef uint8_t IRSND_PAUSE_LEN; #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_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_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) @@ -331,10 +387,10 @@ 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; +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 @@ -352,6 +408,12 @@ irsnd_on (void) if (! irsnd_is_on) { #ifndef DEBUG + +#if defined(PIC_C18) + IRSND_PIN = 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off) +#else + + #if IRSND_OCx == IRSND_OC2 // use OC2 TCCR2 |= (1< disbale PWM output pin (0=PWM on, 1=PWM off) +#else //AVR + #if IRSND_OCx == IRSND_OC2 // use OC2 TCCR2 &= ~(1<> 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; } @@ -615,13 +698,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; } @@ -670,16 +775,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]; @@ -919,26 +1026,27 @@ irsnd_stop (void) 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 send_trailer = FALSE; + static uint8_t current_bit = 0;// 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; - static uint8_t n_repeat_frames; // number of repetition frames - 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 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 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; #endif @@ -1018,6 +1126,15 @@ 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) @@ -1077,6 +1194,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: { @@ -1472,6 +1625,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: @@ -1517,7 +1676,8 @@ irsnd_ISR (void) #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_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1 @@ -1557,6 +1717,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) { @@ -1872,6 +2058,8 @@ irsnd_ISR (void) } else { + irsnd_busy = TRUE; //Rainer + send_trailer = TRUE; n_repeat_frames = 0; repeat_counter = 0; } @@ -1904,7 +2092,6 @@ irsnd_ISR (void) int main (int argc, char ** argv) { - int idx; int protocol; int address; int command; @@ -1942,11 +2129,6 @@ main (int argc, char ** argv) irsnd_ISR (); } - for (idx = 0; idx < 20; idx++) - { - irsnd_ISR (); - } - putchar ('\n'); } else