1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
4 * Copyright (c) 2010-2012 Frank Meyer - frank(at)fli4l.de
6 * Supported mikrocontrollers:
11 * ATmega8, ATmega16, ATmega32
13 * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284
14 * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P
16 * $Id: irsnd.c,v 1.59 2012/06/18 09:00:46 fm Exp $
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *---------------------------------------------------------------------------------------------------------------------------------------------------
27 /*---------------------------------------------------------------------------------------------------------------------------------------------------
28 * ATtiny pin definition of OC0A / OC0B
29 * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B
30 *---------------------------------------------------------------------------------------------------------------------------------------------------
32 #if defined (__AVR_ATtiny84__) // ATtiny84 uses OC0A = PB2 or OC0B = PA7
33 # if IRSND_OCx == IRSND_OC0A // OC0A
34 # define IRSND_PORT PORTB // port B
35 # define IRSND_DDR DDRB // ddr B
36 # define IRSND_BIT 2 // OC0A
37 # elif IRSND_OCx == IRSND_OC0B // OC0B
38 # define IRSND_PORT PORTA // port A
39 # define IRSND_DDR DDRA // ddr A
40 # define IRSND_BIT 7 // OC0B
42 # error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h
44 #elif defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) // ATtiny45/85 uses OC0A = PB0 or OC0B = PB1
45 # if IRSND_OCx == IRSND_OC0A // OC0A
46 # define IRSND_PORT PORTB // port B
47 # define IRSND_DDR DDRB // ddr B
48 # define IRSND_BIT 0 // OC0A
49 # elif IRSND_OCx == IRSND_OC0B // OC0B
50 # define IRSND_PORT PORTB // port B
51 # define IRSND_DDR DDRB // ddr B
52 # define IRSND_BIT 1 // OC0B
54 # error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h
56 #elif defined (__AVR_ATtiny87__) || defined (__AVR_ATtiny167__) // ATtiny87/167 uses OC0A = PA2
57 # if IRSND_OCx == IRSND_OC0A // OC0A
58 # define IRSND_PORT PORTA // port A
59 # define IRSND_DDR DDRA // ddr A
60 # define IRSND_BIT 2 // OC0A
62 # error Wrong value for IRSND_OCx, choose IRSND_OC0A in irsndconfig.h
64 #elif defined (__AVR_ATmega8__) // ATmega8 uses only OC2 = PB3
65 # if IRSND_OCx == IRSND_OC2 // OC0A
66 # define IRSND_PORT PORTB // port B
67 # define IRSND_DDR DDRB // ddr B
68 # define IRSND_BIT 3 // OC0A
70 # error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h
72 #elif defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) // ATmega16|32 uses OC2 = PD7
73 # if IRSND_OCx == IRSND_OC2 // OC2
74 # define IRSND_PORT PORTD // port D
75 # define IRSND_DDR DDRD // ddr D
76 # define IRSND_BIT 7 // OC2
78 # error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h
80 #elif defined (__AVR_ATmega162__) // ATmega162 uses OC2 = PB1 or OC0 = PB0
81 # if IRSND_OCx == IRSND_OC2 // OC2
82 # define IRSND_PORT PORTB // port B
83 # define IRSND_DDR DDRB // ddr B
84 # define IRSND_BIT 1 // OC2
85 # elif IRSND_OCx == IRSND_OC0 // OC0
86 # define IRSND_PORT PORTB // port B
87 # define IRSND_DDR DDRB // ddr B
88 # define IRSND_BIT 0 // OC0
90 # error Wrong value for IRSND_OCx, choose IRSND_OC2 or IRSND_OC0 in irsndconfig.h
92 #elif defined (__AVR_ATmega164__) \
93 || defined (__AVR_ATmega324__) \
94 || defined (__AVR_ATmega644__) \
95 || defined (__AVR_ATmega644P__) \
96 || defined (__AVR_ATmega1284__) \
97 || defined (__AVR_ATmega1284P__) // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4
98 # if IRSND_OCx == IRSND_OC2A // OC2A
99 # define IRSND_PORT PORTD // port D
100 # define IRSND_DDR DDRD // ddr D
101 # define IRSND_BIT 7 // OC2A
102 # elif IRSND_OCx == IRSND_OC2B // OC2B
103 # define IRSND_PORT PORTD // port D
104 # define IRSND_DDR DDRD // ddr D
105 # define IRSND_BIT 6 // OC2B
106 # elif IRSND_OCx == IRSND_OC0A // OC0A
107 # define IRSND_PORT PORTB // port B
108 # define IRSND_DDR DDRB // ddr B
109 # define IRSND_BIT 3 // OC0A
110 # elif IRSND_OCx == IRSND_OC0B // OC0B
111 # define IRSND_PORT PORTB // port B
112 # define IRSND_DDR DDRB // ddr B
113 # define IRSND_BIT 4 // OC0B
115 # error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h
117 #elif defined (__AVR_ATmega48__) \
118 || defined (__AVR_ATmega88__) \
119 || defined (__AVR_ATmega88P__) \
120 || defined (__AVR_ATmega168__) \
121 || defined (__AVR_ATmega168P__) \
122 || defined (__AVR_ATmega328P__) // ATmega48|88|168|168|328 uses OC2A = PB3 or OC2B = PD3 or OC0A = PD6 or OC0B = PD5
123 # if IRSND_OCx == IRSND_OC2A // OC2A
124 # define IRSND_PORT PORTB // port B
125 # define IRSND_DDR DDRB // ddr B
126 # define IRSND_BIT 3 // OC2A
127 # elif IRSND_OCx == IRSND_OC2B // OC2B
128 # define IRSND_PORT PORTD // port D
129 # define IRSND_DDR DDRD // ddr D
130 # define IRSND_BIT 3 // OC2B
131 # elif IRSND_OCx == IRSND_OC0A // OC0A
132 # define IRSND_PORT PORTB // port B
133 # define IRSND_DDR DDRB // ddr B
134 # define IRSND_BIT 6 // OC0A
135 # elif IRSND_OCx == IRSND_OC0B // OC0B
136 # define IRSND_PORT PORTD // port D
137 # define IRSND_DDR DDRD // ddr D
138 # define IRSND_BIT 5 // OC0B
140 # error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h
142 #elif defined (__AVR_ATmega8515__)
143 # if IRSND_OCx == IRSND_OC0
144 # define IRSND_PORT PORTB // port B
145 # define IRSND_DDR DDRB // ddr B
146 # define IRSND_BIT 0 // OC0
147 # elif IRSND_OCx == IRSND_OC1A
148 # define IRSND_PORT PORTD // port D
149 # define IRSND_DDR DDRD // ddr D
150 # define IRSND_BIT 5 // OC1A
151 # elif IRSND_OCx == IRSND_OC1B
152 # define IRSND_PORT PORTE // port E
153 # define IRSND_DDR DDRE // ddr E
154 # define IRSND_BIT 2 // OC1E
156 # error Wrong value for IRSND_OCx, choose IRSND_OC0, IRSND_OC1A, or IRSND_OC1B in irsndconfig.h
158 #elif defined (PIC_C18) //Microchip C18 compiler
159 //Nothing here to do here -> See irsndconfig.h
160 #elif defined (ARM_STM32) //STM32
161 //Nothing here to do here -> See irsndconfig.h
163 # if !defined (unix) && !defined (WIN32)
164 # error mikrocontroller not defined, please fill in definitions here.
165 # endif // unix, WIN32
168 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
169 typedef uint16_t IRSND_PAUSE_LEN
;
171 typedef uint8_t IRSND_PAUSE_LEN
;
174 /*---------------------------------------------------------------------------------------------------------------------------------------------------
176 *---------------------------------------------------------------------------------------------------------------------------------------------------
178 #define SIRCS_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME + 0.5)
179 #define SIRCS_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME + 0.5)
180 #define SIRCS_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME + 0.5)
181 #define SIRCS_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME + 0.5)
182 #define SIRCS_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME + 0.5)
183 #define SIRCS_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
184 #define SIRCS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
186 #define NEC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME + 0.5)
187 #define NEC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME + 0.5)
188 #define NEC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME + 0.5)
189 #define NEC_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME + 0.5)
190 #define NEC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME + 0.5)
191 #define NEC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME + 0.5)
192 #define NEC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
194 #define SAMSUNG_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME + 0.5)
195 #define SAMSUNG_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME + 0.5)
196 #define SAMSUNG_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME + 0.5)
197 #define SAMSUNG_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME + 0.5)
198 #define SAMSUNG_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME + 0.5)
199 #define SAMSUNG_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
201 #define SAMSUNG32_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
202 #define SAMSUNG32_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
204 #define MATSUSHITA_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME + 0.5)
205 #define MATSUSHITA_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME + 0.5)
206 #define MATSUSHITA_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME + 0.5)
207 #define MATSUSHITA_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME + 0.5)
208 #define MATSUSHITA_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME + 0.5)
209 #define MATSUSHITA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * MATSUSHITA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
211 #define KASEIKYO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME + 0.5)
212 #define KASEIKYO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME + 0.5)
213 #define KASEIKYO_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME + 0.5)
214 #define KASEIKYO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME + 0.5)
215 #define KASEIKYO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME + 0.5)
216 #define KASEIKYO_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
217 #define KASEIKYO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
219 #define RECS80_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME + 0.5)
220 #define RECS80_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME + 0.5)
221 #define RECS80_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME + 0.5)
222 #define RECS80_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME + 0.5)
223 #define RECS80_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME + 0.5)
224 #define RECS80_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
226 #define RC5_START_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5)
227 #define RC5_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5)
228 #define RC5_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC5_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
230 #define RC6_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME + 0.5)
231 #define RC6_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME + 0.5)
232 #define RC6_TOGGLE_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME + 0.5)
233 #define RC6_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_BIT_TIME + 0.5)
234 #define RC6_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC6_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
236 #define DENON_PULSE_LEN (uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME + 0.5)
237 #define DENON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME + 0.5)
238 #define DENON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME + 0.5)
239 #define DENON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
240 #define DENON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
242 #define THOMSON_PULSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME + 0.5)
243 #define THOMSON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME + 0.5)
244 #define THOMSON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME + 0.5)
245 #define THOMSON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * THOMSON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
246 #define THOMSON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * THOMSON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
248 #define RECS80EXT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME + 0.5)
249 #define RECS80EXT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME + 0.5)
250 #define RECS80EXT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME + 0.5)
251 #define RECS80EXT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME + 0.5)
252 #define RECS80EXT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME + 0.5)
253 #define RECS80EXT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80EXT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
255 #define NUBERT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME + 0.5)
256 #define NUBERT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME + 0.5)
257 #define NUBERT_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME + 0.5)
258 #define NUBERT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME + 0.5)
259 #define NUBERT_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME + 0.5)
260 #define NUBERT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME + 0.5)
261 #define NUBERT_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
262 #define NUBERT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
264 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME + 0.5)
265 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME + 0.5)
266 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME + 0.5)
267 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME + 0.5)
268 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME + 0.5)
269 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME + 0.5)
270 #define BANG_OLUFSEN_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME + 0.5)
271 #define BANG_OLUFSEN_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME + 0.5)
272 #define BANG_OLUFSEN_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME + 0.5)
273 #define BANG_OLUFSEN_R_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME + 0.5)
274 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME + 0.5)
275 #define BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BANG_OLUFSEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
277 #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME + 0.5)
278 #define GRUNDIG_NOKIA_IR60_BIT_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME + 0.5)
279 #define GRUNDIG_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
280 #define NOKIA_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NOKIA_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
281 #define GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
283 #define IR60_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * IR60_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
285 #define SIEMENS_START_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME + 0.5)
286 #define SIEMENS_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME + 0.5)
287 #define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
290 #ifdef PIC_C18 // PIC C18
291 # define IRSND_FREQ_TYPE uint8_t
292 # define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 30000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
293 # define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 32000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
294 # define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 36000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
295 # define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 38000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
296 # define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 40000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
297 # define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 56000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
298 # define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 455000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
299 #elif defined (ARM_STM32) // STM32
300 # define IRSND_FREQ_TYPE uint32_t
301 # define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) (30000)
302 # define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) (32000)
303 # define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) (36000)
304 # define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) (38000)
305 # define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) (40000)
306 # define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) (56000)
307 # define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) (455000)
309 # define IRSND_FREQ_TYPE uint8_t
310 # define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 30000 / 2) - 1)
311 # define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 32000 / 2) - 1)
312 # define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 36000 / 2) - 1)
313 # define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 38000 / 2) - 1)
314 # define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 40000 / 2) - 1)
315 # define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 56000 / 2) - 1)
316 # define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 455000 / 2) - 1)
319 #define FDC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME + 0.5)
320 #define FDC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME + 0.5)
321 #define FDC_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME + 0.5)
322 #define FDC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME + 0.5)
323 #define FDC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME + 0.5)
324 #define FDC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * FDC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
326 #define RCCAR_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME + 0.5)
327 #define RCCAR_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME + 0.5)
328 #define RCCAR_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME + 0.5)
329 #define RCCAR_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME + 0.5)
330 #define RCCAR_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME + 0.5)
331 #define RCCAR_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RCCAR_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
333 #define JVC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME + 0.5)
334 #define JVC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PAUSE_TIME + 0.5)
335 #define JVC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_REPEAT_START_BIT_PAUSE_TIME + 0.5)
336 #define JVC_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME + 0.5)
337 #define JVC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME + 0.5)
338 #define JVC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME + 0.5)
339 #define JVC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
341 #define NIKON_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME + 0.5)
342 #define NIKON_START_BIT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME + 0.5)
343 #define NIKON_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME + 0.5)
344 #define NIKON_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME + 0.5)
345 #define NIKON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME + 0.5)
346 #define NIKON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME + 0.5)
347 #define NIKON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
349 #define LEGO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME + 0.5)
350 #define LEGO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME + 0.5)
351 #define LEGO_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_REPEAT_START_BIT_PAUSE_TIME + 0.5)
352 #define LEGO_PULSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_PULSE_TIME + 0.5)
353 #define LEGO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME + 0.5)
354 #define LEGO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME + 0.5)
355 #define LEGO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * LEGO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
357 static volatile uint8_t irsnd_busy
= 0;
358 static volatile uint8_t irsnd_protocol
= 0;
359 static volatile uint8_t irsnd_buffer
[6] = {0};
360 static volatile uint8_t irsnd_repeat
= 0;
361 static volatile uint8_t irsnd_is_on
= FALSE
;
363 #if IRSND_USE_CALLBACK == 1
364 static void (*irsnd_callback_ptr
) (uint8_t);
365 #endif // IRSND_USE_CALLBACK == 1
367 /*---------------------------------------------------------------------------------------------------------------------------------------------------
369 * @details Switches PWM on with a narrow spike on all 3 channels -> leds glowing
370 *---------------------------------------------------------------------------------------------------------------------------------------------------
378 # if defined(PIC_C18) // PIC C18
379 IRSND_PIN
= 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off)
380 # elif defined (ARM_STM32) // STM32
381 TIM_SelectOCxM(IRSND_TIMER
, IRSND_TIMER_CHANNEL
, TIM_OCMode_PWM1
); // enable PWM as OC-mode
382 TIM_CCxCmd(IRSND_TIMER
, IRSND_TIMER_CHANNEL
, TIM_CCx_Enable
); // enable OC-output (is being disabled in TIM_SelectOCxM())
383 TIM_Cmd(IRSND_TIMER
, ENABLE
); // enable counter
385 # if IRSND_OCx == IRSND_OC2 // use OC2
386 TCCR2
|= (1<<COM20
)|(1<<WGM21
); // toggle OC2 on compare match, clear Timer 2 at compare match OCR2
387 # elif IRSND_OCx == IRSND_OC2A // use OC2A
388 TCCR2A
|= (1<<COM2A0
)|(1<<WGM21
); // toggle OC2A on compare match, clear Timer 2 at compare match OCR2A
389 # elif IRSND_OCx == IRSND_OC2B // use OC2B
390 TCCR2A
|= (1<<COM2B0
)|(1<<WGM21
); // toggle OC2B on compare match, clear Timer 2 at compare match OCR2A (yes: A, not B!)
391 # elif IRSND_OCx == IRSND_OC0 // use OC0
392 TCCR0
|= (1<<COM00
)|(1<<WGM01
); // toggle OC0 on compare match, clear Timer 0 at compare match OCR0
393 # elif IRSND_OCx == IRSND_OC0A // use OC0A
394 TCCR0A
|= (1<<COM0A0
)|(1<<WGM01
); // toggle OC0A on compare match, clear Timer 0 at compare match OCR0A
395 # elif IRSND_OCx == IRSND_OC0B // use OC0B
396 TCCR0A
|= (1<<COM0B0
)|(1<<WGM01
); // toggle OC0B on compare match, clear Timer 0 at compare match OCR0A (yes: A, not B!)
398 # error wrong value of IRSND_OCx
403 #if IRSND_USE_CALLBACK == 1
404 if (irsnd_callback_ptr
)
406 (*irsnd_callback_ptr
) (TRUE
);
408 #endif // IRSND_USE_CALLBACK == 1
414 /*---------------------------------------------------------------------------------------------------------------------------------------------------
416 * @details Switches PWM off
417 *---------------------------------------------------------------------------------------------------------------------------------------------------
426 # if defined(PIC_C18) // PIC C18
427 IRSND_PIN
= 1; //input mode -> disbale PWM output pin (0=PWM on, 1=PWM off)
428 # elif defined (ARM_STM32) // STM32
429 TIM_Cmd(IRSND_TIMER
, DISABLE
); // disable counter
430 TIM_SelectOCxM(IRSND_TIMER
, IRSND_TIMER_CHANNEL
, TIM_ForcedAction_InActive
); // force output inactive
431 TIM_CCxCmd(IRSND_TIMER
, IRSND_TIMER_CHANNEL
, TIM_CCx_Enable
); // enable OC-output (is being disabled in TIM_SelectOCxM())
432 TIM_SetCounter(IRSND_TIMER
, 0); // reset counter value
435 # if IRSND_OCx == IRSND_OC2 // use OC2
436 TCCR2
&= ~(1<<COM20
); // normal port operation, OC2 disconnected.
437 # elif IRSND_OCx == IRSND_OC2A // use OC2A
438 TCCR2A
&= ~(1<<COM2A0
); // normal port operation, OC2A disconnected.
439 # elif IRSND_OCx == IRSND_OC2B // use OC2B
440 TCCR2A
&= ~(1<<COM2B0
); // normal port operation, OC2B disconnected.
441 # elif IRSND_OCx == IRSND_OC0 // use OC0
442 TCCR0
&= ~(1<<COM00
); // normal port operation, OC0 disconnected.
443 # elif IRSND_OCx == IRSND_OC0A // use OC0A
444 TCCR0A
&= ~(1<<COM0A0
); // normal port operation, OC0A disconnected.
445 # elif IRSND_OCx == IRSND_OC0B // use OC0B
446 TCCR0A
&= ~(1<<COM0B0
); // normal port operation, OC0B disconnected.
448 # error wrong value of IRSND_OCx
450 IRSND_PORT
&= ~(1<<IRSND_BIT
); // set IRSND_BIT to low
454 #if IRSND_USE_CALLBACK == 1
455 if (irsnd_callback_ptr
)
457 (*irsnd_callback_ptr
) (FALSE
);
459 #endif // IRSND_USE_CALLBACK == 1
465 /*---------------------------------------------------------------------------------------------------------------------------------------------------
467 * @details sets pwm frequency
468 *---------------------------------------------------------------------------------------------------------------------------------------------------
471 irsnd_set_freq (IRSND_FREQ_TYPE freq
)
474 # if defined(PIC_C18) // PIC C18
476 SetDCPWM( (uint16_t) freq
* 2); // freq*2 = Duty cycles 50%
477 # elif defined (ARM_STM32) // STM32
478 static uint32_t TimeBaseFreq
= 0;
480 if (TimeBaseFreq
== 0)
482 RCC_ClocksTypeDef RCC_ClocksStructure
;
483 /* Get system clocks and store timer clock in variable */
484 RCC_GetClocksFreq(&RCC_ClocksStructure
);
485 # if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14))
486 if (RCC_ClocksStructure
.PCLK1_Frequency
== RCC_ClocksStructure
.HCLK_Frequency
)
488 TimeBaseFreq
= RCC_ClocksStructure
.PCLK1_Frequency
;
492 TimeBaseFreq
= RCC_ClocksStructure
.PCLK1_Frequency
* 2;
495 if (RCC_ClocksStructure
.PCLK2_Frequency
== RCC_ClocksStructure
.HCLK_Frequency
)
497 TimeBaseFreq
= RCC_ClocksStructure
.PCLK2_Frequency
;
501 TimeBaseFreq
= RCC_ClocksStructure
.PCLK2_Frequency
* 2;
506 freq
= TimeBaseFreq
/freq
;
509 TIM_SetAutoreload(IRSND_TIMER
, freq
- 1);
511 TIM_SetCompare1(IRSND_TIMER
, (freq
+ 1) / 2);
514 # if IRSND_OCx == IRSND_OC2
515 OCR2
= freq
; // use register OCR2 for OC2
516 # elif IRSND_OCx == IRSND_OC2A // use OC2A
517 OCR2A
= freq
; // use register OCR2A for OC2A and OC2B!
518 # elif IRSND_OCx == IRSND_OC2B // use OC2B
519 OCR2A
= freq
; // use register OCR2A for OC2A and OC2B!
520 # elif IRSND_OCx == IRSND_OC0 // use OC0
521 OCR0
= freq
; // use register OCR2 for OC2
522 # elif IRSND_OCx == IRSND_OC0A // use OC0A
523 OCR0A
= freq
; // use register OCR0A for OC0A and OC0B!
524 # elif IRSND_OCx == IRSND_OC0B // use OC0B
525 OCR0A
= freq
; // use register OCR0A for OC0A and OC0B!
527 # error wrong value of IRSND_OCx
533 /*---------------------------------------------------------------------------------------------------------------------------------------------------
535 * @details Configures 0CR0A, 0CR0B and 0CR2B as PWM channels
536 *---------------------------------------------------------------------------------------------------------------------------------------------------
542 # if defined(PIC_C18) // PIC C18
544 irsnd_set_freq (IRSND_FREQ_36_KHZ
); //default frequency
545 IRSND_PIN
= 1; //default PWM output pin off (0=PWM on, 1=PWM off)
546 # elif defined (ARM_STM32) // STM32
547 GPIO_InitTypeDef GPIO_InitStructure
;
548 TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure
;
549 TIM_OCInitTypeDef TIM_OCInitStructure
;
551 /* GPIOx clock enable */
552 # if defined (ARM_STM32L1XX)
553 RCC_AHBPeriphClockCmd(IRSND_PORT_RCC
, ENABLE
);
554 # elif defined (ARM_STM32F10X)
555 RCC_APB2PeriphClockCmd(IRSND_PORT_RCC
, ENABLE
);
556 # elif defined (ARM_STM32F4XX)
557 RCC_AHB1PeriphClockCmd(IRSND_PORT_RCC
, ENABLE
);
560 /* GPIO Configuration */
561 GPIO_InitStructure
.GPIO_Pin
= IRSND_BIT
;
562 # if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX)
563 GPIO_InitStructure
.GPIO_Mode
= GPIO_Mode_AF
;
564 GPIO_InitStructure
.GPIO_Speed
= GPIO_Speed_2MHz
;
565 GPIO_InitStructure
.GPIO_OType
= GPIO_OType_PP
;
566 GPIO_InitStructure
.GPIO_PuPd
= GPIO_PuPd_NOPULL
;
567 GPIO_Init(IRSND_PORT
, &GPIO_InitStructure
);
568 GPIO_PinAFConfig(IRSND_PORT
, (uint8_t)IRSND_BIT_NUMBER
, IRSND_GPIO_AF
);
569 # elif defined (ARM_STM32F10X)
570 GPIO_InitStructure
.GPIO_Speed
= GPIO_Speed_2MHz
;
571 GPIO_InitStructure
.GPIO_Mode
= GPIO_Mode_AF_PP
;
572 GPIO_Init(IRSND_PORT
, &GPIO_InitStructure
);
573 GPIO_PinRemapConfig(, ENABLE
); // TODO: remapping required
576 /* TIMx clock enable */
577 # if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14))
578 RCC_APB1PeriphClockCmd(IRSND_TIMER_RCC
, ENABLE
);
580 RCC_APB2PeriphClockCmd(IRSND_TIMER_RCC
, ENABLE
);
583 /* Time base configuration */
584 TIM_TimeBaseStructure
.TIM_Period
= -1; // set dummy value (don't set to 0), will be initialized later
585 TIM_TimeBaseStructure
.TIM_Prescaler
= 0;
586 TIM_TimeBaseStructure
.TIM_ClockDivision
= 0;
587 TIM_TimeBaseStructure
.TIM_CounterMode
= TIM_CounterMode_Up
;
588 TIM_TimeBaseInit(IRSND_TIMER
, &TIM_TimeBaseStructure
);
590 /* PWM1 Mode configuration */
591 TIM_OCInitStructure
.TIM_OCMode
= TIM_OCMode_PWM1
;
592 TIM_OCInitStructure
.TIM_OutputState
= TIM_OutputState_Enable
;
593 TIM_OCInitStructure
.TIM_Pulse
= 0; // will be initialized later
594 TIM_OCInitStructure
.TIM_OCPolarity
= TIM_OCPolarity_High
;
595 TIM_OC1Init(IRSND_TIMER
, &TIM_OCInitStructure
);
597 /* Preload configuration */
598 TIM_ARRPreloadConfig(IRSND_TIMER
, ENABLE
);
599 TIM_OC1PreloadConfig(IRSND_TIMER
, TIM_OCPreload_Enable
);
601 irsnd_set_freq (IRSND_FREQ_36_KHZ
); // set default frequency
603 IRSND_PORT
&= ~(1<<IRSND_BIT
); // set IRSND_BIT to low
604 IRSND_DDR
|= (1<<IRSND_BIT
); // set IRSND_BIT to output
606 # if IRSND_OCx == IRSND_OC2 // use OC2
607 TCCR2
= (1<<WGM21
); // CTC mode
608 TCCR2
|= (1<<CS20
); // 0x01, start Timer 2, no prescaling
609 # elif IRSND_OCx == IRSND_OC2A || IRSND_OCx == IRSND_OC2B // use OC2A or OC2B
610 TCCR2A
= (1<<WGM21
); // CTC mode
611 TCCR2B
|= (1<<CS20
); // 0x01, start Timer 2, no prescaling
612 # elif IRSND_OCx == IRSND_OC0 // use OC0
613 TCCR0
= (1<<WGM01
); // CTC mode
614 TCCR0
|= (1<<CS00
); // 0x01, start Timer 0, no prescaling
615 # elif IRSND_OCx == IRSND_OC0A || IRSND_OCx == IRSND_OC0B // use OC0A or OC0B
616 TCCR0A
= (1<<WGM01
); // CTC mode
617 TCCR0B
|= (1<<CS00
); // 0x01, start Timer 0, no prescaling
619 # error wrong value of IRSND_OCx
621 irsnd_set_freq (IRSND_FREQ_36_KHZ
); // default frequency
626 #if IRSND_USE_CALLBACK == 1
628 irsnd_set_callback_ptr (void (*cb
)(uint8_t))
630 irsnd_callback_ptr
= cb
;
632 #endif // IRSND_USE_CALLBACK == 1
641 bitsrevervse (uint16_t x
, uint8_t len
)
659 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
660 static uint8_t sircs_additional_bitlen
;
661 #endif // IRSND_SUPPORT_SIRCS_PROTOCOL == 1
664 irsnd_send_data (IRMP_DATA
* irmp_data_p
, uint8_t do_wait
)
666 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
667 static uint8_t toggle_bit_recs80
;
669 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
670 static uint8_t toggle_bit_recs80ext
;
672 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
673 static uint8_t toggle_bit_rc5
;
675 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
676 static uint8_t toggle_bit_rc6
;
678 #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1
679 static uint8_t toggle_bit_thomson
;
696 irsnd_protocol
= irmp_data_p
->protocol
;
697 irsnd_repeat
= irmp_data_p
->flags
& IRSND_REPETITION_MASK
;
699 switch (irsnd_protocol
)
701 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
702 case IRMP_SIRCS_PROTOCOL
:
704 // uint8_t sircs_additional_command_len;
705 uint8_t sircs_additional_address_len
;
707 sircs_additional_bitlen
= (irmp_data_p
->address
& 0xFF00) >> 8; // additional bitlen
709 if (sircs_additional_bitlen
> 15 - SIRCS_MINIMUM_DATA_LEN
)
711 // sircs_additional_command_len = 15 - SIRCS_MINIMUM_DATA_LEN;
712 sircs_additional_address_len
= sircs_additional_bitlen
- (15 - SIRCS_MINIMUM_DATA_LEN
);
716 // sircs_additional_command_len = sircs_additional_bitlen;
717 sircs_additional_address_len
= 0;
720 command
= bitsrevervse (irmp_data_p
->command
, 15);
722 irsnd_buffer
[0] = (command
& 0x7F80) >> 7; // CCCCCCCC
723 irsnd_buffer
[1] = (command
& 0x007F) << 1; // CCCC****
725 if (sircs_additional_address_len
> 0)
727 address
= bitsrevervse (irmp_data_p
->address
, 5);
728 irsnd_buffer
[1] |= (address
& 0x0010) >> 4;
729 irsnd_buffer
[2] = (address
& 0x000F) << 4;
735 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
736 case IRMP_APPLE_PROTOCOL
:
738 command
= irmp_data_p
->command
| (irmp_data_p
->address
<< 8); // store address as ID in upper byte of command
739 address
= 0x87EE; // set fixed NEC-lookalike address (customer ID of apple)
741 address
= bitsrevervse (address
, NEC_ADDRESS_LEN
);
742 command
= bitsrevervse (command
, NEC_COMMAND_LEN
);
744 irsnd_protocol
= IRMP_NEC_PROTOCOL
; // APPLE protocol is NEC with id instead of inverted command
746 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
747 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
748 irsnd_buffer
[2] = (command
& 0xFF00) >> 8; // CCCCCCCC
749 irsnd_buffer
[3] = 0x8B; // 10001011 (id)
753 case IRMP_NEC_PROTOCOL
:
755 address
= bitsrevervse (irmp_data_p
->address
, NEC_ADDRESS_LEN
);
756 command
= bitsrevervse (irmp_data_p
->command
, NEC_COMMAND_LEN
);
758 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
759 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
760 irsnd_buffer
[2] = (command
& 0xFF00) >> 8; // CCCCCCCC
761 irsnd_buffer
[3] = ~((command
& 0xFF00) >> 8); // cccccccc
766 #if IRSND_SUPPORT_NEC16_PROTOCOL == 1
767 case IRMP_NEC16_PROTOCOL
:
769 address
= bitsrevervse (irmp_data_p
->address
, NEC16_ADDRESS_LEN
);
770 command
= bitsrevervse (irmp_data_p
->command
, NEC16_COMMAND_LEN
);
772 irsnd_buffer
[0] = (address
& 0x00FF); // AAAAAAAA
773 irsnd_buffer
[1] = (command
& 0x00FF); // CCCCCCCC
778 #if IRSND_SUPPORT_NEC42_PROTOCOL == 1
779 case IRMP_NEC42_PROTOCOL
:
781 address
= bitsrevervse (irmp_data_p
->address
, NEC42_ADDRESS_LEN
);
782 command
= bitsrevervse (irmp_data_p
->command
, NEC42_COMMAND_LEN
);
784 irsnd_buffer
[0] = ( (address
& 0x1FE0) >> 5); // AAAAAAAA
785 irsnd_buffer
[1] = ( (address
& 0x001F) << 3) | ((~address
& 0x1C00) >> 10); // AAAAAaaa
786 irsnd_buffer
[2] = ((~address
& 0x03FC) >> 2); // aaaaaaaa
787 irsnd_buffer
[3] = ((~address
& 0x0003) << 6) | ( (command
& 0x00FC) >> 2); // aaCCCCCC
788 irsnd_buffer
[4] = ( (command
& 0x0003) << 6) | ((~command
& 0x00FC) >> 2); // CCcccccc
789 irsnd_buffer
[5] = ((~command
& 0x0003) << 6); // cc
794 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
795 case IRMP_SAMSUNG_PROTOCOL
:
797 address
= bitsrevervse (irmp_data_p
->address
, SAMSUNG_ADDRESS_LEN
);
798 command
= bitsrevervse (irmp_data_p
->command
, SAMSUNG_COMMAND_LEN
);
800 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
801 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
802 irsnd_buffer
[2] = (command
& 0x00F0) | ((command
& 0xF000) >> 12); // IIIICCCC
803 irsnd_buffer
[3] = ((command
& 0x0F00) >> 4) | ((~(command
& 0xF000) >> 12) & 0x0F); // CCCCcccc
804 irsnd_buffer
[4] = (~(command
& 0x0F00) >> 4) & 0xF0; // cccc0000
808 case IRMP_SAMSUNG32_PROTOCOL
:
810 address
= bitsrevervse (irmp_data_p
->address
, SAMSUNG_ADDRESS_LEN
);
811 command
= bitsrevervse (irmp_data_p
->command
, SAMSUNG32_COMMAND_LEN
);
813 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
814 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
815 irsnd_buffer
[2] = (command
& 0xFF00) >> 8; // CCCCCCCC
816 irsnd_buffer
[3] = (command
& 0x00FF); // CCCCCCCC
821 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
822 case IRMP_MATSUSHITA_PROTOCOL
:
824 address
= bitsrevervse (irmp_data_p
->address
, MATSUSHITA_ADDRESS_LEN
);
825 command
= bitsrevervse (irmp_data_p
->command
, MATSUSHITA_COMMAND_LEN
);
827 irsnd_buffer
[0] = (command
& 0x0FF0) >> 4; // CCCCCCCC
828 irsnd_buffer
[1] = ((command
& 0x000F) << 4) | ((address
& 0x0F00) >> 8); // CCCCAAAA
829 irsnd_buffer
[2] = (address
& 0x00FF); // AAAAAAAA
834 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
835 case IRMP_KASEIKYO_PROTOCOL
:
840 address
= bitsrevervse (irmp_data_p
->address
, KASEIKYO_ADDRESS_LEN
);
841 command
= bitsrevervse (irmp_data_p
->command
, KASEIKYO_COMMAND_LEN
+ 4);
842 genre2
= bitsrevervse ((irmp_data_p
->flags
& ~IRSND_REPETITION_MASK
) >> 4, 4);
844 xor = ((address
& 0x000F) ^ ((address
& 0x00F0) >> 4) ^ ((address
& 0x0F00) >> 8) ^ ((address
& 0xF000) >> 12)) & 0x0F;
846 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
847 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
848 irsnd_buffer
[2] = xor << 4 | (command
& 0x000F); // XXXXCCCC
849 irsnd_buffer
[3] = (genre2
<< 4) | (command
& 0xF000) >> 12; // ggggCCCC
850 irsnd_buffer
[4] = (command
& 0x0FF0) >> 4; // CCCCCCCC
852 xor = irsnd_buffer
[2] ^ irsnd_buffer
[3] ^ irsnd_buffer
[4];
854 irsnd_buffer
[5] = xor;
859 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
860 case IRMP_RECS80_PROTOCOL
:
862 toggle_bit_recs80
= toggle_bit_recs80
? 0x00 : 0x40;
864 irsnd_buffer
[0] = 0x80 | toggle_bit_recs80
| ((irmp_data_p
->address
& 0x0007) << 3) |
865 ((irmp_data_p
->command
& 0x0038) >> 3); // STAAACCC
866 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x07) << 5; // CCC00000
871 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
872 case IRMP_RECS80EXT_PROTOCOL
:
874 toggle_bit_recs80ext
= toggle_bit_recs80ext
? 0x00 : 0x40;
876 irsnd_buffer
[0] = 0x80 | toggle_bit_recs80ext
| ((irmp_data_p
->address
& 0x000F) << 2) |
877 ((irmp_data_p
->command
& 0x0030) >> 4); // STAAAACC
878 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x0F) << 4; // CCCC0000
883 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
884 case IRMP_RC5_PROTOCOL
:
886 toggle_bit_rc5
= toggle_bit_rc5
? 0x00 : 0x40;
888 irsnd_buffer
[0] = ((irmp_data_p
->command
& 0x40) ? 0x00 : 0x80) | toggle_bit_rc5
|
889 ((irmp_data_p
->address
& 0x001F) << 1) | ((irmp_data_p
->command
& 0x20) >> 5); // CTAAAAAC
890 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x1F) << 3; // CCCCC000
895 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
896 case IRMP_RC6_PROTOCOL
:
898 toggle_bit_rc6
= toggle_bit_rc6
? 0x00 : 0x08;
900 irsnd_buffer
[0] = 0x80 | toggle_bit_rc6
| ((irmp_data_p
->address
& 0x00E0) >> 5); // 1MMMTAAA, MMM = 000
901 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x001F) << 3) | ((irmp_data_p
->command
& 0xE0) >> 5); // AAAAACCC
902 irsnd_buffer
[2] = (irmp_data_p
->command
& 0x1F) << 3; // CCCCC
907 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
908 case IRMP_RC6A_PROTOCOL
:
910 toggle_bit_rc6
= toggle_bit_rc6
? 0x00 : 0x08;
912 irsnd_buffer
[0] = 0x80 | 0x60 | ((irmp_data_p
->address
& 0x3000) >> 12); // 1MMMT0AA, MMM = 110
913 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x0FFF) >> 4) ; // AAAAAAAA
914 irsnd_buffer
[2] = ((irmp_data_p
->address
& 0x000F) << 4) | ((irmp_data_p
->command
& 0xF000) >> 12) | toggle_bit_rc6
; // AAAACCCC
915 irsnd_buffer
[3] = (irmp_data_p
->command
& 0x0FF0) >> 4; // CCCCCCCC
916 irsnd_buffer
[4] = (irmp_data_p
->command
& 0x000F) << 4; // CCCC
921 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
922 case IRMP_DENON_PROTOCOL
:
924 irsnd_buffer
[0] = ((irmp_data_p
->address
& 0x1F) << 3) | ((irmp_data_p
->command
& 0x0380) >> 7); // AAAAACCC (1st frame)
925 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x7F) << 1; // CCCCCCC
926 irsnd_buffer
[2] = ((irmp_data_p
->address
& 0x1F) << 3) | (((~irmp_data_p
->command
) & 0x0380) >> 7); // AAAAAccc (2nd frame)
927 irsnd_buffer
[3] = (~(irmp_data_p
->command
) & 0x7F) << 1; // ccccccc
932 #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1
933 case IRMP_THOMSON_PROTOCOL
:
935 toggle_bit_thomson
= toggle_bit_thomson
? 0x00 : 0x08;
937 irsnd_buffer
[0] = ((irmp_data_p
->address
& 0x0F) << 4) | toggle_bit_thomson
| ((irmp_data_p
->command
& 0x0070) >> 4); // AAAATCCC (1st frame)
938 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x0F) << 4; // CCCC
943 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
944 case IRMP_NUBERT_PROTOCOL
:
946 irsnd_buffer
[0] = irmp_data_p
->command
>> 2; // CCCCCCCC
947 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x0003) << 6; // CC000000
952 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
953 case IRMP_BANG_OLUFSEN_PROTOCOL
:
955 irsnd_buffer
[0] = irmp_data_p
->command
>> 11; // SXSCCCCC
956 irsnd_buffer
[1] = irmp_data_p
->command
>> 3; // CCCCCCCC
957 irsnd_buffer
[2] = (irmp_data_p
->command
& 0x0007) << 5; // CCC00000
962 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
963 case IRMP_GRUNDIG_PROTOCOL
:
965 command
= bitsrevervse (irmp_data_p
->command
, GRUNDIG_COMMAND_LEN
);
967 irsnd_buffer
[0] = 0xFF; // S1111111 (1st frame)
968 irsnd_buffer
[1] = 0xC0; // 11
969 irsnd_buffer
[2] = 0x80 | (command
>> 2); // SCCCCCCC (2nd frame)
970 irsnd_buffer
[3] = (command
<< 6) & 0xC0; // CC
976 #if IRSND_SUPPORT_IR60_PROTOCOL == 1
977 case IRMP_IR60_PROTOCOL
:
979 command
= (bitsrevervse (0x7d, IR60_COMMAND_LEN
) << 7) | bitsrevervse (irmp_data_p
->command
, IR60_COMMAND_LEN
);
981 irsnd_buffer
[0] = command
>> 6 | 0x01; // 1011111S (start instruction frame)
982 irsnd_buffer
[1] = (command
& 0x7F) << 1; // CCCCCCC_ (2nd frame)
984 irsnd_buffer
[0] = ((command
& 0x7F) << 1) | 0x01; // CCCCCCCS (1st frame)
985 irsnd_buffer
[1] = command
>> 6; // 1011111_ (start instruction frame)
992 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
993 case IRMP_NOKIA_PROTOCOL
:
995 address
= bitsrevervse (irmp_data_p
->address
, NOKIA_ADDRESS_LEN
);
996 command
= bitsrevervse (irmp_data_p
->command
, NOKIA_COMMAND_LEN
);
998 irsnd_buffer
[0] = 0xBF; // S0111111 (1st + 3rd frame)
999 irsnd_buffer
[1] = 0xFF; // 11111111
1000 irsnd_buffer
[2] = 0x80; // 1
1001 irsnd_buffer
[3] = 0x80 | command
>> 1; // SCCCCCCC (2nd frame)
1002 irsnd_buffer
[4] = (command
<< 7) | (address
>> 1); // CAAAAAAA
1003 irsnd_buffer
[5] = (address
<< 7); // A
1009 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
1010 case IRMP_SIEMENS_PROTOCOL
:
1012 irsnd_buffer
[0] = ((irmp_data_p
->address
& 0x0FFF) >> 5); // SAAAAAAA
1013 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x1F) << 3) | ((irmp_data_p
->command
& 0x7F) >> 5); // AAAAA0CC
1014 irsnd_buffer
[2] = (irmp_data_p
->command
<< 3) | ((~irmp_data_p
->command
& 0x01) << 2); // CCCCCc
1020 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1021 case IRMP_FDC_PROTOCOL
:
1023 address
= bitsrevervse (irmp_data_p
->address
, FDC_ADDRESS_LEN
);
1024 command
= bitsrevervse (irmp_data_p
->command
, FDC_COMMAND_LEN
);
1026 irsnd_buffer
[0] = (address
& 0xFF); // AAAAAAAA
1027 irsnd_buffer
[1] = 0; // 00000000
1028 irsnd_buffer
[2] = 0; // 0000RRRR
1029 irsnd_buffer
[3] = (command
& 0xFF); // CCCCCCCC
1030 irsnd_buffer
[4] = ~(command
& 0xFF); // cccccccc
1035 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
1036 case IRMP_RCCAR_PROTOCOL
:
1038 address
= bitsrevervse (irmp_data_p
->address
, 2); // A0 A1
1039 command
= bitsrevervse (irmp_data_p
->command
, RCCAR_COMMAND_LEN
- 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V
1041 irsnd_buffer
[0] = ((command
& 0x06) << 5) | ((address
& 0x0003) << 4) | ((command
& 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3
1042 irsnd_buffer
[1] = ((command
& 0x78) << 1) | ((command
& 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0
1048 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
1049 case IRMP_JVC_PROTOCOL
:
1051 address
= bitsrevervse (irmp_data_p
->address
, JVC_ADDRESS_LEN
);
1052 command
= bitsrevervse (irmp_data_p
->command
, JVC_COMMAND_LEN
);
1054 irsnd_buffer
[0] = ((address
& 0x000F) << 4) | (command
& 0x0F00) >> 8; // AAAACCCC
1055 irsnd_buffer
[1] = (command
& 0x00FF); // CCCCCCCC
1061 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
1062 case IRMP_NIKON_PROTOCOL
:
1064 irsnd_buffer
[0] = (irmp_data_p
->command
& 0x0003) << 6; // CC
1069 #if IRSND_SUPPORT_LEGO_PROTOCOL == 1
1070 case IRMP_LEGO_PROTOCOL
:
1072 uint8_t crc
= 0x0F ^ ((irmp_data_p
->command
& 0x0F00) >> 8) ^ ((irmp_data_p
->command
& 0x00F0) >> 4) ^ (irmp_data_p
->command
& 0x000F);
1074 irsnd_buffer
[0] = (irmp_data_p
->command
& 0x0FF0) >> 4; // CCCCCCCC
1075 irsnd_buffer
[1] = ((irmp_data_p
->command
& 0x000F) << 4) | crc
; // CCCCcccc
1077 irsnd_protocol
= IRMP_LEGO_PROTOCOL
;
1097 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1099 * @details ISR routine, called 10000 times per second
1100 *---------------------------------------------------------------------------------------------------------------------------------------------------
1105 static uint8_t send_trailer
= FALSE
;
1106 static uint8_t current_bit
= 0xFF;
1107 static uint8_t pulse_counter
= 0;
1108 static IRSND_PAUSE_LEN pause_counter
= 0;
1109 static uint8_t startbit_pulse_len
= 0;
1110 static IRSND_PAUSE_LEN startbit_pause_len
= 0;
1111 static uint8_t pulse_1_len
= 0;
1112 static uint8_t pause_1_len
= 0;
1113 static uint8_t pulse_0_len
= 0;
1114 static uint8_t pause_0_len
= 0;
1115 static uint8_t has_stop_bit
= 0;
1116 static uint8_t new_frame
= TRUE
;
1117 static uint8_t complete_data_len
= 0;
1118 static uint8_t n_repeat_frames
= 0; // number of repetition frames
1119 static uint8_t n_auto_repetitions
= 0; // number of auto_repetitions
1120 static uint8_t auto_repetition_counter
= 0; // auto_repetition counter
1121 static uint16_t auto_repetition_pause_len
= 0; // pause before auto_repetition, uint16_t!
1122 static uint16_t auto_repetition_pause_counter
= 0; // pause before auto_repetition, uint16_t!
1123 static uint8_t repeat_counter
= 0; // repeat counter
1124 static uint16_t repeat_frame_pause_len
= 0; // pause before repeat, uint16_t!
1125 static uint16_t packet_repeat_pause_counter
= 0; // pause before repeat, uint16_t!
1126 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1127 static uint8_t last_bit_value
;
1129 static uint8_t pulse_len
= 0xFF;
1130 static IRSND_PAUSE_LEN pause_len
= 0xFF;
1134 if (current_bit
== 0xFF && new_frame
) // start of transmission...
1136 if (auto_repetition_counter
> 0)
1138 auto_repetition_pause_counter
++;
1140 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1141 if (repeat_frame_pause_len
> 0) // frame repeat distance counts from beginning of 1st frame!
1143 repeat_frame_pause_len
--;
1147 if (auto_repetition_pause_counter
>= auto_repetition_pause_len
)
1149 auto_repetition_pause_counter
= 0;
1151 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1152 if (irsnd_protocol
== IRMP_DENON_PROTOCOL
) // n'th denon frame
1155 complete_data_len
= 2 * DENON_COMPLETE_DATA_LEN
+ 1;
1159 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
1160 if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
) // n'th grundig frame
1163 complete_data_len
= 16 + GRUNDIG_COMPLETE_DATA_LEN
;
1167 #if IRSND_SUPPORT_IR60_PROTOCOL == 1
1168 if (irsnd_protocol
== IRMP_IR60_PROTOCOL
) // n'th IR60 frame
1171 complete_data_len
= 2 * IR60_COMPLETE_DATA_LEN
+ 1;
1175 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1176 if (irsnd_protocol
== IRMP_NOKIA_PROTOCOL
) // n'th nokia frame
1178 if (auto_repetition_counter
+ 1 < n_auto_repetitions
)
1181 complete_data_len
= 24 + NOKIA_COMPLETE_DATA_LEN
;
1183 else // nokia stop frame
1186 complete_data_len
= NOKIA_COMPLETE_DATA_LEN
;
1211 else if (repeat_counter
> 0 && packet_repeat_pause_counter
< repeat_frame_pause_len
)
1213 else if (packet_repeat_pause_counter
< repeat_frame_pause_len
)
1216 packet_repeat_pause_counter
++;
1235 send_trailer
= FALSE
;
1239 n_repeat_frames
= irsnd_repeat
;
1241 if (n_repeat_frames
== IRSND_ENDLESS_REPETITION
)
1243 n_repeat_frames
= 255;
1246 packet_repeat_pause_counter
= 0;
1250 switch (irsnd_protocol
)
1252 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
1253 case IRMP_SIRCS_PROTOCOL
:
1255 startbit_pulse_len
= SIRCS_START_BIT_PULSE_LEN
;
1256 startbit_pause_len
= SIRCS_START_BIT_PAUSE_LEN
- 1;
1257 pulse_1_len
= SIRCS_1_PULSE_LEN
;
1258 pause_1_len
= SIRCS_PAUSE_LEN
- 1;
1259 pulse_0_len
= SIRCS_0_PULSE_LEN
;
1260 pause_0_len
= SIRCS_PAUSE_LEN
- 1;
1261 has_stop_bit
= SIRCS_STOP_BIT
;
1262 complete_data_len
= SIRCS_MINIMUM_DATA_LEN
+ sircs_additional_bitlen
;
1263 n_auto_repetitions
= (repeat_counter
== 0) ? SIRCS_FRAMES
: 1; // 3 frames auto repetition if first frame
1264 auto_repetition_pause_len
= SIRCS_AUTO_REPETITION_PAUSE_LEN
; // 25ms pause
1265 repeat_frame_pause_len
= SIRCS_FRAME_REPEAT_PAUSE_LEN
;
1266 irsnd_set_freq (IRSND_FREQ_40_KHZ
);
1270 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
1271 case IRMP_NEC_PROTOCOL
:
1273 startbit_pulse_len
= NEC_START_BIT_PULSE_LEN
;
1275 if (repeat_counter
> 0)
1277 startbit_pause_len
= NEC_REPEAT_START_BIT_PAUSE_LEN
- 1;
1278 complete_data_len
= 0;
1282 startbit_pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
1283 complete_data_len
= NEC_COMPLETE_DATA_LEN
;
1286 pulse_1_len
= NEC_PULSE_LEN
;
1287 pause_1_len
= NEC_1_PAUSE_LEN
- 1;
1288 pulse_0_len
= NEC_PULSE_LEN
;
1289 pause_0_len
= NEC_0_PAUSE_LEN
- 1;
1290 has_stop_bit
= NEC_STOP_BIT
;
1291 n_auto_repetitions
= 1; // 1 frame
1292 auto_repetition_pause_len
= 0;
1293 repeat_frame_pause_len
= NEC_FRAME_REPEAT_PAUSE_LEN
;
1294 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1298 #if IRSND_SUPPORT_NEC16_PROTOCOL == 1
1299 case IRMP_NEC16_PROTOCOL
:
1301 startbit_pulse_len
= NEC_START_BIT_PULSE_LEN
;
1302 startbit_pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
1303 pulse_1_len
= NEC_PULSE_LEN
;
1304 pause_1_len
= NEC_1_PAUSE_LEN
- 1;
1305 pulse_0_len
= NEC_PULSE_LEN
;
1306 pause_0_len
= NEC_0_PAUSE_LEN
- 1;
1307 has_stop_bit
= NEC_STOP_BIT
;
1308 complete_data_len
= NEC16_COMPLETE_DATA_LEN
+ 1; // 1 more: sync bit
1309 n_auto_repetitions
= 1; // 1 frame
1310 auto_repetition_pause_len
= 0;
1311 repeat_frame_pause_len
= NEC_FRAME_REPEAT_PAUSE_LEN
;
1312 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1316 #if IRSND_SUPPORT_NEC42_PROTOCOL == 1
1317 case IRMP_NEC42_PROTOCOL
:
1319 startbit_pulse_len
= NEC_START_BIT_PULSE_LEN
;
1320 startbit_pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
1321 pulse_1_len
= NEC_PULSE_LEN
;
1322 pause_1_len
= NEC_1_PAUSE_LEN
- 1;
1323 pulse_0_len
= NEC_PULSE_LEN
;
1324 pause_0_len
= NEC_0_PAUSE_LEN
- 1;
1325 has_stop_bit
= NEC_STOP_BIT
;
1326 complete_data_len
= NEC42_COMPLETE_DATA_LEN
;
1327 n_auto_repetitions
= 1; // 1 frame
1328 auto_repetition_pause_len
= 0;
1329 repeat_frame_pause_len
= NEC_FRAME_REPEAT_PAUSE_LEN
;
1330 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1334 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
1335 case IRMP_SAMSUNG_PROTOCOL
:
1337 startbit_pulse_len
= SAMSUNG_START_BIT_PULSE_LEN
;
1338 startbit_pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
1339 pulse_1_len
= SAMSUNG_PULSE_LEN
;
1340 pause_1_len
= SAMSUNG_1_PAUSE_LEN
- 1;
1341 pulse_0_len
= SAMSUNG_PULSE_LEN
;
1342 pause_0_len
= SAMSUNG_0_PAUSE_LEN
- 1;
1343 has_stop_bit
= SAMSUNG_STOP_BIT
;
1344 complete_data_len
= SAMSUNG_COMPLETE_DATA_LEN
;
1345 n_auto_repetitions
= 1; // 1 frame
1346 auto_repetition_pause_len
= 0;
1347 repeat_frame_pause_len
= SAMSUNG_FRAME_REPEAT_PAUSE_LEN
;
1348 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1352 case IRMP_SAMSUNG32_PROTOCOL
:
1354 startbit_pulse_len
= SAMSUNG_START_BIT_PULSE_LEN
;
1355 startbit_pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
1356 pulse_1_len
= SAMSUNG_PULSE_LEN
;
1357 pause_1_len
= SAMSUNG_1_PAUSE_LEN
- 1;
1358 pulse_0_len
= SAMSUNG_PULSE_LEN
;
1359 pause_0_len
= SAMSUNG_0_PAUSE_LEN
- 1;
1360 has_stop_bit
= SAMSUNG_STOP_BIT
;
1361 complete_data_len
= SAMSUNG32_COMPLETE_DATA_LEN
;
1362 n_auto_repetitions
= SAMSUNG32_FRAMES
; // 2 frames
1363 auto_repetition_pause_len
= SAMSUNG32_AUTO_REPETITION_PAUSE_LEN
; // 47 ms pause
1364 repeat_frame_pause_len
= SAMSUNG32_FRAME_REPEAT_PAUSE_LEN
;
1365 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1369 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
1370 case IRMP_MATSUSHITA_PROTOCOL
:
1372 startbit_pulse_len
= MATSUSHITA_START_BIT_PULSE_LEN
;
1373 startbit_pause_len
= MATSUSHITA_START_BIT_PAUSE_LEN
- 1;
1374 pulse_1_len
= MATSUSHITA_PULSE_LEN
;
1375 pause_1_len
= MATSUSHITA_1_PAUSE_LEN
- 1;
1376 pulse_0_len
= MATSUSHITA_PULSE_LEN
;
1377 pause_0_len
= MATSUSHITA_0_PAUSE_LEN
- 1;
1378 has_stop_bit
= MATSUSHITA_STOP_BIT
;
1379 complete_data_len
= MATSUSHITA_COMPLETE_DATA_LEN
;
1380 n_auto_repetitions
= 1; // 1 frame
1381 auto_repetition_pause_len
= 0;
1382 repeat_frame_pause_len
= MATSUSHITA_FRAME_REPEAT_PAUSE_LEN
;
1383 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1387 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
1388 case IRMP_KASEIKYO_PROTOCOL
:
1390 startbit_pulse_len
= KASEIKYO_START_BIT_PULSE_LEN
;
1391 startbit_pause_len
= KASEIKYO_START_BIT_PAUSE_LEN
- 1;
1392 pulse_1_len
= KASEIKYO_PULSE_LEN
;
1393 pause_1_len
= KASEIKYO_1_PAUSE_LEN
- 1;
1394 pulse_0_len
= KASEIKYO_PULSE_LEN
;
1395 pause_0_len
= KASEIKYO_0_PAUSE_LEN
- 1;
1396 has_stop_bit
= KASEIKYO_STOP_BIT
;
1397 complete_data_len
= KASEIKYO_COMPLETE_DATA_LEN
;
1398 n_auto_repetitions
= (repeat_counter
== 0) ? KASEIKYO_FRAMES
: 1; // 2 frames auto repetition if first frame
1399 auto_repetition_pause_len
= KASEIKYO_AUTO_REPETITION_PAUSE_LEN
; // 75 ms pause
1400 repeat_frame_pause_len
= KASEIKYO_FRAME_REPEAT_PAUSE_LEN
;
1401 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1405 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
1406 case IRMP_RECS80_PROTOCOL
:
1408 startbit_pulse_len
= RECS80_START_BIT_PULSE_LEN
;
1409 startbit_pause_len
= RECS80_START_BIT_PAUSE_LEN
- 1;
1410 pulse_1_len
= RECS80_PULSE_LEN
;
1411 pause_1_len
= RECS80_1_PAUSE_LEN
- 1;
1412 pulse_0_len
= RECS80_PULSE_LEN
;
1413 pause_0_len
= RECS80_0_PAUSE_LEN
- 1;
1414 has_stop_bit
= RECS80_STOP_BIT
;
1415 complete_data_len
= RECS80_COMPLETE_DATA_LEN
;
1416 n_auto_repetitions
= 1; // 1 frame
1417 auto_repetition_pause_len
= 0;
1418 repeat_frame_pause_len
= RECS80_FRAME_REPEAT_PAUSE_LEN
;
1419 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1423 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
1424 case IRMP_RECS80EXT_PROTOCOL
:
1426 startbit_pulse_len
= RECS80EXT_START_BIT_PULSE_LEN
;
1427 startbit_pause_len
= RECS80EXT_START_BIT_PAUSE_LEN
- 1;
1428 pulse_1_len
= RECS80EXT_PULSE_LEN
;
1429 pause_1_len
= RECS80EXT_1_PAUSE_LEN
- 1;
1430 pulse_0_len
= RECS80EXT_PULSE_LEN
;
1431 pause_0_len
= RECS80EXT_0_PAUSE_LEN
- 1;
1432 has_stop_bit
= RECS80EXT_STOP_BIT
;
1433 complete_data_len
= RECS80EXT_COMPLETE_DATA_LEN
;
1434 n_auto_repetitions
= 1; // 1 frame
1435 auto_repetition_pause_len
= 0;
1436 repeat_frame_pause_len
= RECS80EXT_FRAME_REPEAT_PAUSE_LEN
;
1437 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1441 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
1442 case IRMP_RC5_PROTOCOL
:
1444 startbit_pulse_len
= RC5_BIT_LEN
;
1445 startbit_pause_len
= RC5_BIT_LEN
;
1446 pulse_len
= RC5_BIT_LEN
;
1447 pause_len
= RC5_BIT_LEN
;
1448 has_stop_bit
= RC5_STOP_BIT
;
1449 complete_data_len
= RC5_COMPLETE_DATA_LEN
;
1450 n_auto_repetitions
= 1; // 1 frame
1451 auto_repetition_pause_len
= 0;
1452 repeat_frame_pause_len
= RC5_FRAME_REPEAT_PAUSE_LEN
;
1453 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1457 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
1458 case IRMP_RC6_PROTOCOL
:
1460 startbit_pulse_len
= RC6_START_BIT_PULSE_LEN
;
1461 startbit_pause_len
= RC6_START_BIT_PAUSE_LEN
- 1;
1462 pulse_len
= RC6_BIT_LEN
;
1463 pause_len
= RC6_BIT_LEN
;
1464 has_stop_bit
= RC6_STOP_BIT
;
1465 complete_data_len
= RC6_COMPLETE_DATA_LEN_SHORT
;
1466 n_auto_repetitions
= 1; // 1 frame
1467 auto_repetition_pause_len
= 0;
1468 repeat_frame_pause_len
= RC6_FRAME_REPEAT_PAUSE_LEN
;
1469 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1473 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
1474 case IRMP_RC6A_PROTOCOL
:
1476 startbit_pulse_len
= RC6_START_BIT_PULSE_LEN
;
1477 startbit_pause_len
= RC6_START_BIT_PAUSE_LEN
- 1;
1478 pulse_len
= RC6_BIT_LEN
;
1479 pause_len
= RC6_BIT_LEN
;
1480 has_stop_bit
= RC6_STOP_BIT
;
1481 complete_data_len
= RC6_COMPLETE_DATA_LEN_LONG
;
1482 n_auto_repetitions
= 1; // 1 frame
1483 auto_repetition_pause_len
= 0;
1484 repeat_frame_pause_len
= RC6_FRAME_REPEAT_PAUSE_LEN
;
1485 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1489 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1490 case IRMP_DENON_PROTOCOL
:
1492 startbit_pulse_len
= 0x00;
1493 startbit_pause_len
= 0x00;
1494 pulse_1_len
= DENON_PULSE_LEN
;
1495 pause_1_len
= DENON_1_PAUSE_LEN
- 1;
1496 pulse_0_len
= DENON_PULSE_LEN
;
1497 pause_0_len
= DENON_0_PAUSE_LEN
- 1;
1498 has_stop_bit
= DENON_STOP_BIT
;
1499 complete_data_len
= DENON_COMPLETE_DATA_LEN
;
1500 n_auto_repetitions
= DENON_FRAMES
; // 2 frames, 2nd with inverted command
1501 auto_repetition_pause_len
= DENON_AUTO_REPETITION_PAUSE_LEN
; // 65 ms pause after 1st frame
1502 repeat_frame_pause_len
= DENON_FRAME_REPEAT_PAUSE_LEN
;
1503 irsnd_set_freq (IRSND_FREQ_36_KHZ
); // in theory 32kHz, in practice 36kHz is better
1507 #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1
1508 case IRMP_THOMSON_PROTOCOL
:
1510 startbit_pulse_len
= 0x00;
1511 startbit_pause_len
= 0x00;
1512 pulse_1_len
= THOMSON_PULSE_LEN
;
1513 pause_1_len
= THOMSON_1_PAUSE_LEN
- 1;
1514 pulse_0_len
= THOMSON_PULSE_LEN
;
1515 pause_0_len
= THOMSON_0_PAUSE_LEN
- 1;
1516 has_stop_bit
= THOMSON_STOP_BIT
;
1517 complete_data_len
= THOMSON_COMPLETE_DATA_LEN
;
1518 n_auto_repetitions
= THOMSON_FRAMES
; // only 1 frame
1519 auto_repetition_pause_len
= THOMSON_AUTO_REPETITION_PAUSE_LEN
;
1520 repeat_frame_pause_len
= DENON_FRAME_REPEAT_PAUSE_LEN
;
1521 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1525 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
1526 case IRMP_NUBERT_PROTOCOL
:
1528 startbit_pulse_len
= NUBERT_START_BIT_PULSE_LEN
;
1529 startbit_pause_len
= NUBERT_START_BIT_PAUSE_LEN
- 1;
1530 pulse_1_len
= NUBERT_1_PULSE_LEN
;
1531 pause_1_len
= NUBERT_1_PAUSE_LEN
- 1;
1532 pulse_0_len
= NUBERT_0_PULSE_LEN
;
1533 pause_0_len
= NUBERT_0_PAUSE_LEN
- 1;
1534 has_stop_bit
= NUBERT_STOP_BIT
;
1535 complete_data_len
= NUBERT_COMPLETE_DATA_LEN
;
1536 n_auto_repetitions
= NUBERT_FRAMES
; // 2 frames
1537 auto_repetition_pause_len
= NUBERT_AUTO_REPETITION_PAUSE_LEN
; // 35 ms pause
1538 repeat_frame_pause_len
= NUBERT_FRAME_REPEAT_PAUSE_LEN
;
1539 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1543 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1544 case IRMP_BANG_OLUFSEN_PROTOCOL
:
1546 startbit_pulse_len
= BANG_OLUFSEN_START_BIT1_PULSE_LEN
;
1547 startbit_pause_len
= BANG_OLUFSEN_START_BIT1_PAUSE_LEN
- 1;
1548 pulse_1_len
= BANG_OLUFSEN_PULSE_LEN
;
1549 pause_1_len
= BANG_OLUFSEN_1_PAUSE_LEN
- 1;
1550 pulse_0_len
= BANG_OLUFSEN_PULSE_LEN
;
1551 pause_0_len
= BANG_OLUFSEN_0_PAUSE_LEN
- 1;
1552 has_stop_bit
= BANG_OLUFSEN_STOP_BIT
;
1553 complete_data_len
= BANG_OLUFSEN_COMPLETE_DATA_LEN
;
1554 n_auto_repetitions
= 1; // 1 frame
1555 auto_repetition_pause_len
= 0;
1556 repeat_frame_pause_len
= BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN
;
1558 irsnd_set_freq (IRSND_FREQ_455_KHZ
);
1562 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
1563 case IRMP_GRUNDIG_PROTOCOL
:
1565 startbit_pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1566 startbit_pause_len
= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN
- 1;
1567 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1568 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1569 has_stop_bit
= GRUNDIG_NOKIA_IR60_STOP_BIT
;
1570 complete_data_len
= GRUNDIG_COMPLETE_DATA_LEN
;
1571 n_auto_repetitions
= GRUNDIG_FRAMES
; // 2 frames
1572 auto_repetition_pause_len
= GRUNDIG_AUTO_REPETITION_PAUSE_LEN
; // 20m sec pause
1573 repeat_frame_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
; // 117 msec pause
1574 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1578 #if IRSND_SUPPORT_IR60_PROTOCOL == 1
1579 case IRMP_IR60_PROTOCOL
:
1581 startbit_pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1582 startbit_pause_len
= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN
- 1;
1583 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1584 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1585 has_stop_bit
= GRUNDIG_NOKIA_IR60_STOP_BIT
;
1586 complete_data_len
= IR60_COMPLETE_DATA_LEN
;
1587 n_auto_repetitions
= IR60_FRAMES
; // 2 frames
1588 auto_repetition_pause_len
= IR60_AUTO_REPETITION_PAUSE_LEN
; // 20m sec pause
1589 repeat_frame_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
; // 117 msec pause
1590 irsnd_set_freq (IRSND_FREQ_30_KHZ
);
1594 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1595 case IRMP_NOKIA_PROTOCOL
:
1597 startbit_pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1598 startbit_pause_len
= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN
- 1;
1599 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1600 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1601 has_stop_bit
= GRUNDIG_NOKIA_IR60_STOP_BIT
;
1602 complete_data_len
= NOKIA_COMPLETE_DATA_LEN
;
1603 n_auto_repetitions
= NOKIA_FRAMES
; // 2 frames
1604 auto_repetition_pause_len
= NOKIA_AUTO_REPETITION_PAUSE_LEN
; // 20 msec pause
1605 repeat_frame_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
; // 117 msec pause
1606 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1610 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
1611 case IRMP_SIEMENS_PROTOCOL
:
1613 startbit_pulse_len
= SIEMENS_BIT_LEN
;
1614 startbit_pause_len
= SIEMENS_BIT_LEN
;
1615 pulse_len
= SIEMENS_BIT_LEN
;
1616 pause_len
= SIEMENS_BIT_LEN
;
1617 has_stop_bit
= SIEMENS_OR_RUWIDO_STOP_BIT
;
1618 complete_data_len
= SIEMENS_COMPLETE_DATA_LEN
- 1;
1619 n_auto_repetitions
= 1; // 1 frame
1620 auto_repetition_pause_len
= 0;
1621 repeat_frame_pause_len
= SIEMENS_FRAME_REPEAT_PAUSE_LEN
;
1622 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1626 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1627 case IRMP_FDC_PROTOCOL
:
1629 startbit_pulse_len
= FDC_START_BIT_PULSE_LEN
;
1630 startbit_pause_len
= FDC_START_BIT_PAUSE_LEN
- 1;
1631 complete_data_len
= FDC_COMPLETE_DATA_LEN
;
1632 pulse_1_len
= FDC_PULSE_LEN
;
1633 pause_1_len
= FDC_1_PAUSE_LEN
- 1;
1634 pulse_0_len
= FDC_PULSE_LEN
;
1635 pause_0_len
= FDC_0_PAUSE_LEN
- 1;
1636 has_stop_bit
= FDC_STOP_BIT
;
1637 n_auto_repetitions
= 1; // 1 frame
1638 auto_repetition_pause_len
= 0;
1639 repeat_frame_pause_len
= FDC_FRAME_REPEAT_PAUSE_LEN
;
1640 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1644 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
1645 case IRMP_RCCAR_PROTOCOL
:
1647 startbit_pulse_len
= RCCAR_START_BIT_PULSE_LEN
;
1648 startbit_pause_len
= RCCAR_START_BIT_PAUSE_LEN
- 1;
1649 complete_data_len
= RCCAR_COMPLETE_DATA_LEN
;
1650 pulse_1_len
= RCCAR_PULSE_LEN
;
1651 pause_1_len
= RCCAR_1_PAUSE_LEN
- 1;
1652 pulse_0_len
= RCCAR_PULSE_LEN
;
1653 pause_0_len
= RCCAR_0_PAUSE_LEN
- 1;
1654 has_stop_bit
= RCCAR_STOP_BIT
;
1655 n_auto_repetitions
= 1; // 1 frame
1656 auto_repetition_pause_len
= 0;
1657 repeat_frame_pause_len
= RCCAR_FRAME_REPEAT_PAUSE_LEN
;
1658 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1662 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
1663 case IRMP_JVC_PROTOCOL
:
1665 if (repeat_counter
!= 0) // skip start bit if repetition frame
1670 startbit_pulse_len
= JVC_START_BIT_PULSE_LEN
;
1671 startbit_pause_len
= JVC_START_BIT_PAUSE_LEN
- 1;
1672 complete_data_len
= JVC_COMPLETE_DATA_LEN
;
1673 pulse_1_len
= JVC_PULSE_LEN
;
1674 pause_1_len
= JVC_1_PAUSE_LEN
- 1;
1675 pulse_0_len
= JVC_PULSE_LEN
;
1676 pause_0_len
= JVC_0_PAUSE_LEN
- 1;
1677 has_stop_bit
= JVC_STOP_BIT
;
1678 n_auto_repetitions
= 1; // 1 frame
1679 auto_repetition_pause_len
= 0;
1680 repeat_frame_pause_len
= JVC_FRAME_REPEAT_PAUSE_LEN
;
1681 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1685 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
1686 case IRMP_NIKON_PROTOCOL
:
1688 startbit_pulse_len
= NIKON_START_BIT_PULSE_LEN
;
1689 startbit_pause_len
= 271 - 1; // NIKON_START_BIT_PAUSE_LEN;
1690 complete_data_len
= NIKON_COMPLETE_DATA_LEN
;
1691 pulse_1_len
= NIKON_PULSE_LEN
;
1692 pause_1_len
= NIKON_1_PAUSE_LEN
- 1;
1693 pulse_0_len
= NIKON_PULSE_LEN
;
1694 pause_0_len
= NIKON_0_PAUSE_LEN
- 1;
1695 has_stop_bit
= NIKON_STOP_BIT
;
1696 n_auto_repetitions
= 1; // 1 frame
1697 auto_repetition_pause_len
= 0;
1698 repeat_frame_pause_len
= NIKON_FRAME_REPEAT_PAUSE_LEN
;
1699 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1703 #if IRSND_SUPPORT_LEGO_PROTOCOL == 1
1704 case IRMP_LEGO_PROTOCOL
:
1706 startbit_pulse_len
= LEGO_START_BIT_PULSE_LEN
;
1707 startbit_pause_len
= LEGO_START_BIT_PAUSE_LEN
- 1;
1708 complete_data_len
= LEGO_COMPLETE_DATA_LEN
;
1709 pulse_1_len
= LEGO_PULSE_LEN
;
1710 pause_1_len
= LEGO_1_PAUSE_LEN
- 1;
1711 pulse_0_len
= LEGO_PULSE_LEN
;
1712 pause_0_len
= LEGO_0_PAUSE_LEN
- 1;
1713 has_stop_bit
= LEGO_STOP_BIT
;
1714 n_auto_repetitions
= 1; // 1 frame
1715 auto_repetition_pause_len
= 0;
1716 repeat_frame_pause_len
= LEGO_FRAME_REPEAT_PAUSE_LEN
;
1717 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1734 switch (irsnd_protocol
)
1736 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
1737 case IRMP_SIRCS_PROTOCOL
:
1739 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
1740 case IRMP_NEC_PROTOCOL
:
1742 #if IRSND_SUPPORT_NEC16_PROTOCOL == 1
1743 case IRMP_NEC16_PROTOCOL
:
1745 #if IRSND_SUPPORT_NEC42_PROTOCOL == 1
1746 case IRMP_NEC42_PROTOCOL
:
1748 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
1749 case IRMP_SAMSUNG_PROTOCOL
:
1750 case IRMP_SAMSUNG32_PROTOCOL
:
1752 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
1753 case IRMP_MATSUSHITA_PROTOCOL
:
1755 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
1756 case IRMP_KASEIKYO_PROTOCOL
:
1758 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
1759 case IRMP_RECS80_PROTOCOL
:
1761 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
1762 case IRMP_RECS80EXT_PROTOCOL
:
1764 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1765 case IRMP_DENON_PROTOCOL
:
1767 #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1
1768 case IRMP_THOMSON_PROTOCOL
:
1770 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
1771 case IRMP_NUBERT_PROTOCOL
:
1773 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1774 case IRMP_BANG_OLUFSEN_PROTOCOL
:
1776 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1777 case IRMP_FDC_PROTOCOL
:
1779 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
1780 case IRMP_RCCAR_PROTOCOL
:
1782 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
1783 case IRMP_JVC_PROTOCOL
:
1785 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
1786 case IRMP_NIKON_PROTOCOL
:
1788 #if IRSND_SUPPORT_LEGO_PROTOCOL == 1
1789 case IRMP_LEGO_PROTOCOL
:
1793 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_NEC16_PROTOCOL == 1 || IRSND_SUPPORT_NEC42_PROTOCOL == 1 || \
1794 IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \
1795 IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \
1796 IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || \
1797 IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1
1799 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1800 if (irsnd_protocol
== IRMP_DENON_PROTOCOL
)
1802 if (auto_repetition_pause_len
> 0) // 2nd frame distance counts from beginning of 1st frame!
1804 auto_repetition_pause_len
--;
1807 if (repeat_frame_pause_len
> 0) // frame repeat distance counts from beginning of 1st frame!
1809 repeat_frame_pause_len
--;
1814 if (pulse_counter
== 0)
1816 if (current_bit
== 0xFF) // send start bit
1818 pulse_len
= startbit_pulse_len
;
1819 pause_len
= startbit_pause_len
;
1821 else if (current_bit
< complete_data_len
) // send n'th bit
1823 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
1824 if (irsnd_protocol
== IRMP_SAMSUNG_PROTOCOL
)
1826 if (current_bit
< SAMSUNG_ADDRESS_LEN
) // send address bits
1828 pulse_len
= SAMSUNG_PULSE_LEN
;
1829 pause_len
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ?
1830 (SAMSUNG_1_PAUSE_LEN
- 1) : (SAMSUNG_0_PAUSE_LEN
- 1);
1832 else if (current_bit
== SAMSUNG_ADDRESS_LEN
) // send SYNC bit (16th bit)
1834 pulse_len
= SAMSUNG_PULSE_LEN
;
1835 pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
1837 else if (current_bit
< SAMSUNG_COMPLETE_DATA_LEN
) // send n'th bit
1839 uint8_t cur_bit
= current_bit
- 1; // sync skipped, offset = -1 !
1841 pulse_len
= SAMSUNG_PULSE_LEN
;
1842 pause_len
= (irsnd_buffer
[cur_bit
/ 8] & (1<<(7-(cur_bit
% 8)))) ?
1843 (SAMSUNG_1_PAUSE_LEN
- 1) : (SAMSUNG_0_PAUSE_LEN
- 1);
1849 #if IRSND_SUPPORT_NEC16_PROTOCOL == 1
1850 if (irsnd_protocol
== IRMP_NEC16_PROTOCOL
)
1852 if (current_bit
< NEC16_ADDRESS_LEN
) // send address bits
1854 pulse_len
= NEC_PULSE_LEN
;
1855 pause_len
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ?
1856 (NEC_1_PAUSE_LEN
- 1) : (NEC_0_PAUSE_LEN
- 1);
1858 else if (current_bit
== NEC16_ADDRESS_LEN
) // send SYNC bit (8th bit)
1860 pulse_len
= NEC_PULSE_LEN
;
1861 pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
1863 else if (current_bit
< NEC16_COMPLETE_DATA_LEN
+ 1) // send n'th bit
1865 uint8_t cur_bit
= current_bit
- 1; // sync skipped, offset = -1 !
1867 pulse_len
= NEC_PULSE_LEN
;
1868 pause_len
= (irsnd_buffer
[cur_bit
/ 8] & (1<<(7-(cur_bit
% 8)))) ?
1869 (NEC_1_PAUSE_LEN
- 1) : (NEC_0_PAUSE_LEN
- 1);
1875 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1876 if (irsnd_protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
1878 if (current_bit
== 0) // send 2nd start bit
1880 pulse_len
= BANG_OLUFSEN_START_BIT2_PULSE_LEN
;
1881 pause_len
= BANG_OLUFSEN_START_BIT2_PAUSE_LEN
- 1;
1883 else if (current_bit
== 1) // send 3rd start bit
1885 pulse_len
= BANG_OLUFSEN_START_BIT3_PULSE_LEN
;
1886 pause_len
= BANG_OLUFSEN_START_BIT3_PAUSE_LEN
- 1;
1888 else if (current_bit
== 2) // send 4th start bit
1890 pulse_len
= BANG_OLUFSEN_START_BIT2_PULSE_LEN
;
1891 pause_len
= BANG_OLUFSEN_START_BIT2_PAUSE_LEN
- 1;
1893 else if (current_bit
== 19) // send trailer bit
1895 pulse_len
= BANG_OLUFSEN_PULSE_LEN
;
1896 pause_len
= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN
- 1;
1898 else if (current_bit
< BANG_OLUFSEN_COMPLETE_DATA_LEN
) // send n'th bit
1900 uint8_t cur_bit_value
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? 1 : 0;
1901 pulse_len
= BANG_OLUFSEN_PULSE_LEN
;
1903 if (cur_bit_value
== last_bit_value
)
1905 pause_len
= BANG_OLUFSEN_R_PAUSE_LEN
- 1;
1909 pause_len
= cur_bit_value
? (BANG_OLUFSEN_1_PAUSE_LEN
- 1) : (BANG_OLUFSEN_0_PAUSE_LEN
- 1);
1910 last_bit_value
= cur_bit_value
;
1916 if (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8))))
1918 pulse_len
= pulse_1_len
;
1919 pause_len
= pause_1_len
;
1923 pulse_len
= pulse_0_len
;
1924 pause_len
= pause_0_len
;
1927 else if (has_stop_bit
) // send stop bit
1929 pulse_len
= pulse_0_len
;
1931 if (auto_repetition_counter
< n_auto_repetitions
)
1933 pause_len
= pause_0_len
;
1937 pause_len
= 255; // last frame: pause of 255
1942 if (pulse_counter
< pulse_len
)
1944 if (pulse_counter
== 0)
1950 else if (pause_counter
< pause_len
)
1952 if (pause_counter
== 0)
1962 if (current_bit
>= complete_data_len
+ has_stop_bit
)
1965 auto_repetition_counter
++;
1967 if (auto_repetition_counter
== n_auto_repetitions
)
1970 auto_repetition_counter
= 0;
1982 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
1983 case IRMP_RC5_PROTOCOL
:
1985 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
1986 case IRMP_RC6_PROTOCOL
:
1988 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
1989 case IRMP_RC6A_PROTOCOL
:
1991 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
1992 case IRMP_SIEMENS_PROTOCOL
:
1994 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
1995 case IRMP_GRUNDIG_PROTOCOL
:
1997 #if IRSND_SUPPORT_IR60_PROTOCOL == 1
1998 case IRMP_IR60_PROTOCOL
:
2000 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
2001 case IRMP_NOKIA_PROTOCOL
:
2004 #if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || \
2005 IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
2007 if (pulse_counter
== pulse_len
&& pause_counter
== pause_len
)
2011 if (current_bit
>= complete_data_len
)
2015 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
2016 if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
|| irsnd_protocol
== IRMP_IR60_PROTOCOL
|| irsnd_protocol
== IRMP_NOKIA_PROTOCOL
)
2018 auto_repetition_counter
++;
2020 if (repeat_counter
> 0)
2021 { // set 117 msec pause time
2022 auto_repetition_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
;
2025 if (repeat_counter
< n_repeat_frames
) // tricky: repeat n info frames per auto repetition before sending last stop frame
2027 n_auto_repetitions
++; // increment number of auto repetitions
2030 else if (auto_repetition_counter
== n_auto_repetitions
)
2033 auto_repetition_counter
= 0;
2052 uint8_t first_pulse
;
2054 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
2055 if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
|| irsnd_protocol
== IRMP_IR60_PROTOCOL
|| irsnd_protocol
== IRMP_NOKIA_PROTOCOL
)
2057 if (current_bit
== 0xFF || // start bit of start-frame
2058 (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
&& current_bit
== 15) || // start bit of info-frame (Grundig)
2059 (irsnd_protocol
== IRMP_IR60_PROTOCOL
&& current_bit
== 7) || // start bit of data frame (IR60)
2060 (irsnd_protocol
== IRMP_NOKIA_PROTOCOL
&& (current_bit
== 23 || current_bit
== 47))) // start bit of info- or stop-frame (Nokia)
2062 pulse_len
= startbit_pulse_len
;
2063 pause_len
= startbit_pause_len
;
2066 else // send n'th bit
2068 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
2069 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
2070 first_pulse
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? TRUE
: FALSE
;
2073 else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL ||
2074 // irsnd_protocol == IRMP_SIEMENS_PROTOCOL)
2077 if (current_bit
== 0xFF) // 1 start bit
2079 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
2080 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
|| irsnd_protocol
== IRMP_RC6A_PROTOCOL
)
2082 pulse_len
= startbit_pulse_len
;
2083 pause_len
= startbit_pause_len
;
2088 else // send n'th bit
2090 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
2091 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
|| irsnd_protocol
== IRMP_RC6A_PROTOCOL
)
2093 pulse_len
= RC6_BIT_LEN
;
2094 pause_len
= RC6_BIT_LEN
;
2096 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
)
2098 if (current_bit
== 4) // toggle bit (double len)
2100 pulse_len
= 2 * RC6_BIT_LEN
;
2101 pause_len
= 2 * RC6_BIT_LEN
;
2104 else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL)
2106 if (current_bit
== 4) // toggle bit (double len)
2108 pulse_len
= 2 * RC6_BIT_LEN
+ RC6_BIT_LEN
; // hack!
2109 pause_len
= 2 * RC6_BIT_LEN
;
2111 else if (current_bit
== 5) // toggle bit (double len)
2113 pause_len
= 2 * RC6_BIT_LEN
;
2118 first_pulse
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? TRUE
: FALSE
;
2121 if (irsnd_protocol
== IRMP_RC5_PROTOCOL
)
2123 first_pulse
= first_pulse
? FALSE
: TRUE
;
2129 if (pulse_counter
< pulse_len
)
2131 if (pulse_counter
== 0)
2137 else // if (pause_counter < pause_len)
2139 if (pause_counter
== 0)
2148 if (pause_counter
< pause_len
)
2150 if (pause_counter
== 0)
2156 else // if (pulse_counter < pulse_len)
2158 if (pulse_counter
== 0)
2168 #endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 ||
2169 // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
2181 if (repeat_counter
< n_repeat_frames
)
2183 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
2184 if (irsnd_protocol
== IRMP_FDC_PROTOCOL
)
2186 irsnd_buffer
[2] |= 0x0F;
2194 irsnd_busy
= TRUE
; //Rainer
2195 send_trailer
= TRUE
;
2196 n_repeat_frames
= 0;
2218 // main function - for unix/linux + windows only!
2220 // Compile it under linux with:
2221 // cc irsnd.c -o irsnd
2223 // usage: ./irsnd protocol hex-address hex-command >filename
2226 main (int argc
, char ** argv
)
2231 IRMP_DATA irmp_data
;
2233 if (argc
!= 4 && argc
!= 5)
2235 fprintf (stderr
, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv
[0]);
2239 if (sscanf (argv
[1], "%d", &protocol
) == 1 &&
2240 sscanf (argv
[2], "%x", &address
) == 1 &&
2241 sscanf (argv
[3], "%x", &command
) == 1)
2243 irmp_data
.protocol
= protocol
;
2244 irmp_data
.address
= address
;
2245 irmp_data
.command
= command
;
2249 irmp_data
.flags
= atoi (argv
[4]);
2253 irmp_data
.flags
= 0;
2258 (void) irsnd_send_data (&irmp_data
, TRUE
);
2269 fprintf (stderr
, "%s: wrong arguments\n", argv
[0]);