1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
4 * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de
6 * $Id: irsnd.c,v 1.32 2011/02/22 17:05:57 fm Exp $
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *---------------------------------------------------------------------------------------------------------------------------------------------------
15 #ifdef unix // test/debug on linux/unix
23 #define F_CPU 8000000L
27 #ifdef WIN32 // test/debug on windows
32 #define F_CPU 8000000L
33 typedef unsigned char uint8_t;
34 typedef unsigned short uint16_t;
46 #include <util/delay.h>
47 #include <avr/pgmspace.h>
54 #include "irsndconfig.h"
57 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
58 typedef uint16_t IRSND_PAUSE_LEN
;
60 typedef uint8_t IRSND_PAUSE_LEN
;
63 #define SIRCS_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME + 0.5)
64 #define SIRCS_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME + 0.5)
65 #define SIRCS_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME + 0.5)
66 #define SIRCS_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME + 0.5)
67 #define SIRCS_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME + 0.5)
68 #define SIRCS_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
69 #define SIRCS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
71 #define NEC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME + 0.5)
72 #define NEC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME + 0.5)
73 #define NEC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME + 0.5)
74 #define NEC_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME + 0.5)
75 #define NEC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME + 0.5)
76 #define NEC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME + 0.5)
77 #define NEC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
79 #define SAMSUNG_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME + 0.5)
80 #define SAMSUNG_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME + 0.5)
81 #define SAMSUNG_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME + 0.5)
82 #define SAMSUNG_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME + 0.5)
83 #define SAMSUNG_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME + 0.5)
84 #define SAMSUNG_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
86 #define SAMSUNG32_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
87 #define SAMSUNG32_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
89 #define MATSUSHITA_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME + 0.5)
90 #define MATSUSHITA_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME + 0.5)
91 #define MATSUSHITA_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME + 0.5)
92 #define MATSUSHITA_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME + 0.5)
93 #define MATSUSHITA_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME + 0.5)
94 #define MATSUSHITA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * MATSUSHITA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
96 #define KASEIKYO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME + 0.5)
97 #define KASEIKYO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME + 0.5)
98 #define KASEIKYO_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME + 0.5)
99 #define KASEIKYO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME + 0.5)
100 #define KASEIKYO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME + 0.5)
101 #define KASEIKYO_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
102 #define KASEIKYO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
104 #define RECS80_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME + 0.5)
105 #define RECS80_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME + 0.5)
106 #define RECS80_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME + 0.5)
107 #define RECS80_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME + 0.5)
108 #define RECS80_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME + 0.5)
109 #define RECS80_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
111 #define RC5_START_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5)
112 #define RC5_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5)
113 #define RC5_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC5_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
115 #define RC6_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME + 0.5)
116 #define RC6_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME + 0.5)
117 #define RC6_TOGGLE_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME + 0.5)
118 #define RC6_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_BIT_TIME + 0.5)
119 #define RC6_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC6_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
121 #define DENON_PULSE_LEN (uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME + 0.5)
122 #define DENON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME + 0.5)
123 #define DENON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME + 0.5)
124 #define DENON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
125 #define DENON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
127 #define RECS80EXT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME + 0.5)
128 #define RECS80EXT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME + 0.5)
129 #define RECS80EXT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME + 0.5)
130 #define RECS80EXT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME + 0.5)
131 #define RECS80EXT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME + 0.5)
132 #define RECS80EXT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80EXT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
134 #define NUBERT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME + 0.5)
135 #define NUBERT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME + 0.5)
136 #define NUBERT_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME + 0.5)
137 #define NUBERT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME + 0.5)
138 #define NUBERT_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME + 0.5)
139 #define NUBERT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME + 0.5)
140 #define NUBERT_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
141 #define NUBERT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
143 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME + 0.5)
144 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME + 0.5)
145 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME + 0.5)
146 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME + 0.5)
147 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME + 0.5)
148 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME + 0.5)
149 #define BANG_OLUFSEN_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME + 0.5)
150 #define BANG_OLUFSEN_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME + 0.5)
151 #define BANG_OLUFSEN_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME + 0.5)
152 #define BANG_OLUFSEN_R_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME + 0.5)
153 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME + 0.5)
154 #define BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BANG_OLUFSEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
156 #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME + 0.5)
157 #define GRUNDIG_NOKIA_IR60_BIT_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME + 0.5)
158 #define GRUNDIG_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
159 #define NOKIA_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NOKIA_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
160 #define GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
162 #define SIEMENS_START_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME + 0.5)
163 #define SIEMENS_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME + 0.5)
164 #define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
166 #define IRSND_FREQ_32_KHZ (uint8_t) ((F_CPU / 32000 / 2) - 1)
167 #define IRSND_FREQ_36_KHZ (uint8_t) ((F_CPU / 36000 / 2) - 1)
168 #define IRSND_FREQ_38_KHZ (uint8_t) ((F_CPU / 38000 / 2) - 1)
169 #define IRSND_FREQ_40_KHZ (uint8_t) ((F_CPU / 40000 / 2) - 1)
170 #define IRSND_FREQ_56_KHZ (uint8_t) ((F_CPU / 56000 / 2) - 1)
171 #define IRSND_FREQ_455_KHZ (uint8_t) ((F_CPU / 455000 / 2) - 1)
173 #define FDC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME + 0.5)
174 #define FDC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME + 0.5)
175 #define FDC_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME + 0.5)
176 #define FDC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME + 0.5)
177 #define FDC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME + 0.5)
178 #define FDC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * FDC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
180 #define RCCAR_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME + 0.5)
181 #define RCCAR_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME + 0.5)
182 #define RCCAR_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME + 0.5)
183 #define RCCAR_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME + 0.5)
184 #define RCCAR_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME + 0.5)
185 #define RCCAR_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RCCAR_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
187 #define JVC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME + 0.5)
188 #define JVC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PAUSE_TIME + 0.5)
189 #define JVC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_REPEAT_START_BIT_PAUSE_TIME + 0.5)
190 #define JVC_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME + 0.5)
191 #define JVC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME + 0.5)
192 #define JVC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME + 0.5)
193 #define JVC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
195 #define NIKON_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME + 0.5)
196 #define NIKON_START_BIT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME + 0.5)
197 #define NIKON_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME + 0.5)
198 #define NIKON_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME + 0.5)
199 #define NIKON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME + 0.5)
200 #define NIKON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME + 0.5)
201 #define NIKON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
203 static volatile uint8_t irsnd_busy
;
204 static volatile uint8_t irsnd_protocol
;
205 static volatile uint8_t irsnd_buffer
[6];
206 static volatile uint8_t irsnd_repeat
;
207 static volatile uint8_t irsnd_is_on
= FALSE
;
209 /*---------------------------------------------------------------------------------------------------------------------------------------------------
211 * @details Switches PWM on with a narrow spike on all 3 channels -> leds glowing
212 *---------------------------------------------------------------------------------------------------------------------------------------------------
220 #if defined (__AVR_ATmega32__)
221 TCCR2
|= (1<<COM20
)|(1<<WGM21
); // = 0x42: toggle OC2A on compare match, clear Timer 2 at compare match OCR2A
223 TCCR2A
|= (1<<COM2A0
)|(1<<WGM21
); // = 0x42: toggle OC2A on compare match, clear Timer 2 at compare match OCR2A
230 /*---------------------------------------------------------------------------------------------------------------------------------------------------
232 * @details Switches PWM off
233 *---------------------------------------------------------------------------------------------------------------------------------------------------
241 #if defined (__AVR_ATmega32__)
242 TCCR2
&= ~(1<<COM20
); // normal port operation, OC2A disconnected.
244 TCCR2A
&= ~(1<<COM2A0
); // normal port operation, OC2A disconnected.
246 IRSND_PORT
&= ~(1<<IRSND_BIT
); // set IRSND_BIT to low
252 /*---------------------------------------------------------------------------------------------------------------------------------------------------
254 * @details sets pwm frequency
255 *---------------------------------------------------------------------------------------------------------------------------------------------------
258 irsnd_set_freq (uint8_t freq
)
261 #if defined (__AVR_ATmega32__)
269 /*---------------------------------------------------------------------------------------------------------------------------------------------------
271 * @details Configures 0CR0A, 0CR0B and 0CR2B as PWM channels
272 *---------------------------------------------------------------------------------------------------------------------------------------------------
278 IRSND_PORT
&= ~(1<<IRSND_BIT
); // set IRSND_BIT to low
279 IRSND_DDR
|= (1<<IRSND_BIT
); // set IRSND_BIT to output
281 #if defined (__AVR_ATmega32__)
282 TCCR2
= (1<<WGM21
); // CTC mode
283 TCCR2
|= (1<<CS20
); // 0x01, start Timer 2, no prescaling
285 TCCR2A
= (1<<WGM21
); // CTC mode
286 TCCR2B
|= (1<<CS20
); // 0x01, start Timer 2, no prescaling
289 irsnd_set_freq (IRSND_FREQ_36_KHZ
); // default frequency
300 bitsrevervse (uint16_t x
, uint8_t len
)
318 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
319 static uint8_t sircs_additional_bitlen
;
320 #endif // IRSND_SUPPORT_SIRCS_PROTOCOL == 1
323 irsnd_send_data (IRMP_DATA
* irmp_data_p
, uint8_t do_wait
)
325 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
326 static uint8_t toggle_bit_recs80
;
328 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
329 static uint8_t toggle_bit_recs80ext
;
331 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
332 static uint8_t toggle_bit_rc5
;
334 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
335 static uint8_t toggle_bit_rc6
;
352 irsnd_protocol
= irmp_data_p
->protocol
;
353 irsnd_repeat
= irmp_data_p
->flags
;
355 switch (irsnd_protocol
)
357 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
358 case IRMP_SIRCS_PROTOCOL
:
360 uint8_t sircs_additional_command_len
;
361 uint8_t sircs_additional_address_len
;
363 sircs_additional_bitlen
= (irmp_data_p
->address
& 0xFF00) >> 8; // additional bitlen
365 if (sircs_additional_bitlen
> 15 - SIRCS_MINIMUM_DATA_LEN
)
367 sircs_additional_command_len
= 15 - SIRCS_MINIMUM_DATA_LEN
;
368 sircs_additional_address_len
= sircs_additional_bitlen
- (15 - SIRCS_MINIMUM_DATA_LEN
);
372 sircs_additional_command_len
= sircs_additional_bitlen
;
373 sircs_additional_address_len
= 0;
376 command
= bitsrevervse (irmp_data_p
->command
, 15);
378 irsnd_buffer
[0] = (command
& 0x7F80) >> 7; // CCCCCCCC
379 irsnd_buffer
[1] = (command
& 0x007F) << 1; // CCCC****
381 if (sircs_additional_address_len
> 0)
383 address
= bitsrevervse (irmp_data_p
->address
, 5);
384 irsnd_buffer
[1] |= (address
& 0x0010) >> 4;
385 irsnd_buffer
[2] = (address
& 0x000F) << 4;
391 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
392 case IRMP_APPLE_PROTOCOL
:
394 command
= irmp_data_p
->command
| (irmp_data_p
->address
<< 8); // store address as ID in upper byte of command
395 address
= 0x87EE; // set fixed NEC-lookalike address (customer ID of apple)
397 address
= bitsrevervse (address
, NEC_ADDRESS_LEN
);
398 command
= bitsrevervse (command
, NEC_COMMAND_LEN
);
400 irsnd_protocol
= IRMP_NEC_PROTOCOL
; // APPLE protocol is NEC with id instead of inverted command
402 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
403 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
404 irsnd_buffer
[2] = (command
& 0xFF00) >> 8; // CCCCCCCC
405 irsnd_buffer
[3] = (command
& 0x00FF); // CCCCCCCC
410 case IRMP_NEC_PROTOCOL
:
412 address
= bitsrevervse (irmp_data_p
->address
, NEC_ADDRESS_LEN
);
413 command
= bitsrevervse (irmp_data_p
->command
, NEC_COMMAND_LEN
);
415 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
416 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
417 irsnd_buffer
[2] = (command
& 0xFF00) >> 8; // CCCCCCCC
419 irsnd_protocol
= IRMP_NEC_PROTOCOL
; // APPLE protocol is NEC with fix bitmask instead of inverted command
420 irsnd_buffer
[3] = 0x8B; // 10001011
422 irsnd_buffer
[3] = ~((command
& 0xFF00) >> 8); // cccccccc
429 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
430 case IRMP_SAMSUNG_PROTOCOL
:
432 address
= bitsrevervse (irmp_data_p
->address
, SAMSUNG_ADDRESS_LEN
);
433 command
= bitsrevervse (irmp_data_p
->command
, SAMSUNG_COMMAND_LEN
);
435 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
436 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
437 irsnd_buffer
[2] = (command
& 0x00F0) | ((command
& 0xF000) >> 12); // IIIICCCC
438 irsnd_buffer
[3] = ((command
& 0x0F00) >> 4) | ((~(command
& 0xF000) >> 12) & 0x0F); // CCCCcccc
439 irsnd_buffer
[4] = (~(command
& 0x0F00) >> 4) & 0xF0; // cccc0000
443 case IRMP_SAMSUNG32_PROTOCOL
:
445 address
= bitsrevervse (irmp_data_p
->address
, SAMSUNG_ADDRESS_LEN
);
446 command
= bitsrevervse (irmp_data_p
->command
, SAMSUNG32_COMMAND_LEN
);
448 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
449 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
450 irsnd_buffer
[2] = (command
& 0xFF00) >> 8; // CCCCCCCC
451 irsnd_buffer
[3] = (command
& 0x00FF); // CCCCCCCC
456 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
457 case IRMP_MATSUSHITA_PROTOCOL
:
459 address
= bitsrevervse (irmp_data_p
->address
, MATSUSHITA_ADDRESS_LEN
);
460 command
= bitsrevervse (irmp_data_p
->command
, MATSUSHITA_COMMAND_LEN
);
462 irsnd_buffer
[0] = (command
& 0x0FF0) >> 4; // CCCCCCCC
463 irsnd_buffer
[1] = ((command
& 0x000F) << 4) | ((address
& 0x0F00) >> 8); // CCCCAAAA
464 irsnd_buffer
[2] = (address
& 0x00FF); // AAAAAAAA
469 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
470 case IRMP_KASEIKYO_PROTOCOL
:
474 address
= bitsrevervse (irmp_data_p
->address
, KASEIKYO_ADDRESS_LEN
);
475 command
= bitsrevervse (irmp_data_p
->command
, KASEIKYO_COMMAND_LEN
+ 4);
477 xor = ((address
& 0x000F) ^ ((address
& 0x00F0) >> 4) ^ ((address
& 0x0F00) >> 8) ^ ((address
& 0xF000) >> 12)) & 0x0F;
479 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
480 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
481 irsnd_buffer
[2] = xor << 4 | (command
& 0x000F); // XXXXCCCC
482 irsnd_buffer
[3] = 0 | (command
& 0xF000) >> 12; // 0000CCCC
483 irsnd_buffer
[4] = (command
& 0x0FF0) >> 4; // CCCCCCCC
485 xor = irsnd_buffer
[2] ^ irsnd_buffer
[3] ^ irsnd_buffer
[4];
487 irsnd_buffer
[5] = xor;
492 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
493 case IRMP_RECS80_PROTOCOL
:
495 toggle_bit_recs80
= toggle_bit_recs80
? 0x00 : 0x40;
497 irsnd_buffer
[0] = 0x80 | toggle_bit_recs80
| ((irmp_data_p
->address
& 0x0007) << 3) |
498 ((irmp_data_p
->command
& 0x0038) >> 3); // STAAACCC
499 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x07) << 5; // CCC00000
504 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
505 case IRMP_RECS80EXT_PROTOCOL
:
507 toggle_bit_recs80ext
= toggle_bit_recs80ext
? 0x00 : 0x40;
509 irsnd_buffer
[0] = 0x80 | toggle_bit_recs80ext
| ((irmp_data_p
->address
& 0x000F) << 2) |
510 ((irmp_data_p
->command
& 0x0030) >> 4); // STAAAACC
511 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x0F) << 4; // CCCC0000
516 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
517 case IRMP_RC5_PROTOCOL
:
519 toggle_bit_rc5
= toggle_bit_rc5
? 0x00 : 0x40;
521 irsnd_buffer
[0] = ((irmp_data_p
->command
& 0x40) ? 0x00 : 0x80) | toggle_bit_rc5
|
522 ((irmp_data_p
->address
& 0x001F) << 1) | ((irmp_data_p
->command
& 0x20) >> 5); // CTAAAAAC
523 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x1F) << 3; // CCCCC000
528 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
529 case IRMP_RC6_PROTOCOL
:
531 toggle_bit_rc6
= toggle_bit_rc6
? 0x00 : 0x08;
533 irsnd_buffer
[0] = 0x80 | toggle_bit_rc6
| ((irmp_data_p
->address
& 0x00E0) >> 5); // 1MMMTAAA, MMM = 000
534 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x001F) << 3) | ((irmp_data_p
->command
& 0xE0) >> 5); // AAAAACCC
535 irsnd_buffer
[2] = (irmp_data_p
->command
& 0x1F) << 3; // CCCCC
540 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
541 case IRMP_RC6A_PROTOCOL
:
543 toggle_bit_rc6
= toggle_bit_rc6
? 0x00 : 0x08;
545 irsnd_buffer
[0] = 0x80 | 0x60 | ((irmp_data_p
->address
& 0x3000) >> 12); // 1MMMT0AA, MMM = 110
546 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x0FFF) >> 4) ; // AAAAAAAA
547 irsnd_buffer
[2] = ((irmp_data_p
->address
& 0x000F) << 4) | ((irmp_data_p
->command
& 0xF000) >> 12) | toggle_bit_rc6
; // AAAACCCC
548 irsnd_buffer
[3] = (irmp_data_p
->command
& 0x0FF0) >> 4; // CCCCCCCC
549 irsnd_buffer
[4] = (irmp_data_p
->command
& 0x000F) << 4; // CCCC
554 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
555 case IRMP_DENON_PROTOCOL
:
557 irsnd_buffer
[0] = ((irmp_data_p
->address
& 0x1F) << 3) | ((irmp_data_p
->command
& 0x0380) >> 7); // AAAAACCC (1st frame)
558 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x7F) << 1; // CCCCCCC
559 irsnd_buffer
[2] = ((irmp_data_p
->address
& 0x1F) << 3) | (((~irmp_data_p
->command
) & 0x0380) >> 7); // AAAAACCC (2nd frame)
560 irsnd_buffer
[3] = (~(irmp_data_p
->command
) & 0x7F) << 1; // CCCCCCC
565 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
566 case IRMP_NUBERT_PROTOCOL
:
568 irsnd_buffer
[0] = irmp_data_p
->command
>> 2; // CCCCCCCC
569 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x0003) << 6; // CC000000
574 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
575 case IRMP_BANG_OLUFSEN_PROTOCOL
:
577 irsnd_buffer
[0] = irmp_data_p
->command
>> 11; // SXSCCCCC
578 irsnd_buffer
[1] = irmp_data_p
->command
>> 3; // CCCCCCCC
579 irsnd_buffer
[2] = (irmp_data_p
->command
& 0x0007) << 5; // CCC00000
584 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
585 case IRMP_GRUNDIG_PROTOCOL
:
587 command
= bitsrevervse (irmp_data_p
->command
, GRUNDIG_COMMAND_LEN
);
589 irsnd_buffer
[0] = 0xFF; // S1111111 (1st frame)
590 irsnd_buffer
[1] = 0xC0; // 11
591 irsnd_buffer
[2] = 0x80 | (command
>> 2); // SCCCCCCC (2nd frame)
592 irsnd_buffer
[3] = (command
<< 6) & 0xC0; // CC
598 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
599 case IRMP_NOKIA_PROTOCOL
:
601 address
= bitsrevervse (irmp_data_p
->address
, NOKIA_ADDRESS_LEN
);
602 command
= bitsrevervse (irmp_data_p
->command
, NOKIA_COMMAND_LEN
);
604 irsnd_buffer
[0] = 0xBF; // S0111111 (1st + 3rd frame)
605 irsnd_buffer
[1] = 0xFF; // 11111111
606 irsnd_buffer
[2] = 0x80; // 1
607 irsnd_buffer
[3] = 0x80 | command
>> 1; // SCCCCCCC (2nd frame)
608 irsnd_buffer
[4] = (command
<< 7) | (address
>> 1); // CAAAAAAA
609 irsnd_buffer
[5] = (address
<< 7); // A
615 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
616 case IRMP_SIEMENS_PROTOCOL
:
618 irsnd_buffer
[0] = ((irmp_data_p
->address
& 0x0FFF) >> 5); // SAAAAAAA
619 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x1F) << 3) | ((irmp_data_p
->command
& 0x7F) >> 5); // AAAAA0CC
620 irsnd_buffer
[2] = (irmp_data_p
->command
<< 3) | ((~irmp_data_p
->command
& 0x01) << 2); // CCCCCc
626 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
627 case IRMP_FDC_PROTOCOL
:
629 address
= bitsrevervse (irmp_data_p
->address
, FDC_ADDRESS_LEN
);
630 command
= bitsrevervse (irmp_data_p
->command
, FDC_COMMAND_LEN
);
632 irsnd_buffer
[0] = (address
& 0xFF); // AAAAAAAA
633 irsnd_buffer
[1] = 0; // 00000000
634 irsnd_buffer
[2] = 0; // 0000RRRR
635 irsnd_buffer
[3] = (command
& 0xFF); // CCCCCCCC
636 irsnd_buffer
[4] = ~(command
& 0xFF); // cccccccc
641 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
642 case IRMP_RCCAR_PROTOCOL
:
644 address
= bitsrevervse (irmp_data_p
->address
, 2); // A0 A1
645 command
= bitsrevervse (irmp_data_p
->command
, RCCAR_COMMAND_LEN
- 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V
647 irsnd_buffer
[0] = ((command
& 0x06) << 5) | ((address
& 0x0003) << 4) | ((command
& 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3
648 irsnd_buffer
[1] = ((command
& 0x78) << 1) | ((command
& 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0
654 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
655 case IRMP_JVC_PROTOCOL
:
657 address
= bitsrevervse (irmp_data_p
->address
, JVC_ADDRESS_LEN
);
658 command
= bitsrevervse (irmp_data_p
->command
, JVC_COMMAND_LEN
);
660 irsnd_buffer
[0] = ((address
& 0x000F) << 4) | (command
& 0x0F00) >> 8; // AAAACCCC
661 irsnd_buffer
[1] = (command
& 0x00FF); // CCCCCCCC
667 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
668 case IRMP_NIKON_PROTOCOL
:
670 irsnd_buffer
[0] = (irmp_data_p
->command
& 0x0003) << 6; // CC
684 /*---------------------------------------------------------------------------------------------------------------------------------------------------
686 * @details ISR routine, called 10000 times per second
687 *---------------------------------------------------------------------------------------------------------------------------------------------------
692 static uint8_t current_bit
= 0xFF;
693 static uint8_t pulse_counter
;
694 static IRSND_PAUSE_LEN pause_counter
;
695 static uint8_t startbit_pulse_len
;
696 static IRSND_PAUSE_LEN startbit_pause_len
;
697 static uint8_t pulse_1_len
;
698 static uint8_t pause_1_len
;
699 static uint8_t pulse_0_len
;
700 static uint8_t pause_0_len
;
701 static uint8_t has_stop_bit
;
702 static uint8_t new_frame
= TRUE
;
703 static uint8_t complete_data_len
;
704 static uint8_t n_auto_repetitions
; // number of auto_repetitions
705 static uint8_t auto_repetition_counter
; // auto_repetition counter
706 static uint16_t auto_repetition_pause_len
; // pause before auto_repetition, uint16_t!
707 static uint16_t auto_repetition_pause_counter
; // pause before auto_repetition, uint16_t!
708 static uint8_t n_repeat_frames
; // number of repeat frames
709 static uint8_t repeat_counter
; // repeat counter
710 static uint16_t repeat_frame_pause_len
; // pause before repeat, uint16_t!
711 static uint16_t packet_repeat_pause_counter
; // pause before repeat, uint16_t!
712 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
713 static uint8_t last_bit_value
;
715 static uint8_t pulse_len
= 0xFF;
716 static IRSND_PAUSE_LEN pause_len
= 0xFF;
720 if (current_bit
== 0xFF && new_frame
) // start of transmission...
722 if (auto_repetition_counter
> 0)
724 auto_repetition_pause_counter
++;
726 if (auto_repetition_pause_counter
>= auto_repetition_pause_len
)
728 auto_repetition_pause_counter
= 0;
730 if (irsnd_protocol
== IRMP_DENON_PROTOCOL
)
733 complete_data_len
= 2 * DENON_COMPLETE_DATA_LEN
+ 1;
735 else if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
) // n'th grundig info frame
738 complete_data_len
= 16 + GRUNDIG_COMPLETE_DATA_LEN
;
740 else if (irsnd_protocol
== IRMP_NOKIA_PROTOCOL
) // n'th nokia info frame
742 if (auto_repetition_counter
+ 1 < n_auto_repetitions
)
745 complete_data_len
= 24 + NOKIA_COMPLETE_DATA_LEN
;
747 else // nokia stop frame
750 complete_data_len
= NOKIA_COMPLETE_DATA_LEN
;
769 else if (repeat_counter
> 0 && packet_repeat_pause_counter
< repeat_frame_pause_len
)
771 packet_repeat_pause_counter
++;
787 n_repeat_frames
= irsnd_repeat
;
788 packet_repeat_pause_counter
= 0;
792 switch (irsnd_protocol
)
794 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
795 case IRMP_SIRCS_PROTOCOL
:
797 startbit_pulse_len
= SIRCS_START_BIT_PULSE_LEN
;
798 startbit_pause_len
= SIRCS_START_BIT_PAUSE_LEN
- 1;
799 pulse_1_len
= SIRCS_1_PULSE_LEN
;
800 pause_1_len
= SIRCS_PAUSE_LEN
- 1;
801 pulse_0_len
= SIRCS_0_PULSE_LEN
;
802 pause_0_len
= SIRCS_PAUSE_LEN
- 1;
803 has_stop_bit
= SIRCS_STOP_BIT
;
804 complete_data_len
= SIRCS_MINIMUM_DATA_LEN
+ sircs_additional_bitlen
;
805 n_auto_repetitions
= (repeat_counter
== 0) ? SIRCS_FRAMES
: 1; // 3 frames auto repetition if first frame
806 auto_repetition_pause_len
= SIRCS_AUTO_REPETITION_PAUSE_LEN
; // 25ms pause
807 repeat_frame_pause_len
= SIRCS_FRAME_REPEAT_PAUSE_LEN
;
808 irsnd_set_freq (IRSND_FREQ_40_KHZ
);
812 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
813 case IRMP_NEC_PROTOCOL
:
815 startbit_pulse_len
= NEC_START_BIT_PULSE_LEN
;
817 if (repeat_counter
> 0)
819 startbit_pause_len
= NEC_REPEAT_START_BIT_PAUSE_LEN
- 1;
820 complete_data_len
= 0;
824 startbit_pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
825 complete_data_len
= NEC_COMPLETE_DATA_LEN
;
828 pulse_1_len
= NEC_PULSE_LEN
;
829 pause_1_len
= NEC_1_PAUSE_LEN
- 1;
830 pulse_0_len
= NEC_PULSE_LEN
;
831 pause_0_len
= NEC_0_PAUSE_LEN
- 1;
832 has_stop_bit
= NEC_STOP_BIT
;
833 n_auto_repetitions
= 1; // 1 frame
834 auto_repetition_pause_len
= 0;
835 repeat_frame_pause_len
= NEC_FRAME_REPEAT_PAUSE_LEN
;
836 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
840 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
841 case IRMP_SAMSUNG_PROTOCOL
:
843 startbit_pulse_len
= SAMSUNG_START_BIT_PULSE_LEN
;
844 startbit_pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
845 pulse_1_len
= SAMSUNG_PULSE_LEN
;
846 pause_1_len
= SAMSUNG_1_PAUSE_LEN
- 1;
847 pulse_0_len
= SAMSUNG_PULSE_LEN
;
848 pause_0_len
= SAMSUNG_0_PAUSE_LEN
- 1;
849 has_stop_bit
= SAMSUNG_STOP_BIT
;
850 complete_data_len
= SAMSUNG_COMPLETE_DATA_LEN
;
851 n_auto_repetitions
= 1; // 1 frame
852 auto_repetition_pause_len
= 0;
853 repeat_frame_pause_len
= SAMSUNG_FRAME_REPEAT_PAUSE_LEN
;
854 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
858 case IRMP_SAMSUNG32_PROTOCOL
:
860 startbit_pulse_len
= SAMSUNG_START_BIT_PULSE_LEN
;
861 startbit_pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
862 pulse_1_len
= SAMSUNG_PULSE_LEN
;
863 pause_1_len
= SAMSUNG_1_PAUSE_LEN
- 1;
864 pulse_0_len
= SAMSUNG_PULSE_LEN
;
865 pause_0_len
= SAMSUNG_0_PAUSE_LEN
- 1;
866 has_stop_bit
= SAMSUNG_STOP_BIT
;
867 complete_data_len
= SAMSUNG32_COMPLETE_DATA_LEN
;
868 n_auto_repetitions
= SAMSUNG32_FRAMES
; // 2 frames
869 auto_repetition_pause_len
= SAMSUNG32_AUTO_REPETITION_PAUSE_LEN
; // 47 ms pause
870 repeat_frame_pause_len
= SAMSUNG32_FRAME_REPEAT_PAUSE_LEN
;
871 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
875 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
876 case IRMP_MATSUSHITA_PROTOCOL
:
878 startbit_pulse_len
= MATSUSHITA_START_BIT_PULSE_LEN
;
879 startbit_pause_len
= MATSUSHITA_START_BIT_PAUSE_LEN
- 1;
880 pulse_1_len
= MATSUSHITA_PULSE_LEN
;
881 pause_1_len
= MATSUSHITA_1_PAUSE_LEN
- 1;
882 pulse_0_len
= MATSUSHITA_PULSE_LEN
;
883 pause_0_len
= MATSUSHITA_0_PAUSE_LEN
- 1;
884 has_stop_bit
= MATSUSHITA_STOP_BIT
;
885 complete_data_len
= MATSUSHITA_COMPLETE_DATA_LEN
;
886 n_auto_repetitions
= 1; // 1 frame
887 auto_repetition_pause_len
= 0;
888 repeat_frame_pause_len
= MATSUSHITA_FRAME_REPEAT_PAUSE_LEN
;
889 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
893 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
894 case IRMP_KASEIKYO_PROTOCOL
:
896 startbit_pulse_len
= KASEIKYO_START_BIT_PULSE_LEN
;
897 startbit_pause_len
= KASEIKYO_START_BIT_PAUSE_LEN
- 1;
898 pulse_1_len
= KASEIKYO_PULSE_LEN
;
899 pause_1_len
= KASEIKYO_1_PAUSE_LEN
- 1;
900 pulse_0_len
= KASEIKYO_PULSE_LEN
;
901 pause_0_len
= KASEIKYO_0_PAUSE_LEN
- 1;
902 has_stop_bit
= KASEIKYO_STOP_BIT
;
903 complete_data_len
= KASEIKYO_COMPLETE_DATA_LEN
;
904 n_auto_repetitions
= (repeat_counter
== 0) ? KASEIKYO_FRAMES
: 1; // 2 frames auto repetition if first frame
905 auto_repetition_pause_len
= KASEIKYO_AUTO_REPETITION_PAUSE_LEN
; // 75 ms pause
906 repeat_frame_pause_len
= KASEIKYO_FRAME_REPEAT_PAUSE_LEN
;
907 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
911 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
912 case IRMP_RECS80_PROTOCOL
:
914 startbit_pulse_len
= RECS80_START_BIT_PULSE_LEN
;
915 startbit_pause_len
= RECS80_START_BIT_PAUSE_LEN
- 1;
916 pulse_1_len
= RECS80_PULSE_LEN
;
917 pause_1_len
= RECS80_1_PAUSE_LEN
- 1;
918 pulse_0_len
= RECS80_PULSE_LEN
;
919 pause_0_len
= RECS80_0_PAUSE_LEN
- 1;
920 has_stop_bit
= RECS80_STOP_BIT
;
921 complete_data_len
= RECS80_COMPLETE_DATA_LEN
;
922 n_auto_repetitions
= 1; // 1 frame
923 auto_repetition_pause_len
= 0;
924 repeat_frame_pause_len
= RECS80_FRAME_REPEAT_PAUSE_LEN
;
925 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
929 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
930 case IRMP_RECS80EXT_PROTOCOL
:
932 startbit_pulse_len
= RECS80EXT_START_BIT_PULSE_LEN
;
933 startbit_pause_len
= RECS80EXT_START_BIT_PAUSE_LEN
- 1;
934 pulse_1_len
= RECS80EXT_PULSE_LEN
;
935 pause_1_len
= RECS80EXT_1_PAUSE_LEN
- 1;
936 pulse_0_len
= RECS80EXT_PULSE_LEN
;
937 pause_0_len
= RECS80EXT_0_PAUSE_LEN
- 1;
938 has_stop_bit
= RECS80EXT_STOP_BIT
;
939 complete_data_len
= RECS80EXT_COMPLETE_DATA_LEN
;
940 n_auto_repetitions
= 1; // 1 frame
941 auto_repetition_pause_len
= 0;
942 repeat_frame_pause_len
= RECS80EXT_FRAME_REPEAT_PAUSE_LEN
;
943 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
947 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
948 case IRMP_RC5_PROTOCOL
:
950 startbit_pulse_len
= RC5_BIT_LEN
;
951 startbit_pause_len
= RC5_BIT_LEN
;
952 pulse_len
= RC5_BIT_LEN
;
953 pause_len
= RC5_BIT_LEN
;
954 has_stop_bit
= RC5_STOP_BIT
;
955 complete_data_len
= RC5_COMPLETE_DATA_LEN
;
956 n_auto_repetitions
= 1; // 1 frame
957 auto_repetition_pause_len
= 0;
958 repeat_frame_pause_len
= RC5_FRAME_REPEAT_PAUSE_LEN
;
959 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
963 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
964 case IRMP_RC6_PROTOCOL
:
966 startbit_pulse_len
= RC6_START_BIT_PULSE_LEN
;
967 startbit_pause_len
= RC6_START_BIT_PAUSE_LEN
- 1;
968 pulse_len
= RC6_BIT_LEN
;
969 pause_len
= RC6_BIT_LEN
;
970 has_stop_bit
= RC6_STOP_BIT
;
971 complete_data_len
= RC6_COMPLETE_DATA_LEN_SHORT
;
972 n_auto_repetitions
= 1; // 1 frame
973 auto_repetition_pause_len
= 0;
974 repeat_frame_pause_len
= RC6_FRAME_REPEAT_PAUSE_LEN
;
975 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
979 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
980 case IRMP_RC6A_PROTOCOL
:
982 startbit_pulse_len
= RC6_START_BIT_PULSE_LEN
;
983 startbit_pause_len
= RC6_START_BIT_PAUSE_LEN
- 1;
984 pulse_len
= RC6_BIT_LEN
;
985 pause_len
= RC6_BIT_LEN
;
986 has_stop_bit
= RC6_STOP_BIT
;
987 complete_data_len
= RC6_COMPLETE_DATA_LEN_LONG
;
988 n_auto_repetitions
= 1; // 1 frame
989 auto_repetition_pause_len
= 0;
990 repeat_frame_pause_len
= RC6_FRAME_REPEAT_PAUSE_LEN
;
991 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
995 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
996 case IRMP_DENON_PROTOCOL
:
998 startbit_pulse_len
= 0x00;
999 startbit_pause_len
= 0x00;
1000 pulse_1_len
= DENON_PULSE_LEN
;
1001 pause_1_len
= DENON_1_PAUSE_LEN
- 1;
1002 pulse_0_len
= DENON_PULSE_LEN
;
1003 pause_0_len
= DENON_0_PAUSE_LEN
- 1;
1004 has_stop_bit
= DENON_STOP_BIT
;
1005 complete_data_len
= DENON_COMPLETE_DATA_LEN
;
1006 n_auto_repetitions
= DENON_FRAMES
; // 2 frames, 2nd with inverted command
1007 auto_repetition_pause_len
= DENON_AUTO_REPETITION_PAUSE_LEN
; // 65 ms pause after 1st frame
1008 repeat_frame_pause_len
= DENON_FRAME_REPEAT_PAUSE_LEN
;
1009 irsnd_set_freq (IRSND_FREQ_36_KHZ
); // in theory 32kHz, in practice 36kHz is better
1013 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
1014 case IRMP_NUBERT_PROTOCOL
:
1016 startbit_pulse_len
= NUBERT_START_BIT_PULSE_LEN
;
1017 startbit_pause_len
= NUBERT_START_BIT_PAUSE_LEN
- 1;
1018 pulse_1_len
= NUBERT_1_PULSE_LEN
;
1019 pause_1_len
= NUBERT_1_PAUSE_LEN
- 1;
1020 pulse_0_len
= NUBERT_0_PULSE_LEN
;
1021 pause_0_len
= NUBERT_0_PAUSE_LEN
- 1;
1022 has_stop_bit
= NUBERT_STOP_BIT
;
1023 complete_data_len
= NUBERT_COMPLETE_DATA_LEN
;
1024 n_auto_repetitions
= NUBERT_FRAMES
; // 2 frames
1025 auto_repetition_pause_len
= NUBERT_AUTO_REPETITION_PAUSE_LEN
; // 35 ms pause
1026 repeat_frame_pause_len
= NUBERT_FRAME_REPEAT_PAUSE_LEN
;
1027 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1031 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1032 case IRMP_BANG_OLUFSEN_PROTOCOL
:
1034 startbit_pulse_len
= BANG_OLUFSEN_START_BIT1_PULSE_LEN
;
1035 startbit_pause_len
= BANG_OLUFSEN_START_BIT1_PAUSE_LEN
- 1;
1036 pulse_1_len
= BANG_OLUFSEN_PULSE_LEN
;
1037 pause_1_len
= BANG_OLUFSEN_1_PAUSE_LEN
- 1;
1038 pulse_0_len
= BANG_OLUFSEN_PULSE_LEN
;
1039 pause_0_len
= BANG_OLUFSEN_0_PAUSE_LEN
- 1;
1040 has_stop_bit
= BANG_OLUFSEN_STOP_BIT
;
1041 complete_data_len
= BANG_OLUFSEN_COMPLETE_DATA_LEN
;
1042 n_auto_repetitions
= 1; // 1 frame
1043 auto_repetition_pause_len
= 0;
1044 repeat_frame_pause_len
= BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN
;
1046 irsnd_set_freq (IRSND_FREQ_455_KHZ
);
1050 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
1051 case IRMP_GRUNDIG_PROTOCOL
:
1053 startbit_pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1054 startbit_pause_len
= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN
- 1;
1055 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1056 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1057 has_stop_bit
= GRUNDIG_NOKIA_IR60_STOP_BIT
;
1058 complete_data_len
= GRUNDIG_COMPLETE_DATA_LEN
;
1059 n_auto_repetitions
= GRUNDIG_FRAMES
; // 2 frames
1060 auto_repetition_pause_len
= GRUNDIG_AUTO_REPETITION_PAUSE_LEN
; // 20m sec pause
1061 repeat_frame_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
; // 117 msec pause
1062 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1067 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1068 case IRMP_NOKIA_PROTOCOL
:
1070 startbit_pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1071 startbit_pause_len
= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN
- 1;
1072 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1073 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1074 has_stop_bit
= GRUNDIG_NOKIA_IR60_STOP_BIT
;
1075 complete_data_len
= NOKIA_COMPLETE_DATA_LEN
;
1076 n_auto_repetitions
= NOKIA_FRAMES
; // 2 frames
1077 auto_repetition_pause_len
= NOKIA_AUTO_REPETITION_PAUSE_LEN
; // 20 msec pause
1078 repeat_frame_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
; // 117 msec pause
1079 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1083 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
1084 case IRMP_SIEMENS_PROTOCOL
:
1086 startbit_pulse_len
= SIEMENS_BIT_LEN
;
1087 startbit_pause_len
= SIEMENS_BIT_LEN
;
1088 pulse_len
= SIEMENS_BIT_LEN
;
1089 pause_len
= SIEMENS_BIT_LEN
;
1090 has_stop_bit
= SIEMENS_OR_RUWIDO_STOP_BIT
;
1091 complete_data_len
= SIEMENS_COMPLETE_DATA_LEN
- 1;
1092 n_auto_repetitions
= 1; // 1 frame
1093 auto_repetition_pause_len
= 0;
1094 repeat_frame_pause_len
= SIEMENS_FRAME_REPEAT_PAUSE_LEN
;
1095 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1099 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1100 case IRMP_FDC_PROTOCOL
:
1102 startbit_pulse_len
= FDC_START_BIT_PULSE_LEN
;
1103 startbit_pause_len
= FDC_START_BIT_PAUSE_LEN
- 1;
1104 complete_data_len
= FDC_COMPLETE_DATA_LEN
;
1105 pulse_1_len
= FDC_PULSE_LEN
;
1106 pause_1_len
= FDC_1_PAUSE_LEN
- 1;
1107 pulse_0_len
= FDC_PULSE_LEN
;
1108 pause_0_len
= FDC_0_PAUSE_LEN
- 1;
1109 has_stop_bit
= FDC_STOP_BIT
;
1110 n_auto_repetitions
= 1; // 1 frame
1111 auto_repetition_pause_len
= 0;
1112 repeat_frame_pause_len
= FDC_FRAME_REPEAT_PAUSE_LEN
;
1113 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1117 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
1118 case IRMP_RCCAR_PROTOCOL
:
1120 startbit_pulse_len
= RCCAR_START_BIT_PULSE_LEN
;
1121 startbit_pause_len
= RCCAR_START_BIT_PAUSE_LEN
- 1;
1122 complete_data_len
= RCCAR_COMPLETE_DATA_LEN
;
1123 pulse_1_len
= RCCAR_PULSE_LEN
;
1124 pause_1_len
= RCCAR_1_PAUSE_LEN
- 1;
1125 pulse_0_len
= RCCAR_PULSE_LEN
;
1126 pause_0_len
= RCCAR_0_PAUSE_LEN
- 1;
1127 has_stop_bit
= RCCAR_STOP_BIT
;
1128 n_auto_repetitions
= 1; // 1 frame
1129 auto_repetition_pause_len
= 0;
1130 repeat_frame_pause_len
= RCCAR_FRAME_REPEAT_PAUSE_LEN
;
1131 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1135 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
1136 case IRMP_JVC_PROTOCOL
:
1138 if (repeat_counter
!= 0) // skip start bit if repetition frame
1143 startbit_pulse_len
= JVC_START_BIT_PULSE_LEN
;
1144 startbit_pause_len
= JVC_START_BIT_PAUSE_LEN
- 1;
1145 complete_data_len
= JVC_COMPLETE_DATA_LEN
;
1146 pulse_1_len
= JVC_PULSE_LEN
;
1147 pause_1_len
= JVC_1_PAUSE_LEN
- 1;
1148 pulse_0_len
= JVC_PULSE_LEN
;
1149 pause_0_len
= JVC_0_PAUSE_LEN
- 1;
1150 has_stop_bit
= JVC_STOP_BIT
;
1151 n_auto_repetitions
= 1; // 1 frame
1152 auto_repetition_pause_len
= 0;
1153 repeat_frame_pause_len
= JVC_FRAME_REPEAT_PAUSE_LEN
;
1154 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1159 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
1160 case IRMP_NIKON_PROTOCOL
:
1162 startbit_pulse_len
= NIKON_START_BIT_PULSE_LEN
;
1163 startbit_pause_len
= 271 - 1; // NIKON_START_BIT_PAUSE_LEN;
1164 complete_data_len
= NIKON_COMPLETE_DATA_LEN
;
1165 pulse_1_len
= NIKON_PULSE_LEN
;
1166 pause_1_len
= NIKON_1_PAUSE_LEN
- 1;
1167 pulse_0_len
= NIKON_PULSE_LEN
;
1168 pause_0_len
= NIKON_0_PAUSE_LEN
- 1;
1169 has_stop_bit
= NIKON_STOP_BIT
;
1170 n_auto_repetitions
= 1; // 1 frame
1171 auto_repetition_pause_len
= 0;
1172 repeat_frame_pause_len
= NIKON_FRAME_REPEAT_PAUSE_LEN
;
1173 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1191 switch (irsnd_protocol
)
1193 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
1194 case IRMP_SIRCS_PROTOCOL
:
1196 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
1197 case IRMP_NEC_PROTOCOL
:
1199 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
1200 case IRMP_SAMSUNG_PROTOCOL
:
1201 case IRMP_SAMSUNG32_PROTOCOL
:
1203 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
1204 case IRMP_MATSUSHITA_PROTOCOL
:
1206 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
1207 case IRMP_KASEIKYO_PROTOCOL
:
1209 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
1210 case IRMP_RECS80_PROTOCOL
:
1212 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
1213 case IRMP_RECS80EXT_PROTOCOL
:
1215 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1216 case IRMP_DENON_PROTOCOL
:
1218 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
1219 case IRMP_NUBERT_PROTOCOL
:
1221 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1222 case IRMP_BANG_OLUFSEN_PROTOCOL
:
1224 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1225 case IRMP_FDC_PROTOCOL
:
1227 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
1228 case IRMP_RCCAR_PROTOCOL
:
1230 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
1231 case IRMP_JVC_PROTOCOL
:
1233 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
1234 case IRMP_NIKON_PROTOCOL
:
1238 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \
1239 IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \
1240 IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || \
1241 IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1
1243 if (pulse_counter
== 0)
1245 if (current_bit
== 0xFF) // send start bit
1247 pulse_len
= startbit_pulse_len
;
1248 pause_len
= startbit_pause_len
;
1250 else if (current_bit
< complete_data_len
) // send n'th bit
1252 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
1253 if (irsnd_protocol
== IRMP_SAMSUNG_PROTOCOL
)
1255 if (current_bit
< SAMSUNG_ADDRESS_LEN
) // send address bits
1257 pulse_len
= SAMSUNG_PULSE_LEN
;
1258 pause_len
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ?
1259 (SAMSUNG_1_PAUSE_LEN
- 1) : (SAMSUNG_0_PAUSE_LEN
- 1);
1261 else if (current_bit
== SAMSUNG_ADDRESS_LEN
) // send SYNC bit (16th bit)
1263 pulse_len
= SAMSUNG_PULSE_LEN
;
1264 pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
1266 else if (current_bit
< SAMSUNG_COMPLETE_DATA_LEN
) // send n'th bit
1268 uint8_t cur_bit
= current_bit
- 1; // sync skipped, offset = -1 !
1270 pulse_len
= SAMSUNG_PULSE_LEN
;
1271 pause_len
= (irsnd_buffer
[cur_bit
/ 8] & (1<<(7-(cur_bit
% 8)))) ?
1272 (SAMSUNG_1_PAUSE_LEN
- 1) : (SAMSUNG_0_PAUSE_LEN
- 1);
1278 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1279 if (irsnd_protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
1281 if (current_bit
== 0) // send 2nd start bit
1283 pulse_len
= BANG_OLUFSEN_START_BIT2_PULSE_LEN
;
1284 pause_len
= BANG_OLUFSEN_START_BIT2_PAUSE_LEN
- 1;
1286 else if (current_bit
== 1) // send 3rd start bit
1288 pulse_len
= BANG_OLUFSEN_START_BIT3_PULSE_LEN
;
1289 pause_len
= BANG_OLUFSEN_START_BIT3_PAUSE_LEN
- 1;
1291 else if (current_bit
== 2) // send 4th start bit
1293 pulse_len
= BANG_OLUFSEN_START_BIT2_PULSE_LEN
;
1294 pause_len
= BANG_OLUFSEN_START_BIT2_PAUSE_LEN
- 1;
1296 else if (current_bit
== 19) // send trailer bit
1298 pulse_len
= BANG_OLUFSEN_PULSE_LEN
;
1299 pause_len
= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN
- 1;
1301 else if (current_bit
< BANG_OLUFSEN_COMPLETE_DATA_LEN
) // send n'th bit
1303 uint8_t cur_bit_value
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? 1 : 0;
1304 pulse_len
= BANG_OLUFSEN_PULSE_LEN
;
1306 if (cur_bit_value
== last_bit_value
)
1308 pause_len
= BANG_OLUFSEN_R_PAUSE_LEN
- 1;
1312 pause_len
= cur_bit_value
? (BANG_OLUFSEN_1_PAUSE_LEN
- 1) : (BANG_OLUFSEN_0_PAUSE_LEN
- 1);
1313 last_bit_value
= cur_bit_value
;
1319 if (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8))))
1321 pulse_len
= pulse_1_len
;
1322 pause_len
= pause_1_len
;
1326 pulse_len
= pulse_0_len
;
1327 pause_len
= pause_0_len
;
1330 else if (has_stop_bit
) // send stop bit
1332 pulse_len
= pulse_0_len
;
1334 if (auto_repetition_counter
< n_auto_repetitions
)
1336 pause_len
= pause_0_len
;
1340 pause_len
= 255; // last frame: pause of 255
1345 if (pulse_counter
< pulse_len
)
1347 if (pulse_counter
== 0)
1353 else if (pause_counter
< pause_len
)
1355 if (pause_counter
== 0)
1365 if (current_bit
>= complete_data_len
+ has_stop_bit
)
1368 auto_repetition_counter
++;
1370 if (auto_repetition_counter
== n_auto_repetitions
)
1373 auto_repetition_counter
= 0;
1385 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
1386 case IRMP_RC5_PROTOCOL
:
1388 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
1389 case IRMP_RC6_PROTOCOL
:
1391 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
1392 case IRMP_RC6A_PROTOCOL
:
1394 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
1395 case IRMP_SIEMENS_PROTOCOL
:
1397 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
1398 case IRMP_GRUNDIG_PROTOCOL
:
1400 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1401 case IRMP_NOKIA_PROTOCOL
:
1404 #if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || \
1405 IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1407 if (pulse_counter
== pulse_len
&& pause_counter
== pause_len
)
1411 if (current_bit
>= complete_data_len
)
1415 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1416 if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
|| irsnd_protocol
== IRMP_NOKIA_PROTOCOL
)
1418 auto_repetition_counter
++;
1420 if (repeat_counter
> 0)
1421 { // set 117 msec pause time
1422 auto_repetition_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
;
1425 if (repeat_counter
< n_repeat_frames
) // tricky: repeat n info frames per auto repetition before sending last stop frame
1427 n_auto_repetitions
++; // increment number of auto repetitions
1430 else if (auto_repetition_counter
== n_auto_repetitions
)
1433 auto_repetition_counter
= 0;
1452 uint8_t first_pulse
;
1454 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1455 if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
|| irsnd_protocol
== IRMP_NOKIA_PROTOCOL
)
1457 if (current_bit
== 0xFF || // start bit of start-frame
1458 (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
&& current_bit
== 15) || // start bit of info-frame (Grundig)
1459 (irsnd_protocol
== IRMP_NOKIA_PROTOCOL
&& (current_bit
== 23 || current_bit
== 47))) // start bit of info- or stop-frame (Nokia)
1461 pulse_len
= startbit_pulse_len
;
1462 pause_len
= startbit_pause_len
;
1465 else // send n'th bit
1467 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1468 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1469 first_pulse
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? TRUE
: FALSE
;
1472 else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL ||
1473 // irsnd_protocol == IRMP_SIEMENS_PROTOCOL)
1476 if (current_bit
== 0xFF) // 1 start bit
1478 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
1479 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
|| irsnd_protocol
== IRMP_RC6A_PROTOCOL
)
1481 pulse_len
= startbit_pulse_len
;
1482 pause_len
= startbit_pause_len
;
1487 else // send n'th bit
1489 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
1490 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
|| irsnd_protocol
== IRMP_RC6A_PROTOCOL
)
1492 pulse_len
= RC6_BIT_LEN
;
1493 pause_len
= RC6_BIT_LEN
;
1495 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
)
1497 if (current_bit
== 4) // toggle bit (double len)
1499 pulse_len
= 2 * RC6_BIT_LEN
;
1500 pause_len
= 2 * RC6_BIT_LEN
;
1503 else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL)
1505 if (current_bit
== 4) // toggle bit (double len)
1507 pulse_len
= 2 * RC6_BIT_LEN
+ RC6_BIT_LEN
; // hack!
1508 pause_len
= 2 * RC6_BIT_LEN
;
1510 else if (current_bit
== 5) // toggle bit (double len)
1512 pause_len
= 2 * RC6_BIT_LEN
;
1517 first_pulse
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? TRUE
: FALSE
;
1520 if (irsnd_protocol
== IRMP_RC5_PROTOCOL
)
1522 first_pulse
= first_pulse
? FALSE
: TRUE
;
1528 if (pulse_counter
< pulse_len
)
1530 if (pulse_counter
== 0)
1536 else // if (pause_counter < pause_len)
1538 if (pause_counter
== 0)
1547 if (pause_counter
< pause_len
)
1549 if (pause_counter
== 0)
1555 else // if (pulse_counter < pulse_len)
1557 if (pulse_counter
== 0)
1567 #endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 ||
1568 // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1580 if (repeat_counter
< n_repeat_frames
)
1582 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1583 if (irsnd_protocol
== IRMP_FDC_PROTOCOL
)
1585 irsnd_buffer
[2] |= 0x0F;
1593 n_repeat_frames
= 0;
1615 // main function - for unix/linux + windows only!
1617 // Compile it under linux with:
1618 // cc irsnd.c -o irsnd
1620 // usage: ./irsnd protocol hex-address hex-command >filename
1623 main (int argc
, char ** argv
)
1629 IRMP_DATA irmp_data
;
1631 if (argc
!= 4 && argc
!= 5)
1633 fprintf (stderr
, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv
[0]);
1637 if (sscanf (argv
[1], "%d", &protocol
) == 1 &&
1638 sscanf (argv
[2], "%x", &address
) == 1 &&
1639 sscanf (argv
[3], "%x", &command
) == 1)
1641 irmp_data
.protocol
= protocol
;
1642 irmp_data
.address
= address
;
1643 irmp_data
.command
= command
;
1647 irmp_data
.flags
= atoi (argv
[4]);
1651 irmp_data
.flags
= 0;
1656 (void) irsnd_send_data (&irmp_data
, TRUE
);
1662 for (idx
= 0; idx
< 20; idx
++)
1671 fprintf (stderr
, "%s: wrong arguments\n", argv
[0]);