]> cloudbase.mooo.com Git - irmp.git/blame - irmp.c
Version 2.0.3:
[irmp.git] / irmp.c
Content-type: text/html ]> cloudbase.mooo.com Git - irmp.git/blame - irmp.c


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 6) line 1, <$fd> line 7953.
CommitLineData
4225a882 1/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
2 * irmp.c - infrared multi-protocol decoder, supports several remote control protocols\r
3 *\r
f50e01e7 4 * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de\r
4225a882 5 *\r
0f700c8e 6 * $Id: irmp.c,v 1.112 2012/02/13 10:59:07 fm Exp $\r
cb8474cc 7 *\r
4225a882 8 * ATMEGA88 @ 8 MHz\r
9 *\r
7644ac04 10 * Supported mikrocontrollers:\r
11 *\r
476267f4 12 * ATtiny45, ATtiny85\r
13 * ATtiny84\r
7644ac04 14 * ATmega8, ATmega16, ATmega32\r
15 * ATmega162\r
16 * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284\r
17 * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P\r
18 *\r
19 * Typical manufacturers of remote controls:\r
4225a882 20 *\r
a42d1ee6 21 * SIRCS - Sony\r
22 * NEC - NEC, Yamaha, Canon, Tevion, Harman/Kardon, Hitachi, JVC, Pioneer, Toshiba, Xoro, Orion, and many other Japanese manufacturers\r
23 * SAMSUNG - Samsung\r
24 * SAMSUNG32 - Samsung\r
25 * MATSUSHITA - Matsushita\r
26 * KASEIKYO - Panasonic, Denon & other Japanese manufacturers (members of "Japan's Association for Electric Home Application")\r
27 * RECS80 - Philips, Nokia, Thomson, Nordmende, Telefunken, Saba\r
28 * RC5 - Philips and other European manufacturers\r
29 * DENON - Denon, Sharp\r
30 * RC6 - Philips and other European manufacturers\r
31 * APPLE - Apple\r
32 * NUBERT - Nubert Subwoofer System\r
33 * B&O - Bang & Olufsen\r
34 * PANASONIC - Panasonic (older, yet not implemented)\r
35 * GRUNDIG - Grundig\r
36 * NOKIA - Nokia\r
37 * SIEMENS - Siemens, e.g. Gigaset M740AV\r
38 * FDC - FDC IR keyboard\r
39 * RCCAR - IR remote control for RC cars\r
40 * JVC - JVC\r
beda975f 41 * THOMSON - Thomson\r
a42d1ee6 42 * NIKON - Nikon cameras\r
43 * RUWIDO - T-Home\r
44 * KATHREIN - Kathrein\r
f50e01e7 45 * LEGO - Lego Power Functions RC\r
4225a882 46 *\r
47 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
48 *\r
49 * SIRCS\r
50 * -----\r
51 *\r
52 * frame: 1 start bit + 12-20 data bits + no stop bit\r
53 * data: 7 command bits + 5 address bits + 0 to 8 additional bits\r
54 *\r
55 * start bit: data "0": data "1": stop bit:\r
56 * -----------------_________ ------_____ ------------______\r
57 * 2400us 600us 600us 600us 1200us 600 us no stop bit\r
58 *\r
59 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
60 *\r
61 * NEC + extended NEC\r
62 * -------------------------\r
63 *\r
64 * frame: 1 start bit + 32 data bits + 1 stop bit\r
65 * data NEC: 8 address bits + 8 inverted address bits + 8 command bits + 8 inverted command bits\r
66 * data extended NEC: 16 address bits + 8 command bits + 8 inverted command bits\r
67 *\r
68 * start bit: data "0": data "1": stop bit:\r
69 * -----------------_________ ------______ ------________________ ------______....\r
70 * 9000us 4500us 560us 560us 560us 1690 us 560us\r
71 *\r
72 *\r
73 * Repetition frame:\r
74 *\r
75 * -----------------_________------______ .... ~100ms Pause, then repeat\r
76 * 9000us 2250us 560us\r
77 *\r
78 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
79 *\r
80 * SAMSUNG\r
81 * -------\r
82 *\r
83 * frame: 1 start bit + 16 data(1) bits + 1 sync bit + additional 20 data(2) bits + 1 stop bit\r
84 * data(1): 16 address bits\r
85 * data(2): 4 ID bits + 8 command bits + 8 inverted command bits\r
86 *\r
87 * start bit: data "0": data "1": sync bit: stop bit:\r
88 * ----------______________ ------______ ------________________ ------______________ ------______....\r
89 * 4500us 4500us 550us 450us 550us 1450us 550us 4500us 550us\r
90 *\r
91 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
92 *\r
93 * SAMSUNG32\r
94 * ----------\r
95 *\r
96 * frame: 1 start bit + 32 data bits + 1 stop bit\r
97 * data: 16 address bits + 16 command bits\r
98 *\r
99 * start bit: data "0": data "1": stop bit:\r
100 * ----------______________ ------______ ------________________ ------______....\r
101 * 4500us 4500us 550us 450us 550us 1450us 550us\r
102 *\r
103 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
104 *\r
105 * MATSUSHITA\r
106 * ----------\r
107 *\r
108 * frame: 1 start bit + 24 data bits + 1 stop bit\r
109 * data: 6 custom bits + 6 command bits + 12 address bits\r
110 *\r
111 * start bit: data "0": data "1": stop bit:\r
112 * ----------_________ ------______ ------________________ ------______....\r
113 * 3488us 3488us 872us 872us 872us 2616us 872us\r
114 *\r
115 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
116 *\r
117 * KASEIKYO\r
118 * --------\r
119 *\r
120 * frame: 1 start bit + 48 data bits + 1 stop bit\r
121 * data: 16 manufacturer bits + 4 parity bits + 4 genre1 bits + 4 genre2 bits + 10 command bits + 2 id bits + 8 parity bits\r
122 *\r
123 * start bit: data "0": data "1": stop bit:\r
124 * ----------______ ------______ ------________________ ------______....\r
125 * 3380us 1690us 423us 423us 423us 1269us 423us\r
126 *\r
127 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
128 *\r
129 * RECS80\r
130 * ------\r
131 *\r
132 * frame: 2 start bits + 10 data bits + 1 stop bit\r
133 * data: 1 toggle bit + 3 address bits + 6 command bits\r
134 *\r
135 * start bit: data "0": data "1": stop bit:\r
136 * -----_____________________ -----____________ -----______________ ------_______....\r
137 * 158us 7432us 158us 4902us 158us 7432us 158us\r
138 *\r
139 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
140 *\r
141 * RECS80EXT\r
142 * ---------\r
143 *\r
144 * frame: 2 start bits + 11 data bits + 1 stop bit\r
145 * data: 1 toggle bit + 4 address bits + 6 command bits\r
146 *\r
147 * start bit: data "0": data "1": stop bit:\r
148 * -----_____________________ -----____________ -----______________ ------_______....\r
149 * 158us 3637us 158us 4902us 158us 7432us 158us\r
150 *\r
151 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
152 *\r
153 * RC5 + RC5X\r
154 * ----------\r
155 *\r
156 * RC5 frame: 2 start bits + 12 data bits + no stop bit\r
157 * RC5 data: 1 toggle bit + 5 address bits + 6 command bits\r
158 * RC5X frame: 1 start bit + 13 data bits + no stop bit\r
159 * RC5X data: 1 inverted command bit + 1 toggle bit + 5 address bits + 6 command bits\r
160 *\r
161 * start bit: data "0": data "1":\r
162 * ______----- ------______ ______------\r
163 * 889us 889us 889us 889us 889us 889us\r
164 *\r
165 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
166 *\r
167 * DENON\r
168 * -----\r
169 *\r
170 * frame: 0 start bits + 16 data bits + stop bit + 65ms pause + 16 inverted data bits + stop bit\r
171 * data: 5 address bits + 10 command bits\r
172 *\r
53c11f07 173 * Theory:\r
174 *\r
4225a882 175 * data "0": data "1":\r
176 * ------________________ ------______________\r
b5ea7869 177 * 275us 775us 275us 1900us\r
4225a882 178 *\r
53c11f07 179 * Practice:\r
180 *\r
181 * data "0": data "1":\r
182 * ------________________ ------______________\r
183 * 310us 745us 310us 1780us\r
184 *\r
4225a882 185 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
186 *\r
187 * RC6\r
188 * ---\r
189 *\r
35213800 190 * RC6 frame: 1 start bit + 1 bit "1" + 3 mode bits + 1 toggle bit + 16 data bits + 2666 us pause\r
4225a882 191 * RC6 data: 8 address bits + 8 command bits\r
192 *\r
193 * start bit toggle bit "0": toggle bit "1": data/mode "0": data/mode "1":\r
194 * ____________------- _______------- -------_______ _______------- -------_______\r
195 * 2666us 889us 889us 889us 889us 889us 444us 444us 444us 444us\r
196 *\r
197 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
198 *\r
199 * APPLE\r
200 * -----\r
201 *\r
202 * frame: 1 start bit + 32 data bits + 1 stop bit\r
203 * data: 16 address bits + 11100000 + 8 command bits\r
204 *\r
205 * start bit: data "0": data "1": stop bit:\r
206 * -----------------_________ ------______ ------________________ ------______....\r
207 * 9000us 4500us 560us 560us 560us 1690 us 560us\r
208 *\r
209 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
210 *\r
211 * NUBERT (subwoofer system)\r
212 * -------------------------\r
213 *\r
214 * frame: 1 start bit + 10 data bits + 1 stop bit\r
215 * data: 0 address bits + 10 command bits ?\r
216 *\r
217 * start bit: data "0": data "1": stop bit:\r
218 * ----------_____ ------______ ------________________ ------______....\r
219 * 1340us 340us 500us 1300us 1340us 340us 500us\r
220 *\r
221 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
222 *\r
504d9df9 223 * BANG_OLUFSEN\r
224 * ------------\r
225 *\r
226 * frame: 4 start bits + 16 data bits + 1 trailer bit + 1 stop bit\r
227 * data: 0 address bits + 16 command bits\r
228 *\r
229 * 1st start bit: 2nd start bit: 3rd start bit: 4th start bit:\r
230 * -----________ -----________ -----_____________ -----________\r
231 * 210us 3000us 210us 3000us 210us 15000us 210us 3000us\r
232 *\r
233 * data "0": data "1": data "repeat bit": trailer bit: stop bit:\r
234 * -----________ -----_____________ -----___________ -----_____________ -----____...\r
235 * 210us 3000us 210us 9000us 210us 6000us 210us 12000us 210us\r
236 *\r
237 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
238 *\r
d155e9ab 239 * GRUNDIG\r
592411d1 240 * -------\r
241 *\r
d155e9ab 242 * packet: 1 start frame + 19,968ms pause + N info frames + 117,76ms pause + 1 stop frame\r
243 * frame: 1 pre bit + 1 start bit + 9 data bits + no stop bit\r
244 * pause between info frames: 117,76ms\r
245 *\r
246 * data of start frame: 9 x 1\r
247 * data of info frame: 9 command bits\r
248 * data of stop frame: 9 x 1\r
592411d1 249 *\r
250 * pre bit: start bit data "0": data "1":\r
251 * ------____________ ------______ ______------ ------______ \r
252 * 528us 2639us 528us 528us 528us 528us 528us 528us\r
253 *\r
254 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
255 *\r
d155e9ab 256 * NOKIA:\r
257 * ------\r
258 *\r
259 * Timing similar to Grundig, but 16 data bits:\r
260 * frame: 1 pre bit + 1 start bit + 8 command bits + 8 address bits + no stop bit\r
261 *\r
262 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
263 *\r
12948cf3 264 * SIEMENS or RUWIDO:\r
265 * ------------------\r
2eab5ec9 266 *\r
267 * SIEMENS frame: 1 start bit + 22 data bits + no stop bit\r
268 * SIEMENS data: 13 address bits + 1 repeat bit + 7 data bits + 1 unknown bit\r
269 *\r
270 * start bit data "0": data "1":\r
271 * -------_______ _______------- -------_______\r
272 * 250us 250us 250us 250us 250us 250us\r
273 *\r
274 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
275 *\r
4225a882 276 * PANASONIC (older protocol, yet not implemented, see also MATSUSHITA, timing very similar)\r
277 * -----------------------------------------------------------------------------------------\r
278 *\r
279 * frame: 1 start bit + 22 data bits + 1 stop bit\r
280 * 22 data bits = 5 custom bits + 6 data bits + 5 inverted custom bits + 6 inverted data bits\r
281 *\r
282 * European version: T = 456us\r
283 * USA & Canada version: T = 422us\r
284 *\r
285 * start bit: data "0": data "1": stop bit:\r
286 * 8T 8T 2T 2T 2T 6T 2T\r
287 * -------------____________ ------_____ ------_____________ ------_______....\r
288 * 3648us 3648us 912us 912us 912us 2736us 912us (Europe)\r
289 * 3376us 3376us 844us 844us 844us 2532us 844us (US)\r
290 *\r
291 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
292 *\r
293 * This program is free software; you can redistribute it and/or modify\r
294 * it under the terms of the GNU General Public License as published by\r
295 * the Free Software Foundation; either version 2 of the License, or\r
296 * (at your option) any later version.\r
297 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
298 */\r
299\r
93ba2e01 300#if defined(__18CXX)\r
301#define PIC_C18 // Microchip C18 Compiler\r
302#endif\r
303\r
4225a882 304#if defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC Compiler instead of AVR\r
305#define PIC_CCS_COMPILER\r
306#endif\r
307\r
308#ifdef unix // test on linux/unix\r
309#include <stdio.h>\r
310#include <unistd.h>\r
311#include <stdlib.h>\r
312#include <string.h>\r
313#include <inttypes.h>\r
314\r
48664931 315#define ANALYZE\r
4225a882 316#define PROGMEM\r
317#define memcpy_P memcpy\r
318\r
319#else // not unix:\r
320\r
321#ifdef WIN32\r
322#include <stdio.h>\r
323#include <string.h>\r
324typedef unsigned char uint8_t;\r
325typedef unsigned short uint16_t;\r
48664931 326#define ANALYZE\r
4225a882 327#define PROGMEM\r
328#define memcpy_P memcpy\r
329\r
330#else\r
331\r
93ba2e01 332#if defined (PIC_CCS_COMPILER) || defined(PIC_C18)\r
4225a882 333\r
334#include <string.h>\r
4225a882 335#define PROGMEM\r
336#define memcpy_P memcpy\r
337\r
93ba2e01 338#if defined (PIC_CCS_COMPILER)\r
339typedef unsigned int8 uint8_t;\r
340typedef unsigned int16 uint16_t;\r
341#endif\r
342\r
4225a882 343#else // AVR:\r
344\r
345#include <inttypes.h>\r
346#include <stdio.h>\r
347#include <string.h>\r
348#include <avr/io.h>\r
349#include <util/delay.h>\r
350#include <avr/pgmspace.h>\r
351\r
93ba2e01 352#endif // PIC_CCS_COMPILER or PIC_C18\r
4225a882 353\r
354#endif // windows\r
355#endif // unix\r
356\r
d823e852 357#ifndef IRMP_USE_AS_LIB\r
cb8474cc 358#include "irmpconfig.h"\r
d823e852 359#endif\r
f5ca0147 360#include "irmp.h"\r
4225a882 361\r
89e8cafb 362#if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRMP_SUPPORT_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_IR60_PROTOCOL == 1\r
363#define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 1\r
d155e9ab 364#else\r
89e8cafb 365#define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 0\r
d155e9ab 366#endif\r
367\r
12948cf3 368#if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 || IRMP_SUPPORT_RUWIDO_PROTOCOL == 1\r
369#define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 1\r
370#else\r
371#define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 0\r
372#endif\r
373\r
deba2a0a 374#if IRMP_SUPPORT_RC5_PROTOCOL == 1 || \\r
375 IRMP_SUPPORT_RC6_PROTOCOL == 1 || \\r
376 IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 || \\r
377 IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 || \\r
89e8cafb 378 IRMP_SUPPORT_IR60_PROTOCOL\r
77f488bb 379#define IRMP_SUPPORT_MANCHESTER 1\r
380#else\r
381#define IRMP_SUPPORT_MANCHESTER 0\r
382#endif\r
383\r
93570cd9 384#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1\r
deba2a0a 385#define IRMP_SUPPORT_SERIAL 1\r
386#else\r
387#define IRMP_SUPPORT_SERIAL 0\r
388#endif\r
389\r
6db2522c 390#define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec\r
4225a882 391\r
fef942f6 392#define MIN_TOLERANCE_00 1.0 // -0%\r
393#define MAX_TOLERANCE_00 1.0 // +0%\r
394\r
395#define MIN_TOLERANCE_05 0.95 // -5%\r
396#define MAX_TOLERANCE_05 1.05 // +5%\r
397\r
4225a882 398#define MIN_TOLERANCE_10 0.9 // -10%\r
399#define MAX_TOLERANCE_10 1.1 // +10%\r
400\r
fef942f6 401#define MIN_TOLERANCE_15 0.85 // -15%\r
402#define MAX_TOLERANCE_15 1.15 // +15%\r
403\r
4225a882 404#define MIN_TOLERANCE_20 0.8 // -20%\r
405#define MAX_TOLERANCE_20 1.2 // +20%\r
406\r
407#define MIN_TOLERANCE_30 0.7 // -30%\r
408#define MAX_TOLERANCE_30 1.3 // +30%\r
409\r
410#define MIN_TOLERANCE_40 0.6 // -40%\r
411#define MAX_TOLERANCE_40 1.4 // +40%\r
412\r
413#define MIN_TOLERANCE_50 0.5 // -50%\r
414#define MAX_TOLERANCE_50 1.5 // +50%\r
415\r
416#define MIN_TOLERANCE_60 0.4 // -60%\r
417#define MAX_TOLERANCE_60 1.6 // +60%\r
418\r
9405f84a 419#define MIN_TOLERANCE_70 0.3 // -70%\r
420#define MAX_TOLERANCE_70 1.7 // +70%\r
421\r
fef942f6 422#define SIRCS_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
423#define SIRCS_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
424#define SIRCS_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
deba2a0a 425#if IRMP_SUPPORT_NETBOX_PROTOCOL // only 5% to avoid conflict with NETBOX:\r
426#define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5))\r
427#else // only 5% + 1 to avoid conflict with RC6:\r
428#define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)\r
429#endif\r
fef942f6 430#define SIRCS_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
431#define SIRCS_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
432#define SIRCS_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
433#define SIRCS_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
434#define SIRCS_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
435#define SIRCS_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
436\r
93ba2e01 437#define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
438#define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
439#define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
440#define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
441#define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
442#define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
443#define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
444#define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
445#define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
446#define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
447#define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
448#define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
6db2522c 449// autodetect nec repetition frame within 50 msec:\r
450// NEC seems to send the first repetition frame after 40ms, further repetition frames after 100 ms\r
451#if 0\r
452#define NEC_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)\r
453#else\r
454#define NEC_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * 100.0e-3 * MAX_TOLERANCE_20 + 0.5)\r
455#endif\r
fef942f6 456\r
457#define SAMSUNG_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
458#define SAMSUNG_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
459#define SAMSUNG_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
460#define SAMSUNG_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
5b437ff6 461#define SAMSUNG_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
462#define SAMSUNG_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
463#define SAMSUNG_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
464#define SAMSUNG_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
465#define SAMSUNG_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
466#define SAMSUNG_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
fef942f6 467\r
468#define MATSUSHITA_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
469#define MATSUSHITA_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
470#define MATSUSHITA_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
471#define MATSUSHITA_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
472#define MATSUSHITA_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
473#define MATSUSHITA_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
474#define MATSUSHITA_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
475#define MATSUSHITA_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
476#define MATSUSHITA_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
477#define MATSUSHITA_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
478\r
479#define KASEIKYO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
480#define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
481#define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
482#define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
483#define KASEIKYO_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)\r
770a1a9d 484#define KASEIKYO_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)\r
485#define KASEIKYO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
486#define KASEIKYO_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
fef942f6 487#define KASEIKYO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)\r
488#define KASEIKYO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)\r
489\r
490#define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)\r
491#define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
492#define RECS80_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
493#define RECS80_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
494#define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
495#define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
496#define RECS80_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
497#define RECS80_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
498#define RECS80_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
499#define RECS80_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
500\r
02dbaeff 501#define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
502#define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
31c1f035 503\r
02dbaeff 504#define RC5_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
505#define RC5_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
fef942f6 506\r
b5ea7869 507#define DENON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
508#define DENON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
509#define DENON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
510#define DENON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
12948cf3 511#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
512#define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5)) // no -1, avoid conflict with RUWIDO\r
513#else\r
514#define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) // be more tolerant\r
515#endif\r
b5ea7869 516#define DENON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
fef942f6 517\r
beda975f 518#define THOMSON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
519#define THOMSON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
520#define THOMSON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
521#define THOMSON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
522#define THOMSON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
523#define THOMSON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
524\r
fef942f6 525#define RC6_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
526#define RC6_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
527#define RC6_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
528#define RC6_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
529#define RC6_TOGGLE_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
530#define RC6_TOGGLE_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
c7a47e89 531#define RC6_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
31c1f035 532#define RC6_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_60 + 0.5) + 1) // pulses: 300 - 800\r
533#define RC6_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
534#define RC6_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) // pauses: 300 - 600\r
1aee56bc 535\r
fef942f6 536#define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)\r
537#define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_00 + 0.5) + 1)\r
538#define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)\r
539#define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)\r
540#define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
541#define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
542#define RECS80EXT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
543#define RECS80EXT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
544#define RECS80EXT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
545#define RECS80EXT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
546\r
547#define NUBERT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
548#define NUBERT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
549#define NUBERT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
550#define NUBERT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
551#define NUBERT_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
552#define NUBERT_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
553#define NUBERT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
554#define NUBERT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
555#define NUBERT_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
556#define NUBERT_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
557#define NUBERT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
558#define NUBERT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
559\r
b5ea7869 560#define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
561#define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
562#define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
563#define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
564#define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
565#define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
566#define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
567#define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
568#define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
569#define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
570#define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
2eab5ec9 571#define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX ((PAUSE_LEN)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) // value must be below IRMP_TIMEOUT\r
b5ea7869 572#define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
573#define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
574#define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
575#define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
576#define BANG_OLUFSEN_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
577#define BANG_OLUFSEN_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
578#define BANG_OLUFSEN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
579#define BANG_OLUFSEN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
580#define BANG_OLUFSEN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
581#define BANG_OLUFSEN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
582#define BANG_OLUFSEN_R_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
583#define BANG_OLUFSEN_R_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
584#define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
585#define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
504d9df9 586\r
89e8cafb 587#define IR60_TIMEOUT_LEN ((uint8_t)(F_INTERRUPTS * IR60_TIMEOUT_TIME * 0.5))\r
588#define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
589#define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
590#define GRUNDIG_NOKIA_IR60_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
591#define GRUNDIG_NOKIA_IR60_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
89e8cafb 592#define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) + 1)\r
593#define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
594\r
595#define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
596#define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
597#define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
598#define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
89e8cafb 599#define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
600#define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
601#define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
602#define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
592411d1 603\r
a42d1ee6 604#define FDC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) // 5%: avoid conflict with NETBOX\r
605#define FDC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MAX_TOLERANCE_05 + 0.5))\r
606#define FDC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)\r
607#define FDC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5))\r
6f750020 608#define FDC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
609#define FDC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)\r
610#define FDC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
611#define FDC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
612#if 0\r
613#define FDC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) // could be negative: 255\r
614#else\r
615#define FDC_0_PAUSE_LEN_MIN (1) // simply use 1\r
616#endif\r
617#define FDC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
b5ea7869 618\r
9e16d699 619#define RCCAR_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
620#define RCCAR_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
621#define RCCAR_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
622#define RCCAR_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
48664931 623#define RCCAR_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
624#define RCCAR_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
625#define RCCAR_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
626#define RCCAR_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
627#define RCCAR_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
628#define RCCAR_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
9e16d699 629\r
770a1a9d 630#define JVC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
631#define JVC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
632#define JVC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * (JVC_FRAME_REPEAT_PAUSE_TIME - IRMP_TIMEOUT_TIME) * MIN_TOLERANCE_40 + 0.5) - 1) // HACK!\r
9405f84a 633#define JVC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * (JVC_FRAME_REPEAT_PAUSE_TIME - IRMP_TIMEOUT_TIME) * MAX_TOLERANCE_70 + 0.5) - 1) // HACK!\r
770a1a9d 634#define JVC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
635#define JVC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
636#define JVC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
637#define JVC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
638#define JVC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
639#define JVC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
640// autodetect JVC repetition frame within 50 msec:\r
641#define JVC_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)\r
642\r
9405f84a 643#define NIKON_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
644#define NIKON_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
645#define NIKON_START_BIT_PAUSE_LEN_MIN ((uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
646#define NIKON_START_BIT_PAUSE_LEN_MAX ((uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
647#define NIKON_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
648#define NIKON_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
649#define NIKON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
650#define NIKON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
651#define NIKON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
652#define NIKON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
653#define NIKON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
654#define NIKON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
655#define NIKON_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)\r
656\r
111d6191 657#define KATHREIN_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
658#define KATHREIN_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
659#define KATHREIN_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
660#define KATHREIN_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
661#define KATHREIN_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
662#define KATHREIN_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
663#define KATHREIN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
664#define KATHREIN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
665#define KATHREIN_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
666#define KATHREIN_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
667#define KATHREIN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
668#define KATHREIN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
669#define KATHREIN_SYNC_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_SYNC_BIT_PAUSE_LEN_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
670#define KATHREIN_SYNC_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_SYNC_BIT_PAUSE_LEN_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
671\r
deba2a0a 672#define NETBOX_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NETBOX_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
673#define NETBOX_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NETBOX_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
674#define NETBOX_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NETBOX_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
675#define NETBOX_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NETBOX_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
676#define NETBOX_PULSE_LEN ((uint8_t)(F_INTERRUPTS * NETBOX_PULSE_TIME))\r
677#define NETBOX_PAUSE_LEN ((uint8_t)(F_INTERRUPTS * NETBOX_PAUSE_TIME))\r
678#define NETBOX_PULSE_REST_LEN ((uint8_t)(F_INTERRUPTS * NETBOX_PULSE_TIME / 4))\r
679#define NETBOX_PAUSE_REST_LEN ((uint8_t)(F_INTERRUPTS * NETBOX_PAUSE_TIME / 4))\r
680\r
f50e01e7 681#define LEGO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
682#define LEGO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
683#define LEGO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
684#define LEGO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
685#define LEGO_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
686#define LEGO_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
687#define LEGO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
688#define LEGO_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
689#define LEGO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
690#define LEGO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
691\r
d155e9ab 692#define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t!\r
4225a882 693\r
48664931 694#ifdef ANALYZE\r
7644ac04 695#define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } }\r
696#define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } }\r
697#define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } }\r
698#define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } }\r
699static int silent;\r
700static int time_counter;\r
701static int verbose;\r
4225a882 702#else\r
48664931 703#define ANALYZE_PUTCHAR(a)\r
704#define ANALYZE_ONLY_NORMAL_PUTCHAR(a)\r
705#define ANALYZE_PRINTF(...)\r
706#define ANALYZE_NEWLINE()\r
4225a882 707#endif\r
708\r
7644ac04 709#if IRMP_USE_CALLBACK == 1\r
710static void (*irmp_callback_ptr) (uint8_t);\r
711#endif // IRMP_USE_CALLBACK == 1\r
712\r
1f54e86c 713/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
714 * Protocol names\r
715 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
716 */\r
717#if IRMP_PROTOCOL_NAMES == 1\r
718char *\r
719irmp_protocol_names[IRMP_N_PROTOCOLS + 1] =\r
720{\r
721 "UNKNOWN",\r
722 "SIRCS",\r
723 "NEC",\r
724 "SAMSUNG",\r
725 "MATSUSH",\r
726 "KASEIKYO",\r
727 "RECS80",\r
728 "RC5",\r
729 "DENON",\r
730 "RC6",\r
731 "SAMSG32",\r
732 "APPLE",\r
733 "RECS80EX",\r
734 "NUBERT",\r
735 "BANG OLU",\r
736 "GRUNDIG",\r
737 "NOKIA",\r
738 "SIEMENS",\r
739 "FDC",\r
740 "RCCAR",\r
741 "JVC",\r
742 "RC6A",\r
743 "NIKON",\r
744 "RUWIDO",\r
745 "IR60",\r
746 "KATHREIN",\r
747 "NETBOX",\r
748 "NEC16",\r
749 "NEC42",\r
750 "LEGO",\r
93570cd9 751 "THOMSON"\r
1f54e86c 752};\r
753#endif\r
754\r
755/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
756 * Logging\r
757 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
758 */\r
4225a882 759#if IRMP_LOGGING == 1\r
879b06c2 760#define BAUD 9600L\r
761#include <util/setbaud.h>\r
762\r
763#ifdef UBRR0H\r
764\r
765#define UART0_UBRRH UBRR0H\r
766#define UART0_UBRRL UBRR0L\r
767#define UART0_UCSRA UCSR0A\r
768#define UART0_UCSRB UCSR0B\r
769#define UART0_UCSRC UCSR0C\r
770#define UART0_UDRE_BIT_VALUE (1<<UDRE0)\r
771#define UART0_UCSZ1_BIT_VALUE (1<<UCSZ01)\r
772#define UART0_UCSZ0_BIT_VALUE (1<<UCSZ00)\r
773#ifdef URSEL0\r
774#define UART0_URSEL_BIT_VALUE (1<<URSEL0)\r
775#else\r
776#define UART0_URSEL_BIT_VALUE (0)\r
777#endif\r
778#define UART0_TXEN_BIT_VALUE (1<<TXEN0)\r
e92413eb 779#define UART0_UDR UDR0\r
c7a47e89 780#define UART0_U2X U2X0\r
879b06c2 781\r
782#else\r
4225a882 783\r
879b06c2 784#define UART0_UBRRH UBRRH\r
785#define UART0_UBRRL UBRRL\r
786#define UART0_UCSRA UCSRA\r
787#define UART0_UCSRB UCSRB\r
788#define UART0_UCSRC UCSRC\r
789#define UART0_UDRE_BIT_VALUE (1<<UDRE)\r
790#define UART0_UCSZ1_BIT_VALUE (1<<UCSZ1)\r
791#define UART0_UCSZ0_BIT_VALUE (1<<UCSZ0)\r
792#ifdef URSEL\r
793#define UART0_URSEL_BIT_VALUE (1<<URSEL)\r
794#else\r
795#define UART0_URSEL_BIT_VALUE (0)\r
796#endif\r
797#define UART0_TXEN_BIT_VALUE (1<<TXEN)\r
e92413eb 798#define UART0_UDR UDR\r
c7a47e89 799#define UART0_U2X U2X\r
4225a882 800\r
4225a882 801#endif\r
802\r
4225a882 803/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
804 * Initialize UART\r
805 * @details Initializes UART\r
806 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
807 */\r
808void\r
809irmp_uart_init (void)\r
810{\r
879b06c2 811 UART0_UBRRH = UBRRH_VALUE; // set baud rate\r
812 UART0_UBRRL = UBRRL_VALUE;\r
813\r
814#if USE_2X\r
c7a47e89 815 UART0_UCSRA |= (1<<UART0_U2X);\r
879b06c2 816#else\r
c7a47e89 817 UART0_UCSRA &= ~(1<<UART0_U2X);\r
879b06c2 818#endif\r
819\r
820 UART0_UCSRC = UART0_UCSZ1_BIT_VALUE | UART0_UCSZ0_BIT_VALUE | UART0_URSEL_BIT_VALUE;\r
821 UART0_UCSRB |= UART0_TXEN_BIT_VALUE; // enable UART TX\r
4225a882 822}\r
823\r
824/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
825 * Send character\r
826 * @details Sends character\r
827 * @param ch character to be transmitted\r
828 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
829 */\r
830void\r
831irmp_uart_putc (unsigned char ch)\r
832{\r
879b06c2 833 while (!(UART0_UCSRA & UART0_UDRE_BIT_VALUE))\r
4225a882 834 {\r
835 ;\r
836 }\r
837\r
879b06c2 838 UART0_UDR = ch;\r
4225a882 839}\r
840\r
841/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
842 * Log IR signal\r
843 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
844 */\r
d155e9ab 845\r
846#define STARTCYCLES 2 // min count of zeros before start of logging\r
847#define ENDBITS 1000 // number of sequenced highbits to detect end\r
848#define DATALEN 700 // log buffer size\r
4225a882 849\r
850static void\r
d155e9ab 851irmp_log (uint8_t val)\r
4225a882 852{\r
d155e9ab 853 static uint8_t buf[DATALEN]; // logging buffer\r
854 static uint16_t buf_idx; // number of written bits\r
855 static uint8_t startcycles; // current number of start-zeros\r
856 static uint16_t cnt; // counts sequenced highbits - to detect end\r
4225a882 857\r
d155e9ab 858 if (! val && (startcycles < STARTCYCLES) && !buf_idx) // prevent that single random zeros init logging\r
4225a882 859 {\r
d155e9ab 860 startcycles++;\r
4225a882 861 }\r
862 else\r
863 {\r
d155e9ab 864 startcycles = 0;\r
4225a882 865\r
d155e9ab 866 if (! val || (val && buf_idx != 0)) // start or continue logging on "0", "1" cannot init logging\r
4225a882 867 {\r
d155e9ab 868 if (buf_idx < DATALEN * 8) // index in range?\r
869 { // yes\r
870 if (val)\r
871 {\r
872 buf[(buf_idx / 8)] |= (1<<(buf_idx % 8)); // set bit\r
873 }\r
874 else\r
875 {\r
876 buf[(buf_idx / 8)] &= ~(1<<(buf_idx % 8)); // reset bit\r
877 }\r
4225a882 878\r
d155e9ab 879 buf_idx++;\r
880 }\r
4225a882 881\r
882 if (val)\r
46dd89b7 883 { // if high received then look at log-stop condition\r
d155e9ab 884 cnt++;\r
4225a882 885\r
d155e9ab 886 if (cnt > ENDBITS)\r
887 { // if stop condition is true, output on uart\r
4225a882 888 uint16_t i;\r
889\r
d155e9ab 890 for (i = 0; i < STARTCYCLES; i++)\r
4225a882 891 {\r
46dd89b7 892 irmp_uart_putc ('0'); // the ignored starting zeros\r
4225a882 893 }\r
894\r
d155e9ab 895 for (i = 0; i < (buf_idx - ENDBITS + 20) / 8; i++) // transform bitset into uart chars\r
4225a882 896 {\r
d155e9ab 897 uint8_t d = buf[i];\r
4225a882 898 uint8_t j;\r
899\r
d155e9ab 900 for (j = 0; j < 8; j++)\r
4225a882 901 {\r
902 irmp_uart_putc ((d & 1) + '0');\r
903 d >>= 1;\r
904 }\r
905 }\r
906\r
907 irmp_uart_putc ('\n');\r
d155e9ab 908 buf_idx = 0;\r
4225a882 909 }\r
910 }\r
911 else\r
912 {\r
d155e9ab 913 cnt = 0;\r
4225a882 914 }\r
915 }\r
916 }\r
917}\r
918\r
919#else\r
d155e9ab 920#define irmp_log(val)\r
4225a882 921#endif\r
922\r
923typedef struct\r
924{\r
925 uint8_t protocol; // ir protocol\r
926 uint8_t pulse_1_len_min; // minimum length of pulse with bit value 1\r
927 uint8_t pulse_1_len_max; // maximum length of pulse with bit value 1\r
928 uint8_t pause_1_len_min; // minimum length of pause with bit value 1\r
929 uint8_t pause_1_len_max; // maximum length of pause with bit value 1\r
930 uint8_t pulse_0_len_min; // minimum length of pulse with bit value 0\r
931 uint8_t pulse_0_len_max; // maximum length of pulse with bit value 0\r
932 uint8_t pause_0_len_min; // minimum length of pause with bit value 0\r
933 uint8_t pause_0_len_max; // maximum length of pause with bit value 0\r
934 uint8_t address_offset; // address offset\r
935 uint8_t address_end; // end of address\r
936 uint8_t command_offset; // command offset\r
937 uint8_t command_end; // end of command\r
938 uint8_t complete_len; // complete length of frame\r
939 uint8_t stop_bit; // flag: frame has stop bit\r
940 uint8_t lsb_first; // flag: LSB first\r
77f488bb 941 uint8_t flags; // some flags\r
4225a882 942} IRMP_PARAMETER;\r
943\r
944#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
945\r
63b94f48 946static const PROGMEM IRMP_PARAMETER sircs_param =\r
4225a882 947{\r
d155e9ab 948 IRMP_SIRCS_PROTOCOL, // protocol: ir protocol\r
949 SIRCS_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
950 SIRCS_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
951 SIRCS_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
952 SIRCS_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
953 SIRCS_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
954 SIRCS_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
955 SIRCS_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
956 SIRCS_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
957 SIRCS_ADDRESS_OFFSET, // address_offset: address offset\r
958 SIRCS_ADDRESS_OFFSET + SIRCS_ADDRESS_LEN, // address_end: end of address\r
959 SIRCS_COMMAND_OFFSET, // command_offset: command offset\r
960 SIRCS_COMMAND_OFFSET + SIRCS_COMMAND_LEN, // command_end: end of command\r
961 SIRCS_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
962 SIRCS_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 963 SIRCS_LSB, // lsb_first: flag: LSB first\r
964 SIRCS_FLAGS // flags: some flags\r
4225a882 965};\r
966\r
967#endif\r
968\r
969#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
970\r
63b94f48 971static const PROGMEM IRMP_PARAMETER nec_param =\r
4225a882 972{\r
d155e9ab 973 IRMP_NEC_PROTOCOL, // protocol: ir protocol\r
974 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
975 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
976 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
977 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
978 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
979 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
980 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
981 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
982 NEC_ADDRESS_OFFSET, // address_offset: address offset\r
983 NEC_ADDRESS_OFFSET + NEC_ADDRESS_LEN, // address_end: end of address\r
984 NEC_COMMAND_OFFSET, // command_offset: command offset\r
985 NEC_COMMAND_OFFSET + NEC_COMMAND_LEN, // command_end: end of command\r
986 NEC_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
987 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 988 NEC_LSB, // lsb_first: flag: LSB first\r
989 NEC_FLAGS // flags: some flags\r
4225a882 990};\r
991\r
63b94f48 992static const PROGMEM IRMP_PARAMETER nec_rep_param =\r
46dd89b7 993{\r
d155e9ab 994 IRMP_NEC_PROTOCOL, // protocol: ir protocol\r
995 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
996 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
997 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
998 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
999 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1000 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1001 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1002 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1003 0, // address_offset: address offset\r
1004 0, // address_end: end of address\r
1005 0, // command_offset: command offset\r
1006 0, // command_end: end of command\r
1007 0, // complete_len: complete length of frame\r
1008 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1009 NEC_LSB, // lsb_first: flag: LSB first\r
1010 NEC_FLAGS // flags: some flags\r
46dd89b7 1011};\r
1012\r
4225a882 1013#endif\r
1014\r
35213800 1015#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
fc80d688 1016\r
63b94f48 1017static const PROGMEM IRMP_PARAMETER nec42_param =\r
fc80d688 1018{\r
35213800 1019 IRMP_NEC42_PROTOCOL, // protocol: ir protocol\r
fc80d688 1020 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1021 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1022 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1023 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1024 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1025 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1026 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1027 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
35213800 1028 NEC42_ADDRESS_OFFSET, // address_offset: address offset\r
7644ac04 1029 NEC42_ADDRESS_OFFSET + NEC42_ADDRESS_LEN, // address_end: end of address\r
35213800 1030 NEC42_COMMAND_OFFSET, // command_offset: command offset\r
7644ac04 1031 NEC42_COMMAND_OFFSET + NEC42_COMMAND_LEN, // command_end: end of command\r
35213800 1032 NEC42_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1033 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1034 NEC_LSB, // lsb_first: flag: LSB first\r
1035 NEC_FLAGS // flags: some flags\r
fc80d688 1036};\r
1037\r
1038#endif\r
1039\r
4225a882 1040#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
1041\r
63b94f48 1042static const PROGMEM IRMP_PARAMETER samsung_param =\r
4225a882 1043{\r
d155e9ab 1044 IRMP_SAMSUNG_PROTOCOL, // protocol: ir protocol\r
1045 SAMSUNG_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1046 SAMSUNG_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1047 SAMSUNG_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1048 SAMSUNG_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1049 SAMSUNG_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1050 SAMSUNG_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1051 SAMSUNG_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1052 SAMSUNG_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1053 SAMSUNG_ADDRESS_OFFSET, // address_offset: address offset\r
1054 SAMSUNG_ADDRESS_OFFSET + SAMSUNG_ADDRESS_LEN, // address_end: end of address\r
1055 SAMSUNG_COMMAND_OFFSET, // command_offset: command offset\r
1056 SAMSUNG_COMMAND_OFFSET + SAMSUNG_COMMAND_LEN, // command_end: end of command\r
1057 SAMSUNG_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1058 SAMSUNG_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1059 SAMSUNG_LSB, // lsb_first: flag: LSB first\r
1060 SAMSUNG_FLAGS // flags: some flags\r
4225a882 1061};\r
1062\r
1063#endif\r
1064\r
1065#if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1\r
1066\r
63b94f48 1067static const PROGMEM IRMP_PARAMETER matsushita_param =\r
4225a882 1068{\r
d155e9ab 1069 IRMP_MATSUSHITA_PROTOCOL, // protocol: ir protocol\r
1070 MATSUSHITA_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1071 MATSUSHITA_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1072 MATSUSHITA_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1073 MATSUSHITA_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1074 MATSUSHITA_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1075 MATSUSHITA_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1076 MATSUSHITA_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1077 MATSUSHITA_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1078 MATSUSHITA_ADDRESS_OFFSET, // address_offset: address offset\r
1079 MATSUSHITA_ADDRESS_OFFSET + MATSUSHITA_ADDRESS_LEN, // address_end: end of address\r
1080 MATSUSHITA_COMMAND_OFFSET, // command_offset: command offset\r
1081 MATSUSHITA_COMMAND_OFFSET + MATSUSHITA_COMMAND_LEN, // command_end: end of command\r
1082 MATSUSHITA_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1083 MATSUSHITA_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1084 MATSUSHITA_LSB, // lsb_first: flag: LSB first\r
1085 MATSUSHITA_FLAGS // flags: some flags\r
4225a882 1086};\r
1087\r
1088#endif\r
1089\r
1090#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
1091\r
63b94f48 1092static const PROGMEM IRMP_PARAMETER kaseikyo_param =\r
4225a882 1093{\r
d155e9ab 1094 IRMP_KASEIKYO_PROTOCOL, // protocol: ir protocol\r
1095 KASEIKYO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1096 KASEIKYO_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1097 KASEIKYO_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1098 KASEIKYO_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1099 KASEIKYO_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1100 KASEIKYO_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1101 KASEIKYO_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1102 KASEIKYO_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1103 KASEIKYO_ADDRESS_OFFSET, // address_offset: address offset\r
1104 KASEIKYO_ADDRESS_OFFSET + KASEIKYO_ADDRESS_LEN, // address_end: end of address\r
1105 KASEIKYO_COMMAND_OFFSET, // command_offset: command offset\r
1106 KASEIKYO_COMMAND_OFFSET + KASEIKYO_COMMAND_LEN, // command_end: end of command\r
1107 KASEIKYO_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1108 KASEIKYO_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1109 KASEIKYO_LSB, // lsb_first: flag: LSB first\r
1110 KASEIKYO_FLAGS // flags: some flags\r
4225a882 1111};\r
1112\r
1113#endif\r
1114\r
1115#if IRMP_SUPPORT_RECS80_PROTOCOL == 1\r
1116\r
63b94f48 1117static const PROGMEM IRMP_PARAMETER recs80_param =\r
4225a882 1118{\r
d155e9ab 1119 IRMP_RECS80_PROTOCOL, // protocol: ir protocol\r
1120 RECS80_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1121 RECS80_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1122 RECS80_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1123 RECS80_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1124 RECS80_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1125 RECS80_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1126 RECS80_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1127 RECS80_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1128 RECS80_ADDRESS_OFFSET, // address_offset: address offset\r
1129 RECS80_ADDRESS_OFFSET + RECS80_ADDRESS_LEN, // address_end: end of address\r
1130 RECS80_COMMAND_OFFSET, // command_offset: command offset\r
1131 RECS80_COMMAND_OFFSET + RECS80_COMMAND_LEN, // command_end: end of command\r
1132 RECS80_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1133 RECS80_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1134 RECS80_LSB, // lsb_first: flag: LSB first\r
1135 RECS80_FLAGS // flags: some flags\r
4225a882 1136};\r
1137\r
1138#endif\r
1139\r
1140#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
1141\r
63b94f48 1142static const PROGMEM IRMP_PARAMETER rc5_param =\r
4225a882 1143{\r
d155e9ab 1144 IRMP_RC5_PROTOCOL, // protocol: ir protocol\r
1aee56bc 1145 RC5_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse\r
1146 RC5_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse\r
1147 RC5_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause\r
1148 RC5_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause\r
31c1f035 1149 0, // pulse_0_len_min: here: not used\r
1150 0, // pulse_0_len_max: here: not used\r
1151 0, // pause_0_len_min: here: not used\r
1152 0, // pause_0_len_max: here: not used\r
d155e9ab 1153 RC5_ADDRESS_OFFSET, // address_offset: address offset\r
1154 RC5_ADDRESS_OFFSET + RC5_ADDRESS_LEN, // address_end: end of address\r
1155 RC5_COMMAND_OFFSET, // command_offset: command offset\r
1156 RC5_COMMAND_OFFSET + RC5_COMMAND_LEN, // command_end: end of command\r
1157 RC5_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1158 RC5_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1159 RC5_LSB, // lsb_first: flag: LSB first\r
1160 RC5_FLAGS // flags: some flags\r
4225a882 1161};\r
1162\r
1163#endif\r
1164\r
1165#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
1166\r
63b94f48 1167static const PROGMEM IRMP_PARAMETER denon_param =\r
4225a882 1168{\r
d155e9ab 1169 IRMP_DENON_PROTOCOL, // protocol: ir protocol\r
1170 DENON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1171 DENON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1172 DENON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1173 DENON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1174 DENON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1175 DENON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1176 DENON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1177 DENON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1178 DENON_ADDRESS_OFFSET, // address_offset: address offset\r
1179 DENON_ADDRESS_OFFSET + DENON_ADDRESS_LEN, // address_end: end of address\r
1180 DENON_COMMAND_OFFSET, // command_offset: command offset\r
1181 DENON_COMMAND_OFFSET + DENON_COMMAND_LEN, // command_end: end of command\r
1182 DENON_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1183 DENON_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1184 DENON_LSB, // lsb_first: flag: LSB first\r
1185 DENON_FLAGS // flags: some flags\r
4225a882 1186};\r
1187\r
1188#endif\r
1189\r
1190#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
1191\r
63b94f48 1192static const PROGMEM IRMP_PARAMETER rc6_param =\r
4225a882 1193{\r
d155e9ab 1194 IRMP_RC6_PROTOCOL, // protocol: ir protocol\r
1aee56bc 1195\r
1196 RC6_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse\r
1197 RC6_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse\r
1198 RC6_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause\r
1199 RC6_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause\r
31c1f035 1200 0, // pulse_0_len_min: here: not used\r
1201 0, // pulse_0_len_max: here: not used\r
1202 0, // pause_0_len_min: here: not used\r
1203 0, // pause_0_len_max: here: not used\r
d155e9ab 1204 RC6_ADDRESS_OFFSET, // address_offset: address offset\r
1205 RC6_ADDRESS_OFFSET + RC6_ADDRESS_LEN, // address_end: end of address\r
1206 RC6_COMMAND_OFFSET, // command_offset: command offset\r
1207 RC6_COMMAND_OFFSET + RC6_COMMAND_LEN, // command_end: end of command\r
1208 RC6_COMPLETE_DATA_LEN_SHORT, // complete_len: complete length of frame\r
1209 RC6_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1210 RC6_LSB, // lsb_first: flag: LSB first\r
1211 RC6_FLAGS // flags: some flags\r
4225a882 1212};\r
1213\r
1214#endif\r
1215\r
1216#if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1\r
1217\r
63b94f48 1218static const PROGMEM IRMP_PARAMETER recs80ext_param =\r
4225a882 1219{\r
d155e9ab 1220 IRMP_RECS80EXT_PROTOCOL, // protocol: ir protocol\r
1221 RECS80EXT_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1222 RECS80EXT_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1223 RECS80EXT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1224 RECS80EXT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1225 RECS80EXT_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1226 RECS80EXT_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1227 RECS80EXT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1228 RECS80EXT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1229 RECS80EXT_ADDRESS_OFFSET, // address_offset: address offset\r
1230 RECS80EXT_ADDRESS_OFFSET + RECS80EXT_ADDRESS_LEN, // address_end: end of address\r
1231 RECS80EXT_COMMAND_OFFSET, // command_offset: command offset\r
1232 RECS80EXT_COMMAND_OFFSET + RECS80EXT_COMMAND_LEN, // command_end: end of command\r
1233 RECS80EXT_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1234 RECS80EXT_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1235 RECS80EXT_LSB, // lsb_first: flag: LSB first\r
1236 RECS80EXT_FLAGS // flags: some flags\r
4225a882 1237};\r
1238\r
1239#endif\r
1240\r
504d9df9 1241#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1\r
4225a882 1242\r
63b94f48 1243static const PROGMEM IRMP_PARAMETER nubert_param =\r
4225a882 1244{\r
d155e9ab 1245 IRMP_NUBERT_PROTOCOL, // protocol: ir protocol\r
1246 NUBERT_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1247 NUBERT_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1248 NUBERT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1249 NUBERT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1250 NUBERT_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1251 NUBERT_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1252 NUBERT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1253 NUBERT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1254 NUBERT_ADDRESS_OFFSET, // address_offset: address offset\r
1255 NUBERT_ADDRESS_OFFSET + NUBERT_ADDRESS_LEN, // address_end: end of address\r
1256 NUBERT_COMMAND_OFFSET, // command_offset: command offset\r
1257 NUBERT_COMMAND_OFFSET + NUBERT_COMMAND_LEN, // command_end: end of command\r
1258 NUBERT_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1259 NUBERT_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1260 NUBERT_LSB, // lsb_first: flag: LSB first\r
1261 NUBERT_FLAGS // flags: some flags\r
4225a882 1262};\r
1263\r
1264#endif\r
1265\r
504d9df9 1266#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
1267\r
63b94f48 1268static const PROGMEM IRMP_PARAMETER bang_olufsen_param =\r
504d9df9 1269{\r
d155e9ab 1270 IRMP_BANG_OLUFSEN_PROTOCOL, // protocol: ir protocol\r
1271 BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1272 BANG_OLUFSEN_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1273 BANG_OLUFSEN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1274 BANG_OLUFSEN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1275 BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1276 BANG_OLUFSEN_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1277 BANG_OLUFSEN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1278 BANG_OLUFSEN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1279 BANG_OLUFSEN_ADDRESS_OFFSET, // address_offset: address offset\r
1280 BANG_OLUFSEN_ADDRESS_OFFSET + BANG_OLUFSEN_ADDRESS_LEN, // address_end: end of address\r
1281 BANG_OLUFSEN_COMMAND_OFFSET, // command_offset: command offset\r
1282 BANG_OLUFSEN_COMMAND_OFFSET + BANG_OLUFSEN_COMMAND_LEN, // command_end: end of command\r
1283 BANG_OLUFSEN_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1284 BANG_OLUFSEN_STOP_BIT, // stop_bit: flag: frame has stop bit\r
77f488bb 1285 BANG_OLUFSEN_LSB, // lsb_first: flag: LSB first\r
1286 BANG_OLUFSEN_FLAGS // flags: some flags\r
504d9df9 1287};\r
1288\r
1289#endif\r
1290\r
89e8cafb 1291#if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
1292\r
1293static uint8_t first_bit;\r
592411d1 1294\r
63b94f48 1295static const PROGMEM IRMP_PARAMETER grundig_param =\r
592411d1 1296{\r
d155e9ab 1297 IRMP_GRUNDIG_PROTOCOL, // protocol: ir protocol\r
1aee56bc 1298\r
89e8cafb 1299 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse\r
1300 GRUNDIG_NOKIA_IR60_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse\r
1301 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause\r
1302 GRUNDIG_NOKIA_IR60_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause\r
31c1f035 1303 0, // pulse_0_len_min: here: not used\r
1304 0, // pulse_0_len_max: here: not used\r
1305 0, // pause_0_len_min: here: not used\r
1306 0, // pause_0_len_max: here: not used\r
d155e9ab 1307 GRUNDIG_ADDRESS_OFFSET, // address_offset: address offset\r
1308 GRUNDIG_ADDRESS_OFFSET + GRUNDIG_ADDRESS_LEN, // address_end: end of address\r
1309 GRUNDIG_COMMAND_OFFSET, // command_offset: command offset\r
1310 GRUNDIG_COMMAND_OFFSET + GRUNDIG_COMMAND_LEN + 1, // command_end: end of command (USE 1 bit MORE to STORE NOKIA DATA!)\r
1311 NOKIA_COMPLETE_DATA_LEN, // complete_len: complete length of frame, here: NOKIA instead of GRUNDIG!\r
89e8cafb 1312 GRUNDIG_NOKIA_IR60_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1313 GRUNDIG_NOKIA_IR60_LSB, // lsb_first: flag: LSB first\r
1314 GRUNDIG_NOKIA_IR60_FLAGS // flags: some flags\r
592411d1 1315};\r
1316\r
1317#endif\r
1318\r
12948cf3 1319#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
a7054daf 1320\r
63b94f48 1321static const PROGMEM IRMP_PARAMETER ruwido_param =\r
a7054daf 1322{\r
12948cf3 1323 IRMP_RUWIDO_PROTOCOL, // protocol: ir protocol\r
1324 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse\r
1325 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse\r
1326 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause\r
1327 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause\r
31c1f035 1328 0, // pulse_0_len_min: here: not used\r
1329 0, // pulse_0_len_max: here: not used\r
1330 0, // pause_0_len_min: here: not used\r
1331 0, // pause_0_len_max: here: not used\r
12948cf3 1332 RUWIDO_ADDRESS_OFFSET, // address_offset: address offset\r
1333 RUWIDO_ADDRESS_OFFSET + RUWIDO_ADDRESS_LEN, // address_end: end of address\r
1334 RUWIDO_COMMAND_OFFSET, // command_offset: command offset\r
1335 RUWIDO_COMMAND_OFFSET + RUWIDO_COMMAND_LEN, // command_end: end of command\r
1336 SIEMENS_COMPLETE_DATA_LEN, // complete_len: complete length of frame, here: SIEMENS instead of RUWIDO!\r
1337 SIEMENS_OR_RUWIDO_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1338 SIEMENS_OR_RUWIDO_LSB, // lsb_first: flag: LSB first\r
1339 SIEMENS_OR_RUWIDO_FLAGS // flags: some flags\r
a7054daf 1340};\r
1341\r
1342#endif\r
1343\r
48664931 1344#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
b5ea7869 1345\r
63b94f48 1346static const PROGMEM IRMP_PARAMETER fdc_param =\r
b5ea7869 1347{\r
48664931 1348 IRMP_FDC_PROTOCOL, // protocol: ir protocol\r
1349 FDC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1350 FDC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1351 FDC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1352 FDC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1353 FDC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1354 FDC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1355 FDC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1356 FDC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1357 FDC_ADDRESS_OFFSET, // address_offset: address offset\r
1358 FDC_ADDRESS_OFFSET + FDC_ADDRESS_LEN, // address_end: end of address\r
1359 FDC_COMMAND_OFFSET, // command_offset: command offset\r
1360 FDC_COMMAND_OFFSET + FDC_COMMAND_LEN, // command_end: end of command\r
1361 FDC_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1362 FDC_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1363 FDC_LSB, // lsb_first: flag: LSB first\r
1364 FDC_FLAGS // flags: some flags\r
b5ea7869 1365};\r
1366\r
1367#endif\r
1368\r
9e16d699 1369#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
1370\r
63b94f48 1371static const PROGMEM IRMP_PARAMETER rccar_param =\r
9e16d699 1372{\r
1373 IRMP_RCCAR_PROTOCOL, // protocol: ir protocol\r
1374 RCCAR_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1375 RCCAR_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1376 RCCAR_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1377 RCCAR_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1378 RCCAR_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1379 RCCAR_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1380 RCCAR_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1381 RCCAR_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1382 RCCAR_ADDRESS_OFFSET, // address_offset: address offset\r
1383 RCCAR_ADDRESS_OFFSET + RCCAR_ADDRESS_LEN, // address_end: end of address\r
1384 RCCAR_COMMAND_OFFSET, // command_offset: command offset\r
1385 RCCAR_COMMAND_OFFSET + RCCAR_COMMAND_LEN, // command_end: end of command\r
1386 RCCAR_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1387 RCCAR_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1388 RCCAR_LSB, // lsb_first: flag: LSB first\r
1389 RCCAR_FLAGS // flags: some flags\r
1390};\r
1391\r
1392#endif\r
1393\r
9405f84a 1394#if IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
1395\r
63b94f48 1396static const PROGMEM IRMP_PARAMETER nikon_param =\r
9405f84a 1397{\r
1398 IRMP_NIKON_PROTOCOL, // protocol: ir protocol\r
1399 NIKON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1400 NIKON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1401 NIKON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1402 NIKON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1403 NIKON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1404 NIKON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1405 NIKON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1406 NIKON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1407 NIKON_ADDRESS_OFFSET, // address_offset: address offset\r
1408 NIKON_ADDRESS_OFFSET + NIKON_ADDRESS_LEN, // address_end: end of address\r
1409 NIKON_COMMAND_OFFSET, // command_offset: command offset\r
1410 NIKON_COMMAND_OFFSET + NIKON_COMMAND_LEN, // command_end: end of command\r
1411 NIKON_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1412 NIKON_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1413 NIKON_LSB, // lsb_first: flag: LSB first\r
1414 NIKON_FLAGS // flags: some flags\r
1415};\r
1416\r
1417#endif\r
1418\r
111d6191 1419#if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1\r
1420\r
63b94f48 1421static const PROGMEM IRMP_PARAMETER kathrein_param =\r
111d6191 1422{\r
1423 IRMP_KATHREIN_PROTOCOL, // protocol: ir protocol\r
1424 KATHREIN_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1425 KATHREIN_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1426 KATHREIN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1427 KATHREIN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1428 KATHREIN_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1429 KATHREIN_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1430 KATHREIN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1431 KATHREIN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1432 KATHREIN_ADDRESS_OFFSET, // address_offset: address offset\r
1433 KATHREIN_ADDRESS_OFFSET + KATHREIN_ADDRESS_LEN, // address_end: end of address\r
1434 KATHREIN_COMMAND_OFFSET, // command_offset: command offset\r
1435 KATHREIN_COMMAND_OFFSET + KATHREIN_COMMAND_LEN, // command_end: end of command\r
1436 KATHREIN_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1437 KATHREIN_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1438 KATHREIN_LSB, // lsb_first: flag: LSB first\r
1439 KATHREIN_FLAGS // flags: some flags\r
1440};\r
1441\r
1442#endif\r
1443\r
deba2a0a 1444#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1\r
1445\r
63b94f48 1446static const PROGMEM IRMP_PARAMETER netbox_param =\r
deba2a0a 1447{\r
1448 IRMP_NETBOX_PROTOCOL, // protocol: ir protocol\r
a42d1ee6 1449 NETBOX_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1, here: exact value\r
1450 NETBOX_PULSE_REST_LEN, // pulse_1_len_max: maximum length of pulse with bit value 1, here: rest value\r
1451 NETBOX_PAUSE_LEN, // pause_1_len_min: minimum length of pause with bit value 1, here: exact value\r
1452 NETBOX_PAUSE_REST_LEN, // pause_1_len_max: maximum length of pause with bit value 1, here: rest value\r
1453 NETBOX_PULSE_LEN, // pulse_0_len_min: minimum length of pulse with bit value 0, here: exact value\r
1454 NETBOX_PULSE_REST_LEN, // pulse_0_len_max: maximum length of pulse with bit value 0, here: rest value\r
1455 NETBOX_PAUSE_LEN, // pause_0_len_min: minimum length of pause with bit value 0, here: exact value\r
1456 NETBOX_PAUSE_REST_LEN, // pause_0_len_max: maximum length of pause with bit value 0, here: rest value\r
deba2a0a 1457 NETBOX_ADDRESS_OFFSET, // address_offset: address offset\r
1458 NETBOX_ADDRESS_OFFSET + NETBOX_ADDRESS_LEN, // address_end: end of address\r
1459 NETBOX_COMMAND_OFFSET, // command_offset: command offset\r
1460 NETBOX_COMMAND_OFFSET + NETBOX_COMMAND_LEN, // command_end: end of command\r
1461 NETBOX_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1462 NETBOX_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1463 NETBOX_LSB, // lsb_first: flag: LSB first\r
1464 NETBOX_FLAGS // flags: some flags\r
1465};\r
1466\r
1467#endif\r
1468\r
f50e01e7 1469#if IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
1470\r
63b94f48 1471static const PROGMEM IRMP_PARAMETER lego_param =\r
f50e01e7 1472{\r
1473 IRMP_LEGO_PROTOCOL, // protocol: ir protocol\r
1474 LEGO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1475 LEGO_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1476 LEGO_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1477 LEGO_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1478 LEGO_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1479 LEGO_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1480 LEGO_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1481 LEGO_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1482 LEGO_ADDRESS_OFFSET, // address_offset: address offset\r
1483 LEGO_ADDRESS_OFFSET + LEGO_ADDRESS_LEN, // address_end: end of address\r
1484 LEGO_COMMAND_OFFSET, // command_offset: command offset\r
1485 LEGO_COMMAND_OFFSET + LEGO_COMMAND_LEN, // command_end: end of command\r
1486 LEGO_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1487 LEGO_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1488 LEGO_LSB, // lsb_first: flag: LSB first\r
1489 LEGO_FLAGS // flags: some flags\r
1490};\r
1491\r
1492#endif\r
1493\r
beda975f 1494#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
1495\r
63b94f48 1496static const PROGMEM IRMP_PARAMETER thomson_param =\r
beda975f 1497{\r
1498 IRMP_THOMSON_PROTOCOL, // protocol: ir protocol\r
1499 THOMSON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
1500 THOMSON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1\r
1501 THOMSON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1\r
1502 THOMSON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1\r
1503 THOMSON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0\r
1504 THOMSON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0\r
1505 THOMSON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0\r
1506 THOMSON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0\r
1507 THOMSON_ADDRESS_OFFSET, // address_offset: address offset\r
1508 THOMSON_ADDRESS_OFFSET + THOMSON_ADDRESS_LEN, // address_end: end of address\r
1509 THOMSON_COMMAND_OFFSET, // command_offset: command offset\r
1510 THOMSON_COMMAND_OFFSET + THOMSON_COMMAND_LEN, // command_end: end of command\r
1511 THOMSON_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
1512 THOMSON_STOP_BIT, // stop_bit: flag: frame has stop bit\r
1513 THOMSON_LSB, // lsb_first: flag: LSB first\r
1514 THOMSON_FLAGS // flags: some flags\r
1515};\r
1516\r
1517#endif\r
1518\r
d155e9ab 1519static uint8_t irmp_bit; // current bit position\r
4225a882 1520static IRMP_PARAMETER irmp_param;\r
1521\r
6f750020 1522#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
1523static IRMP_PARAMETER irmp_param2;\r
1524#endif\r
1525\r
4225a882 1526static volatile uint8_t irmp_ir_detected;\r
1527static volatile uint8_t irmp_protocol;\r
1528static volatile uint16_t irmp_address;\r
1529static volatile uint16_t irmp_command;\r
d155e9ab 1530static volatile uint16_t irmp_id; // only used for SAMSUNG protocol\r
4225a882 1531static volatile uint8_t irmp_flags;\r
1f54e86c 1532// static volatile uint8_t irmp_busy_flag;\r
4225a882 1533\r
48664931 1534#ifdef ANALYZE\r
4225a882 1535static uint8_t IRMP_PIN;\r
1536#endif\r
1537\r
1538/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
1539 * Initialize IRMP decoder\r
1540 * @details Configures IRMP input pin\r
1541 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
1542 */\r
48664931 1543#ifndef ANALYZE\r
4225a882 1544void\r
1545irmp_init (void)\r
1546{\r
93ba2e01 1547#if !defined(PIC_CCS_COMPILER) && !defined(PIC_C18) // only AVR\r
d155e9ab 1548 IRMP_PORT &= ~(1<<IRMP_BIT); // deactivate pullup\r
1549 IRMP_DDR &= ~(1<<IRMP_BIT); // set pin to input\r
93ba2e01 1550#endif\r
4225a882 1551\r
1552#if IRMP_LOGGING == 1\r
1553 irmp_uart_init ();\r
1554#endif\r
1555}\r
1556#endif\r
1557/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
1558 * Get IRMP data\r
1559 * @details gets decoded IRMP data\r
1560 * @param pointer in order to store IRMP data\r
1561 * @return TRUE: successful, FALSE: failed\r
1562 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
1563 */\r
1564uint8_t\r
1565irmp_get_data (IRMP_DATA * irmp_data_p)\r
1566{\r
1567 uint8_t rtc = FALSE;\r
1568\r
1569 if (irmp_ir_detected)\r
1570 {\r
1571 switch (irmp_protocol)\r
1572 {\r
1573#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
1574 case IRMP_SAMSUNG_PROTOCOL:\r
1575 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))\r
1576 {\r
1577 irmp_command &= 0xff;\r
1578 irmp_command |= irmp_id << 8;\r
1579 rtc = TRUE;\r
1580 }\r
1581 break;\r
1582#endif\r
1583#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
1584 case IRMP_NEC_PROTOCOL:\r
1585 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))\r
1586 {\r
1587 irmp_command &= 0xff;\r
1588 rtc = TRUE;\r
1589 }\r
770a1a9d 1590 else if (irmp_address == 0x87EE)\r
4225a882 1591 {\r
48664931 1592 ANALYZE_PRINTF ("Switching to APPLE protocol\n");\r
4225a882 1593 irmp_protocol = IRMP_APPLE_PROTOCOL;\r
770a1a9d 1594 irmp_address = (irmp_command & 0xFF00) >> 8;\r
1595 irmp_command &= 0x00FF;\r
4225a882 1596 rtc = TRUE;\r
1597 }\r
1598 break;\r
48664931 1599#endif\r
12948cf3 1600#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
9405f84a 1601 case IRMP_SIEMENS_PROTOCOL:\r
12948cf3 1602 case IRMP_RUWIDO_PROTOCOL:\r
9405f84a 1603 if (((irmp_command >> 1) & 0x0001) == (~irmp_command & 0x0001))\r
1604 {\r
1605 irmp_command >>= 1;\r
1606 rtc = TRUE;\r
1607 }\r
1608 break;\r
1609#endif\r
111d6191 1610#if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1\r
1611 case IRMP_KATHREIN_PROTOCOL:\r
2cfc146d 1612 if (irmp_command != 0x0000)\r
111d6191 1613 {\r
1614 rtc = TRUE;\r
1615 }\r
1616 break;\r
1617#endif\r
03780b34 1618#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
1619 case IRMP_RC5_PROTOCOL:\r
1620 irmp_address &= ~0x20; // clear toggle bit\r
1621 rtc = TRUE;\r
1622 break;\r
1623#endif\r
89e8cafb 1624#if IRMP_SUPPORT_IR60_PROTOCOL == 1\r
1625 case IRMP_IR60_PROTOCOL:\r
1626 if (irmp_command != 0x007d) // 0x007d (== 62<<1 + 1) is start instruction frame\r
1627 {\r
1628 rtc = TRUE;\r
1629 }\r
1630 break;\r
1631#endif\r
48664931 1632#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
1633 case IRMP_RCCAR_PROTOCOL:\r
1634 // frame in irmp_data:\r
1635 // Bit 12 11 10 9 8 7 6 5 4 3 2 1 0\r
1636 // V D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0 // 10 9 8 7 6 5 4 3 2 1 0\r
1637 irmp_address = (irmp_command & 0x000C) >> 2; // addr: 0 0 0 0 0 0 0 0 0 A1 A0\r
1638 irmp_command = ((irmp_command & 0x1000) >> 2) | // V-Bit: V 0 0 0 0 0 0 0 0 0 0\r
1639 ((irmp_command & 0x0003) << 8) | // C-Bits: 0 C1 C0 0 0 0 0 0 0 0 0\r
1640 ((irmp_command & 0x0FF0) >> 4); // D-Bits: D7 D6 D5 D4 D3 D2 D1 D0\r
1641 rtc = TRUE; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0\r
1642 break;\r
4225a882 1643#endif\r
beda975f 1644\r
1645#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 // squeeze code to 8 bit, upper bit indicates release-key\r
deba2a0a 1646 case IRMP_NETBOX_PROTOCOL:\r
1647 if (irmp_command & 0x1000) // last bit set?\r
1648 {\r
1649 if ((irmp_command & 0x1f) == 0x15) // key pressed: 101 01 (LSB)\r
1650 {\r
1651 irmp_command >>= 5;\r
1652 irmp_command &= 0x7F;\r
1653 rtc = TRUE;\r
1654 }\r
1655 else if ((irmp_command & 0x1f) == 0x10) // key released: 000 01 (LSB)\r
1656 {\r
1657 irmp_command >>= 5;\r
1658 irmp_command |= 0x80;\r
1659 rtc = TRUE;\r
1660 }\r
1661 else\r
1662 {\r
1663 ANALYZE_PRINTF("error NETBOX: bit6/7 must be 0/1\n");\r
1664 }\r
1665 }\r
1666 else\r
1667 {\r
1668 ANALYZE_PRINTF("error NETBOX: last bit not set\n");\r
1669 }\r
1670 break;\r
1671#endif\r
f50e01e7 1672#if IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
1673 case IRMP_LEGO_PROTOCOL:\r
1674 {\r
1675 uint8_t crc = 0x0F ^ ((irmp_command & 0xF000) >> 12) ^ ((irmp_command & 0x0F00) >> 8) ^ ((irmp_command & 0x00F0) >> 4);\r
1676\r
1677 if ((irmp_command & 0x000F) == crc)\r
1678 {\r
1679 irmp_command >>= 4;\r
1680 rtc = TRUE;\r
1681 }\r
1682 else\r
1683 {\r
1684 ANALYZE_PRINTF ("CRC error in LEGO protocol\n");\r
1685 rtc = TRUE;\r
1686 }\r
1687 break;\r
1688 }\r
1689#endif\r
4225a882 1690 default:\r
1691 rtc = TRUE;\r
1692 }\r
1693\r
1694 if (rtc)\r
1695 {\r
1696 irmp_data_p->protocol = irmp_protocol;\r
1697 irmp_data_p->address = irmp_address;\r
1698 irmp_data_p->command = irmp_command;\r
1699 irmp_data_p->flags = irmp_flags;\r
1700 irmp_command = 0;\r
1701 irmp_address = 0;\r
1702 irmp_flags = 0;\r
1703 }\r
1704\r
1705 irmp_ir_detected = FALSE;\r
1706 }\r
1707\r
1708 return rtc;\r
1709}\r
1710\r
1f54e86c 1711// uint8_t\r
1712// irmp_is_busy (void)\r
1713// {\r
1714// return irmp_busy_flag;\r
1715// }\r
1716\r
7644ac04 1717#if IRMP_USE_CALLBACK == 1\r
1718void\r
1719irmp_set_callback_ptr (void (*cb)(uint8_t))\r
1720{\r
1721 irmp_callback_ptr = cb;\r
1722}\r
1723#endif // IRMP_USE_CALLBACK == 1\r
1724\r
4225a882 1725// these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR()\r
770a1a9d 1726static uint16_t irmp_tmp_address; // ir address\r
1727static uint16_t irmp_tmp_command; // ir command\r
6f750020 1728\r
35213800 1729#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
770a1a9d 1730static uint16_t irmp_tmp_address2; // ir address\r
1731static uint16_t irmp_tmp_command2; // ir command\r
6f750020 1732#endif\r
1733\r
4225a882 1734#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
770a1a9d 1735static uint16_t irmp_tmp_id; // ir id (only SAMSUNG)\r
1736#endif\r
1737#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
1738static uint8_t xor_check[6]; // check kaseikyo "parity" bits\r
0f700c8e 1739static uint8_t genre2; // save genre2 bits here, later copied to MSB in flags\r
4225a882 1740#endif\r
1741\r
4225a882 1742/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
1743 * store bit\r
1744 * @details store bit in temp address or temp command\r
1745 * @param value to store: 0 or 1\r
1746 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
1747 */\r
d823e852 1748// verhindert, dass irmp_store_bit() inline compiliert wird:\r
1749// static void irmp_store_bit (uint8_t) __attribute__ ((noinline));\r
1750\r
4225a882 1751static void\r
1752irmp_store_bit (uint8_t value)\r
1753{\r
89e8cafb 1754#if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
1755 if (irmp_bit == 0 && irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL)\r
1756 {\r
1757 first_bit = value;\r
1758 }\r
1759 else\r
1760#endif\r
770a1a9d 1761\r
4225a882 1762 if (irmp_bit >= irmp_param.address_offset && irmp_bit < irmp_param.address_end)\r
1763 {\r
1764 if (irmp_param.lsb_first)\r
1765 {\r
1766 irmp_tmp_address |= (((uint16_t) (value)) << (irmp_bit - irmp_param.address_offset)); // CV wants cast\r
1767 }\r
1768 else\r
1769 {\r
1770 irmp_tmp_address <<= 1;\r
1771 irmp_tmp_address |= value;\r
1772 }\r
1773 }\r
1774 else if (irmp_bit >= irmp_param.command_offset && irmp_bit < irmp_param.command_end)\r
1775 {\r
1776 if (irmp_param.lsb_first)\r
1777 {\r
1778 irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast\r
1779 }\r
1780 else\r
1781 {\r
1782 irmp_tmp_command <<= 1;\r
1783 irmp_tmp_command |= value;\r
1784 }\r
1785 }\r
770a1a9d 1786\r
35213800 1787#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
1788 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit >= 13 && irmp_bit < 26)\r
1789 {\r
1790 irmp_tmp_address2 |= (((uint16_t) (value)) << (irmp_bit - 13)); // CV wants cast\r
1791 }\r
1792#endif\r
1793\r
4225a882 1794#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
1795 else if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit >= SAMSUNG_ID_OFFSET && irmp_bit < SAMSUNG_ID_OFFSET + SAMSUNG_ID_LEN)\r
1796 {\r
1797 irmp_tmp_id |= (((uint16_t) (value)) << (irmp_bit - SAMSUNG_ID_OFFSET)); // store with LSB first\r
1798 }\r
1799#endif\r
770a1a9d 1800\r
1801#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
0f700c8e 1802 else if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)\r
770a1a9d 1803 {\r
0f700c8e 1804 if (irmp_bit >= 20 && irmp_bit < 24)\r
770a1a9d 1805 {\r
0f700c8e 1806 irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first\r
770a1a9d 1807 }\r
0f700c8e 1808 else if (irmp_bit >= 24 && irmp_bit < 28)\r
770a1a9d 1809 {\r
0f700c8e 1810 genre2 |= (((uint8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first\r
770a1a9d 1811 }\r
770a1a9d 1812\r
0f700c8e 1813 if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)\r
1814 {\r
1815 if (value)\r
1816 {\r
1817 xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);\r
1818 }\r
1819 else\r
1820 {\r
1821 xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));\r
1822 }\r
1823 }\r
1824 }\r
770a1a9d 1825#endif\r
1826\r
4225a882 1827 irmp_bit++;\r
1828}\r
1829\r
6f750020 1830/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
1831 * store bit\r
1832 * @details store bit in temp address or temp command\r
1833 * @param value to store: 0 or 1\r
1834 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
1835 */\r
1836#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
1837static void\r
1838irmp_store_bit2 (uint8_t value)\r
1839{\r
1840 uint8_t irmp_bit2;\r
1841\r
1842 if (irmp_param.protocol)\r
1843 {\r
1844 irmp_bit2 = irmp_bit - 2;\r
1845 }\r
1846 else\r
1847 {\r
1848 irmp_bit2 = irmp_bit - 1;\r
1849 }\r
1850\r
1851 if (irmp_bit2 >= irmp_param2.address_offset && irmp_bit2 < irmp_param2.address_end)\r
1852 {\r
1853 irmp_tmp_address2 |= (((uint16_t) (value)) << (irmp_bit2 - irmp_param2.address_offset)); // CV wants cast\r
1854 }\r
1855 else if (irmp_bit2 >= irmp_param2.command_offset && irmp_bit2 < irmp_param2.command_end)\r
1856 {\r
1857 irmp_tmp_command2 |= (((uint16_t) (value)) << (irmp_bit2 - irmp_param2.command_offset)); // CV wants cast\r
1858 }\r
1859}\r
1860#endif // IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
1861\r
4225a882 1862/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
1863 * ISR routine\r
1864 * @details ISR routine, called 10000 times per second\r
1865 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
1866 */\r
879b06c2 1867uint8_t\r
4225a882 1868irmp_ISR (void)\r
1869{\r
48664931 1870 static uint8_t irmp_start_bit_detected; // flag: start bit detected\r
1871 static uint8_t wait_for_space; // flag: wait for data bit space\r
1872 static uint8_t wait_for_start_space; // flag: wait for start bit space\r
1873 static uint8_t irmp_pulse_time; // count bit time for pulse\r
1874 static PAUSE_LEN irmp_pause_time; // count bit time for pause\r
1875 static uint16_t last_irmp_address = 0xFFFF; // save last irmp address to recognize key repetition\r
1876 static uint16_t last_irmp_command = 0xFFFF; // save last irmp command to recognize key repetition\r
c7a47e89 1877 static uint16_t repetition_len; // SIRCS repeats frame 2-5 times with 45 ms pause\r
48664931 1878 static uint8_t repetition_frame_number;\r
4225a882 1879#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
48664931 1880 static uint16_t last_irmp_denon_command; // save last irmp command to recognize DENON frame repetition\r
4225a882 1881#endif\r
1882#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
48664931 1883 static uint8_t rc5_cmd_bit6; // bit 6 of RC5 command is the inverted 2nd start bit\r
4225a882 1884#endif\r
77f488bb 1885#if IRMP_SUPPORT_MANCHESTER == 1\r
48664931 1886 static PAUSE_LEN last_pause; // last pause value\r
504d9df9 1887#endif\r
77f488bb 1888#if IRMP_SUPPORT_MANCHESTER == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
48664931 1889 static uint8_t last_value; // last bit value\r
4225a882 1890#endif\r
48664931 1891 uint8_t irmp_input; // input value\r
4225a882 1892\r
48664931 1893#ifdef ANALYZE\r
592411d1 1894 time_counter++;\r
1895#endif\r
1896\r
4225a882 1897 irmp_input = input(IRMP_PIN);\r
1898\r
7644ac04 1899#if IRMP_USE_CALLBACK == 1\r
1900 if (irmp_callback_ptr)\r
1901 {\r
1902 static uint8_t last_inverted_input;\r
1903\r
1904 if (last_inverted_input != !irmp_input)\r
1905 {\r
1906 (*irmp_callback_ptr) (! irmp_input);\r
1907 last_inverted_input = !irmp_input;\r
1908 }\r
1909 }\r
1910#endif // IRMP_USE_CALLBACK == 1\r
1911\r
d155e9ab 1912 irmp_log(irmp_input); // log ir signal, if IRMP_LOGGING defined\r
4225a882 1913\r
1914 if (! irmp_ir_detected) // ir code already detected?\r
1915 { // no...\r
1916 if (! irmp_start_bit_detected) // start bit detected?\r
1917 { // no...\r
d155e9ab 1918 if (! irmp_input) // receiving burst?\r
4225a882 1919 { // yes...\r
1f54e86c 1920// irmp_busy_flag = TRUE;\r
48664931 1921#ifdef ANALYZE\r
d155e9ab 1922 if (! irmp_pulse_time)\r
1923 {\r
0f700c8e 1924 ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS);\r
d155e9ab 1925 }\r
1926#endif\r
4225a882 1927 irmp_pulse_time++; // increment counter\r
1928 }\r
1929 else\r
1930 { // no...\r
1931 if (irmp_pulse_time) // it's dark....\r
1932 { // set flags for counting the time of darkness...\r
1933 irmp_start_bit_detected = 1;\r
1934 wait_for_start_space = 1;\r
1935 wait_for_space = 0;\r
1936 irmp_tmp_command = 0;\r
1937 irmp_tmp_address = 0;\r
0f700c8e 1938#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
1939 genre2 = 0;\r
1940#endif\r
6f750020 1941\r
35213800 1942#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
6f750020 1943 irmp_tmp_command2 = 0;\r
1944 irmp_tmp_address2 = 0;\r
1945#endif\r
1946\r
4225a882 1947 irmp_bit = 0xff;\r
1948 irmp_pause_time = 1; // 1st pause: set to 1, not to 0!\r
1949#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
1950 rc5_cmd_bit6 = 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame!\r
1951#endif\r
1952 }\r
1953 else\r
1954 {\r
c7a47e89 1955 if (repetition_len < 0xFFFF) // avoid overflow of counter\r
6db2522c 1956 {\r
c7a47e89 1957 repetition_len++;\r
6db2522c 1958 }\r
4225a882 1959 }\r
1960 }\r
1961 }\r
1962 else\r
1963 {\r
1964 if (wait_for_start_space) // we have received start bit...\r
1965 { // ...and are counting the time of darkness\r
1966 if (irmp_input) // still dark?\r
1967 { // yes\r
1968 irmp_pause_time++; // increment counter\r
1969\r
9405f84a 1970#if IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
1971 if (((irmp_pulse_time < NIKON_START_BIT_PULSE_LEN_MIN || irmp_pulse_time > NIKON_START_BIT_PULSE_LEN_MAX) && irmp_pause_time > IRMP_TIMEOUT_LEN) ||\r
1972 irmp_pause_time > IRMP_TIMEOUT_NIKON_LEN)\r
1973#else\r
504d9df9 1974 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?\r
9405f84a 1975#endif\r
4225a882 1976 { // yes...\r
c7a47e89 1977#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
1978 if (irmp_protocol == IRMP_JVC_PROTOCOL) // don't show eror if JVC protocol, irmp_pulse_time has been set below!\r
1979 {\r
1980 ;\r
1981 }\r
1982 else\r
1983#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
1984 {\r
0f700c8e 1985 ANALYZE_PRINTF ("%8.3fms error 1: pause after start bit pulse %d too long: %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);\r
c7a47e89 1986 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1987 }\r
1f54e86c 1988// irmp_busy_flag = FALSE;\r
4225a882 1989 irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit\r
1990 irmp_pulse_time = 0;\r
1991 irmp_pause_time = 0;\r
1992 }\r
1993 }\r
1994 else\r
1995 { // receiving first data pulse!\r
46dd89b7 1996 IRMP_PARAMETER * irmp_param_p = (IRMP_PARAMETER *) 0;\r
1997\r
6f750020 1998#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
1999 irmp_param2.protocol = 0;\r
2000#endif\r
2001\r
0f700c8e 2002 ANALYZE_PRINTF ("%8.3fms [start-bit: pulse = %2d, pause = %2d]\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);\r
4225a882 2003\r
2004#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
2005 if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX &&\r
2006 irmp_pause_time >= SIRCS_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIRCS_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2007 { // it's SIRCS\r
48664931 2008 ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2009 SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX,\r
2010 SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2011 irmp_param_p = (IRMP_PARAMETER *) (IRMP_PARAMETER *) &sircs_param;\r
4225a882 2012 }\r
2013 else\r
2014#endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
2015\r
770a1a9d 2016#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2017 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame\r
2018 irmp_pulse_time >= JVC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= JVC_START_BIT_PULSE_LEN_MAX &&\r
2019 irmp_pause_time >= JVC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= JVC_REPEAT_START_BIT_PAUSE_LEN_MAX)\r
2020 {\r
93ba2e01 2021 ANALYZE_PRINTF ("protocol = NEC or JVC (type 1) repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
770a1a9d 2022 JVC_START_BIT_PULSE_LEN_MIN, JVC_START_BIT_PULSE_LEN_MAX,\r
2023 JVC_REPEAT_START_BIT_PAUSE_LEN_MIN, JVC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
35213800 2024 irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
770a1a9d 2025 }\r
2026 else\r
2027#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2028\r
4225a882 2029#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
2030 if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
46dd89b7 2031 irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)\r
2032 {\r
35213800 2033#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
2034 ANALYZE_PRINTF ("protocol = NEC42, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2035 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2036 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);\r
2037 irmp_param_p = (IRMP_PARAMETER *) &nec42_param;\r
2038#else\r
48664931 2039 ANALYZE_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
46dd89b7 2040 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2041 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);\r
2042 irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
35213800 2043#endif\r
2044\r
46dd89b7 2045 }\r
2046 else if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
2047 irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX)\r
2048 { // it's NEC\r
93ba2e01 2049#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2050 if (irmp_protocol == IRMP_JVC_PROTOCOL) // last protocol was JVC, awaiting repeat frame\r
2051 { // some jvc remote controls use nec repetition frame for jvc repetition frame\r
2052 ANALYZE_PRINTF ("protocol = JVC repeat frame type 2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2053 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2054 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
2055 irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
2056 }\r
2057 else\r
2058#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2059 {\r
2060 ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2061 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2062 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2063\r
93ba2e01 2064 irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param;\r
2065 }\r
2066 }\r
2067 else\r
2068\r
2069#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2070 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame\r
2071 irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
2072 irmp_pause_time >= NEC_0_PAUSE_LEN_MIN && irmp_pause_time <= NEC_0_PAUSE_LEN_MAX)\r
2073 { // it's JVC repetition type 3\r
2074 ANALYZE_PRINTF ("protocol = JVC repeat frame type 3, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2075 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2076 NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX);\r
2077 irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
4225a882 2078 }\r
2079 else\r
93ba2e01 2080#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2081\r
4225a882 2082#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
2083\r
9405f84a 2084#if IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
2085 if (irmp_pulse_time >= NIKON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NIKON_START_BIT_PULSE_LEN_MAX &&\r
2086 irmp_pause_time >= NIKON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NIKON_START_BIT_PAUSE_LEN_MAX)\r
2087 {\r
2088 ANALYZE_PRINTF ("protocol = NIKON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2089 NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX,\r
2090 NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX);\r
2091 irmp_param_p = (IRMP_PARAMETER *) &nikon_param;\r
2092 }\r
2093 else\r
2094#endif // IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
2095\r
4225a882 2096#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
2097 if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX &&\r
2098 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2099 { // it's SAMSUNG\r
48664931 2100 ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2101 SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX,\r
2102 SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2103 irmp_param_p = (IRMP_PARAMETER *) &samsung_param;\r
4225a882 2104 }\r
2105 else\r
2106#endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
2107\r
2108#if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1\r
2109 if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX &&\r
2110 irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2111 { // it's MATSUSHITA\r
48664931 2112 ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2113 MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX,\r
2114 MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2115 irmp_param_p = (IRMP_PARAMETER *) &matsushita_param;\r
4225a882 2116 }\r
2117 else\r
2118#endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1\r
2119\r
2120#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
2121 if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX &&\r
2122 irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2123 { // it's KASEIKYO\r
48664931 2124 ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2125 KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX,\r
2126 KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2127 irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param;\r
4225a882 2128 }\r
2129 else\r
2130#endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
2131\r
2132#if IRMP_SUPPORT_RECS80_PROTOCOL == 1\r
2133 if (irmp_pulse_time >= RECS80_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80_START_BIT_PULSE_LEN_MAX &&\r
2134 irmp_pause_time >= RECS80_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2135 { // it's RECS80\r
48664931 2136 ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2137 RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX,\r
2138 RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2139 irmp_param_p = (IRMP_PARAMETER *) &recs80_param;\r
4225a882 2140 }\r
2141 else\r
2142#endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1\r
2143\r
2144#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
31c1f035 2145 if (((irmp_pulse_time >= RC5_START_BIT_LEN_MIN && irmp_pulse_time <= RC5_START_BIT_LEN_MAX) ||\r
2146 (irmp_pulse_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX)) &&\r
2147 ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) ||\r
2148 (irmp_pause_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)))\r
46dd89b7 2149 { // it's RC5\r
6f750020 2150#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2151 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&\r
2152 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)\r
2153 {\r
2154 ANALYZE_PRINTF ("protocol = RC5 or FDC\n");\r
2155 ANALYZE_PRINTF ("FDC start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2156 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,\r
2157 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);\r
2158 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2159 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
2160 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);\r
2161 memcpy_P (&irmp_param2, &fdc_param, sizeof (IRMP_PARAMETER));\r
2162 }\r
2163 else\r
2164#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
12948cf3 2165\r
6f750020 2166#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2167 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&\r
2168 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)\r
2169 {\r
2170 ANALYZE_PRINTF ("protocol = RC5 or RCCAR\n");\r
2171 ANALYZE_PRINTF ("RCCAR start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2172 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,\r
2173 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);\r
2174 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2175 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
2176 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);\r
2177 memcpy_P (&irmp_param2, &rccar_param, sizeof (IRMP_PARAMETER));\r
2178 }\r
2179 else\r
2180#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2181 {\r
1aee56bc 2182 ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n",\r
6f750020 2183 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
31c1f035 2184 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX,\r
1aee56bc 2185 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
31c1f035 2186 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX);\r
6f750020 2187 }\r
2188\r
46dd89b7 2189 irmp_param_p = (IRMP_PARAMETER *) &rc5_param;\r
504d9df9 2190 last_pause = irmp_pause_time;\r
4225a882 2191\r
31c1f035 2192 if ((irmp_pulse_time > RC5_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX) ||\r
2193 (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX))\r
4225a882 2194 {\r
504d9df9 2195 last_value = 0;\r
4225a882 2196 rc5_cmd_bit6 = 1<<6;\r
2197 }\r
2198 else\r
2199 {\r
504d9df9 2200 last_value = 1;\r
4225a882 2201 }\r
2202 }\r
2203 else\r
2204#endif // IRMP_SUPPORT_RC5_PROTOCOL == 1\r
2205\r
2206#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
2207 if ( (irmp_pulse_time >= DENON_PULSE_LEN_MIN && irmp_pulse_time <= DENON_PULSE_LEN_MAX) &&\r
2208 ((irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) ||\r
2209 (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)))\r
2210 { // it's DENON\r
48664931 2211 ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",\r
4225a882 2212 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,\r
2213 DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX,\r
2214 DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX);\r
46dd89b7 2215 irmp_param_p = (IRMP_PARAMETER *) &denon_param;\r
4225a882 2216 }\r
2217 else\r
2218#endif // IRMP_SUPPORT_DENON_PROTOCOL == 1\r
2219\r
beda975f 2220#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
2221 if ( (irmp_pulse_time >= THOMSON_PULSE_LEN_MIN && irmp_pulse_time <= THOMSON_PULSE_LEN_MAX) &&\r
2222 ((irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) ||\r
2223 (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)))\r
2224 { // it's THOMSON\r
2225 ANALYZE_PRINTF ("protocol = THOMSON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",\r
2226 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX,\r
2227 THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX,\r
2228 THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX);\r
2229 irmp_param_p = (IRMP_PARAMETER *) &thomson_param;\r
2230 }\r
2231 else\r
2232#endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
2233\r
4225a882 2234#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2235 if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX &&\r
2236 irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX)\r
2237 { // it's RC6\r
48664931 2238 ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2239 RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX,\r
2240 RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2241 irmp_param_p = (IRMP_PARAMETER *) &rc6_param;\r
504d9df9 2242 last_pause = 0;\r
c7a47e89 2243 last_value = 1;\r
4225a882 2244 }\r
2245 else\r
2246#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2247\r
2248#if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1\r
2249 if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX &&\r
2250 irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2251 { // it's RECS80EXT\r
48664931 2252 ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2253 RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX,\r
2254 RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2255 irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param;\r
4225a882 2256 }\r
2257 else\r
2258#endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1\r
2259\r
2260#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1\r
2261 if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX &&\r
2262 irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2263 { // it's NUBERT\r
48664931 2264 ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2265 NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX,\r
2266 NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2267 irmp_param_p = (IRMP_PARAMETER *) &nubert_param;\r
4225a882 2268 }\r
2269 else\r
2270#endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1\r
2271\r
504d9df9 2272#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
2273 if (irmp_pulse_time >= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX &&\r
2274 irmp_pause_time >= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX)\r
46dd89b7 2275 { // it's BANG_OLUFSEN\r
48664931 2276 ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n");\r
2277 ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
504d9df9 2278 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,\r
2279 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);\r
48664931 2280 ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
504d9df9 2281 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,\r
2282 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);\r
48664931 2283 ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
504d9df9 2284 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,\r
2285 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);\r
48664931 2286 ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
504d9df9 2287 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,\r
2288 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);\r
46dd89b7 2289 irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param;\r
504d9df9 2290 last_value = 0;\r
2291 }\r
2292 else\r
2293#endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
2294\r
89e8cafb 2295#if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
2296 if (irmp_pulse_time >= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX &&\r
2297 irmp_pause_time >= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX)\r
592411d1 2298 { // it's GRUNDIG\r
48664931 2299 ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
89e8cafb 2300 GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX,\r
2301 GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX);\r
592411d1 2302 irmp_param_p = (IRMP_PARAMETER *) &grundig_param;\r
2303 last_pause = irmp_pause_time;\r
2304 last_value = 1;\r
2305 }\r
2306 else\r
89e8cafb 2307#endif // IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
592411d1 2308\r
12948cf3 2309#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
2310 if (((irmp_pulse_time >= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX) ||\r
31c1f035 2311 (irmp_pulse_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX)) &&\r
fc80d688 2312 ((irmp_pause_time >= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX) || \r
31c1f035 2313 (irmp_pause_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX)))\r
12948cf3 2314 { // it's RUWIDO or SIEMENS\r
2315 ANALYZE_PRINTF ("protocol = RUWIDO, start bit timings: pulse: %3d - %3d or %3d - %3d, pause: %3d - %3d or %3d - %3d\n",\r
2316 SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,\r
31c1f035 2317 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,\r
12948cf3 2318 SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX,\r
31c1f035 2319 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX);\r
12948cf3 2320 irmp_param_p = (IRMP_PARAMETER *) &ruwido_param;\r
a7054daf 2321 last_pause = irmp_pause_time;\r
2322 last_value = 1;\r
2323 }\r
2324 else\r
12948cf3 2325#endif // IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
2326\r
48664931 2327#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2328 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&\r
2329 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)\r
eaaf80c3 2330 {\r
48664931 2331 ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2332 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,\r
2333 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);\r
2334 irmp_param_p = (IRMP_PARAMETER *) &fdc_param;\r
eaaf80c3 2335 }\r
2336 else\r
48664931 2337#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
12948cf3 2338\r
9e16d699 2339#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2340 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&\r
2341 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)\r
2342 {\r
48664931 2343 ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
9e16d699 2344 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,\r
2345 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);\r
2346 irmp_param_p = (IRMP_PARAMETER *) &rccar_param;\r
2347 }\r
2348 else\r
2349#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
89e8cafb 2350\r
111d6191 2351#if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1\r
2352 if (irmp_pulse_time >= KATHREIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_START_BIT_PULSE_LEN_MAX &&\r
2353 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)\r
2354 { // it's KATHREIN\r
2355 ANALYZE_PRINTF ("protocol = KATHREIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2356 KATHREIN_START_BIT_PULSE_LEN_MIN, KATHREIN_START_BIT_PULSE_LEN_MAX,\r
2357 KATHREIN_START_BIT_PAUSE_LEN_MIN, KATHREIN_START_BIT_PAUSE_LEN_MAX);\r
2358 irmp_param_p = (IRMP_PARAMETER *) &kathrein_param;\r
2359 }\r
2360 else\r
2361#endif // IRMP_SUPPORT_KATHREIN_PROTOCOL == 1\r
2362\r
deba2a0a 2363#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1\r
2364 if (irmp_pulse_time >= NETBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NETBOX_START_BIT_PULSE_LEN_MAX &&\r
2365 irmp_pause_time >= NETBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NETBOX_START_BIT_PAUSE_LEN_MAX)\r
2366 { // it's NETBOX\r
2367 ANALYZE_PRINTF ("protocol = NETBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2368 NETBOX_START_BIT_PULSE_LEN_MIN, NETBOX_START_BIT_PULSE_LEN_MAX,\r
2369 NETBOX_START_BIT_PAUSE_LEN_MIN, NETBOX_START_BIT_PAUSE_LEN_MAX);\r
2370 irmp_param_p = (IRMP_PARAMETER *) &netbox_param;\r
2371 }\r
2372 else\r
2373#endif // IRMP_SUPPORT_NETBOX_PROTOCOL == 1\r
2374\r
f50e01e7 2375#if IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
2376 if (irmp_pulse_time >= LEGO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= LEGO_START_BIT_PULSE_LEN_MAX &&\r
2377 irmp_pause_time >= LEGO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= LEGO_START_BIT_PAUSE_LEN_MAX)\r
2378 {\r
2379 ANALYZE_PRINTF ("protocol = LEGO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2380 LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX,\r
2381 LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX);\r
2382 irmp_param_p = (IRMP_PARAMETER *) &lego_param;\r
2383 }\r
2384 else\r
93ba2e01 2385#endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
f50e01e7 2386\r
4225a882 2387 {\r
48664931 2388 ANALYZE_PRINTF ("protocol = UNKNOWN\n");\r
1f54e86c 2389// irmp_busy_flag = FALSE;\r
4225a882 2390 irmp_start_bit_detected = 0; // wait for another start bit...\r
2391 }\r
2392\r
2393 if (irmp_start_bit_detected)\r
2394 {\r
46dd89b7 2395 memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER));\r
2396\r
48664931 2397#ifdef ANALYZE\r
77f488bb 2398 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
2399 {\r
48664931 2400 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max);\r
2401 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max);\r
77f488bb 2402 }\r
2403 else\r
2404 {\r
48664931 2405 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max,\r
31c1f035 2406 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max);\r
48664931 2407 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max,\r
31c1f035 2408 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max);\r
77f488bb 2409 }\r
46dd89b7 2410\r
6f750020 2411#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
2412 if (irmp_param2.protocol)\r
2413 {\r
2414 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param2.pulse_0_len_min, irmp_param2.pulse_0_len_max);\r
2415 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param2.pause_0_len_min, irmp_param2.pause_0_len_max);\r
2416 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param2.pulse_1_len_min, irmp_param2.pulse_1_len_max);\r
2417 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param2.pause_1_len_min, irmp_param2.pause_1_len_max);\r
2418 }\r
2419#endif\r
2420\r
d823e852 2421\r
504d9df9 2422#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
4225a882 2423 if (irmp_param.protocol == IRMP_RC6_PROTOCOL)\r
2424 {\r
48664931 2425 ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX);\r
4225a882 2426 }\r
504d9df9 2427#endif\r
77f488bb 2428\r
2429 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
2430 {\r
93ba2e01 2431 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
2432 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max);\r
2433 }\r
2434 else\r
2435 {\r
2436 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max,\r
2437 2 * irmp_param.pulse_0_len_min, 2 * irmp_param.pulse_0_len_max);\r
2438 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max,\r
2439 2 * irmp_param.pause_0_len_min, 2 * irmp_param.pause_0_len_max);\r
77f488bb 2440 }\r
46dd89b7 2441\r
504d9df9 2442#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
2443 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)\r
2444 {\r
48664931 2445 ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
2446 ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX);\r
504d9df9 2447 }\r
2448#endif\r
2449\r
48664931 2450 ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param.command_offset);\r
2451 ANALYZE_PRINTF ("command_len: %3d\n", irmp_param.command_end - irmp_param.command_offset);\r
2452 ANALYZE_PRINTF ("complete_len: %3d\n", irmp_param.complete_len);\r
2453 ANALYZE_PRINTF ("stop_bit: %3d\n", irmp_param.stop_bit);\r
2454#endif // ANALYZE\r
4225a882 2455 }\r
2456\r
2457 irmp_bit = 0;\r
2458\r
77f488bb 2459#if IRMP_SUPPORT_MANCHESTER == 1\r
12948cf3 2460 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&\r
2461 irmp_param.protocol != IRMP_RUWIDO_PROTOCOL && // Manchester, but not RUWIDO\r
2462 irmp_param.protocol != IRMP_RC6_PROTOCOL) // Manchester, but not RC6\r
4225a882 2463 {\r
31c1f035 2464 if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max)\r
4225a882 2465 {\r
0f700c8e 2466 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
48664931 2467 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
2468 ANALYZE_NEWLINE ();\r
77f488bb 2469 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1);\r
592411d1 2470 }\r
6f750020 2471 else if (! last_value) // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)\r
592411d1 2472 {\r
0f700c8e 2473 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
592411d1 2474\r
48664931 2475 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
2476 ANALYZE_NEWLINE ();\r
77f488bb 2477 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0);\r
a7054daf 2478 }\r
2479 }\r
2480 else\r
77f488bb 2481#endif // IRMP_SUPPORT_MANCHESTER == 1\r
a7054daf 2482\r
deba2a0a 2483#if IRMP_SUPPORT_SERIAL == 1\r
2484 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)\r
2485 {\r
2486 ; // do nothing\r
2487 }\r
2488 else\r
2489#endif // IRMP_SUPPORT_SERIAL == 1\r
2490\r
2491\r
4225a882 2492#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
2493 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)\r
2494 {\r
0f700c8e 2495 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
4225a882 2496\r
2497 if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)\r
2498 { // pause timings correct for "1"?\r
48664931 2499 ANALYZE_PUTCHAR ('1'); // yes, store 1\r
2500 ANALYZE_NEWLINE ();\r
4225a882 2501 irmp_store_bit (1);\r
2502 }\r
2503 else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)\r
2504 { // pause timings correct for "0"?\r
48664931 2505 ANALYZE_PUTCHAR ('0'); // yes, store 0\r
2506 ANALYZE_NEWLINE ();\r
4225a882 2507 irmp_store_bit (0);\r
2508 }\r
2509 }\r
881dbf79 2510 else\r
4225a882 2511#endif // IRMP_SUPPORT_DENON_PROTOCOL == 1\r
beda975f 2512#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
2513 if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL)\r
2514 {\r
0f700c8e 2515 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
beda975f 2516\r
2517 if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX)\r
2518 { // pause timings correct for "1"?\r
2519 ANALYZE_PUTCHAR ('1'); // yes, store 1\r
2520 ANALYZE_NEWLINE ();\r
2521 irmp_store_bit (1);\r
2522 }\r
2523 else // if (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)\r
2524 { // pause timings correct for "0"?\r
2525 ANALYZE_PUTCHAR ('0'); // yes, store 0\r
2526 ANALYZE_NEWLINE ();\r
2527 irmp_store_bit (0);\r
2528 }\r
2529 }\r
2530 else\r
2531#endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
881dbf79 2532 {\r
2533 ; // else do nothing\r
2534 }\r
4225a882 2535\r
2536 irmp_pulse_time = 1; // set counter to 1, not 0\r
2537 irmp_pause_time = 0;\r
2538 wait_for_start_space = 0;\r
2539 }\r
2540 }\r
2541 else if (wait_for_space) // the data section....\r
2542 { // counting the time of darkness....\r
2543 uint8_t got_light = FALSE;\r
2544\r
2545 if (irmp_input) // still dark?\r
2546 { // yes...\r
2547 if (irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 1)\r
2548 {\r
a42d1ee6 2549 if (\r
2550#if IRMP_SUPPORT_MANCHESTER == 1\r
2551 (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) ||\r
2552#endif\r
2553#if IRMP_SUPPORT_SERIAL == 1\r
deba2a0a 2554 (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) ||\r
a42d1ee6 2555#endif\r
1aee56bc 2556 (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max))\r
4225a882 2557 {\r
48664931 2558#ifdef ANALYZE\r
77f488bb 2559 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
4225a882 2560 {\r
48664931 2561 ANALYZE_PRINTF ("stop bit detected\n");\r
4225a882 2562 }\r
2563#endif\r
2564 irmp_param.stop_bit = 0;\r
2565 }\r
2566 else\r
2567 {\r
93ba2e01 2568 ANALYZE_PRINTF ("error: stop bit timing wrong, irmp_bit = %d, irmp_pulse_time = %d, pulse_0_len_min = %d, pulse_0_len_max = %d\n",\r
2569 irmp_bit, irmp_pulse_time, irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
4225a882 2570\r
1f54e86c 2571// irmp_busy_flag = FALSE;\r
4225a882 2572 irmp_start_bit_detected = 0; // wait for another start bit...\r
2573 irmp_pulse_time = 0;\r
2574 irmp_pause_time = 0;\r
2575 }\r
2576 }\r
2577 else\r
2578 {\r
9547ee89 2579 irmp_pause_time++; // increment counter\r
4225a882 2580\r
2581#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
9547ee89 2582 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && // Sony has a variable number of bits:\r
2583 irmp_pause_time > SIRCS_PAUSE_LEN_MAX && // minimum is 12\r
2584 irmp_bit >= 12 - 1) // pause too long?\r
2585 { // yes, break and close this frame\r
2586 irmp_param.complete_len = irmp_bit + 1; // set new complete length\r
2587 got_light = TRUE; // this is a lie, but helps (generates stop bit)\r
2588 irmp_tmp_address |= (irmp_bit - SIRCS_MINIMUM_DATA_LEN + 1) << 8; // new: store number of additional bits in upper byte of address!\r
2589 irmp_param.command_end = irmp_param.command_offset + irmp_bit + 1; // correct command length\r
2590 irmp_pause_time = SIRCS_PAUSE_LEN_MAX - 1; // correct pause length\r
4225a882 2591 }\r
2592 else\r
2593#endif\r
deba2a0a 2594#if IRMP_SUPPORT_SERIAL == 1\r
a42d1ee6 2595 // NETBOX generates no stop bit, here is the timeout condition:\r
deba2a0a 2596 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) && irmp_param.protocol == IRMP_NETBOX_PROTOCOL &&\r
a42d1ee6 2597 irmp_pause_time >= NETBOX_PULSE_LEN * (NETBOX_COMPLETE_DATA_LEN - irmp_bit))\r
deba2a0a 2598 {\r
2599 got_light = TRUE; // this is a lie, but helps (generates stop bit)\r
2600 }\r
2601 else\r
2602#endif\r
89e8cafb 2603#if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
77f488bb 2604 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit)\r
d155e9ab 2605 {\r
89e8cafb 2606 if (irmp_pause_time > IR60_TIMEOUT_LEN && irmp_bit == 6)\r
2607 {\r
2608 ANALYZE_PRINTF ("Switching to IR60 protocol\n");\r
2609 got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
2610 irmp_param.stop_bit = TRUE; // set flag\r
2611\r
2612 irmp_param.protocol = IRMP_IR60_PROTOCOL; // change protocol\r
2613 irmp_param.complete_len = IR60_COMPLETE_DATA_LEN; // correct complete len\r
2614 irmp_param.address_offset = IR60_ADDRESS_OFFSET;\r
2615 irmp_param.address_end = IR60_ADDRESS_OFFSET + IR60_ADDRESS_LEN;\r
2616 irmp_param.command_offset = IR60_COMMAND_OFFSET;\r
2617 irmp_param.command_end = IR60_COMMAND_OFFSET + IR60_COMMAND_LEN;\r
2618\r
2619 irmp_tmp_command <<= 1;\r
2620 irmp_tmp_command |= first_bit;\r
2621 }\r
31c1f035 2622 else if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2)\r
77f488bb 2623 { // special manchester decoder\r
2624 irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len\r
2625 got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
2626 irmp_param.stop_bit = TRUE; // set flag\r
2627 }\r
2628 else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN)\r
d155e9ab 2629 {\r
48664931 2630 ANALYZE_PRINTF ("Switching to NOKIA protocol\n");\r
77f488bb 2631 irmp_param.protocol = IRMP_NOKIA_PROTOCOL; // change protocol\r
2632 irmp_param.address_offset = NOKIA_ADDRESS_OFFSET;\r
2633 irmp_param.address_end = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN;\r
2634 irmp_param.command_offset = NOKIA_COMMAND_OFFSET;\r
2635 irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN;\r
2636\r
2637 if (irmp_tmp_command & 0x300)\r
2638 {\r
2639 irmp_tmp_address = (irmp_tmp_command >> 8);\r
2640 irmp_tmp_command &= 0xFF;\r
2641 }\r
d155e9ab 2642 }\r
2643 }\r
2644 else\r
2645#endif\r
12948cf3 2646#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
2647 if (irmp_param.protocol == IRMP_RUWIDO_PROTOCOL && !irmp_param.stop_bit)\r
2648 {\r
31c1f035 2649 if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= RUWIDO_COMPLETE_DATA_LEN - 2)\r
12948cf3 2650 { // special manchester decoder\r
2651 irmp_param.complete_len = RUWIDO_COMPLETE_DATA_LEN; // correct complete len\r
2652 got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
2653 irmp_param.stop_bit = TRUE; // set flag\r
2654 }\r
2655 else if (irmp_bit >= RUWIDO_COMPLETE_DATA_LEN)\r
2656 {\r
2657 ANALYZE_PRINTF ("Switching to SIEMENS protocol\n");\r
2658 irmp_param.protocol = IRMP_SIEMENS_PROTOCOL; // change protocol\r
2659 irmp_param.address_offset = SIEMENS_ADDRESS_OFFSET;\r
2660 irmp_param.address_end = SIEMENS_ADDRESS_OFFSET + SIEMENS_ADDRESS_LEN;\r
2661 irmp_param.command_offset = SIEMENS_COMMAND_OFFSET;\r
2662 irmp_param.command_end = SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN;\r
2663\r
2664 // 76543210\r
2665 // RUWIDO: AAAAAAAAACCCCCCCp\r
2666 // SIEMENS: AAAAAAAAAAACCCCCCCCCCp\r
2667 irmp_tmp_address <<= 2;\r
2668 irmp_tmp_address |= (irmp_tmp_command >> 6);\r
2669 irmp_tmp_command &= 0x003F;\r
2670 irmp_tmp_command <<= 4;\r
2671 irmp_tmp_command |= last_value;\r
2672 }\r
2673 }\r
2674 else\r
2675#endif\r
77f488bb 2676#if IRMP_SUPPORT_MANCHESTER == 1\r
2677 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&\r
31c1f035 2678 irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit)\r
77f488bb 2679 { // special manchester decoder\r
a7054daf 2680 got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
2681 irmp_param.stop_bit = TRUE; // set flag\r
2682 }\r
2683 else\r
77f488bb 2684#endif // IRMP_SUPPORT_MANCHESTER == 1\r
504d9df9 2685 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?\r
4225a882 2686 { // yes...\r
2687 if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0)\r
2688 {\r
2689 irmp_bit++;\r
2690 }\r
770a1a9d 2691#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2692 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit\r
2693 {\r
93ba2e01 2694 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);\r
770a1a9d 2695 irmp_param.stop_bit = TRUE; // set flag\r
2696 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol\r
2697 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17\r
2698 irmp_tmp_command = (irmp_tmp_address >> 4); // set command: upper 12 bits are command bits\r
2699 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits\r
2700 irmp_start_bit_detected = 1; // tricky: don't wait for another start bit...\r
2701 }\r
2702#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
35213800 2703\r
2704#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
2705#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
2706 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 32) // it was a NEC stop bit\r
2707 {\r
2708 ANALYZE_PRINTF ("Switching to NEC protocol\n");\r
2709 irmp_param.stop_bit = TRUE; // set flag\r
2710 irmp_param.protocol = IRMP_NEC_PROTOCOL; // switch protocol\r
2711 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17\r
2712\r
2713 // 0123456789ABC0123456789ABC0123456701234567\r
2714 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc\r
2715 // NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc\r
0f700c8e 2716 irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 13; // fm 2012-02-13: 12 -> 13\r
35213800 2717 irmp_tmp_command = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10);\r
2718 }\r
2719#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
2720#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
93ba2e01 2721 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit\r
35213800 2722 {\r
93ba2e01 2723 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);\r
35213800 2724 irmp_param.stop_bit = TRUE; // set flag\r
2725 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol\r
2726 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17\r
2727\r
2728 // 0123456789ABC0123456789ABC0123456701234567\r
2729 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc\r
2730 // JVC: AAAACCCCCCCCCCCC\r
2731 irmp_tmp_command = (irmp_tmp_address >> 4) | (irmp_tmp_address2 << 9); // set command: upper 12 bits are command bits\r
2732 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits\r
2733 }\r
2734#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2735#endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
4225a882 2736 else\r
2737 {\r
48664931 2738 ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);\r
2739 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
4225a882 2740\r
1f54e86c 2741// irmp_busy_flag = FALSE;\r
4225a882 2742 irmp_start_bit_detected = 0; // wait for another start bit...\r
2743 irmp_pulse_time = 0;\r
2744 irmp_pause_time = 0;\r
2745 }\r
2746 }\r
2747 }\r
2748 }\r
2749 else\r
2750 { // got light now!\r
2751 got_light = TRUE;\r
2752 }\r
2753\r
2754 if (got_light)\r
2755 {\r
0f700c8e 2756 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
4225a882 2757\r
77f488bb 2758#if IRMP_SUPPORT_MANCHESTER == 1\r
d823e852 2759 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester\r
4225a882 2760 {\r
31c1f035 2761#if 1\r
2762 if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max */)\r
2763#else // better, but some IR-RCs use asymmetric timings :-/\r
2764 if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max &&\r
2765 irmp_pause_time <= 2 * irmp_param.pause_1_len_max)\r
fc80d688 2766#endif\r
4225a882 2767 {\r
c7a47e89 2768#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2769 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit\r
4225a882 2770 {\r
c7a47e89 2771 ANALYZE_PUTCHAR ('T');\r
2772 if (irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode 6A\r
2773 {\r
2774 irmp_store_bit (1);\r
2775 last_value = 1;\r
2776 }\r
2777 else // RC6 mode 0\r
2778 {\r
2779 irmp_store_bit (0);\r
2780 last_value = 0;\r
2781 }\r
2782 ANALYZE_NEWLINE ();\r
4225a882 2783 }\r
c7a47e89 2784 else\r
2785#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2786 {\r
2787 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
2788 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 );\r
4225a882 2789\r
c7a47e89 2790#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2791 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit\r
2792 {\r
2793 ANALYZE_PUTCHAR ('T');\r
2794 irmp_store_bit (1);\r
2795\r
31c1f035 2796 if (irmp_pause_time > 2 * irmp_param.pause_1_len_max)\r
c7a47e89 2797 {\r
2798 last_value = 0;\r
2799 }\r
2800 else\r
2801 {\r
2802 last_value = 1;\r
2803 }\r
2804 ANALYZE_NEWLINE ();\r
2805 }\r
2806 else\r
77f488bb 2807#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
c7a47e89 2808 {\r
2809 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
2810 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 );\r
6f750020 2811#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
c7a47e89 2812 if (! irmp_param2.protocol)\r
6f750020 2813#endif\r
c7a47e89 2814 {\r
2815 ANALYZE_NEWLINE ();\r
2816 }\r
2817 last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0;\r
2818 }\r
6f750020 2819 }\r
592411d1 2820 }\r
31c1f035 2821 else if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max\r
2822 /* && irmp_pause_time <= 2 * irmp_param.pause_1_len_max */)\r
592411d1 2823 {\r
77f488bb 2824 uint8_t manchester_value;\r
592411d1 2825\r
31c1f035 2826 if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max)\r
592411d1 2827 {\r
77f488bb 2828 manchester_value = last_value ? 0 : 1;\r
2829 last_value = manchester_value;\r
592411d1 2830 }\r
2831 else\r
2832 {\r
77f488bb 2833 manchester_value = last_value;\r
592411d1 2834 }\r
2835\r
48664931 2836 ANALYZE_PUTCHAR (manchester_value + '0');\r
c7a47e89 2837\r
6f750020 2838#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
2839 if (! irmp_param2.protocol)\r
2840#endif\r
2841 {\r
2842 ANALYZE_NEWLINE ();\r
2843 }\r
c7a47e89 2844\r
2845#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2846 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 1) // RC6 mode != 0 ???\r
2847 {\r
2848 ANALYZE_PRINTF ("Switching to RC6A protocol\n");\r
2849 irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG;\r
2850 irmp_param.address_offset = 5;\r
2851 irmp_param.address_end = irmp_param.address_offset + 15;\r
2852 irmp_param.command_offset = irmp_param.address_end + 1; // skip 1 system bit, changes like a toggle bit\r
2853 irmp_param.command_end = irmp_param.command_offset + 16 - 1;\r
9547ee89 2854 irmp_tmp_address = 0;\r
c7a47e89 2855 }\r
2856#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2857\r
77f488bb 2858 irmp_store_bit (manchester_value);\r
a7054daf 2859 }\r
6f750020 2860 else\r
2861 {\r
2862#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2863 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL &&\r
2864 irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX &&\r
2865 ((irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) ||\r
2866 (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)))\r
2867 {\r
2868 ANALYZE_PUTCHAR ('?');\r
d823e852 2869 irmp_param.protocol = 0; // switch to FDC, see below\r
6f750020 2870 }\r
2871 else\r
2872#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2873#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2874 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL &&\r
2875 irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX &&\r
2876 ((irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) ||\r
2877 (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)))\r
2878 {\r
2879 ANALYZE_PUTCHAR ('?');\r
d823e852 2880 irmp_param.protocol = 0; // switch to RCCAR, see below\r
6f750020 2881 }\r
2882 else\r
2883#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2884 {\r
2885 ANALYZE_PUTCHAR ('?');\r
2886 ANALYZE_NEWLINE ();\r
c7a47e89 2887 ANALYZE_PRINTF ("error 3 manchester: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
6f750020 2888 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 2889// irmp_busy_flag = FALSE;\r
6f750020 2890 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
2891 irmp_pause_time = 0;\r
2892 }\r
2893 }\r
2894\r
2895#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2896 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX)\r
2897 {\r
2898 if (irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX)\r
2899 {\r
2900 ANALYZE_PRINTF (" 1 (FDC)\n");\r
2901 irmp_store_bit2 (1);\r
2902 }\r
2903 else if (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)\r
2904 {\r
2905 ANALYZE_PRINTF (" 0 (FDC)\n");\r
2906 irmp_store_bit2 (0);\r
2907 }\r
2908\r
2909 if (! irmp_param.protocol)\r
2910 {\r
2911 ANALYZE_PRINTF ("Switching to FDC protocol\n");\r
2912 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));\r
2913 irmp_param2.protocol = 0;\r
2914 irmp_tmp_address = irmp_tmp_address2;\r
2915 irmp_tmp_command = irmp_tmp_command2;\r
2916 }\r
2917 }\r
2918#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2919#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2920 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX)\r
2921 {\r
2922 if (irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX)\r
2923 {\r
2924 ANALYZE_PRINTF (" 1 (RCCAR)\n");\r
2925 irmp_store_bit2 (1);\r
2926 }\r
2927 else if (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)\r
2928 {\r
2929 ANALYZE_PRINTF (" 0 (RCCAR)\n");\r
2930 irmp_store_bit2 (0);\r
2931 }\r
2932\r
2933 if (! irmp_param.protocol)\r
2934 {\r
2935 ANALYZE_PRINTF ("Switching to RCCAR protocol\n");\r
2936 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));\r
2937 irmp_param2.protocol = 0;\r
2938 irmp_tmp_address = irmp_tmp_address2;\r
2939 irmp_tmp_command = irmp_tmp_command2;\r
2940 }\r
2941 }\r
2942#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
a7054daf 2943\r
77f488bb 2944 last_pause = irmp_pause_time;\r
2945 wait_for_space = 0;\r
a7054daf 2946 }\r
2947 else\r
77f488bb 2948#endif // IRMP_SUPPORT_MANCHESTER == 1\r
2949\r
deba2a0a 2950#if IRMP_SUPPORT_SERIAL == 1\r
2951 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)\r
2952 {\r
2953 while (irmp_bit < irmp_param.complete_len && irmp_pulse_time > irmp_param.pulse_1_len_max)\r
2954 {\r
2955 ANALYZE_PUTCHAR ('1');\r
2956 irmp_store_bit (1);\r
2957\r
2958 if (irmp_pulse_time >= irmp_param.pulse_1_len_min)\r
2959 {\r
2960 irmp_pulse_time -= irmp_param.pulse_1_len_min;\r
2961 }\r
2962 else\r
2963 {\r
2964 irmp_pulse_time = 0;\r
2965 }\r
2966 }\r
2967\r
2968 while (irmp_bit < irmp_param.complete_len && irmp_pause_time > irmp_param.pause_1_len_max)\r
2969 {\r
2970 ANALYZE_PUTCHAR ('0');\r
2971 irmp_store_bit (0);\r
2972\r
2973 if (irmp_pause_time >= irmp_param.pause_1_len_min)\r
2974 {\r
2975 irmp_pause_time -= irmp_param.pause_1_len_min;\r
2976 }\r
2977 else\r
2978 {\r
2979 irmp_pause_time = 0;\r
2980 }\r
2981 }\r
2982 ANALYZE_NEWLINE ();\r
2983 wait_for_space = 0;\r
2984 }\r
2985 else\r
2986#endif // IRMP_SUPPORT_SERIAL == 1\r
a7054daf 2987\r
4225a882 2988#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
2989 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit\r
2990 {\r
2991 if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX &&\r
2992 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)\r
2993 {\r
48664931 2994 ANALYZE_PRINTF ("SYNC\n");\r
4225a882 2995 wait_for_space = 0;\r
2996 irmp_tmp_id = 0;\r
2997 irmp_bit++;\r
2998 }\r
2999 else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX)\r
3000 {\r
5b437ff6 3001 irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL;\r
3002 irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET;\r
3003 irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN;\r
3004 irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN;\r
3005\r
4225a882 3006 if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX)\r
3007 {\r
48664931 3008 ANALYZE_PUTCHAR ('1');\r
3009 ANALYZE_NEWLINE ();\r
4225a882 3010 irmp_store_bit (1);\r
3011 wait_for_space = 0;\r
3012 }\r
3013 else\r
3014 {\r
48664931 3015 ANALYZE_PUTCHAR ('0');\r
3016 ANALYZE_NEWLINE ();\r
4225a882 3017 irmp_store_bit (0);\r
3018 wait_for_space = 0;\r
3019 }\r
3020\r
48664931 3021 ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n");\r
4225a882 3022 }\r
3023 else\r
3024 { // timing incorrect!\r
48664931 3025 ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
3026 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3027// irmp_busy_flag = FALSE;\r
504d9df9 3028 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
4225a882 3029 irmp_pause_time = 0;\r
3030 }\r
4225a882 3031 }\r
3032 else\r
3033#endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL\r
3034\r
fc80d688 3035#if IRMP_SUPPORT_NEC16_PROTOCOL\r
35213800 3036#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
3037 if (irmp_param.protocol == IRMP_NEC42_PROTOCOL &&\r
3038#else // IRMP_SUPPORT_NEC_PROTOCOL instead\r
3039 if (irmp_param.protocol == IRMP_NEC_PROTOCOL &&\r
3040#endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
3041 irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)\r
fc80d688 3042 {\r
3043 ANALYZE_PRINTF ("Switching to NEC16 protocol\n");\r
7644ac04 3044 irmp_param.protocol = IRMP_NEC16_PROTOCOL;\r
35213800 3045 irmp_param.address_offset = NEC16_ADDRESS_OFFSET;\r
3046 irmp_param.address_end = NEC16_ADDRESS_OFFSET + NEC16_ADDRESS_LEN;\r
3047 irmp_param.command_offset = NEC16_COMMAND_OFFSET;\r
3048 irmp_param.command_end = NEC16_COMMAND_OFFSET + NEC16_COMMAND_LEN;\r
3049 irmp_param.complete_len = NEC16_COMPLETE_DATA_LEN;\r
fc80d688 3050 wait_for_space = 0;\r
3051 }\r
3052 else\r
3053#endif // IRMP_SUPPORT_NEC16_PROTOCOL\r
3054\r
504d9df9 3055#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
3056 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)\r
3057 {\r
3058 if (irmp_pulse_time >= BANG_OLUFSEN_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_PULSE_LEN_MAX)\r
3059 {\r
46dd89b7 3060 if (irmp_bit == 1) // Bang & Olufsen: 3rd bit\r
504d9df9 3061 {\r
3062 if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX)\r
3063 {\r
48664931 3064 ANALYZE_PRINTF ("3rd start bit\n");\r
504d9df9 3065 wait_for_space = 0;\r
504d9df9 3066 irmp_bit++;\r
3067 }\r
3068 else\r
d155e9ab 3069 { // timing incorrect!\r
48664931 3070 ANALYZE_PRINTF ("error 3a B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
3071 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3072// irmp_busy_flag = FALSE;\r
46dd89b7 3073 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
504d9df9 3074 irmp_pause_time = 0;\r
3075 }\r
504d9df9 3076 }\r
46dd89b7 3077 else if (irmp_bit == 19) // Bang & Olufsen: trailer bit\r
504d9df9 3078 {\r
3079 if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX)\r
3080 {\r
48664931 3081 ANALYZE_PRINTF ("trailer bit\n");\r
504d9df9 3082 wait_for_space = 0;\r
504d9df9 3083 irmp_bit++;\r
3084 }\r
3085 else\r
46dd89b7 3086 { // timing incorrect!\r
48664931 3087 ANALYZE_PRINTF ("error 3b B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
3088 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3089// irmp_busy_flag = FALSE;\r
46dd89b7 3090 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
504d9df9 3091 irmp_pause_time = 0;\r
3092 }\r
504d9df9 3093 }\r
3094 else\r
3095 {\r
46dd89b7 3096 if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX)\r
3097 { // pulse & pause timings correct for "1"?\r
48664931 3098 ANALYZE_PUTCHAR ('1');\r
3099 ANALYZE_NEWLINE ();\r
504d9df9 3100 irmp_store_bit (1);\r
3101 last_value = 1;\r
3102 wait_for_space = 0;\r
3103 }\r
46dd89b7 3104 else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX)\r
3105 { // pulse & pause timings correct for "0"?\r
48664931 3106 ANALYZE_PUTCHAR ('0');\r
3107 ANALYZE_NEWLINE ();\r
504d9df9 3108 irmp_store_bit (0);\r
3109 last_value = 0;\r
3110 wait_for_space = 0;\r
3111 }\r
3112 else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX)\r
3113 {\r
48664931 3114 ANALYZE_PUTCHAR (last_value + '0');\r
3115 ANALYZE_NEWLINE ();\r
504d9df9 3116 irmp_store_bit (last_value);\r
3117 wait_for_space = 0;\r
3118 }\r
3119 else\r
46dd89b7 3120 { // timing incorrect!\r
48664931 3121 ANALYZE_PRINTF ("error 3c B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
3122 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3123// irmp_busy_flag = FALSE;\r
46dd89b7 3124 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
504d9df9 3125 irmp_pause_time = 0;\r
3126 }\r
3127 }\r
3128 }\r
3129 else\r
46dd89b7 3130 { // timing incorrect!\r
48664931 3131 ANALYZE_PRINTF ("error 3d B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
3132 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3133// irmp_busy_flag = FALSE;\r
46dd89b7 3134 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
504d9df9 3135 irmp_pause_time = 0;\r
3136 }\r
3137 }\r
3138 else\r
3139#endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL\r
3140\r
4225a882 3141 if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max &&\r
3142 irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)\r
3143 { // pulse & pause timings correct for "1"?\r
48664931 3144 ANALYZE_PUTCHAR ('1');\r
3145 ANALYZE_NEWLINE ();\r
4225a882 3146 irmp_store_bit (1);\r
3147 wait_for_space = 0;\r
3148 }\r
3149 else if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max &&\r
3150 irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max)\r
3151 { // pulse & pause timings correct for "0"?\r
48664931 3152 ANALYZE_PUTCHAR ('0');\r
3153 ANALYZE_NEWLINE ();\r
4225a882 3154 irmp_store_bit (0);\r
3155 wait_for_space = 0;\r
3156 }\r
3157 else\r
111d6191 3158#if IRMP_SUPPORT_KATHREIN_PROTOCOL\r
3159\r
3160 if (irmp_param.protocol == IRMP_KATHREIN_PROTOCOL &&\r
3161 irmp_pulse_time >= KATHREIN_1_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_1_PULSE_LEN_MAX &&\r
3162 (((irmp_bit == 8 || irmp_bit == 6) &&\r
3163 irmp_pause_time >= KATHREIN_SYNC_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_SYNC_BIT_PAUSE_LEN_MAX) ||\r
3164 (irmp_bit == 12 &&\r
3165 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)))\r
3166\r
3167 {\r
3168 if (irmp_bit == 8)\r
3169 {\r
3170 irmp_bit++;\r
3171 ANALYZE_PUTCHAR ('S');\r
3172 ANALYZE_NEWLINE ();\r
111d6191 3173 irmp_tmp_command <<= 1;\r
3174 }\r
3175 else\r
3176 {\r
3177 ANALYZE_PUTCHAR ('S');\r
3178 ANALYZE_NEWLINE ();\r
3179 irmp_store_bit (1);\r
3180 }\r
3181 wait_for_space = 0;\r
3182 }\r
3183 else\r
3184#endif // IRMP_SUPPORT_KATHREIN_PROTOCOL\r
4225a882 3185 { // timing incorrect!\r
48664931 3186 ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
3187 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3188// irmp_busy_flag = FALSE;\r
4225a882 3189 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
3190 irmp_pause_time = 0;\r
3191 }\r
3192\r
3193 irmp_pulse_time = 1; // set counter to 1, not 0\r
3194 }\r
3195 }\r
3196 else\r
3197 { // counting the pulse length ...\r
d155e9ab 3198 if (! irmp_input) // still light?\r
4225a882 3199 { // yes...\r
3200 irmp_pulse_time++; // increment counter\r
3201 }\r
3202 else\r
3203 { // now it's dark!\r
3204 wait_for_space = 1; // let's count the time (see above)\r
3205 irmp_pause_time = 1; // set pause counter to 1, not 0\r
3206 }\r
3207 }\r
3208\r
881dbf79 3209 if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received?\r
4225a882 3210 {\r
c7a47e89 3211 if (last_irmp_command == irmp_tmp_command && repetition_len < AUTO_FRAME_REPETITION_LEN)\r
592411d1 3212 {\r
3213 repetition_frame_number++;\r
3214 }\r
3215 else\r
4225a882 3216 {\r
592411d1 3217 repetition_frame_number = 0;\r
3218 }\r
3219\r
3220#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
3221 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame\r
3222 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2))\r
3223 {\r
48664931 3224 ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
c7a47e89 3225 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
3226 repetition_len = 0;\r
592411d1 3227 }\r
3228 else\r
3229#endif\r
3230\r
770a1a9d 3231#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
3232 // if KASEIKYO protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame\r
3233 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1)\r
3234 {\r
3235 ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
c7a47e89 3236 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
3237 repetition_len = 0;\r
770a1a9d 3238 }\r
3239 else\r
3240#endif\r
3241\r
592411d1 3242#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
3243 // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame\r
3244 if (irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL && (repetition_frame_number & 0x01))\r
3245 {\r
48664931 3246 ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
c7a47e89 3247 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
3248 repetition_len = 0;\r
592411d1 3249 }\r
3250 else\r
3251#endif\r
3252\r
3253#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1\r
d155e9ab 3254 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame\r
592411d1 3255 if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01))\r
3256 {\r
48664931 3257 ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
c7a47e89 3258 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
3259 repetition_len = 0;\r
4225a882 3260 }\r
3261 else\r
592411d1 3262#endif\r
3263\r
4225a882 3264 {\r
0f700c8e 3265 ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit);\r
4225a882 3266 irmp_ir_detected = TRUE;\r
3267\r
3268#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
3269 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)\r
3270 { // check for repetition frame\r
3271 if ((~irmp_tmp_command & 0x3FF) == last_irmp_denon_command) // command bits must be inverted\r
3272 {\r
3273 irmp_tmp_command = last_irmp_denon_command; // use command received before!\r
3274\r
3275 irmp_protocol = irmp_param.protocol; // store protocol\r
3276 irmp_address = irmp_tmp_address; // store address\r
3277 irmp_command = irmp_tmp_command ; // store command\r
3278 }\r
3279 else\r
3280 {\r
48664931 3281 ANALYZE_PRINTF ("waiting for inverted command repetition\n");\r
4225a882 3282 irmp_ir_detected = FALSE;\r
3283 last_irmp_denon_command = irmp_tmp_command;\r
3284 }\r
3285 }\r
3286 else\r
3287#endif // IRMP_SUPPORT_DENON_PROTOCOL\r
592411d1 3288\r
3289#if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1\r
d155e9ab 3290 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff)\r
3291 { // Grundig start frame?\r
48664931 3292 ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");\r
592411d1 3293 irmp_ir_detected = FALSE;\r
592411d1 3294 }\r
3295 else\r
d155e9ab 3296#endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL\r
3297\r
3298#if IRMP_SUPPORT_NOKIA_PROTOCOL == 1\r
3299 if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe)\r
3300 { // Nokia start frame?\r
48664931 3301 ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n");\r
d155e9ab 3302 irmp_ir_detected = FALSE;\r
3303 }\r
3304 else\r
3305#endif // IRMP_SUPPORT_NOKIA_PROTOCOL\r
4225a882 3306 {\r
cb8474cc 3307#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
3308 if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame\r
3309 {\r
c7a47e89 3310 if (repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)\r
6db2522c 3311 {\r
c7a47e89 3312 ANALYZE_PRINTF ("Detected NEC repetition frame, repetition_len = %d\n", repetition_len);\r
6db2522c 3313 irmp_tmp_address = last_irmp_address; // address is last address\r
3314 irmp_tmp_command = last_irmp_command; // command is last command\r
3315 irmp_flags |= IRMP_FLAG_REPETITION;\r
c7a47e89 3316 repetition_len = 0;\r
6db2522c 3317 }\r
3318 else\r
3319 {\r
c7a47e89 3320 ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, repetition_len = %d > %d\n",\r
3321 repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);\r
6db2522c 3322 irmp_ir_detected = FALSE;\r
3323 }\r
cb8474cc 3324 }\r
4225a882 3325#endif // IRMP_SUPPORT_NEC_PROTOCOL\r
770a1a9d 3326\r
3327#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
3328 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)\r
3329 {\r
3330 uint8_t xor;\r
3331 // ANALYZE_PRINTF ("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",\r
3332 // xor_check[0], xor_check[1], xor_check[2], xor_check[3], xor_check[4], xor_check[5]);\r
3333\r
3334 xor = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4);\r
3335\r
3336 if (xor != (xor_check[2] & 0x0F))\r
3337 {\r
3338 ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor, xor_check[2] & 0x0F);\r
3339 irmp_ir_detected = FALSE;\r
3340 }\r
3341\r
3342 xor = xor_check[2] ^ xor_check[3] ^ xor_check[4];\r
3343\r
3344 if (xor != xor_check[5])\r
3345 {\r
3346 ANALYZE_PRINTF ("error 4: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, xor_check[5]);\r
3347 irmp_ir_detected = FALSE;\r
3348 }\r
0f700c8e 3349\r
3350 irmp_flags |= genre2; // write the genre2 bits into MSB of the flag byte\r
770a1a9d 3351 }\r
3352#endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
3353\r
c7a47e89 3354#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
3355 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6?\r
3356 {\r
3357 irmp_protocol = IRMP_RC6A_PROTOCOL;\r
3358 }\r
3359 else\r
3360#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
3361\r
4225a882 3362 irmp_protocol = irmp_param.protocol;\r
d823e852 3363\r
3364#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
3365 if (irmp_param.protocol == IRMP_FDC_PROTOCOL)\r
3366 {\r
3367 if (irmp_tmp_command & 0x000F) // released key?\r
3368 {\r
3369 irmp_tmp_command = (irmp_tmp_command >> 4) | 0x80; // yes, set bit 7\r
3370 }\r
3371 else\r
3372 {\r
3373 irmp_tmp_command >>= 4; // no, it's a pressed key\r
3374 }\r
3375 irmp_tmp_command |= (irmp_tmp_address << 2) & 0x0F00; // 000000CCCCAAAAAA -> 0000CCCC00000000\r
3376 irmp_tmp_address &= 0x003F;\r
3377 }\r
3378#endif\r
3379\r
4225a882 3380 irmp_address = irmp_tmp_address; // store address\r
3381#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
03780b34 3382 if (irmp_param.protocol == IRMP_NEC_PROTOCOL)\r
3383 {\r
3384 last_irmp_address = irmp_tmp_address; // store as last address, too\r
3385 }\r
4225a882 3386#endif\r
3387\r
3388#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
6f750020 3389 if (irmp_param.protocol == IRMP_RC5_PROTOCOL)\r
3390 {\r
3391 irmp_tmp_command |= rc5_cmd_bit6; // store bit 6\r
3392 }\r
4225a882 3393#endif\r
3394 irmp_command = irmp_tmp_command; // store command\r
3395\r
3396#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
3397 irmp_id = irmp_tmp_id;\r
3398#endif\r
3399 }\r
3400 }\r
3401\r
3402 if (irmp_ir_detected)\r
3403 {\r
03780b34 3404 if (last_irmp_command == irmp_tmp_command &&\r
3405 last_irmp_address == irmp_tmp_address &&\r
c7a47e89 3406 repetition_len < IRMP_KEY_REPETITION_LEN)\r
4225a882 3407 {\r
3408 irmp_flags |= IRMP_FLAG_REPETITION;\r
3409 }\r
3410\r
3411 last_irmp_address = irmp_tmp_address; // store as last address, too\r
3412 last_irmp_command = irmp_tmp_command; // store as last command, too\r
3413\r
c7a47e89 3414 repetition_len = 0;\r
4225a882 3415 }\r
879b06c2 3416 else\r
3417 {\r
48664931 3418 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
879b06c2 3419 }\r
4225a882 3420\r
1f54e86c 3421// irmp_busy_flag = FALSE;\r
4225a882 3422 irmp_start_bit_detected = 0; // and wait for next start bit\r
3423 irmp_tmp_command = 0;\r
3424 irmp_pulse_time = 0;\r
3425 irmp_pause_time = 0;\r
770a1a9d 3426\r
3427#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
3428 if (irmp_protocol == IRMP_JVC_PROTOCOL) // the stop bit of JVC frame is also start bit of next frame\r
3429 { // set pulse time here!\r
3430 irmp_pulse_time = ((uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME));\r
3431 }\r
3432#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
4225a882 3433 }\r
3434 }\r
3435 }\r
879b06c2 3436 return (irmp_ir_detected);\r
4225a882 3437}\r
3438\r
48664931 3439#ifdef ANALYZE\r
4225a882 3440\r
2eab5ec9 3441/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
3442 * main functions - for Unix/Linux + Windows only!\r
3443 *\r
3444 * AVR: see main.c!\r
3445 *\r
3446 * Compile it under linux with:\r
3447 * cc irmp.c -o irmp\r
3448 *\r
3449 * usage: ./irmp [-v|-s|-a|-l|-p] < file\r
3450 *\r
3451 * options:\r
3452 * -v verbose\r
3453 * -s silent\r
3454 * -a analyze\r
3455 * -l list pulse/pauses\r
3456 * -p print timings\r
3457 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
3458 */\r
4225a882 3459\r
fef942f6 3460static void\r
3461print_timings (void)\r
3462{\r
c7a47e89 3463 printf ("IRMP_TIMEOUT_LEN: %d [%d byte(s)]\n", IRMP_TIMEOUT_LEN, sizeof (PAUSE_LEN));\r
2eab5ec9 3464 printf ("IRMP_KEY_REPETITION_LEN %d\n", IRMP_KEY_REPETITION_LEN);\r
3465 puts ("");\r
6f750020 3466 printf ("PROTOCOL S S-PULSE S-PAUSE PULSE-0 PAUSE-0 PULSE-1 PAUSE-1\n");\r
fef942f6 3467 printf ("====================================================================================\n");\r
6f750020 3468 printf ("SIRCS 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3469 SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX, SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX,\r
3470 SIRCS_0_PULSE_LEN_MIN, SIRCS_0_PULSE_LEN_MAX, SIRCS_PAUSE_LEN_MIN, SIRCS_PAUSE_LEN_MAX,\r
3471 SIRCS_1_PULSE_LEN_MIN, SIRCS_1_PULSE_LEN_MAX, SIRCS_PAUSE_LEN_MIN, SIRCS_PAUSE_LEN_MAX);\r
3472\r
3473 printf ("NEC 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3474 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX,\r
3475 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX,\r
3476 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_1_PAUSE_LEN_MIN, NEC_1_PAUSE_LEN_MAX);\r
3477\r
3478 printf ("NEC (rep) 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3479 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX,\r
3480 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX,\r
3481 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_1_PAUSE_LEN_MIN, NEC_1_PAUSE_LEN_MAX);\r
3482\r
3483 printf ("SAMSUNG 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3484 SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX, SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX,\r
3485 SAMSUNG_PULSE_LEN_MIN, SAMSUNG_PULSE_LEN_MAX, SAMSUNG_0_PAUSE_LEN_MIN, SAMSUNG_0_PAUSE_LEN_MAX,\r
3486 SAMSUNG_PULSE_LEN_MIN, SAMSUNG_PULSE_LEN_MAX, SAMSUNG_1_PAUSE_LEN_MIN, SAMSUNG_1_PAUSE_LEN_MAX);\r
3487\r
3488 printf ("MATSUSHITA 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3489 MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX, MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX,\r
3490 MATSUSHITA_PULSE_LEN_MIN, MATSUSHITA_PULSE_LEN_MAX, MATSUSHITA_0_PAUSE_LEN_MIN, MATSUSHITA_0_PAUSE_LEN_MAX,\r
3491 MATSUSHITA_PULSE_LEN_MIN, MATSUSHITA_PULSE_LEN_MAX, MATSUSHITA_1_PAUSE_LEN_MIN, MATSUSHITA_1_PAUSE_LEN_MAX);\r
3492\r
3493 printf ("KASEIKYO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3494 KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX, KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX,\r
3495 KASEIKYO_PULSE_LEN_MIN, KASEIKYO_PULSE_LEN_MAX, KASEIKYO_0_PAUSE_LEN_MIN, KASEIKYO_0_PAUSE_LEN_MAX,\r
3496 KASEIKYO_PULSE_LEN_MIN, KASEIKYO_PULSE_LEN_MAX, KASEIKYO_1_PAUSE_LEN_MIN, KASEIKYO_1_PAUSE_LEN_MAX);\r
3497\r
3498 printf ("RECS80 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3499 RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX, RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX,\r
3500 RECS80_PULSE_LEN_MIN, RECS80_PULSE_LEN_MAX, RECS80_0_PAUSE_LEN_MIN, RECS80_0_PAUSE_LEN_MAX,\r
3501 RECS80_PULSE_LEN_MIN, RECS80_PULSE_LEN_MAX, RECS80_1_PAUSE_LEN_MIN, RECS80_1_PAUSE_LEN_MAX);\r
3502\r
3503 printf ("RC5 1 %3d - %3d %3d - %3d %3d - %3d\n",\r
3504 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
3505 RC5_BIT_LEN_MIN, RC5_BIT_LEN_MAX);\r
3506\r
3507 printf ("DENON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3508 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,\r
3509 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX,\r
3510 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX);\r
3511\r
beda975f 3512 printf ("THOMSON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3513 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX,\r
3514 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX,\r
3515 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX);\r
3516\r
c7a47e89 3517 printf ("RC6 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
6f750020 3518 RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX, RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX,\r
c7a47e89 3519 RC6_BIT_PULSE_LEN_MIN, RC6_BIT_PULSE_LEN_MAX, RC6_BIT_PAUSE_LEN_MIN, RC6_BIT_PAUSE_LEN_MAX);\r
6f750020 3520\r
3521 printf ("RECS80EXT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3522 RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX, RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX,\r
3523 RECS80EXT_PULSE_LEN_MIN, RECS80EXT_PULSE_LEN_MAX, RECS80EXT_0_PAUSE_LEN_MIN, RECS80EXT_0_PAUSE_LEN_MAX,\r
3524 RECS80EXT_PULSE_LEN_MIN, RECS80EXT_PULSE_LEN_MAX, RECS80EXT_1_PAUSE_LEN_MIN, RECS80EXT_1_PAUSE_LEN_MAX);\r
3525\r
3526 printf ("NUBERT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3527 NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX, NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX,\r
3528 NUBERT_0_PULSE_LEN_MIN, NUBERT_0_PULSE_LEN_MAX, NUBERT_0_PAUSE_LEN_MIN, NUBERT_0_PAUSE_LEN_MAX,\r
3529 NUBERT_1_PULSE_LEN_MIN, NUBERT_1_PULSE_LEN_MAX, NUBERT_1_PAUSE_LEN_MIN, NUBERT_1_PAUSE_LEN_MAX);\r
3530\r
3531 printf ("BANG_OLUFSEN 1 %3d - %3d %3d - %3d\n",\r
3532 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,\r
3533 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);\r
3534\r
2eab5ec9 3535 printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n",\r
3536 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,\r
3537 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);\r
3538\r
6f750020 3539 printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n",\r
3540 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,\r
3541 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);\r
3542\r
3543 printf ("BANG_OLUFSEN 4 %3d - %3d %3d - %3d\n",\r
3544 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,\r
3545 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);\r
3546\r
3547 printf ("BANG_OLUFSEN - %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3548 BANG_OLUFSEN_PULSE_LEN_MIN, BANG_OLUFSEN_PULSE_LEN_MAX, BANG_OLUFSEN_0_PAUSE_LEN_MIN, BANG_OLUFSEN_0_PAUSE_LEN_MAX,\r
3549 BANG_OLUFSEN_PULSE_LEN_MIN, BANG_OLUFSEN_PULSE_LEN_MAX, BANG_OLUFSEN_1_PAUSE_LEN_MIN, BANG_OLUFSEN_1_PAUSE_LEN_MAX);\r
3550\r
3551 printf ("GRUNDIG/NOKIA 1 %3d - %3d %3d - %3d %3d - %3d\n",\r
89e8cafb 3552 GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX,\r
3553 GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX,\r
3554 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_BIT_LEN_MAX);\r
6f750020 3555\r
12948cf3 3556 printf ("SIEMENS/RUWIDO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3557 SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,\r
3558 SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX,\r
3559 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX,\r
3560 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX,\r
31c1f035 3561 2 * SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX,\r
3562 2 * SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX);\r
6f750020 3563\r
3564 printf ("FDC 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3565 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX, FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX,\r
3566 FDC_PULSE_LEN_MIN, FDC_PULSE_LEN_MAX, FDC_0_PAUSE_LEN_MIN, FDC_0_PAUSE_LEN_MAX,\r
3567 FDC_PULSE_LEN_MIN, FDC_PULSE_LEN_MAX, FDC_1_PAUSE_LEN_MIN, FDC_1_PAUSE_LEN_MAX);\r
3568\r
3569 printf ("RCCAR 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3570 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX, RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX,\r
3571 RCCAR_PULSE_LEN_MIN, RCCAR_PULSE_LEN_MAX, RCCAR_0_PAUSE_LEN_MIN, RCCAR_0_PAUSE_LEN_MAX,\r
3572 RCCAR_PULSE_LEN_MIN, RCCAR_PULSE_LEN_MAX, RCCAR_1_PAUSE_LEN_MIN, RCCAR_1_PAUSE_LEN_MAX);\r
9405f84a 3573\r
3574 printf ("NIKON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3575 NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX, NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX,\r
3576 NIKON_PULSE_LEN_MIN, NIKON_PULSE_LEN_MAX, NIKON_0_PAUSE_LEN_MIN, NIKON_0_PAUSE_LEN_MAX,\r
3577 NIKON_PULSE_LEN_MIN, NIKON_PULSE_LEN_MAX, NIKON_1_PAUSE_LEN_MIN, NIKON_1_PAUSE_LEN_MAX);\r
f50e01e7 3578\r
3579 printf ("LEGO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3580 LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX, LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX,\r
3581 LEGO_PULSE_LEN_MIN, LEGO_PULSE_LEN_MAX, LEGO_0_PAUSE_LEN_MIN, LEGO_0_PAUSE_LEN_MAX,\r
3582 LEGO_PULSE_LEN_MIN, LEGO_PULSE_LEN_MAX, LEGO_1_PAUSE_LEN_MIN, LEGO_1_PAUSE_LEN_MAX);\r
3583\r
fef942f6 3584}\r
3585\r
77f488bb 3586void\r
48664931 3587print_spectrum (char * text, int * buf, int is_pulse)\r
77f488bb 3588{\r
3589 int i;\r
3590 int j;\r
48664931 3591 int min;\r
3592 int max;\r
3593 int max_value = 0;\r
77f488bb 3594 int value;\r
3595 int sum = 0;\r
3596 int counter = 0;\r
3597 double average = 0;\r
48664931 3598 double tolerance;\r
77f488bb 3599\r
48664931 3600 puts ("-------------------------------------------------------------------------------");\r
77f488bb 3601 printf ("%s:\n", text);\r
3602\r
3603 for (i = 0; i < 256; i++)\r
3604 {\r
48664931 3605 if (buf[i] > max_value)\r
77f488bb 3606 {\r
48664931 3607 max_value = buf[i];\r
77f488bb 3608 }\r
3609 }\r
3610\r
53c11f07 3611 for (i = 1; i < 100; i++)\r
77f488bb 3612 {\r
3613 if (buf[i] > 0)\r
3614 {\r
3615 printf ("%3d ", i);\r
48664931 3616 value = (buf[i] * 60) / max_value;\r
77f488bb 3617\r
3618 for (j = 0; j < value; j++)\r
3619 {\r
3620 putchar ('o');\r
3621 }\r
3622 printf (" %d\n", buf[i]);\r
3623\r
3624 sum += i * buf[i];\r
3625 counter += buf[i];\r
3626 }\r
3627 else\r
3628 {\r
48664931 3629 max = i - 1;\r
3630\r
77f488bb 3631 if (counter > 0)\r
3632 {\r
3633 average = (float) sum / (float) counter;\r
48664931 3634\r
3635 if (is_pulse)\r
3636 {\r
3637 printf ("pulse ");\r
3638 }\r
3639 else\r
3640 {\r
3641 printf ("pause ");\r
3642 }\r
3643\r
3644 printf ("avg: %4.1f=%6.1f us, ", average, (1000000. * average) / (float) F_INTERRUPTS);\r
3645 printf ("min: %2d=%6.1f us, ", min, (1000000. * min) / (float) F_INTERRUPTS);\r
3646 printf ("max: %2d=%6.1f us, ", max, (1000000. * max) / (float) F_INTERRUPTS);\r
3647\r
3648 tolerance = (max - average);\r
3649\r
3650 if (average - min > tolerance)\r
3651 {\r
3652 tolerance = average - min;\r
3653 }\r
3654\r
3655 tolerance = tolerance * 100 / average;\r
3656 printf ("tol: %4.1f%%\n", tolerance);\r
77f488bb 3657 }\r
48664931 3658\r
77f488bb 3659 counter = 0;\r
3660 sum = 0;\r
48664931 3661 min = i + 1;\r
77f488bb 3662 }\r
3663 }\r
3664}\r
3665\r
d823e852 3666#define STATE_LEFT_SHIFT 0x01\r
3667#define STATE_RIGHT_SHIFT 0x02\r
3668#define STATE_LEFT_CTRL 0x04\r
3669#define STATE_LEFT_ALT 0x08\r
3670#define STATE_RIGHT_ALT 0x10\r
3671\r
3672#define KEY_ESCAPE 0x1B // keycode = 0x006e\r
3673#define KEY_MENUE 0x80 // keycode = 0x0070\r
3674#define KEY_BACK 0x81 // keycode = 0x0071\r
3675#define KEY_FORWARD 0x82 // keycode = 0x0072\r
3676#define KEY_ADDRESS 0x83 // keycode = 0x0073\r
3677#define KEY_WINDOW 0x84 // keycode = 0x0074\r
3678#define KEY_1ST_PAGE 0x85 // keycode = 0x0075\r
3679#define KEY_STOP 0x86 // keycode = 0x0076\r
3680#define KEY_MAIL 0x87 // keycode = 0x0077\r
3681#define KEY_FAVORITES 0x88 // keycode = 0x0078\r
c6ade1d2 3682#define KEY_NEW_PAGE 0x89 // keycode = 0x0079\r
3683#define KEY_SETUP 0x8A // keycode = 0x007a\r
3684#define KEY_FONT 0x8B // keycode = 0x007b\r
3685#define KEY_PRINT 0x8C // keycode = 0x007c\r
3686#define KEY_ON_OFF 0x8E // keycode = 0x007c\r
3687\r
3688#define KEY_INSERT 0x90 // keycode = 0x004b\r
3689#define KEY_DELETE 0x91 // keycode = 0x004c\r
3690#define KEY_LEFT 0x92 // keycode = 0x004f\r
3691#define KEY_HOME 0x93 // keycode = 0x0050\r
3692#define KEY_END 0x94 // keycode = 0x0051\r
3693#define KEY_UP 0x95 // keycode = 0x0053\r
3694#define KEY_DOWN 0x96 // keycode = 0x0054\r
3695#define KEY_PAGE_UP 0x97 // keycode = 0x0055\r
3696#define KEY_PAGE_DOWN 0x98 // keycode = 0x0056\r
3697#define KEY_RIGHT 0x99 // keycode = 0x0059\r
3698#define KEY_MOUSE_1 0x9E // keycode = 0x0400\r
3699#define KEY_MOUSE_2 0x9F // keycode = 0x0800\r
d823e852 3700\r
3701static uint8_t\r
3702get_fdc_key (uint16_t cmd)\r
3703{\r
3704 static uint8_t key_table[128] =\r
3705 {\r
3706 // 0 1 2 3 4 5 6 7 8 9 A B C D E F\r
3707