1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
4 * Copyright (c) 2010-2012 Frank Meyer - frank(at)fli4l.de
6 * Supported mikrocontrollers:
10 * ATmega8, ATmega16, ATmega32
12 * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284
13 * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P
15 * $Id: irsnd.c,v 1.55 2012/05/24 06:55:11 fm Exp $
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *---------------------------------------------------------------------------------------------------------------------------------------------------
26 /*---------------------------------------------------------------------------------------------------------------------------------------------------
27 * ATtiny pin definition of OC0A / OC0B
28 * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B
29 *---------------------------------------------------------------------------------------------------------------------------------------------------
31 #if defined (__AVR_ATtiny84__) // ATtiny84 uses OC0A = PB2 or OC0B = PA7
32 # if IRSND_OCx == IRSND_OC0A // OC0A
33 # define IRSND_PORT PORTB // port B
34 # define IRSND_DDR DDRB // ddr B
35 # define IRSND_BIT 2 // OC0A
36 # elif IRSND_OCx == IRSND_OC0B // OC0B
37 # define IRSND_PORT PORTA // port A
38 # define IRSND_DDR DDRA // ddr A
39 # define IRSND_BIT 7 // OC0B
41 # error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h
43 #elif defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) // ATtiny45/85 uses OC0A = PB0 or OC0B = PB1
44 # if IRSND_OCx == IRSND_OC0A // OC0A
45 # define IRSND_PORT PORTB // port B
46 # define IRSND_DDR DDRB // ddr B
47 # define IRSND_BIT 0 // OC0A
48 # elif IRSND_OCx == IRSND_OC0B // OC0B
49 # define IRSND_PORT PORTB // port B
50 # define IRSND_DDR DDRB // ddr B
51 # define IRSND_BIT 1 // OC0B
53 # error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h
55 #elif defined (__AVR_ATmega8__) // ATmega8 uses only OC2 = PB3
56 # if IRSND_OCx == IRSND_OC2 // OC0A
57 # define IRSND_PORT PORTB // port B
58 # define IRSND_DDR DDRB // ddr B
59 # define IRSND_BIT 3 // OC0A
61 # error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h
63 #elif defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) // ATmega16|32 uses OC2 = PD7
64 # if IRSND_OCx == IRSND_OC2 // OC2
65 # define IRSND_PORT PORTD // port D
66 # define IRSND_DDR DDRD // ddr D
67 # define IRSND_BIT 7 // OC2
69 # error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h
71 #elif defined (__AVR_ATmega162__) // ATmega162 uses OC2 = PB1 or OC0 = PB0
72 # if IRSND_OCx == IRSND_OC2 // OC2
73 # define IRSND_PORT PORTB // port B
74 # define IRSND_DDR DDRB // ddr B
75 # define IRSND_BIT 1 // OC2
76 # elif IRSND_OCx == IRSND_OC0 // OC0
77 # define IRSND_PORT PORTB // port B
78 # define IRSND_DDR DDRB // ddr B
79 # define IRSND_BIT 0 // OC0
81 # error Wrong value for IRSND_OCx, choose IRSND_OC2 or IRSND_OC0 in irsndconfig.h
83 #elif defined (__AVR_ATmega164__) \
84 || defined (__AVR_ATmega324__) \
85 || defined (__AVR_ATmega644__) \
86 || defined (__AVR_ATmega644P__) \
87 || defined (__AVR_ATmega1284__) \
88 || defined (__AVR_ATmega1284P__) // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4
89 # if IRSND_OCx == IRSND_OC2A // OC2A
90 # define IRSND_PORT PORTD // port D
91 # define IRSND_DDR DDRD // ddr D
92 # define IRSND_BIT 7 // OC2A
93 # elif IRSND_OCx == IRSND_OC2B // OC2B
94 # define IRSND_PORT PORTD // port D
95 # define IRSND_DDR DDRD // ddr D
96 # define IRSND_BIT 6 // OC2B
97 # elif IRSND_OCx == IRSND_OC0A // OC0A
98 # define IRSND_PORT PORTB // port B
99 # define IRSND_DDR DDRB // ddr B
100 # define IRSND_BIT 3 // OC0A
101 # elif IRSND_OCx == IRSND_OC0B // OC0B
102 # define IRSND_PORT PORTB // port B
103 # define IRSND_DDR DDRB // ddr B
104 # define IRSND_BIT 4 // OC0B
106 # error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h
108 #elif defined (__AVR_ATmega48__) \
109 || defined (__AVR_ATmega88__) \
110 || defined (__AVR_ATmega88P__) \
111 || defined (__AVR_ATmega168__) \
112 || defined (__AVR_ATmega168P__) \
113 || defined (__AVR_ATmega328P__) // ATmega48|88|168|168|328 uses OC2A = PB3 or OC2B = PD3 or OC0A = PD6 or OC0B = PD5
114 # if IRSND_OCx == IRSND_OC2A // OC2A
115 # define IRSND_PORT PORTB // port B
116 # define IRSND_DDR DDRB // ddr B
117 # define IRSND_BIT 3 // OC2A
118 # elif IRSND_OCx == IRSND_OC2B // OC2B
119 # define IRSND_PORT PORTD // port D
120 # define IRSND_DDR DDRD // ddr D
121 # define IRSND_BIT 3 // OC2B
122 # elif IRSND_OCx == IRSND_OC0A // OC0A
123 # define IRSND_PORT PORTB // port B
124 # define IRSND_DDR DDRB // ddr B
125 # define IRSND_BIT 6 // OC0A
126 # elif IRSND_OCx == IRSND_OC0B // OC0B
127 # define IRSND_PORT PORTD // port D
128 # define IRSND_DDR DDRD // ddr D
129 # define IRSND_BIT 5 // OC0B
131 # error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h
133 #elif defined (__AVR_ATmega8515__)
134 # if IRSND_OCx == IRSND_OC0
135 # define IRSND_PORT PORTB // port B
136 # define IRSND_DDR DDRB // ddr B
137 # define IRSND_BIT 0 // OC0
138 # elif IRSND_OCx == IRSND_OC1A
139 # define IRSND_PORT PORTD // port D
140 # define IRSND_DDR DDRD // ddr D
141 # define IRSND_BIT 5 // OC1A
142 # elif IRSND_OCx == IRSND_OC1B
143 # define IRSND_PORT PORTE // port E
144 # define IRSND_DDR DDRE // ddr E
145 # define IRSND_BIT 2 // OC1E
147 # error Wrong value for IRSND_OCx, choose IRSND_OC0, IRSND_OC1A, or IRSND_OC1B in irsndconfig.h
149 #elif defined (PIC_C18) //Microchip C18 compiler
150 //Nothing here to do here -> See irsndconfig.h
151 #elif defined (ARM_STM32) //STM32
152 //Nothing here to do here -> See irsndconfig.h
154 # if !defined (unix) && !defined (WIN32)
155 # error mikrocontroller not defined, please fill in definitions here.
156 # endif // unix, WIN32
159 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
160 typedef uint16_t IRSND_PAUSE_LEN
;
162 typedef uint8_t IRSND_PAUSE_LEN
;
165 /*---------------------------------------------------------------------------------------------------------------------------------------------------
167 *---------------------------------------------------------------------------------------------------------------------------------------------------
169 #define SIRCS_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME + 0.5)
170 #define SIRCS_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME + 0.5)
171 #define SIRCS_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME + 0.5)
172 #define SIRCS_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME + 0.5)
173 #define SIRCS_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME + 0.5)
174 #define SIRCS_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
175 #define SIRCS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
177 #define NEC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME + 0.5)
178 #define NEC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME + 0.5)
179 #define NEC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME + 0.5)
180 #define NEC_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME + 0.5)
181 #define NEC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME + 0.5)
182 #define NEC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME + 0.5)
183 #define NEC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
185 #define SAMSUNG_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME + 0.5)
186 #define SAMSUNG_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME + 0.5)
187 #define SAMSUNG_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME + 0.5)
188 #define SAMSUNG_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME + 0.5)
189 #define SAMSUNG_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME + 0.5)
190 #define SAMSUNG_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
192 #define SAMSUNG32_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
193 #define SAMSUNG32_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
195 #define MATSUSHITA_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME + 0.5)
196 #define MATSUSHITA_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME + 0.5)
197 #define MATSUSHITA_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME + 0.5)
198 #define MATSUSHITA_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME + 0.5)
199 #define MATSUSHITA_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME + 0.5)
200 #define MATSUSHITA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * MATSUSHITA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
202 #define KASEIKYO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME + 0.5)
203 #define KASEIKYO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME + 0.5)
204 #define KASEIKYO_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME + 0.5)
205 #define KASEIKYO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME + 0.5)
206 #define KASEIKYO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME + 0.5)
207 #define KASEIKYO_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
208 #define KASEIKYO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
210 #define RECS80_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME + 0.5)
211 #define RECS80_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME + 0.5)
212 #define RECS80_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME + 0.5)
213 #define RECS80_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME + 0.5)
214 #define RECS80_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME + 0.5)
215 #define RECS80_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
217 #define RC5_START_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5)
218 #define RC5_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5)
219 #define RC5_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC5_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
221 #define RC6_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME + 0.5)
222 #define RC6_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME + 0.5)
223 #define RC6_TOGGLE_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME + 0.5)
224 #define RC6_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_BIT_TIME + 0.5)
225 #define RC6_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC6_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
227 #define DENON_PULSE_LEN (uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME + 0.5)
228 #define DENON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME + 0.5)
229 #define DENON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME + 0.5)
230 #define DENON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
231 #define DENON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
233 #define THOMSON_PULSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME + 0.5)
234 #define THOMSON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME + 0.5)
235 #define THOMSON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME + 0.5)
236 #define THOMSON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * THOMSON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
237 #define THOMSON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * THOMSON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
239 #define RECS80EXT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME + 0.5)
240 #define RECS80EXT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME + 0.5)
241 #define RECS80EXT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME + 0.5)
242 #define RECS80EXT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME + 0.5)
243 #define RECS80EXT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME + 0.5)
244 #define RECS80EXT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80EXT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
246 #define NUBERT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME + 0.5)
247 #define NUBERT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME + 0.5)
248 #define NUBERT_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME + 0.5)
249 #define NUBERT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME + 0.5)
250 #define NUBERT_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME + 0.5)
251 #define NUBERT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME + 0.5)
252 #define NUBERT_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
253 #define NUBERT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
255 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME + 0.5)
256 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME + 0.5)
257 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME + 0.5)
258 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME + 0.5)
259 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME + 0.5)
260 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME + 0.5)
261 #define BANG_OLUFSEN_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME + 0.5)
262 #define BANG_OLUFSEN_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME + 0.5)
263 #define BANG_OLUFSEN_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME + 0.5)
264 #define BANG_OLUFSEN_R_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME + 0.5)
265 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME + 0.5)
266 #define BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BANG_OLUFSEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
268 #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME + 0.5)
269 #define GRUNDIG_NOKIA_IR60_BIT_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME + 0.5)
270 #define GRUNDIG_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
271 #define NOKIA_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NOKIA_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
272 #define GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
274 #define IR60_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * IR60_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!
276 #define SIEMENS_START_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME + 0.5)
277 #define SIEMENS_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME + 0.5)
278 #define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
281 #ifdef PIC_C18 // PIC C18
282 # define IRSND_FREQ_TYPE uint8_t
283 # define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 30000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
284 # define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 32000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
285 # define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 36000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
286 # define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 38000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
287 # define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 40000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
288 # define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 56000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
289 # define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 455000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
290 #elif defined (ARM_STM32) // STM32
291 # define IRSND_FREQ_TYPE uint32_t
292 # define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) (30000)
293 # define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) (32000)
294 # define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) (36000)
295 # define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) (38000)
296 # define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) (40000)
297 # define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) (56000)
298 # define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) (455000)
300 # define IRSND_FREQ_TYPE uint8_t
301 # define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 30000 / 2) - 1)
302 # define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 32000 / 2) - 1)
303 # define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 36000 / 2) - 1)
304 # define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 38000 / 2) - 1)
305 # define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 40000 / 2) - 1)
306 # define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 56000 / 2) - 1)
307 # define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 455000 / 2) - 1)
310 #define FDC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME + 0.5)
311 #define FDC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME + 0.5)
312 #define FDC_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME + 0.5)
313 #define FDC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME + 0.5)
314 #define FDC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME + 0.5)
315 #define FDC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * FDC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
317 #define RCCAR_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME + 0.5)
318 #define RCCAR_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME + 0.5)
319 #define RCCAR_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME + 0.5)
320 #define RCCAR_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME + 0.5)
321 #define RCCAR_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME + 0.5)
322 #define RCCAR_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RCCAR_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
324 #define JVC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME + 0.5)
325 #define JVC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PAUSE_TIME + 0.5)
326 #define JVC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_REPEAT_START_BIT_PAUSE_TIME + 0.5)
327 #define JVC_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME + 0.5)
328 #define JVC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME + 0.5)
329 #define JVC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME + 0.5)
330 #define JVC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
332 #define NIKON_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME + 0.5)
333 #define NIKON_START_BIT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME + 0.5)
334 #define NIKON_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME + 0.5)
335 #define NIKON_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME + 0.5)
336 #define NIKON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME + 0.5)
337 #define NIKON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME + 0.5)
338 #define NIKON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
340 #define LEGO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME + 0.5)
341 #define LEGO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME + 0.5)
342 #define LEGO_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_REPEAT_START_BIT_PAUSE_TIME + 0.5)
343 #define LEGO_PULSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_PULSE_TIME + 0.5)
344 #define LEGO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME + 0.5)
345 #define LEGO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME + 0.5)
346 #define LEGO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * LEGO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!
348 static volatile uint8_t irsnd_busy
= 0;
349 static volatile uint8_t irsnd_protocol
= 0;
350 static volatile uint8_t irsnd_buffer
[6] = {0};
351 static volatile uint8_t irsnd_repeat
= 0;
352 static volatile uint8_t irsnd_is_on
= FALSE
;
354 #if IRSND_USE_CALLBACK == 1
355 static void (*irsnd_callback_ptr
) (uint8_t);
356 #endif // IRSND_USE_CALLBACK == 1
358 /*---------------------------------------------------------------------------------------------------------------------------------------------------
360 * @details Switches PWM on with a narrow spike on all 3 channels -> leds glowing
361 *---------------------------------------------------------------------------------------------------------------------------------------------------
369 # if defined(PIC_C18) // PIC C18
370 IRSND_PIN
= 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off)
371 # elif defined (ARM_STM32) // STM32
372 IRSND_TIMER
->CCER
|= (uint16_t)TIM_CCER_CC1E
;
373 TIM_Cmd(IRSND_TIMER
, ENABLE
); // TIMx enable counter
375 # if IRSND_OCx == IRSND_OC2 // use OC2
376 TCCR2
|= (1<<COM20
)|(1<<WGM21
); // toggle OC2 on compare match, clear Timer 2 at compare match OCR2
377 # elif IRSND_OCx == IRSND_OC2A // use OC2A
378 TCCR2A
|= (1<<COM2A0
)|(1<<WGM21
); // toggle OC2A on compare match, clear Timer 2 at compare match OCR2A
379 # elif IRSND_OCx == IRSND_OC2B // use OC2B
380 TCCR2A
|= (1<<COM2B0
)|(1<<WGM21
); // toggle OC2B on compare match, clear Timer 2 at compare match OCR2A (yes: A, not B!)
381 # elif IRSND_OCx == IRSND_OC0 // use OC0
382 TCCR0
|= (1<<COM00
)|(1<<WGM01
); // toggle OC0 on compare match, clear Timer 0 at compare match OCR0
383 # elif IRSND_OCx == IRSND_OC0A // use OC0A
384 TCCR0A
|= (1<<COM0A0
)|(1<<WGM01
); // toggle OC0A on compare match, clear Timer 0 at compare match OCR0A
385 # elif IRSND_OCx == IRSND_OC0B // use OC0B
386 TCCR0A
|= (1<<COM0B0
)|(1<<WGM01
); // toggle OC0B on compare match, clear Timer 0 at compare match OCR0A (yes: A, not B!)
388 # error wrong value of IRSND_OCx
393 #if IRSND_USE_CALLBACK == 1
394 if (irsnd_callback_ptr
)
396 (*irsnd_callback_ptr
) (TRUE
);
398 #endif // IRSND_USE_CALLBACK == 1
404 /*---------------------------------------------------------------------------------------------------------------------------------------------------
406 * @details Switches PWM off
407 *---------------------------------------------------------------------------------------------------------------------------------------------------
416 # if defined(PIC_C18) // PIC C18
417 IRSND_PIN
= 1; //input mode -> disbale PWM output pin (0=PWM on, 1=PWM off)
418 # elif defined (ARM_STM32) // STM32
419 IRSND_TIMER
->CCER
&= (uint16_t)(~(uint16_t)TIM_CCER_CC1E
);
420 TIM_Cmd(IRSND_TIMER
, DISABLE
); // TIMx enable counter
423 # if IRSND_OCx == IRSND_OC2 // use OC2
424 TCCR2
&= ~(1<<COM20
); // normal port operation, OC2 disconnected.
425 # elif IRSND_OCx == IRSND_OC2A // use OC2A
426 TCCR2A
&= ~(1<<COM2A0
); // normal port operation, OC2A disconnected.
427 # elif IRSND_OCx == IRSND_OC2B // use OC2B
428 TCCR2A
&= ~(1<<COM2B0
); // normal port operation, OC2B disconnected.
429 # elif IRSND_OCx == IRSND_OC0 // use OC0
430 TCCR0
&= ~(1<<COM00
); // normal port operation, OC0 disconnected.
431 # elif IRSND_OCx == IRSND_OC0A // use OC0A
432 TCCR0A
&= ~(1<<COM0A0
); // normal port operation, OC0A disconnected.
433 # elif IRSND_OCx == IRSND_OC0B // use OC0B
434 TCCR0A
&= ~(1<<COM0B0
); // normal port operation, OC0B disconnected.
436 # error wrong value of IRSND_OCx
438 IRSND_PORT
&= ~(1<<IRSND_BIT
); // set IRSND_BIT to low
442 #if IRSND_USE_CALLBACK == 1
443 if (irsnd_callback_ptr
)
445 (*irsnd_callback_ptr
) (FALSE
);
447 #endif // IRSND_USE_CALLBACK == 1
453 /*---------------------------------------------------------------------------------------------------------------------------------------------------
455 * @details sets pwm frequency
456 *---------------------------------------------------------------------------------------------------------------------------------------------------
459 irsnd_set_freq (IRSND_FREQ_TYPE freq
)
462 # if defined(PIC_C18) // PIC C18
464 SetDCPWM( (uint16_t) freq
* 2); // freq*2 = Duty cycles 50%
465 # elif defined (ARM_STM32) // STM32
466 static uint32_t TimeBaseFreq
= 0;
468 if (TimeBaseFreq
== 0)
470 RCC_ClocksTypeDef RCC_ClocksStructure
;
471 /* Get system clocks and store timer clock in variable */
472 RCC_GetClocksFreq(&RCC_ClocksStructure
);
473 # if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14))
474 if (RCC_ClocksStructure
.PCLK1_Frequency
== RCC_ClocksStructure
.HCLK_Frequency
)
476 TimeBaseFreq
= RCC_ClocksStructure
.PCLK1_Frequency
;
480 TimeBaseFreq
= RCC_ClocksStructure
.PCLK1_Frequency
* 2;
483 if (RCC_ClocksStructure
.PCLK2_Frequency
== RCC_ClocksStructure
.HCLK_Frequency
)
485 TimeBaseFreq
= RCC_ClocksStructure
.PCLK2_Frequency
;
489 TimeBaseFreq
= RCC_ClocksStructure
.PCLK2_Frequency
* 2;
494 freq
= TimeBaseFreq
/freq
;
497 TIM_SetAutoreload(IRSND_TIMER
, freq
);
499 TIM_SetCompare1(IRSND_TIMER
, (freq
+ 1) / 2);
502 # if IRSND_OCx == IRSND_OC2
503 OCR2
= freq
; // use register OCR2 for OC2
504 # elif IRSND_OCx == IRSND_OC2A // use OC2A
505 OCR2A
= freq
; // use register OCR2A for OC2A and OC2B!
506 # elif IRSND_OCx == IRSND_OC2B // use OC2B
507 OCR2A
= freq
; // use register OCR2A for OC2A and OC2B!
508 # elif IRSND_OCx == IRSND_OC0 // use OC0
509 OCR0
= freq
; // use register OCR2 for OC2
510 # elif IRSND_OCx == IRSND_OC0A // use OC0A
511 OCR0A
= freq
; // use register OCR0A for OC0A and OC0B!
512 # elif IRSND_OCx == IRSND_OC0B // use OC0B
513 OCR0A
= freq
; // use register OCR0A for OC0A and OC0B!
515 # error wrong value of IRSND_OCx
521 /*---------------------------------------------------------------------------------------------------------------------------------------------------
523 * @details Configures 0CR0A, 0CR0B and 0CR2B as PWM channels
524 *---------------------------------------------------------------------------------------------------------------------------------------------------
530 # if defined(PIC_C18) // PIC C18
532 irsnd_set_freq (IRSND_FREQ_36_KHZ
); //default frequency
533 IRSND_PIN
= 1; //default PWM output pin off (0=PWM on, 1=PWM off)
534 # elif defined (ARM_STM32) // STM32
535 GPIO_InitTypeDef GPIO_InitStructure
;
536 TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure
;
537 TIM_OCInitTypeDef TIM_OCInitStructure
;
539 /* GPIOx clock enable */
540 # if defined (ARM_STM32L1XX)
541 RCC_AHBPeriphClockCmd(IRSND_PORT_RCC
, ENABLE
);
542 # elif defined (ARM_STM32F10X)
543 RCC_APB2PeriphClockCmd(IRSND_PORT_RCC
, ENABLE
);
544 # elif defined (ARM_STM32F4XX)
545 RCC_AHB1PeriphClockCmd(IRSND_PORT_RCC
, ENABLE
);
548 /* GPIO Configuration */
549 GPIO_InitStructure
.GPIO_Pin
= IRSND_BIT
;
550 # if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX)
551 GPIO_InitStructure
.GPIO_Mode
= GPIO_Mode_AF
;
552 GPIO_InitStructure
.GPIO_Speed
= GPIO_Speed_2MHz
;
553 GPIO_InitStructure
.GPIO_OType
= GPIO_OType_PP
;
554 GPIO_InitStructure
.GPIO_PuPd
= GPIO_PuPd_NOPULL
;
555 GPIO_Init(IRSND_PORT
, &GPIO_InitStructure
);
556 GPIO_PinAFConfig(IRSND_PORT
, (uint8_t)IRSND_BIT_NUMBER
, IRSND_GPIO_AF
);
557 # elif defined (ARM_STM32F10X)
558 GPIO_InitStructure
.GPIO_Speed
= GPIO_Speed_2MHz
;
559 GPIO_InitStructure
.GPIO_Mode
= GPIO_Mode_AF_PP
;
560 GPIO_Init(IRSND_PORT
, &GPIO_InitStructure
);
561 GPIO_PinRemapConfig(, ENABLE
); // TODO: remapping required
564 /* TIMx clock enable */
565 # if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14))
566 RCC_APB1PeriphClockCmd(IRSND_TIMER_RCC
, ENABLE
);
568 RCC_APB2PeriphClockCmd(IRSND_TIMER_RCC
, ENABLE
);
571 /* Time base configuration */
572 TIM_TimeBaseStructure
.TIM_Period
= 0; // will be initialized later
573 TIM_TimeBaseStructure
.TIM_Prescaler
= 0;
574 TIM_TimeBaseStructure
.TIM_ClockDivision
= 0;
575 TIM_TimeBaseStructure
.TIM_CounterMode
= TIM_CounterMode_Up
;
576 TIM_TimeBaseInit(IRSND_TIMER
, &TIM_TimeBaseStructure
);
578 /* PWM1 Mode configuration */
579 TIM_OCInitStructure
.TIM_OCMode
= TIM_OCMode_PWM1
;
580 TIM_OCInitStructure
.TIM_OutputState
= TIM_OutputState_Enable
;
581 TIM_OCInitStructure
.TIM_Pulse
= 0; // will be initialized later
582 TIM_OCInitStructure
.TIM_OCPolarity
= TIM_OCPolarity_High
;
583 TIM_OC1Init(IRSND_TIMER
, &TIM_OCInitStructure
);
585 /* Preload configuration */
586 TIM_OC1PreloadConfig(IRSND_TIMER
, TIM_OCPreload_Enable
);
587 TIM_ARRPreloadConfig(IRSND_TIMER
, ENABLE
);
589 irsnd_set_freq (IRSND_FREQ_36_KHZ
); // default frequency
591 IRSND_PORT
&= ~(1<<IRSND_BIT
); // set IRSND_BIT to low
592 IRSND_DDR
|= (1<<IRSND_BIT
); // set IRSND_BIT to output
594 # if IRSND_OCx == IRSND_OC2 // use OC2
595 TCCR2
= (1<<WGM21
); // CTC mode
596 TCCR2
|= (1<<CS20
); // 0x01, start Timer 2, no prescaling
597 # elif IRSND_OCx == IRSND_OC2A || IRSND_OCx == IRSND_OC2B // use OC2A or OC2B
598 TCCR2A
= (1<<WGM21
); // CTC mode
599 TCCR2B
|= (1<<CS20
); // 0x01, start Timer 2, no prescaling
600 # elif IRSND_OCx == IRSND_OC0 // use OC0
601 TCCR0
= (1<<WGM01
); // CTC mode
602 TCCR0
|= (1<<CS00
); // 0x01, start Timer 0, no prescaling
603 # elif IRSND_OCx == IRSND_OC0A || IRSND_OCx == IRSND_OC0B // use OC0A or OC0B
604 TCCR0A
= (1<<WGM01
); // CTC mode
605 TCCR0B
|= (1<<CS00
); // 0x01, start Timer 0, no prescaling
607 # error wrong value of IRSND_OCx
609 irsnd_set_freq (IRSND_FREQ_36_KHZ
); // default frequency
614 #if IRSND_USE_CALLBACK == 1
616 irsnd_set_callback_ptr (void (*cb
)(uint8_t))
618 irsnd_callback_ptr
= cb
;
620 #endif // IRSND_USE_CALLBACK == 1
629 bitsrevervse (uint16_t x
, uint8_t len
)
647 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
648 static uint8_t sircs_additional_bitlen
;
649 #endif // IRSND_SUPPORT_SIRCS_PROTOCOL == 1
652 irsnd_send_data (IRMP_DATA
* irmp_data_p
, uint8_t do_wait
)
654 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
655 static uint8_t toggle_bit_recs80
;
657 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
658 static uint8_t toggle_bit_recs80ext
;
660 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
661 static uint8_t toggle_bit_rc5
;
663 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
664 static uint8_t toggle_bit_rc6
;
666 #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1
667 static uint8_t toggle_bit_thomson
;
684 irsnd_protocol
= irmp_data_p
->protocol
;
685 irsnd_repeat
= irmp_data_p
->flags
& IRSND_REPETITION_MASK
;
687 switch (irsnd_protocol
)
689 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
690 case IRMP_SIRCS_PROTOCOL
:
692 // uint8_t sircs_additional_command_len;
693 uint8_t sircs_additional_address_len
;
695 sircs_additional_bitlen
= (irmp_data_p
->address
& 0xFF00) >> 8; // additional bitlen
697 if (sircs_additional_bitlen
> 15 - SIRCS_MINIMUM_DATA_LEN
)
699 // sircs_additional_command_len = 15 - SIRCS_MINIMUM_DATA_LEN;
700 sircs_additional_address_len
= sircs_additional_bitlen
- (15 - SIRCS_MINIMUM_DATA_LEN
);
704 // sircs_additional_command_len = sircs_additional_bitlen;
705 sircs_additional_address_len
= 0;
708 command
= bitsrevervse (irmp_data_p
->command
, 15);
710 irsnd_buffer
[0] = (command
& 0x7F80) >> 7; // CCCCCCCC
711 irsnd_buffer
[1] = (command
& 0x007F) << 1; // CCCC****
713 if (sircs_additional_address_len
> 0)
715 address
= bitsrevervse (irmp_data_p
->address
, 5);
716 irsnd_buffer
[1] |= (address
& 0x0010) >> 4;
717 irsnd_buffer
[2] = (address
& 0x000F) << 4;
723 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
724 case IRMP_APPLE_PROTOCOL
:
726 command
= irmp_data_p
->command
| (irmp_data_p
->address
<< 8); // store address as ID in upper byte of command
727 address
= 0x87EE; // set fixed NEC-lookalike address (customer ID of apple)
729 address
= bitsrevervse (address
, NEC_ADDRESS_LEN
);
730 command
= bitsrevervse (command
, NEC_COMMAND_LEN
);
732 irsnd_protocol
= IRMP_NEC_PROTOCOL
; // APPLE protocol is NEC with id instead of inverted command
734 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
735 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
736 irsnd_buffer
[2] = (command
& 0xFF00) >> 8; // CCCCCCCC
737 irsnd_buffer
[3] = 0x8B; // 10001011 (id)
741 case IRMP_NEC_PROTOCOL
:
743 address
= bitsrevervse (irmp_data_p
->address
, NEC_ADDRESS_LEN
);
744 command
= bitsrevervse (irmp_data_p
->command
, NEC_COMMAND_LEN
);
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] = ~((command
& 0xFF00) >> 8); // cccccccc
754 #if IRSND_SUPPORT_NEC16_PROTOCOL == 1
755 case IRMP_NEC16_PROTOCOL
:
757 address
= bitsrevervse (irmp_data_p
->address
, NEC16_ADDRESS_LEN
);
758 command
= bitsrevervse (irmp_data_p
->command
, NEC16_COMMAND_LEN
);
760 irsnd_buffer
[0] = (address
& 0x00FF); // AAAAAAAA
761 irsnd_buffer
[1] = (command
& 0x00FF); // CCCCCCCC
766 #if IRSND_SUPPORT_NEC42_PROTOCOL == 1
767 case IRMP_NEC42_PROTOCOL
:
769 address
= bitsrevervse (irmp_data_p
->address
, NEC42_ADDRESS_LEN
);
770 command
= bitsrevervse (irmp_data_p
->command
, NEC42_COMMAND_LEN
);
772 irsnd_buffer
[0] = ( (address
& 0x1FE0) >> 5); // AAAAAAAA
773 irsnd_buffer
[1] = ( (address
& 0x001F) << 3) | ((~address
& 0x1C00) >> 10); // AAAAAaaa
774 irsnd_buffer
[2] = ((~address
& 0x03FC) >> 2); // aaaaaaaa
775 irsnd_buffer
[3] = ((~address
& 0x0003) << 6) | ( (command
& 0x00FC) >> 2); // aaCCCCCC
776 irsnd_buffer
[4] = ( (command
& 0x0003) << 6) | ((~command
& 0x00FC) >> 2); // CCcccccc
777 irsnd_buffer
[5] = ((~command
& 0x0003) << 6); // cc
782 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
783 case IRMP_SAMSUNG_PROTOCOL
:
785 address
= bitsrevervse (irmp_data_p
->address
, SAMSUNG_ADDRESS_LEN
);
786 command
= bitsrevervse (irmp_data_p
->command
, SAMSUNG_COMMAND_LEN
);
788 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
789 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
790 irsnd_buffer
[2] = (command
& 0x00F0) | ((command
& 0xF000) >> 12); // IIIICCCC
791 irsnd_buffer
[3] = ((command
& 0x0F00) >> 4) | ((~(command
& 0xF000) >> 12) & 0x0F); // CCCCcccc
792 irsnd_buffer
[4] = (~(command
& 0x0F00) >> 4) & 0xF0; // cccc0000
796 case IRMP_SAMSUNG32_PROTOCOL
:
798 address
= bitsrevervse (irmp_data_p
->address
, SAMSUNG_ADDRESS_LEN
);
799 command
= bitsrevervse (irmp_data_p
->command
, SAMSUNG32_COMMAND_LEN
);
801 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
802 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
803 irsnd_buffer
[2] = (command
& 0xFF00) >> 8; // CCCCCCCC
804 irsnd_buffer
[3] = (command
& 0x00FF); // CCCCCCCC
809 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
810 case IRMP_MATSUSHITA_PROTOCOL
:
812 address
= bitsrevervse (irmp_data_p
->address
, MATSUSHITA_ADDRESS_LEN
);
813 command
= bitsrevervse (irmp_data_p
->command
, MATSUSHITA_COMMAND_LEN
);
815 irsnd_buffer
[0] = (command
& 0x0FF0) >> 4; // CCCCCCCC
816 irsnd_buffer
[1] = ((command
& 0x000F) << 4) | ((address
& 0x0F00) >> 8); // CCCCAAAA
817 irsnd_buffer
[2] = (address
& 0x00FF); // AAAAAAAA
822 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
823 case IRMP_KASEIKYO_PROTOCOL
:
828 address
= bitsrevervse (irmp_data_p
->address
, KASEIKYO_ADDRESS_LEN
);
829 command
= bitsrevervse (irmp_data_p
->command
, KASEIKYO_COMMAND_LEN
+ 4);
830 genre2
= bitsrevervse ((irmp_data_p
->flags
& ~IRSND_REPETITION_MASK
) >> 4, 4);
832 xor = ((address
& 0x000F) ^ ((address
& 0x00F0) >> 4) ^ ((address
& 0x0F00) >> 8) ^ ((address
& 0xF000) >> 12)) & 0x0F;
834 irsnd_buffer
[0] = (address
& 0xFF00) >> 8; // AAAAAAAA
835 irsnd_buffer
[1] = (address
& 0x00FF); // AAAAAAAA
836 irsnd_buffer
[2] = xor << 4 | (command
& 0x000F); // XXXXCCCC
837 irsnd_buffer
[3] = (genre2
<< 4) | (command
& 0xF000) >> 12; // ggggCCCC
838 irsnd_buffer
[4] = (command
& 0x0FF0) >> 4; // CCCCCCCC
840 xor = irsnd_buffer
[2] ^ irsnd_buffer
[3] ^ irsnd_buffer
[4];
842 irsnd_buffer
[5] = xor;
847 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
848 case IRMP_RECS80_PROTOCOL
:
850 toggle_bit_recs80
= toggle_bit_recs80
? 0x00 : 0x40;
852 irsnd_buffer
[0] = 0x80 | toggle_bit_recs80
| ((irmp_data_p
->address
& 0x0007) << 3) |
853 ((irmp_data_p
->command
& 0x0038) >> 3); // STAAACCC
854 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x07) << 5; // CCC00000
859 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
860 case IRMP_RECS80EXT_PROTOCOL
:
862 toggle_bit_recs80ext
= toggle_bit_recs80ext
? 0x00 : 0x40;
864 irsnd_buffer
[0] = 0x80 | toggle_bit_recs80ext
| ((irmp_data_p
->address
& 0x000F) << 2) |
865 ((irmp_data_p
->command
& 0x0030) >> 4); // STAAAACC
866 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x0F) << 4; // CCCC0000
871 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
872 case IRMP_RC5_PROTOCOL
:
874 toggle_bit_rc5
= toggle_bit_rc5
? 0x00 : 0x40;
876 irsnd_buffer
[0] = ((irmp_data_p
->command
& 0x40) ? 0x00 : 0x80) | toggle_bit_rc5
|
877 ((irmp_data_p
->address
& 0x001F) << 1) | ((irmp_data_p
->command
& 0x20) >> 5); // CTAAAAAC
878 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x1F) << 3; // CCCCC000
883 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
884 case IRMP_RC6_PROTOCOL
:
886 toggle_bit_rc6
= toggle_bit_rc6
? 0x00 : 0x08;
888 irsnd_buffer
[0] = 0x80 | toggle_bit_rc6
| ((irmp_data_p
->address
& 0x00E0) >> 5); // 1MMMTAAA, MMM = 000
889 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x001F) << 3) | ((irmp_data_p
->command
& 0xE0) >> 5); // AAAAACCC
890 irsnd_buffer
[2] = (irmp_data_p
->command
& 0x1F) << 3; // CCCCC
895 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
896 case IRMP_RC6A_PROTOCOL
:
898 toggle_bit_rc6
= toggle_bit_rc6
? 0x00 : 0x08;
900 irsnd_buffer
[0] = 0x80 | 0x60 | ((irmp_data_p
->address
& 0x3000) >> 12); // 1MMMT0AA, MMM = 110
901 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x0FFF) >> 4) ; // AAAAAAAA
902 irsnd_buffer
[2] = ((irmp_data_p
->address
& 0x000F) << 4) | ((irmp_data_p
->command
& 0xF000) >> 12) | toggle_bit_rc6
; // AAAACCCC
903 irsnd_buffer
[3] = (irmp_data_p
->command
& 0x0FF0) >> 4; // CCCCCCCC
904 irsnd_buffer
[4] = (irmp_data_p
->command
& 0x000F) << 4; // CCCC
909 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
910 case IRMP_DENON_PROTOCOL
:
912 irsnd_buffer
[0] = ((irmp_data_p
->address
& 0x1F) << 3) | ((irmp_data_p
->command
& 0x0380) >> 7); // AAAAACCC (1st frame)
913 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x7F) << 1; // CCCCCCC
914 irsnd_buffer
[2] = ((irmp_data_p
->address
& 0x1F) << 3) | (((~irmp_data_p
->command
) & 0x0380) >> 7); // AAAAAccc (2nd frame)
915 irsnd_buffer
[3] = (~(irmp_data_p
->command
) & 0x7F) << 1; // ccccccc
920 #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1
921 case IRMP_THOMSON_PROTOCOL
:
923 toggle_bit_thomson
= toggle_bit_thomson
? 0x00 : 0x08;
925 irsnd_buffer
[0] = ((irmp_data_p
->address
& 0x0F) << 4) | toggle_bit_thomson
| ((irmp_data_p
->command
& 0x0070) >> 4); // AAAATCCC (1st frame)
926 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x0F) << 4; // CCCC
931 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
932 case IRMP_NUBERT_PROTOCOL
:
934 irsnd_buffer
[0] = irmp_data_p
->command
>> 2; // CCCCCCCC
935 irsnd_buffer
[1] = (irmp_data_p
->command
& 0x0003) << 6; // CC000000
940 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
941 case IRMP_BANG_OLUFSEN_PROTOCOL
:
943 irsnd_buffer
[0] = irmp_data_p
->command
>> 11; // SXSCCCCC
944 irsnd_buffer
[1] = irmp_data_p
->command
>> 3; // CCCCCCCC
945 irsnd_buffer
[2] = (irmp_data_p
->command
& 0x0007) << 5; // CCC00000
950 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
951 case IRMP_GRUNDIG_PROTOCOL
:
953 command
= bitsrevervse (irmp_data_p
->command
, GRUNDIG_COMMAND_LEN
);
955 irsnd_buffer
[0] = 0xFF; // S1111111 (1st frame)
956 irsnd_buffer
[1] = 0xC0; // 11
957 irsnd_buffer
[2] = 0x80 | (command
>> 2); // SCCCCCCC (2nd frame)
958 irsnd_buffer
[3] = (command
<< 6) & 0xC0; // CC
964 #if IRSND_SUPPORT_IR60_PROTOCOL == 1
965 case IRMP_IR60_PROTOCOL
:
967 command
= (bitsrevervse (0x7d, IR60_COMMAND_LEN
) << 7) | bitsrevervse (irmp_data_p
->command
, IR60_COMMAND_LEN
);
969 irsnd_buffer
[0] = command
>> 6 | 0x01; // 1011111S (start instruction frame)
970 irsnd_buffer
[1] = (command
& 0x7F) << 1; // CCCCCCC_ (2nd frame)
972 irsnd_buffer
[0] = ((command
& 0x7F) << 1) | 0x01; // CCCCCCCS (1st frame)
973 irsnd_buffer
[1] = command
>> 6; // 1011111_ (start instruction frame)
980 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
981 case IRMP_NOKIA_PROTOCOL
:
983 address
= bitsrevervse (irmp_data_p
->address
, NOKIA_ADDRESS_LEN
);
984 command
= bitsrevervse (irmp_data_p
->command
, NOKIA_COMMAND_LEN
);
986 irsnd_buffer
[0] = 0xBF; // S0111111 (1st + 3rd frame)
987 irsnd_buffer
[1] = 0xFF; // 11111111
988 irsnd_buffer
[2] = 0x80; // 1
989 irsnd_buffer
[3] = 0x80 | command
>> 1; // SCCCCCCC (2nd frame)
990 irsnd_buffer
[4] = (command
<< 7) | (address
>> 1); // CAAAAAAA
991 irsnd_buffer
[5] = (address
<< 7); // A
997 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
998 case IRMP_SIEMENS_PROTOCOL
:
1000 irsnd_buffer
[0] = ((irmp_data_p
->address
& 0x0FFF) >> 5); // SAAAAAAA
1001 irsnd_buffer
[1] = ((irmp_data_p
->address
& 0x1F) << 3) | ((irmp_data_p
->command
& 0x7F) >> 5); // AAAAA0CC
1002 irsnd_buffer
[2] = (irmp_data_p
->command
<< 3) | ((~irmp_data_p
->command
& 0x01) << 2); // CCCCCc
1008 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1009 case IRMP_FDC_PROTOCOL
:
1011 address
= bitsrevervse (irmp_data_p
->address
, FDC_ADDRESS_LEN
);
1012 command
= bitsrevervse (irmp_data_p
->command
, FDC_COMMAND_LEN
);
1014 irsnd_buffer
[0] = (address
& 0xFF); // AAAAAAAA
1015 irsnd_buffer
[1] = 0; // 00000000
1016 irsnd_buffer
[2] = 0; // 0000RRRR
1017 irsnd_buffer
[3] = (command
& 0xFF); // CCCCCCCC
1018 irsnd_buffer
[4] = ~(command
& 0xFF); // cccccccc
1023 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
1024 case IRMP_RCCAR_PROTOCOL
:
1026 address
= bitsrevervse (irmp_data_p
->address
, 2); // A0 A1
1027 command
= bitsrevervse (irmp_data_p
->command
, RCCAR_COMMAND_LEN
- 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V
1029 irsnd_buffer
[0] = ((command
& 0x06) << 5) | ((address
& 0x0003) << 4) | ((command
& 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3
1030 irsnd_buffer
[1] = ((command
& 0x78) << 1) | ((command
& 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0
1036 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
1037 case IRMP_JVC_PROTOCOL
:
1039 address
= bitsrevervse (irmp_data_p
->address
, JVC_ADDRESS_LEN
);
1040 command
= bitsrevervse (irmp_data_p
->command
, JVC_COMMAND_LEN
);
1042 irsnd_buffer
[0] = ((address
& 0x000F) << 4) | (command
& 0x0F00) >> 8; // AAAACCCC
1043 irsnd_buffer
[1] = (command
& 0x00FF); // CCCCCCCC
1049 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
1050 case IRMP_NIKON_PROTOCOL
:
1052 irsnd_buffer
[0] = (irmp_data_p
->command
& 0x0003) << 6; // CC
1057 #if IRSND_SUPPORT_LEGO_PROTOCOL == 1
1058 case IRMP_LEGO_PROTOCOL
:
1060 uint8_t crc
= 0x0F ^ ((irmp_data_p
->command
& 0x0F00) >> 8) ^ ((irmp_data_p
->command
& 0x00F0) >> 4) ^ (irmp_data_p
->command
& 0x000F);
1062 irsnd_buffer
[0] = (irmp_data_p
->command
& 0x0FF0) >> 4; // CCCCCCCC
1063 irsnd_buffer
[1] = ((irmp_data_p
->command
& 0x000F) << 4) | crc
; // CCCCcccc
1065 irsnd_protocol
= IRMP_LEGO_PROTOCOL
;
1085 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1087 * @details ISR routine, called 10000 times per second
1088 *---------------------------------------------------------------------------------------------------------------------------------------------------
1093 static uint8_t send_trailer
= FALSE
;
1094 static uint8_t current_bit
= 0xFF;
1095 static uint8_t pulse_counter
= 0;
1096 static IRSND_PAUSE_LEN pause_counter
= 0;
1097 static uint8_t startbit_pulse_len
= 0;
1098 static IRSND_PAUSE_LEN startbit_pause_len
= 0;
1099 static uint8_t pulse_1_len
= 0;
1100 static uint8_t pause_1_len
= 0;
1101 static uint8_t pulse_0_len
= 0;
1102 static uint8_t pause_0_len
= 0;
1103 static uint8_t has_stop_bit
= 0;
1104 static uint8_t new_frame
= TRUE
;
1105 static uint8_t complete_data_len
= 0;
1106 static uint8_t n_repeat_frames
= 0; // number of repetition frames
1107 static uint8_t n_auto_repetitions
= 0; // number of auto_repetitions
1108 static uint8_t auto_repetition_counter
= 0; // auto_repetition counter
1109 static uint16_t auto_repetition_pause_len
= 0; // pause before auto_repetition, uint16_t!
1110 static uint16_t auto_repetition_pause_counter
= 0; // pause before auto_repetition, uint16_t!
1111 static uint8_t repeat_counter
= 0; // repeat counter
1112 static uint16_t repeat_frame_pause_len
= 0; // pause before repeat, uint16_t!
1113 static uint16_t packet_repeat_pause_counter
= 0; // pause before repeat, uint16_t!
1114 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1115 static uint8_t last_bit_value
;
1117 static uint8_t pulse_len
= 0xFF;
1118 static IRSND_PAUSE_LEN pause_len
= 0xFF;
1122 if (current_bit
== 0xFF && new_frame
) // start of transmission...
1124 if (auto_repetition_counter
> 0)
1126 auto_repetition_pause_counter
++;
1128 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1129 if (repeat_frame_pause_len
> 0) // frame repeat distance counts from beginning of 1st frame!
1131 repeat_frame_pause_len
--;
1135 if (auto_repetition_pause_counter
>= auto_repetition_pause_len
)
1137 auto_repetition_pause_counter
= 0;
1139 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1140 if (irsnd_protocol
== IRMP_DENON_PROTOCOL
) // n'th denon frame
1143 complete_data_len
= 2 * DENON_COMPLETE_DATA_LEN
+ 1;
1147 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
1148 if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
) // n'th grundig frame
1151 complete_data_len
= 16 + GRUNDIG_COMPLETE_DATA_LEN
;
1155 #if IRSND_SUPPORT_IR60_PROTOCOL == 1
1156 if (irsnd_protocol
== IRMP_IR60_PROTOCOL
) // n'th IR60 frame
1159 complete_data_len
= 2 * IR60_COMPLETE_DATA_LEN
+ 1;
1163 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1164 if (irsnd_protocol
== IRMP_NOKIA_PROTOCOL
) // n'th nokia frame
1166 if (auto_repetition_counter
+ 1 < n_auto_repetitions
)
1169 complete_data_len
= 24 + NOKIA_COMPLETE_DATA_LEN
;
1171 else // nokia stop frame
1174 complete_data_len
= NOKIA_COMPLETE_DATA_LEN
;
1199 else if (repeat_counter
> 0 && packet_repeat_pause_counter
< repeat_frame_pause_len
)
1201 else if (packet_repeat_pause_counter
< repeat_frame_pause_len
)
1204 packet_repeat_pause_counter
++;
1223 send_trailer
= FALSE
;
1227 n_repeat_frames
= irsnd_repeat
;
1229 if (n_repeat_frames
== IRSND_ENDLESS_REPETITION
)
1231 n_repeat_frames
= 255;
1234 packet_repeat_pause_counter
= 0;
1238 switch (irsnd_protocol
)
1240 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
1241 case IRMP_SIRCS_PROTOCOL
:
1243 startbit_pulse_len
= SIRCS_START_BIT_PULSE_LEN
;
1244 startbit_pause_len
= SIRCS_START_BIT_PAUSE_LEN
- 1;
1245 pulse_1_len
= SIRCS_1_PULSE_LEN
;
1246 pause_1_len
= SIRCS_PAUSE_LEN
- 1;
1247 pulse_0_len
= SIRCS_0_PULSE_LEN
;
1248 pause_0_len
= SIRCS_PAUSE_LEN
- 1;
1249 has_stop_bit
= SIRCS_STOP_BIT
;
1250 complete_data_len
= SIRCS_MINIMUM_DATA_LEN
+ sircs_additional_bitlen
;
1251 n_auto_repetitions
= (repeat_counter
== 0) ? SIRCS_FRAMES
: 1; // 3 frames auto repetition if first frame
1252 auto_repetition_pause_len
= SIRCS_AUTO_REPETITION_PAUSE_LEN
; // 25ms pause
1253 repeat_frame_pause_len
= SIRCS_FRAME_REPEAT_PAUSE_LEN
;
1254 irsnd_set_freq (IRSND_FREQ_40_KHZ
);
1258 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
1259 case IRMP_NEC_PROTOCOL
:
1261 startbit_pulse_len
= NEC_START_BIT_PULSE_LEN
;
1263 if (repeat_counter
> 0)
1265 startbit_pause_len
= NEC_REPEAT_START_BIT_PAUSE_LEN
- 1;
1266 complete_data_len
= 0;
1270 startbit_pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
1271 complete_data_len
= NEC_COMPLETE_DATA_LEN
;
1274 pulse_1_len
= NEC_PULSE_LEN
;
1275 pause_1_len
= NEC_1_PAUSE_LEN
- 1;
1276 pulse_0_len
= NEC_PULSE_LEN
;
1277 pause_0_len
= NEC_0_PAUSE_LEN
- 1;
1278 has_stop_bit
= NEC_STOP_BIT
;
1279 n_auto_repetitions
= 1; // 1 frame
1280 auto_repetition_pause_len
= 0;
1281 repeat_frame_pause_len
= NEC_FRAME_REPEAT_PAUSE_LEN
;
1282 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1286 #if IRSND_SUPPORT_NEC16_PROTOCOL == 1
1287 case IRMP_NEC16_PROTOCOL
:
1289 startbit_pulse_len
= NEC_START_BIT_PULSE_LEN
;
1290 startbit_pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
1291 pulse_1_len
= NEC_PULSE_LEN
;
1292 pause_1_len
= NEC_1_PAUSE_LEN
- 1;
1293 pulse_0_len
= NEC_PULSE_LEN
;
1294 pause_0_len
= NEC_0_PAUSE_LEN
- 1;
1295 has_stop_bit
= NEC_STOP_BIT
;
1296 complete_data_len
= NEC16_COMPLETE_DATA_LEN
+ 1; // 1 more: sync bit
1297 n_auto_repetitions
= 1; // 1 frame
1298 auto_repetition_pause_len
= 0;
1299 repeat_frame_pause_len
= NEC_FRAME_REPEAT_PAUSE_LEN
;
1300 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1304 #if IRSND_SUPPORT_NEC42_PROTOCOL == 1
1305 case IRMP_NEC42_PROTOCOL
:
1307 startbit_pulse_len
= NEC_START_BIT_PULSE_LEN
;
1308 startbit_pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
1309 pulse_1_len
= NEC_PULSE_LEN
;
1310 pause_1_len
= NEC_1_PAUSE_LEN
- 1;
1311 pulse_0_len
= NEC_PULSE_LEN
;
1312 pause_0_len
= NEC_0_PAUSE_LEN
- 1;
1313 has_stop_bit
= NEC_STOP_BIT
;
1314 complete_data_len
= NEC42_COMPLETE_DATA_LEN
;
1315 n_auto_repetitions
= 1; // 1 frame
1316 auto_repetition_pause_len
= 0;
1317 repeat_frame_pause_len
= NEC_FRAME_REPEAT_PAUSE_LEN
;
1318 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1322 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
1323 case IRMP_SAMSUNG_PROTOCOL
:
1325 startbit_pulse_len
= SAMSUNG_START_BIT_PULSE_LEN
;
1326 startbit_pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
1327 pulse_1_len
= SAMSUNG_PULSE_LEN
;
1328 pause_1_len
= SAMSUNG_1_PAUSE_LEN
- 1;
1329 pulse_0_len
= SAMSUNG_PULSE_LEN
;
1330 pause_0_len
= SAMSUNG_0_PAUSE_LEN
- 1;
1331 has_stop_bit
= SAMSUNG_STOP_BIT
;
1332 complete_data_len
= SAMSUNG_COMPLETE_DATA_LEN
;
1333 n_auto_repetitions
= 1; // 1 frame
1334 auto_repetition_pause_len
= 0;
1335 repeat_frame_pause_len
= SAMSUNG_FRAME_REPEAT_PAUSE_LEN
;
1336 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1340 case IRMP_SAMSUNG32_PROTOCOL
:
1342 startbit_pulse_len
= SAMSUNG_START_BIT_PULSE_LEN
;
1343 startbit_pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
1344 pulse_1_len
= SAMSUNG_PULSE_LEN
;
1345 pause_1_len
= SAMSUNG_1_PAUSE_LEN
- 1;
1346 pulse_0_len
= SAMSUNG_PULSE_LEN
;
1347 pause_0_len
= SAMSUNG_0_PAUSE_LEN
- 1;
1348 has_stop_bit
= SAMSUNG_STOP_BIT
;
1349 complete_data_len
= SAMSUNG32_COMPLETE_DATA_LEN
;
1350 n_auto_repetitions
= SAMSUNG32_FRAMES
; // 2 frames
1351 auto_repetition_pause_len
= SAMSUNG32_AUTO_REPETITION_PAUSE_LEN
; // 47 ms pause
1352 repeat_frame_pause_len
= SAMSUNG32_FRAME_REPEAT_PAUSE_LEN
;
1353 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1357 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
1358 case IRMP_MATSUSHITA_PROTOCOL
:
1360 startbit_pulse_len
= MATSUSHITA_START_BIT_PULSE_LEN
;
1361 startbit_pause_len
= MATSUSHITA_START_BIT_PAUSE_LEN
- 1;
1362 pulse_1_len
= MATSUSHITA_PULSE_LEN
;
1363 pause_1_len
= MATSUSHITA_1_PAUSE_LEN
- 1;
1364 pulse_0_len
= MATSUSHITA_PULSE_LEN
;
1365 pause_0_len
= MATSUSHITA_0_PAUSE_LEN
- 1;
1366 has_stop_bit
= MATSUSHITA_STOP_BIT
;
1367 complete_data_len
= MATSUSHITA_COMPLETE_DATA_LEN
;
1368 n_auto_repetitions
= 1; // 1 frame
1369 auto_repetition_pause_len
= 0;
1370 repeat_frame_pause_len
= MATSUSHITA_FRAME_REPEAT_PAUSE_LEN
;
1371 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1375 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
1376 case IRMP_KASEIKYO_PROTOCOL
:
1378 startbit_pulse_len
= KASEIKYO_START_BIT_PULSE_LEN
;
1379 startbit_pause_len
= KASEIKYO_START_BIT_PAUSE_LEN
- 1;
1380 pulse_1_len
= KASEIKYO_PULSE_LEN
;
1381 pause_1_len
= KASEIKYO_1_PAUSE_LEN
- 1;
1382 pulse_0_len
= KASEIKYO_PULSE_LEN
;
1383 pause_0_len
= KASEIKYO_0_PAUSE_LEN
- 1;
1384 has_stop_bit
= KASEIKYO_STOP_BIT
;
1385 complete_data_len
= KASEIKYO_COMPLETE_DATA_LEN
;
1386 n_auto_repetitions
= (repeat_counter
== 0) ? KASEIKYO_FRAMES
: 1; // 2 frames auto repetition if first frame
1387 auto_repetition_pause_len
= KASEIKYO_AUTO_REPETITION_PAUSE_LEN
; // 75 ms pause
1388 repeat_frame_pause_len
= KASEIKYO_FRAME_REPEAT_PAUSE_LEN
;
1389 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1393 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
1394 case IRMP_RECS80_PROTOCOL
:
1396 startbit_pulse_len
= RECS80_START_BIT_PULSE_LEN
;
1397 startbit_pause_len
= RECS80_START_BIT_PAUSE_LEN
- 1;
1398 pulse_1_len
= RECS80_PULSE_LEN
;
1399 pause_1_len
= RECS80_1_PAUSE_LEN
- 1;
1400 pulse_0_len
= RECS80_PULSE_LEN
;
1401 pause_0_len
= RECS80_0_PAUSE_LEN
- 1;
1402 has_stop_bit
= RECS80_STOP_BIT
;
1403 complete_data_len
= RECS80_COMPLETE_DATA_LEN
;
1404 n_auto_repetitions
= 1; // 1 frame
1405 auto_repetition_pause_len
= 0;
1406 repeat_frame_pause_len
= RECS80_FRAME_REPEAT_PAUSE_LEN
;
1407 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1411 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
1412 case IRMP_RECS80EXT_PROTOCOL
:
1414 startbit_pulse_len
= RECS80EXT_START_BIT_PULSE_LEN
;
1415 startbit_pause_len
= RECS80EXT_START_BIT_PAUSE_LEN
- 1;
1416 pulse_1_len
= RECS80EXT_PULSE_LEN
;
1417 pause_1_len
= RECS80EXT_1_PAUSE_LEN
- 1;
1418 pulse_0_len
= RECS80EXT_PULSE_LEN
;
1419 pause_0_len
= RECS80EXT_0_PAUSE_LEN
- 1;
1420 has_stop_bit
= RECS80EXT_STOP_BIT
;
1421 complete_data_len
= RECS80EXT_COMPLETE_DATA_LEN
;
1422 n_auto_repetitions
= 1; // 1 frame
1423 auto_repetition_pause_len
= 0;
1424 repeat_frame_pause_len
= RECS80EXT_FRAME_REPEAT_PAUSE_LEN
;
1425 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1429 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
1430 case IRMP_RC5_PROTOCOL
:
1432 startbit_pulse_len
= RC5_BIT_LEN
;
1433 startbit_pause_len
= RC5_BIT_LEN
;
1434 pulse_len
= RC5_BIT_LEN
;
1435 pause_len
= RC5_BIT_LEN
;
1436 has_stop_bit
= RC5_STOP_BIT
;
1437 complete_data_len
= RC5_COMPLETE_DATA_LEN
;
1438 n_auto_repetitions
= 1; // 1 frame
1439 auto_repetition_pause_len
= 0;
1440 repeat_frame_pause_len
= RC5_FRAME_REPEAT_PAUSE_LEN
;
1441 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1445 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
1446 case IRMP_RC6_PROTOCOL
:
1448 startbit_pulse_len
= RC6_START_BIT_PULSE_LEN
;
1449 startbit_pause_len
= RC6_START_BIT_PAUSE_LEN
- 1;
1450 pulse_len
= RC6_BIT_LEN
;
1451 pause_len
= RC6_BIT_LEN
;
1452 has_stop_bit
= RC6_STOP_BIT
;
1453 complete_data_len
= RC6_COMPLETE_DATA_LEN_SHORT
;
1454 n_auto_repetitions
= 1; // 1 frame
1455 auto_repetition_pause_len
= 0;
1456 repeat_frame_pause_len
= RC6_FRAME_REPEAT_PAUSE_LEN
;
1457 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1461 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
1462 case IRMP_RC6A_PROTOCOL
:
1464 startbit_pulse_len
= RC6_START_BIT_PULSE_LEN
;
1465 startbit_pause_len
= RC6_START_BIT_PAUSE_LEN
- 1;
1466 pulse_len
= RC6_BIT_LEN
;
1467 pause_len
= RC6_BIT_LEN
;
1468 has_stop_bit
= RC6_STOP_BIT
;
1469 complete_data_len
= RC6_COMPLETE_DATA_LEN_LONG
;
1470 n_auto_repetitions
= 1; // 1 frame
1471 auto_repetition_pause_len
= 0;
1472 repeat_frame_pause_len
= RC6_FRAME_REPEAT_PAUSE_LEN
;
1473 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1477 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1478 case IRMP_DENON_PROTOCOL
:
1480 startbit_pulse_len
= 0x00;
1481 startbit_pause_len
= 0x00;
1482 pulse_1_len
= DENON_PULSE_LEN
;
1483 pause_1_len
= DENON_1_PAUSE_LEN
- 1;
1484 pulse_0_len
= DENON_PULSE_LEN
;
1485 pause_0_len
= DENON_0_PAUSE_LEN
- 1;
1486 has_stop_bit
= DENON_STOP_BIT
;
1487 complete_data_len
= DENON_COMPLETE_DATA_LEN
;
1488 n_auto_repetitions
= DENON_FRAMES
; // 2 frames, 2nd with inverted command
1489 auto_repetition_pause_len
= DENON_AUTO_REPETITION_PAUSE_LEN
; // 65 ms pause after 1st frame
1490 repeat_frame_pause_len
= DENON_FRAME_REPEAT_PAUSE_LEN
;
1491 irsnd_set_freq (IRSND_FREQ_36_KHZ
); // in theory 32kHz, in practice 36kHz is better
1495 #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1
1496 case IRMP_THOMSON_PROTOCOL
:
1498 startbit_pulse_len
= 0x00;
1499 startbit_pause_len
= 0x00;
1500 pulse_1_len
= THOMSON_PULSE_LEN
;
1501 pause_1_len
= THOMSON_1_PAUSE_LEN
- 1;
1502 pulse_0_len
= THOMSON_PULSE_LEN
;
1503 pause_0_len
= THOMSON_0_PAUSE_LEN
- 1;
1504 has_stop_bit
= THOMSON_STOP_BIT
;
1505 complete_data_len
= THOMSON_COMPLETE_DATA_LEN
;
1506 n_auto_repetitions
= THOMSON_FRAMES
; // only 1 frame
1507 auto_repetition_pause_len
= THOMSON_AUTO_REPETITION_PAUSE_LEN
;
1508 repeat_frame_pause_len
= DENON_FRAME_REPEAT_PAUSE_LEN
;
1509 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1513 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
1514 case IRMP_NUBERT_PROTOCOL
:
1516 startbit_pulse_len
= NUBERT_START_BIT_PULSE_LEN
;
1517 startbit_pause_len
= NUBERT_START_BIT_PAUSE_LEN
- 1;
1518 pulse_1_len
= NUBERT_1_PULSE_LEN
;
1519 pause_1_len
= NUBERT_1_PAUSE_LEN
- 1;
1520 pulse_0_len
= NUBERT_0_PULSE_LEN
;
1521 pause_0_len
= NUBERT_0_PAUSE_LEN
- 1;
1522 has_stop_bit
= NUBERT_STOP_BIT
;
1523 complete_data_len
= NUBERT_COMPLETE_DATA_LEN
;
1524 n_auto_repetitions
= NUBERT_FRAMES
; // 2 frames
1525 auto_repetition_pause_len
= NUBERT_AUTO_REPETITION_PAUSE_LEN
; // 35 ms pause
1526 repeat_frame_pause_len
= NUBERT_FRAME_REPEAT_PAUSE_LEN
;
1527 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1531 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1532 case IRMP_BANG_OLUFSEN_PROTOCOL
:
1534 startbit_pulse_len
= BANG_OLUFSEN_START_BIT1_PULSE_LEN
;
1535 startbit_pause_len
= BANG_OLUFSEN_START_BIT1_PAUSE_LEN
- 1;
1536 pulse_1_len
= BANG_OLUFSEN_PULSE_LEN
;
1537 pause_1_len
= BANG_OLUFSEN_1_PAUSE_LEN
- 1;
1538 pulse_0_len
= BANG_OLUFSEN_PULSE_LEN
;
1539 pause_0_len
= BANG_OLUFSEN_0_PAUSE_LEN
- 1;
1540 has_stop_bit
= BANG_OLUFSEN_STOP_BIT
;
1541 complete_data_len
= BANG_OLUFSEN_COMPLETE_DATA_LEN
;
1542 n_auto_repetitions
= 1; // 1 frame
1543 auto_repetition_pause_len
= 0;
1544 repeat_frame_pause_len
= BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN
;
1546 irsnd_set_freq (IRSND_FREQ_455_KHZ
);
1550 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
1551 case IRMP_GRUNDIG_PROTOCOL
:
1553 startbit_pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1554 startbit_pause_len
= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN
- 1;
1555 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1556 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1557 has_stop_bit
= GRUNDIG_NOKIA_IR60_STOP_BIT
;
1558 complete_data_len
= GRUNDIG_COMPLETE_DATA_LEN
;
1559 n_auto_repetitions
= GRUNDIG_FRAMES
; // 2 frames
1560 auto_repetition_pause_len
= GRUNDIG_AUTO_REPETITION_PAUSE_LEN
; // 20m sec pause
1561 repeat_frame_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
; // 117 msec pause
1562 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1566 #if IRSND_SUPPORT_IR60_PROTOCOL == 1
1567 case IRMP_IR60_PROTOCOL
:
1569 startbit_pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1570 startbit_pause_len
= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN
- 1;
1571 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1572 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1573 has_stop_bit
= GRUNDIG_NOKIA_IR60_STOP_BIT
;
1574 complete_data_len
= IR60_COMPLETE_DATA_LEN
;
1575 n_auto_repetitions
= IR60_FRAMES
; // 2 frames
1576 auto_repetition_pause_len
= IR60_AUTO_REPETITION_PAUSE_LEN
; // 20m sec pause
1577 repeat_frame_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
; // 117 msec pause
1578 irsnd_set_freq (IRSND_FREQ_30_KHZ
);
1582 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1583 case IRMP_NOKIA_PROTOCOL
:
1585 startbit_pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1586 startbit_pause_len
= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN
- 1;
1587 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1588 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
1589 has_stop_bit
= GRUNDIG_NOKIA_IR60_STOP_BIT
;
1590 complete_data_len
= NOKIA_COMPLETE_DATA_LEN
;
1591 n_auto_repetitions
= NOKIA_FRAMES
; // 2 frames
1592 auto_repetition_pause_len
= NOKIA_AUTO_REPETITION_PAUSE_LEN
; // 20 msec pause
1593 repeat_frame_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
; // 117 msec pause
1594 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1598 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
1599 case IRMP_SIEMENS_PROTOCOL
:
1601 startbit_pulse_len
= SIEMENS_BIT_LEN
;
1602 startbit_pause_len
= SIEMENS_BIT_LEN
;
1603 pulse_len
= SIEMENS_BIT_LEN
;
1604 pause_len
= SIEMENS_BIT_LEN
;
1605 has_stop_bit
= SIEMENS_OR_RUWIDO_STOP_BIT
;
1606 complete_data_len
= SIEMENS_COMPLETE_DATA_LEN
- 1;
1607 n_auto_repetitions
= 1; // 1 frame
1608 auto_repetition_pause_len
= 0;
1609 repeat_frame_pause_len
= SIEMENS_FRAME_REPEAT_PAUSE_LEN
;
1610 irsnd_set_freq (IRSND_FREQ_36_KHZ
);
1614 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1615 case IRMP_FDC_PROTOCOL
:
1617 startbit_pulse_len
= FDC_START_BIT_PULSE_LEN
;
1618 startbit_pause_len
= FDC_START_BIT_PAUSE_LEN
- 1;
1619 complete_data_len
= FDC_COMPLETE_DATA_LEN
;
1620 pulse_1_len
= FDC_PULSE_LEN
;
1621 pause_1_len
= FDC_1_PAUSE_LEN
- 1;
1622 pulse_0_len
= FDC_PULSE_LEN
;
1623 pause_0_len
= FDC_0_PAUSE_LEN
- 1;
1624 has_stop_bit
= FDC_STOP_BIT
;
1625 n_auto_repetitions
= 1; // 1 frame
1626 auto_repetition_pause_len
= 0;
1627 repeat_frame_pause_len
= FDC_FRAME_REPEAT_PAUSE_LEN
;
1628 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1632 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
1633 case IRMP_RCCAR_PROTOCOL
:
1635 startbit_pulse_len
= RCCAR_START_BIT_PULSE_LEN
;
1636 startbit_pause_len
= RCCAR_START_BIT_PAUSE_LEN
- 1;
1637 complete_data_len
= RCCAR_COMPLETE_DATA_LEN
;
1638 pulse_1_len
= RCCAR_PULSE_LEN
;
1639 pause_1_len
= RCCAR_1_PAUSE_LEN
- 1;
1640 pulse_0_len
= RCCAR_PULSE_LEN
;
1641 pause_0_len
= RCCAR_0_PAUSE_LEN
- 1;
1642 has_stop_bit
= RCCAR_STOP_BIT
;
1643 n_auto_repetitions
= 1; // 1 frame
1644 auto_repetition_pause_len
= 0;
1645 repeat_frame_pause_len
= RCCAR_FRAME_REPEAT_PAUSE_LEN
;
1646 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1650 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
1651 case IRMP_JVC_PROTOCOL
:
1653 if (repeat_counter
!= 0) // skip start bit if repetition frame
1658 startbit_pulse_len
= JVC_START_BIT_PULSE_LEN
;
1659 startbit_pause_len
= JVC_START_BIT_PAUSE_LEN
- 1;
1660 complete_data_len
= JVC_COMPLETE_DATA_LEN
;
1661 pulse_1_len
= JVC_PULSE_LEN
;
1662 pause_1_len
= JVC_1_PAUSE_LEN
- 1;
1663 pulse_0_len
= JVC_PULSE_LEN
;
1664 pause_0_len
= JVC_0_PAUSE_LEN
- 1;
1665 has_stop_bit
= JVC_STOP_BIT
;
1666 n_auto_repetitions
= 1; // 1 frame
1667 auto_repetition_pause_len
= 0;
1668 repeat_frame_pause_len
= JVC_FRAME_REPEAT_PAUSE_LEN
;
1669 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1673 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
1674 case IRMP_NIKON_PROTOCOL
:
1676 startbit_pulse_len
= NIKON_START_BIT_PULSE_LEN
;
1677 startbit_pause_len
= 271 - 1; // NIKON_START_BIT_PAUSE_LEN;
1678 complete_data_len
= NIKON_COMPLETE_DATA_LEN
;
1679 pulse_1_len
= NIKON_PULSE_LEN
;
1680 pause_1_len
= NIKON_1_PAUSE_LEN
- 1;
1681 pulse_0_len
= NIKON_PULSE_LEN
;
1682 pause_0_len
= NIKON_0_PAUSE_LEN
- 1;
1683 has_stop_bit
= NIKON_STOP_BIT
;
1684 n_auto_repetitions
= 1; // 1 frame
1685 auto_repetition_pause_len
= 0;
1686 repeat_frame_pause_len
= NIKON_FRAME_REPEAT_PAUSE_LEN
;
1687 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1691 #if IRSND_SUPPORT_LEGO_PROTOCOL == 1
1692 case IRMP_LEGO_PROTOCOL
:
1694 startbit_pulse_len
= LEGO_START_BIT_PULSE_LEN
;
1695 startbit_pause_len
= LEGO_START_BIT_PAUSE_LEN
- 1;
1696 complete_data_len
= LEGO_COMPLETE_DATA_LEN
;
1697 pulse_1_len
= LEGO_PULSE_LEN
;
1698 pause_1_len
= LEGO_1_PAUSE_LEN
- 1;
1699 pulse_0_len
= LEGO_PULSE_LEN
;
1700 pause_0_len
= LEGO_0_PAUSE_LEN
- 1;
1701 has_stop_bit
= LEGO_STOP_BIT
;
1702 n_auto_repetitions
= 1; // 1 frame
1703 auto_repetition_pause_len
= 0;
1704 repeat_frame_pause_len
= LEGO_FRAME_REPEAT_PAUSE_LEN
;
1705 irsnd_set_freq (IRSND_FREQ_38_KHZ
);
1722 switch (irsnd_protocol
)
1724 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1
1725 case IRMP_SIRCS_PROTOCOL
:
1727 #if IRSND_SUPPORT_NEC_PROTOCOL == 1
1728 case IRMP_NEC_PROTOCOL
:
1730 #if IRSND_SUPPORT_NEC16_PROTOCOL == 1
1731 case IRMP_NEC16_PROTOCOL
:
1733 #if IRSND_SUPPORT_NEC42_PROTOCOL == 1
1734 case IRMP_NEC42_PROTOCOL
:
1736 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
1737 case IRMP_SAMSUNG_PROTOCOL
:
1738 case IRMP_SAMSUNG32_PROTOCOL
:
1740 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1
1741 case IRMP_MATSUSHITA_PROTOCOL
:
1743 #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1
1744 case IRMP_KASEIKYO_PROTOCOL
:
1746 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1
1747 case IRMP_RECS80_PROTOCOL
:
1749 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1
1750 case IRMP_RECS80EXT_PROTOCOL
:
1752 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1753 case IRMP_DENON_PROTOCOL
:
1755 #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1
1756 case IRMP_THOMSON_PROTOCOL
:
1758 #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1
1759 case IRMP_NUBERT_PROTOCOL
:
1761 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1762 case IRMP_BANG_OLUFSEN_PROTOCOL
:
1764 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
1765 case IRMP_FDC_PROTOCOL
:
1767 #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1
1768 case IRMP_RCCAR_PROTOCOL
:
1770 #if IRSND_SUPPORT_JVC_PROTOCOL == 1
1771 case IRMP_JVC_PROTOCOL
:
1773 #if IRSND_SUPPORT_NIKON_PROTOCOL == 1
1774 case IRMP_NIKON_PROTOCOL
:
1776 #if IRSND_SUPPORT_LEGO_PROTOCOL == 1
1777 case IRMP_LEGO_PROTOCOL
:
1781 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_NEC16_PROTOCOL == 1 || IRSND_SUPPORT_NEC42_PROTOCOL == 1 || \
1782 IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \
1783 IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \
1784 IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || \
1785 IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1
1787 #if IRSND_SUPPORT_DENON_PROTOCOL == 1
1788 if (irsnd_protocol
== IRMP_DENON_PROTOCOL
)
1790 if (auto_repetition_pause_len
> 0) // 2nd frame distance counts from beginning of 1st frame!
1792 auto_repetition_pause_len
--;
1795 if (repeat_frame_pause_len
> 0) // frame repeat distance counts from beginning of 1st frame!
1797 repeat_frame_pause_len
--;
1802 if (pulse_counter
== 0)
1804 if (current_bit
== 0xFF) // send start bit
1806 pulse_len
= startbit_pulse_len
;
1807 pause_len
= startbit_pause_len
;
1809 else if (current_bit
< complete_data_len
) // send n'th bit
1811 #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1
1812 if (irsnd_protocol
== IRMP_SAMSUNG_PROTOCOL
)
1814 if (current_bit
< SAMSUNG_ADDRESS_LEN
) // send address bits
1816 pulse_len
= SAMSUNG_PULSE_LEN
;
1817 pause_len
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ?
1818 (SAMSUNG_1_PAUSE_LEN
- 1) : (SAMSUNG_0_PAUSE_LEN
- 1);
1820 else if (current_bit
== SAMSUNG_ADDRESS_LEN
) // send SYNC bit (16th bit)
1822 pulse_len
= SAMSUNG_PULSE_LEN
;
1823 pause_len
= SAMSUNG_START_BIT_PAUSE_LEN
- 1;
1825 else if (current_bit
< SAMSUNG_COMPLETE_DATA_LEN
) // send n'th bit
1827 uint8_t cur_bit
= current_bit
- 1; // sync skipped, offset = -1 !
1829 pulse_len
= SAMSUNG_PULSE_LEN
;
1830 pause_len
= (irsnd_buffer
[cur_bit
/ 8] & (1<<(7-(cur_bit
% 8)))) ?
1831 (SAMSUNG_1_PAUSE_LEN
- 1) : (SAMSUNG_0_PAUSE_LEN
- 1);
1837 #if IRSND_SUPPORT_NEC16_PROTOCOL == 1
1838 if (irsnd_protocol
== IRMP_NEC16_PROTOCOL
)
1840 if (current_bit
< NEC16_ADDRESS_LEN
) // send address bits
1842 pulse_len
= NEC_PULSE_LEN
;
1843 pause_len
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ?
1844 (NEC_1_PAUSE_LEN
- 1) : (NEC_0_PAUSE_LEN
- 1);
1846 else if (current_bit
== NEC16_ADDRESS_LEN
) // send SYNC bit (8th bit)
1848 pulse_len
= NEC_PULSE_LEN
;
1849 pause_len
= NEC_START_BIT_PAUSE_LEN
- 1;
1851 else if (current_bit
< NEC16_COMPLETE_DATA_LEN
+ 1) // send n'th bit
1853 uint8_t cur_bit
= current_bit
- 1; // sync skipped, offset = -1 !
1855 pulse_len
= NEC_PULSE_LEN
;
1856 pause_len
= (irsnd_buffer
[cur_bit
/ 8] & (1<<(7-(cur_bit
% 8)))) ?
1857 (NEC_1_PAUSE_LEN
- 1) : (NEC_0_PAUSE_LEN
- 1);
1863 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1864 if (irsnd_protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
1866 if (current_bit
== 0) // send 2nd start bit
1868 pulse_len
= BANG_OLUFSEN_START_BIT2_PULSE_LEN
;
1869 pause_len
= BANG_OLUFSEN_START_BIT2_PAUSE_LEN
- 1;
1871 else if (current_bit
== 1) // send 3rd start bit
1873 pulse_len
= BANG_OLUFSEN_START_BIT3_PULSE_LEN
;
1874 pause_len
= BANG_OLUFSEN_START_BIT3_PAUSE_LEN
- 1;
1876 else if (current_bit
== 2) // send 4th start bit
1878 pulse_len
= BANG_OLUFSEN_START_BIT2_PULSE_LEN
;
1879 pause_len
= BANG_OLUFSEN_START_BIT2_PAUSE_LEN
- 1;
1881 else if (current_bit
== 19) // send trailer bit
1883 pulse_len
= BANG_OLUFSEN_PULSE_LEN
;
1884 pause_len
= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN
- 1;
1886 else if (current_bit
< BANG_OLUFSEN_COMPLETE_DATA_LEN
) // send n'th bit
1888 uint8_t cur_bit_value
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? 1 : 0;
1889 pulse_len
= BANG_OLUFSEN_PULSE_LEN
;
1891 if (cur_bit_value
== last_bit_value
)
1893 pause_len
= BANG_OLUFSEN_R_PAUSE_LEN
- 1;
1897 pause_len
= cur_bit_value
? (BANG_OLUFSEN_1_PAUSE_LEN
- 1) : (BANG_OLUFSEN_0_PAUSE_LEN
- 1);
1898 last_bit_value
= cur_bit_value
;
1904 if (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8))))
1906 pulse_len
= pulse_1_len
;
1907 pause_len
= pause_1_len
;
1911 pulse_len
= pulse_0_len
;
1912 pause_len
= pause_0_len
;
1915 else if (has_stop_bit
) // send stop bit
1917 pulse_len
= pulse_0_len
;
1919 if (auto_repetition_counter
< n_auto_repetitions
)
1921 pause_len
= pause_0_len
;
1925 pause_len
= 255; // last frame: pause of 255
1930 if (pulse_counter
< pulse_len
)
1932 if (pulse_counter
== 0)
1938 else if (pause_counter
< pause_len
)
1940 if (pause_counter
== 0)
1950 if (current_bit
>= complete_data_len
+ has_stop_bit
)
1953 auto_repetition_counter
++;
1955 if (auto_repetition_counter
== n_auto_repetitions
)
1958 auto_repetition_counter
= 0;
1970 #if IRSND_SUPPORT_RC5_PROTOCOL == 1
1971 case IRMP_RC5_PROTOCOL
:
1973 #if IRSND_SUPPORT_RC6_PROTOCOL == 1
1974 case IRMP_RC6_PROTOCOL
:
1976 #if IRSND_SUPPORT_RC6A_PROTOCOL == 1
1977 case IRMP_RC6A_PROTOCOL
:
1979 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1
1980 case IRMP_SIEMENS_PROTOCOL
:
1982 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1
1983 case IRMP_GRUNDIG_PROTOCOL
:
1985 #if IRSND_SUPPORT_IR60_PROTOCOL == 1
1986 case IRMP_IR60_PROTOCOL
:
1988 #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1989 case IRMP_NOKIA_PROTOCOL
:
1992 #if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || \
1993 IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
1995 if (pulse_counter
== pulse_len
&& pause_counter
== pause_len
)
1999 if (current_bit
>= complete_data_len
)
2003 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
2004 if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
|| irsnd_protocol
== IRMP_IR60_PROTOCOL
|| irsnd_protocol
== IRMP_NOKIA_PROTOCOL
)
2006 auto_repetition_counter
++;
2008 if (repeat_counter
> 0)
2009 { // set 117 msec pause time
2010 auto_repetition_pause_len
= GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN
;
2013 if (repeat_counter
< n_repeat_frames
) // tricky: repeat n info frames per auto repetition before sending last stop frame
2015 n_auto_repetitions
++; // increment number of auto repetitions
2018 else if (auto_repetition_counter
== n_auto_repetitions
)
2021 auto_repetition_counter
= 0;
2040 uint8_t first_pulse
;
2042 #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
2043 if (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
|| irsnd_protocol
== IRMP_IR60_PROTOCOL
|| irsnd_protocol
== IRMP_NOKIA_PROTOCOL
)
2045 if (current_bit
== 0xFF || // start bit of start-frame
2046 (irsnd_protocol
== IRMP_GRUNDIG_PROTOCOL
&& current_bit
== 15) || // start bit of info-frame (Grundig)
2047 (irsnd_protocol
== IRMP_IR60_PROTOCOL
&& current_bit
== 7) || // start bit of data frame (IR60)
2048 (irsnd_protocol
== IRMP_NOKIA_PROTOCOL
&& (current_bit
== 23 || current_bit
== 47))) // start bit of info- or stop-frame (Nokia)
2050 pulse_len
= startbit_pulse_len
;
2051 pause_len
= startbit_pause_len
;
2054 else // send n'th bit
2056 pulse_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
2057 pause_len
= GRUNDIG_NOKIA_IR60_BIT_LEN
;
2058 first_pulse
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? TRUE
: FALSE
;
2061 else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL ||
2062 // irsnd_protocol == IRMP_SIEMENS_PROTOCOL)
2065 if (current_bit
== 0xFF) // 1 start bit
2067 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
2068 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
|| irsnd_protocol
== IRMP_RC6A_PROTOCOL
)
2070 pulse_len
= startbit_pulse_len
;
2071 pause_len
= startbit_pause_len
;
2076 else // send n'th bit
2078 #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1
2079 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
|| irsnd_protocol
== IRMP_RC6A_PROTOCOL
)
2081 pulse_len
= RC6_BIT_LEN
;
2082 pause_len
= RC6_BIT_LEN
;
2084 if (irsnd_protocol
== IRMP_RC6_PROTOCOL
)
2086 if (current_bit
== 4) // toggle bit (double len)
2088 pulse_len
= 2 * RC6_BIT_LEN
;
2089 pause_len
= 2 * RC6_BIT_LEN
;
2092 else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL)
2094 if (current_bit
== 4) // toggle bit (double len)
2096 pulse_len
= 2 * RC6_BIT_LEN
+ RC6_BIT_LEN
; // hack!
2097 pause_len
= 2 * RC6_BIT_LEN
;
2099 else if (current_bit
== 5) // toggle bit (double len)
2101 pause_len
= 2 * RC6_BIT_LEN
;
2106 first_pulse
= (irsnd_buffer
[current_bit
/ 8] & (1<<(7-(current_bit
% 8)))) ? TRUE
: FALSE
;
2109 if (irsnd_protocol
== IRMP_RC5_PROTOCOL
)
2111 first_pulse
= first_pulse
? FALSE
: TRUE
;
2117 if (pulse_counter
< pulse_len
)
2119 if (pulse_counter
== 0)
2125 else // if (pause_counter < pause_len)
2127 if (pause_counter
== 0)
2136 if (pause_counter
< pause_len
)
2138 if (pause_counter
== 0)
2144 else // if (pulse_counter < pulse_len)
2146 if (pulse_counter
== 0)
2156 #endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 ||
2157 // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1
2169 if (repeat_counter
< n_repeat_frames
)
2171 #if IRSND_SUPPORT_FDC_PROTOCOL == 1
2172 if (irsnd_protocol
== IRMP_FDC_PROTOCOL
)
2174 irsnd_buffer
[2] |= 0x0F;
2182 irsnd_busy
= TRUE
; //Rainer
2183 send_trailer
= TRUE
;
2184 n_repeat_frames
= 0;
2206 // main function - for unix/linux + windows only!
2208 // Compile it under linux with:
2209 // cc irsnd.c -o irsnd
2211 // usage: ./irsnd protocol hex-address hex-command >filename
2214 main (int argc
, char ** argv
)
2219 IRMP_DATA irmp_data
;
2221 if (argc
!= 4 && argc
!= 5)
2223 fprintf (stderr
, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv
[0]);
2227 if (sscanf (argv
[1], "%d", &protocol
) == 1 &&
2228 sscanf (argv
[2], "%x", &address
) == 1 &&
2229 sscanf (argv
[3], "%x", &command
) == 1)
2231 irmp_data
.protocol
= protocol
;
2232 irmp_data
.address
= address
;
2233 irmp_data
.command
= command
;
2237 irmp_data
.flags
= atoi (argv
[4]);
2241 irmp_data
.flags
= 0;
2246 (void) irsnd_send_data (&irmp_data
, TRUE
);
2257 fprintf (stderr
, "%s: wrong arguments\n", argv
[0]);