X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/4225a882583e3f3f35b5a9ee652d204338059b61..46dd89b73055232942379e65afbb1dab5f95c445:/irsnd.c diff --git a/irsnd.c b/irsnd.c index ac616f1..fb0ac47 100644 --- a/irsnd.c +++ b/irsnd.c @@ -3,6 +3,8 @@ * * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de * + * $Id: irsnd.c,v 1.9 2010/04/28 14:58:59 fm Exp $ + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -46,43 +48,9 @@ typedef unsigned short uint16_t; #endif // unix #include "irmp.h" +#include "irsndconfig.h" #include "irsnd.h" -/*--------------------------------------------------------------------------------------------------------------------------------------------------- - * Change settings from 1 to 0 if you want to disable one or more encoders. - * This saves program space. - * 1 enable decoder - * 0 disable decoder - *--------------------------------------------------------------------------------------------------------------------------------------------------- - */ -#define IRSND_SUPPORT_SIRCS_PROTOCOL 1 // flag: support SIRCS uses ~150 bytes -#define IRSND_SUPPORT_NEC_PROTOCOL 1 // flag: support NEC uses ~100 bytes -#define IRSND_SUPPORT_SAMSUNG_PROTOCOL 1 // flag: support Samsung + Samsung32 uses ~300 bytes -#define IRSND_SUPPORT_MATSUSHITA_PROTOCOL 1 // flag: support Matsushita uses ~150 bytes -#define IRSND_SUPPORT_KASEIKYO_PROTOCOL 0 // flag: support Kaseikyo NOT SUPPORTED YET! -#define IRSND_SUPPORT_RECS80_PROTOCOL 1 // flag: support RECS80 uses ~100 bytes -#define IRSND_SUPPORT_RC5_PROTOCOL 1 // flag: support RC5 uses ~250 bytes -#define IRSND_SUPPORT_DENON_PROTOCOL 1 // flag: support DENON uses ~200 bytes -#define IRSND_SUPPORT_RC6_PROTOCOL 0 // flag: support RC6 NOT SUPPORTED YET! -#define IRSND_SUPPORT_RECS80EXT_PROTOCOL 1 // flag: support RECS80EXT uses ~100 bytes -#define IRSND_SUPPORT_NUBERT_PROTOCOL 1 // flag: support NUBERT uses ~100 bytes - - -/*--------------------------------------------------------------------------------------------------------------------------------------------------- - * Change hardware pin here: - *--------------------------------------------------------------------------------------------------------------------------------------------------- - */ -#if defined (__AVR_ATmega32__) || defined (__AVR_ATmega644P__) -#define IRSND_PORT PORTD // port D -#define IRSND_DDR DDRD // ddr D -#define IRSND_BIT 7 // OC2A -#else -#define IRSND_PORT PORTB // port B -#define IRSND_DDR DDRB // ddr B -#define IRSND_BIT 3 // OC2A -#endif // __AVR... - - #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) @@ -141,11 +109,24 @@ typedef unsigned short uint16_t; #define NUBERT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME + 0.5) #define NUBERT_REPETITION_LEN (uint16_t)(F_INTERRUPTS * NUBERT_REPETITION_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) +#define BANG_OLUFSEN_START_BIT2_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME + 0.5) +#define BANG_OLUFSEN_START_BIT2_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME + 0.5) +#define BANG_OLUFSEN_START_BIT3_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME + 0.5) +#define BANG_OLUFSEN_START_BIT3_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME + 0.5) +#define BANG_OLUFSEN_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME + 0.5) +#define BANG_OLUFSEN_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME + 0.5) +#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 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) static volatile uint8_t irsnd_busy; static volatile uint8_t irsnd_protocol; @@ -167,7 +148,7 @@ irsnd_on (void) TCCR2 |= (1<command, SIRCS_MINIMUM_DATA_LEN); - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC irsnd_buffer[1] = (command & 0x000F) << 4; // CCCC0000 irsnd_busy = TRUE; @@ -299,15 +279,25 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) #endif #if IRSND_SUPPORT_NEC_PROTOCOL == 1 case IRMP_NEC_PROTOCOL: + case IRMP_APPLE_PROTOCOL: { address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN); command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN); - irsnd_protocol = irmp_data_p->protocol; 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 + + if (irsnd_protocol == IRMP_APPLE_PROTOCOL) + { + irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with fix bitmask instead of inverted command + irsnd_buffer[3] = 0x8B; // 10001011 + } + else + { + irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc + } + irsnd_busy = TRUE; break; } @@ -318,7 +308,6 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); command = bitsrevervse (irmp_data_p->command, SAMSUNG_COMMAND_LEN); - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA irsnd_buffer[2] = (command & 0x00F0) | ((command & 0xF000) >> 12); // IIIICCCC @@ -332,7 +321,6 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); command = bitsrevervse (irmp_data_p->command, SAMSUNG32_COMMAND_LEN); - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC @@ -347,7 +335,6 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) address = bitsrevervse (irmp_data_p->address, MATSUSHITA_ADDRESS_LEN); command = bitsrevervse (irmp_data_p->command, MATSUSHITA_COMMAND_LEN); - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC irsnd_buffer[1] = ((command & 0x000F) << 4) | ((address & 0x0F00) >> 8); // CCCCAAAA irsnd_buffer[2] = (address & 0x00FF); // AAAAAAAA @@ -360,7 +347,6 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) { toggle_bit_recs80 = toggle_bit_recs80 ? 0x00 : 0x40; - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = 0x80 | toggle_bit_recs80 | ((irmp_data_p->address & 0x0007) << 3) | ((irmp_data_p->command & 0x0038) >> 3); // STAAACCC irsnd_buffer[1] = (irmp_data_p->command & 0x07) << 5; // CCC00000 @@ -373,7 +359,6 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) { toggle_bit_recs80ext = toggle_bit_recs80ext ? 0x00 : 0x40; - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = 0x80 | toggle_bit_recs80ext | ((irmp_data_p->address & 0x000F) << 2) | ((irmp_data_p->command & 0x0030) >> 4); // STAAAACC irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC0000 @@ -386,7 +371,6 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) { toggle_bit_rc5 = toggle_bit_rc5 ? 0x00 : 0x40; - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = ((irmp_data_p->command & 0x40) ? 0x00 : 0x80) | toggle_bit_rc5 | ((irmp_data_p->address & 0x001F) << 1) | ((irmp_data_p->command & 0x20) >> 5); // CTAAAAAC irsnd_buffer[1] = (irmp_data_p->command & 0x1F) << 3; // CCCCC000 @@ -397,7 +381,6 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) #if IRSND_SUPPORT_DENON_PROTOCOL == 1 case IRMP_DENON_PROTOCOL: { - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x0380) >> 7); // AAAAACCC irsnd_buffer[1] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC0 irsnd_buffer[2] = ((irmp_data_p->address & 0x1F) << 3) | (((~irmp_data_p->command) & 0x0380) >> 7); // AAAAACCC @@ -409,12 +392,21 @@ irsnd_send_data (IRMP_DATA * irmp_data_p) #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 case IRMP_NUBERT_PROTOCOL: { - irsnd_protocol = irmp_data_p->protocol; irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000 irsnd_busy = TRUE; break; } +#endif +#if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + case IRMP_BANG_OLUFSEN_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 11; // SXSCCCCC + irsnd_buffer[1] = irmp_data_p->command >> 3; // CCCCCCCC + irsnd_buffer[2] = (irmp_data_p->command & 0x0007) << 5; // CCC00000 + irsnd_busy = TRUE; + break; + } #endif default: { @@ -445,18 +437,21 @@ irsnd_ISR (void) static uint8_t has_stop_bit; static uint8_t new_frame = TRUE; static uint8_t complete_data_len; - static uint8_t n_repetitions; // number of repetitions - static uint8_t repetition_counter; // repetition counter + static uint8_t n_frames; // number of repetitions + static uint8_t frame_counter; // repetition counter static uint16_t repetition_pause; // pause before repetition, uint16_t! static uint16_t repetition_pause_counter; // pause before repetition, uint16_t! - uint8_t pulse_len = 0xFF; - uint8_t pause_len = 0xFF; +#if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + static uint8_t last_bit_value; +#endif + static uint8_t pulse_len = 0xFF; + static uint8_t pause_len = 0xFF; if (irsnd_busy) { if (current_bit == 0xFF && new_frame) // start of transmission... { - if (repetition_counter > 0) + if (frame_counter > 0) { repetition_pause_counter++; @@ -487,6 +482,9 @@ irsnd_ISR (void) } else { + pulse_counter = 0; + pause_counter = 0; + switch (irsnd_protocol) { #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 @@ -500,7 +498,7 @@ irsnd_ISR (void) pause_0_len = SIRCS_PAUSE_LEN; has_stop_bit = SIRCS_STOP_BIT; complete_data_len = SIRCS_MINIMUM_DATA_LEN; - n_repetitions = SIRCS_REPETITION_CNT; + n_frames = SIRCS_REPETITION_CNT; repetition_pause = SIRCS_REPETITION_LEN; // 45 ms pause irsnd_set_freq (IRSND_FREQ_40_KHZ); break; @@ -517,7 +515,7 @@ irsnd_ISR (void) pause_0_len = NEC_0_PAUSE_LEN; has_stop_bit = NEC_STOP_BIT; complete_data_len = NEC_COMPLETE_DATA_LEN; - n_repetitions = 1; + n_frames = 1; irsnd_set_freq (IRSND_FREQ_38_KHZ); break; } @@ -533,7 +531,7 @@ irsnd_ISR (void) pause_0_len = SAMSUNG_0_PAUSE_LEN; has_stop_bit = SAMSUNG_STOP_BIT; complete_data_len = SAMSUNG_COMPLETE_DATA_LEN; - n_repetitions = 1; + n_frames = 1; irsnd_set_freq (IRSND_FREQ_38_KHZ); break; } @@ -548,7 +546,7 @@ irsnd_ISR (void) pause_0_len = SAMSUNG_0_PAUSE_LEN; has_stop_bit = SAMSUNG_STOP_BIT; complete_data_len = SAMSUNG32_COMPLETE_DATA_LEN; - n_repetitions = 1; + n_frames = 1; irsnd_set_freq (IRSND_FREQ_38_KHZ); break; } @@ -564,7 +562,7 @@ irsnd_ISR (void) pause_0_len = MATSUSHITA_0_PAUSE_LEN; has_stop_bit = MATSUSHITA_STOP_BIT; complete_data_len = MATSUSHITA_COMPLETE_DATA_LEN; - n_repetitions = 1; + n_frames = 1; irsnd_set_freq (IRSND_FREQ_36_KHZ); break; } @@ -580,7 +578,7 @@ irsnd_ISR (void) pause_0_len = RECS80_0_PAUSE_LEN; has_stop_bit = RECS80_STOP_BIT; complete_data_len = RECS80_COMPLETE_DATA_LEN; - n_repetitions = 1; + n_frames = 1; irsnd_set_freq (IRSND_FREQ_38_KHZ); break; } @@ -596,7 +594,7 @@ irsnd_ISR (void) pause_0_len = RECS80EXT_0_PAUSE_LEN; has_stop_bit = RECS80EXT_STOP_BIT; complete_data_len = RECS80EXT_COMPLETE_DATA_LEN; - n_repetitions = 1; + n_frames = 1; irsnd_set_freq (IRSND_FREQ_38_KHZ); break; } @@ -612,7 +610,7 @@ irsnd_ISR (void) pause_0_len = RC5_BIT_LEN; has_stop_bit = RC5_STOP_BIT; complete_data_len = RC5_COMPLETE_DATA_LEN; - n_repetitions = 1; + n_frames = 1; irsnd_set_freq (IRSND_FREQ_36_KHZ); break; } @@ -628,7 +626,7 @@ irsnd_ISR (void) pause_0_len = DENON_0_PAUSE_LEN; has_stop_bit = DENON_STOP_BIT; complete_data_len = DENON_COMPLETE_DATA_LEN; - n_repetitions = 2; + n_frames = 2; repetition_pause = DENON_REPETITION_LEN; // 65 ms pause after 1st frame (15 bits) irsnd_set_freq (IRSND_FREQ_32_KHZ); break; @@ -645,11 +643,28 @@ irsnd_ISR (void) pause_0_len = NUBERT_0_PAUSE_LEN; has_stop_bit = NUBERT_STOP_BIT; complete_data_len = NUBERT_COMPLETE_DATA_LEN; - n_repetitions = 2; + n_frames = 2; repetition_pause = NUBERT_REPETITION_LEN; // 35 ms pause irsnd_set_freq (IRSND_FREQ_36_KHZ); break; } +#endif +#if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + case IRMP_BANG_OLUFSEN_PROTOCOL: + { + startbit_pulse_len = BANG_OLUFSEN_START_BIT1_PULSE_LEN; + startbit_pause_len = BANG_OLUFSEN_START_BIT1_PAUSE_LEN; + pulse_1_len = BANG_OLUFSEN_PULSE_LEN; + pause_1_len = BANG_OLUFSEN_1_PAUSE_LEN; + pulse_0_len = BANG_OLUFSEN_PULSE_LEN; + pause_0_len = BANG_OLUFSEN_0_PAUSE_LEN; + has_stop_bit = BANG_OLUFSEN_STOP_BIT; + complete_data_len = BANG_OLUFSEN_COMPLETE_DATA_LEN; + n_frames = 1; + last_bit_value = 0; + irsnd_set_freq (IRSND_FREQ_455_KHZ); + break; + } #endif default: { @@ -689,59 +704,110 @@ irsnd_ISR (void) #endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 case IRMP_NUBERT_PROTOCOL: +#endif +#if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + case IRMP_BANG_OLUFSEN_PROTOCOL: #endif { - if (current_bit == 0xFF) // send start bit + if (pulse_counter == 0) { - pulse_len = startbit_pulse_len; - pause_len = startbit_pause_len; - } - else if (current_bit < complete_data_len) // send n'th bit - { - if (irsnd_protocol == IRMP_SAMSUNG_PROTOCOL) + if (current_bit == 0xFF) // send start bit + { + pulse_len = startbit_pulse_len; + pause_len = startbit_pause_len; + } + else if (current_bit < complete_data_len) // send n'th bit { - if (current_bit < SAMSUNG_ADDRESS_LEN) // send address bits +#if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 + if (irsnd_protocol == IRMP_SAMSUNG_PROTOCOL) { - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? - SAMSUNG_1_PAUSE_LEN : SAMSUNG_0_PAUSE_LEN; + if (current_bit < SAMSUNG_ADDRESS_LEN) // send address bits + { + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? + SAMSUNG_1_PAUSE_LEN : SAMSUNG_0_PAUSE_LEN; + } + else if (current_bit == SAMSUNG_ADDRESS_LEN) // send SYNC bit (16th bit) + { + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = SAMSUNG_START_BIT_PAUSE_LEN; + } + else if (current_bit < SAMSUNG_COMPLETE_DATA_LEN) // send n'th bit + { + uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! + + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ? + SAMSUNG_1_PAUSE_LEN : SAMSUNG_0_PAUSE_LEN; + } } - else if (current_bit == SAMSUNG_ADDRESS_LEN) // send SYNC bit (16th bit) + else +#endif + +#if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL) { - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = SAMSUNG_START_BIT_PAUSE_LEN; + if (current_bit == 0) // send 2nd start bit + { + pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN; + } + else if (current_bit == 1) // send 3rd start bit + { + pulse_len = BANG_OLUFSEN_START_BIT3_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT3_PAUSE_LEN; + } + else if (current_bit == 2) // send 4th start bit + { + pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN; + } + else if (current_bit == 19) // send trailer bit + { + pulse_len = BANG_OLUFSEN_PULSE_LEN; + pause_len = BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN; + } + else if (current_bit < BANG_OLUFSEN_COMPLETE_DATA_LEN) // send n'th bit + { + uint8_t cur_bit_value = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? 1 : 0; + pulse_len = BANG_OLUFSEN_PULSE_LEN; + + if (cur_bit_value == last_bit_value) + { + pause_len = BANG_OLUFSEN_R_PAUSE_LEN; + } + else + { + pause_len = cur_bit_value ? BANG_OLUFSEN_1_PAUSE_LEN : BANG_OLUFSEN_0_PAUSE_LEN; + last_bit_value = cur_bit_value; + } + } } - else if (current_bit < SAMSUNG_COMPLETE_DATA_LEN) // send n'th bit + else +#endif + if (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) { - uint8_t cur_bit = current_bit - 1; - - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ? - SAMSUNG_1_PAUSE_LEN : SAMSUNG_0_PAUSE_LEN; + pulse_len = pulse_1_len; + pause_len = pause_1_len; + } + else + { + pulse_len = pulse_0_len; + pause_len = pause_0_len; } } - else if (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) - { - pulse_len = pulse_1_len; - pause_len = pause_1_len; - } - else + else if (has_stop_bit) // send stop bit { pulse_len = pulse_0_len; - pause_len = pause_0_len; - } - } - else if (has_stop_bit) // send stop bit - { - pulse_len = pulse_0_len; - if (repetition_counter < n_repetitions) - { - pause_len = pause_0_len; - } - else - { - pause_len = 255; // last frame: pause of 255 + if (frame_counter < n_frames) + { + pause_len = pause_0_len; + } + else + { + pause_len = 255; // last frame: pause of 255 + } } } @@ -768,12 +834,12 @@ irsnd_ISR (void) if (current_bit >= complete_data_len + has_stop_bit) { current_bit = 0xFF; - repetition_counter++; + frame_counter++; - if (repetition_counter == n_repetitions) + if (frame_counter == n_frames) { irsnd_busy = FALSE; - repetition_counter = 0; + frame_counter = 0; } new_frame = TRUE; }