]> cloudbase.mooo.com Git - irmp.git/blame - irmp.c
Version 2.0.2: improved jvc decoder (type 2 and 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 7918.
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
93ba2e01 6 * $Id: irmp.c,v 1.110 2011/09/22 10:19:44 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
4225a882 1739#endif\r
1740\r
4225a882 1741/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
1742 * store bit\r
1743 * @details store bit in temp address or temp command\r
1744 * @param value to store: 0 or 1\r
1745 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
1746 */\r
d823e852 1747// verhindert, dass irmp_store_bit() inline compiliert wird:\r
1748// static void irmp_store_bit (uint8_t) __attribute__ ((noinline));\r
1749\r
4225a882 1750static void\r
1751irmp_store_bit (uint8_t value)\r
1752{\r
89e8cafb 1753#if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
1754 if (irmp_bit == 0 && irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL)\r
1755 {\r
1756 first_bit = value;\r
1757 }\r
1758 else\r
1759#endif\r
770a1a9d 1760\r
4225a882 1761 if (irmp_bit >= irmp_param.address_offset && irmp_bit < irmp_param.address_end)\r
1762 {\r
1763 if (irmp_param.lsb_first)\r
1764 {\r
1765 irmp_tmp_address |= (((uint16_t) (value)) << (irmp_bit - irmp_param.address_offset)); // CV wants cast\r
1766 }\r
1767 else\r
1768 {\r
1769 irmp_tmp_address <<= 1;\r
1770 irmp_tmp_address |= value;\r
1771 }\r
1772 }\r
1773 else if (irmp_bit >= irmp_param.command_offset && irmp_bit < irmp_param.command_end)\r
1774 {\r
1775 if (irmp_param.lsb_first)\r
1776 {\r
1777 irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast\r
1778 }\r
1779 else\r
1780 {\r
1781 irmp_tmp_command <<= 1;\r
1782 irmp_tmp_command |= value;\r
1783 }\r
1784 }\r
770a1a9d 1785\r
35213800 1786#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
1787 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit >= 13 && irmp_bit < 26)\r
1788 {\r
1789 irmp_tmp_address2 |= (((uint16_t) (value)) << (irmp_bit - 13)); // CV wants cast\r
1790 }\r
1791#endif\r
1792\r
4225a882 1793#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
1794 else if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit >= SAMSUNG_ID_OFFSET && irmp_bit < SAMSUNG_ID_OFFSET + SAMSUNG_ID_LEN)\r
1795 {\r
1796 irmp_tmp_id |= (((uint16_t) (value)) << (irmp_bit - SAMSUNG_ID_OFFSET)); // store with LSB first\r
1797 }\r
1798#endif\r
770a1a9d 1799\r
1800#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
1801 else if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit >= 20 && irmp_bit < 24)\r
1802 {\r
1803 irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8)); // store 4 system bits in upper nibble with LSB first\r
1804 }\r
1805\r
1806 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)\r
1807 {\r
1808 if (value)\r
1809 {\r
1810 xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);\r
1811 }\r
1812 else\r
1813 {\r
1814 xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));\r
1815 }\r
1816 }\r
1817\r
1818#endif\r
1819\r
4225a882 1820 irmp_bit++;\r
1821}\r
1822\r
6f750020 1823/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
1824 * store bit\r
1825 * @details store bit in temp address or temp command\r
1826 * @param value to store: 0 or 1\r
1827 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
1828 */\r
1829#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
1830static void\r
1831irmp_store_bit2 (uint8_t value)\r
1832{\r
1833 uint8_t irmp_bit2;\r
1834\r
1835 if (irmp_param.protocol)\r
1836 {\r
1837 irmp_bit2 = irmp_bit - 2;\r
1838 }\r
1839 else\r
1840 {\r
1841 irmp_bit2 = irmp_bit - 1;\r
1842 }\r
1843\r
1844 if (irmp_bit2 >= irmp_param2.address_offset && irmp_bit2 < irmp_param2.address_end)\r
1845 {\r
1846 irmp_tmp_address2 |= (((uint16_t) (value)) << (irmp_bit2 - irmp_param2.address_offset)); // CV wants cast\r
1847 }\r
1848 else if (irmp_bit2 >= irmp_param2.command_offset && irmp_bit2 < irmp_param2.command_end)\r
1849 {\r
1850 irmp_tmp_command2 |= (((uint16_t) (value)) << (irmp_bit2 - irmp_param2.command_offset)); // CV wants cast\r
1851 }\r
1852}\r
1853#endif // IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
1854\r
4225a882 1855/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
1856 * ISR routine\r
1857 * @details ISR routine, called 10000 times per second\r
1858 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
1859 */\r
879b06c2 1860uint8_t\r
4225a882 1861irmp_ISR (void)\r
1862{\r
48664931 1863 static uint8_t irmp_start_bit_detected; // flag: start bit detected\r
1864 static uint8_t wait_for_space; // flag: wait for data bit space\r
1865 static uint8_t wait_for_start_space; // flag: wait for start bit space\r
1866 static uint8_t irmp_pulse_time; // count bit time for pulse\r
1867 static PAUSE_LEN irmp_pause_time; // count bit time for pause\r
1868 static uint16_t last_irmp_address = 0xFFFF; // save last irmp address to recognize key repetition\r
1869 static uint16_t last_irmp_command = 0xFFFF; // save last irmp command to recognize key repetition\r
c7a47e89 1870 static uint16_t repetition_len; // SIRCS repeats frame 2-5 times with 45 ms pause\r
48664931 1871 static uint8_t repetition_frame_number;\r
4225a882 1872#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
48664931 1873 static uint16_t last_irmp_denon_command; // save last irmp command to recognize DENON frame repetition\r
4225a882 1874#endif\r
1875#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
48664931 1876 static uint8_t rc5_cmd_bit6; // bit 6 of RC5 command is the inverted 2nd start bit\r
4225a882 1877#endif\r
77f488bb 1878#if IRMP_SUPPORT_MANCHESTER == 1\r
48664931 1879 static PAUSE_LEN last_pause; // last pause value\r
504d9df9 1880#endif\r
77f488bb 1881#if IRMP_SUPPORT_MANCHESTER == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
48664931 1882 static uint8_t last_value; // last bit value\r
4225a882 1883#endif\r
48664931 1884 uint8_t irmp_input; // input value\r
4225a882 1885\r
48664931 1886#ifdef ANALYZE\r
592411d1 1887 time_counter++;\r
1888#endif\r
1889\r
4225a882 1890 irmp_input = input(IRMP_PIN);\r
1891\r
7644ac04 1892#if IRMP_USE_CALLBACK == 1\r
1893 if (irmp_callback_ptr)\r
1894 {\r
1895 static uint8_t last_inverted_input;\r
1896\r
1897 if (last_inverted_input != !irmp_input)\r
1898 {\r
1899 (*irmp_callback_ptr) (! irmp_input);\r
1900 last_inverted_input = !irmp_input;\r
1901 }\r
1902 }\r
1903#endif // IRMP_USE_CALLBACK == 1\r
1904\r
d155e9ab 1905 irmp_log(irmp_input); // log ir signal, if IRMP_LOGGING defined\r
4225a882 1906\r
1907 if (! irmp_ir_detected) // ir code already detected?\r
1908 { // no...\r
1909 if (! irmp_start_bit_detected) // start bit detected?\r
1910 { // no...\r
d155e9ab 1911 if (! irmp_input) // receiving burst?\r
4225a882 1912 { // yes...\r
1f54e86c 1913// irmp_busy_flag = TRUE;\r
48664931 1914#ifdef ANALYZE\r
d155e9ab 1915 if (! irmp_pulse_time)\r
1916 {\r
48664931 1917 ANALYZE_PRINTF("%8d [starting pulse]\n", time_counter);\r
d155e9ab 1918 }\r
1919#endif\r
4225a882 1920 irmp_pulse_time++; // increment counter\r
1921 }\r
1922 else\r
1923 { // no...\r
1924 if (irmp_pulse_time) // it's dark....\r
1925 { // set flags for counting the time of darkness...\r
1926 irmp_start_bit_detected = 1;\r
1927 wait_for_start_space = 1;\r
1928 wait_for_space = 0;\r
1929 irmp_tmp_command = 0;\r
1930 irmp_tmp_address = 0;\r
6f750020 1931\r
35213800 1932#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
6f750020 1933 irmp_tmp_command2 = 0;\r
1934 irmp_tmp_address2 = 0;\r
1935#endif\r
1936\r
4225a882 1937 irmp_bit = 0xff;\r
1938 irmp_pause_time = 1; // 1st pause: set to 1, not to 0!\r
1939#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
1940 rc5_cmd_bit6 = 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame!\r
1941#endif\r
1942 }\r
1943 else\r
1944 {\r
c7a47e89 1945 if (repetition_len < 0xFFFF) // avoid overflow of counter\r
6db2522c 1946 {\r
c7a47e89 1947 repetition_len++;\r
6db2522c 1948 }\r
4225a882 1949 }\r
1950 }\r
1951 }\r
1952 else\r
1953 {\r
1954 if (wait_for_start_space) // we have received start bit...\r
1955 { // ...and are counting the time of darkness\r
1956 if (irmp_input) // still dark?\r
1957 { // yes\r
1958 irmp_pause_time++; // increment counter\r
1959\r
9405f84a 1960#if IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
1961 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
1962 irmp_pause_time > IRMP_TIMEOUT_NIKON_LEN)\r
1963#else\r
504d9df9 1964 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?\r
9405f84a 1965#endif\r
4225a882 1966 { // yes...\r
c7a47e89 1967#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
1968 if (irmp_protocol == IRMP_JVC_PROTOCOL) // don't show eror if JVC protocol, irmp_pulse_time has been set below!\r
1969 {\r
1970 ;\r
1971 }\r
1972 else\r
1973#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
1974 {\r
1975 ANALYZE_PRINTF ("%8d error 1: pause after start bit pulse %d too long: %d\n", time_counter, irmp_pulse_time, irmp_pause_time);\r
1976 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1977 }\r
1f54e86c 1978// irmp_busy_flag = FALSE;\r
4225a882 1979 irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit\r
1980 irmp_pulse_time = 0;\r
1981 irmp_pause_time = 0;\r
1982 }\r
1983 }\r
1984 else\r
1985 { // receiving first data pulse!\r
46dd89b7 1986 IRMP_PARAMETER * irmp_param_p = (IRMP_PARAMETER *) 0;\r
1987\r
6f750020 1988#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
1989 irmp_param2.protocol = 0;\r
1990#endif\r
1991\r
c7a47e89 1992 ANALYZE_PRINTF ("%8d [start-bit: pulse = %2d, pause = %2d]\n", time_counter, irmp_pulse_time, irmp_pause_time);\r
4225a882 1993\r
1994#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
1995 if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX &&\r
1996 irmp_pause_time >= SIRCS_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIRCS_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 1997 { // it's SIRCS\r
48664931 1998 ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 1999 SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX,\r
2000 SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2001 irmp_param_p = (IRMP_PARAMETER *) (IRMP_PARAMETER *) &sircs_param;\r
4225a882 2002 }\r
2003 else\r
2004#endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
2005\r
770a1a9d 2006#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2007 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame\r
2008 irmp_pulse_time >= JVC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= JVC_START_BIT_PULSE_LEN_MAX &&\r
2009 irmp_pause_time >= JVC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= JVC_REPEAT_START_BIT_PAUSE_LEN_MAX)\r
2010 {\r
93ba2e01 2011 ANALYZE_PRINTF ("protocol = NEC or JVC (type 1) repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
770a1a9d 2012 JVC_START_BIT_PULSE_LEN_MIN, JVC_START_BIT_PULSE_LEN_MAX,\r
2013 JVC_REPEAT_START_BIT_PAUSE_LEN_MIN, JVC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
35213800 2014 irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
770a1a9d 2015 }\r
2016 else\r
2017#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2018\r
4225a882 2019#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
2020 if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
46dd89b7 2021 irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)\r
2022 {\r
35213800 2023#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
2024 ANALYZE_PRINTF ("protocol = NEC42, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2025 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2026 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);\r
2027 irmp_param_p = (IRMP_PARAMETER *) &nec42_param;\r
2028#else\r
48664931 2029 ANALYZE_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
46dd89b7 2030 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2031 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);\r
2032 irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
35213800 2033#endif\r
2034\r
46dd89b7 2035 }\r
2036 else if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
2037 irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX)\r
2038 { // it's NEC\r
93ba2e01 2039#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2040 if (irmp_protocol == IRMP_JVC_PROTOCOL) // last protocol was JVC, awaiting repeat frame\r
2041 { // some jvc remote controls use nec repetition frame for jvc repetition frame\r
2042 ANALYZE_PRINTF ("protocol = JVC repeat frame type 2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2043 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2044 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
2045 irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
2046 }\r
2047 else\r
2048#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2049 {\r
2050 ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2051 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2052 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2053\r
93ba2e01 2054 irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param;\r
2055 }\r
2056 }\r
2057 else\r
2058\r
2059#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2060 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame\r
2061 irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
2062 irmp_pause_time >= NEC_0_PAUSE_LEN_MIN && irmp_pause_time <= NEC_0_PAUSE_LEN_MAX)\r
2063 { // it's JVC repetition type 3\r
2064 ANALYZE_PRINTF ("protocol = JVC repeat frame type 3, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2065 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
2066 NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX);\r
2067 irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
4225a882 2068 }\r
2069 else\r
93ba2e01 2070#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2071\r
4225a882 2072#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
2073\r
9405f84a 2074#if IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
2075 if (irmp_pulse_time >= NIKON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NIKON_START_BIT_PULSE_LEN_MAX &&\r
2076 irmp_pause_time >= NIKON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NIKON_START_BIT_PAUSE_LEN_MAX)\r
2077 {\r
2078 ANALYZE_PRINTF ("protocol = NIKON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2079 NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX,\r
2080 NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX);\r
2081 irmp_param_p = (IRMP_PARAMETER *) &nikon_param;\r
2082 }\r
2083 else\r
2084#endif // IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
2085\r
4225a882 2086#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
2087 if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX &&\r
2088 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2089 { // it's SAMSUNG\r
48664931 2090 ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2091 SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX,\r
2092 SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2093 irmp_param_p = (IRMP_PARAMETER *) &samsung_param;\r
4225a882 2094 }\r
2095 else\r
2096#endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
2097\r
2098#if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1\r
2099 if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX &&\r
2100 irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2101 { // it's MATSUSHITA\r
48664931 2102 ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2103 MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX,\r
2104 MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2105 irmp_param_p = (IRMP_PARAMETER *) &matsushita_param;\r
4225a882 2106 }\r
2107 else\r
2108#endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1\r
2109\r
2110#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
2111 if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX &&\r
2112 irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2113 { // it's KASEIKYO\r
48664931 2114 ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2115 KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX,\r
2116 KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2117 irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param;\r
4225a882 2118 }\r
2119 else\r
2120#endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
2121\r
2122#if IRMP_SUPPORT_RECS80_PROTOCOL == 1\r
2123 if (irmp_pulse_time >= RECS80_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80_START_BIT_PULSE_LEN_MAX &&\r
2124 irmp_pause_time >= RECS80_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2125 { // it's RECS80\r
48664931 2126 ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2127 RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX,\r
2128 RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2129 irmp_param_p = (IRMP_PARAMETER *) &recs80_param;\r
4225a882 2130 }\r
2131 else\r
2132#endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1\r
2133\r
2134#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
31c1f035 2135 if (((irmp_pulse_time >= RC5_START_BIT_LEN_MIN && irmp_pulse_time <= RC5_START_BIT_LEN_MAX) ||\r
2136 (irmp_pulse_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX)) &&\r
2137 ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) ||\r
2138 (irmp_pause_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)))\r
46dd89b7 2139 { // it's RC5\r
6f750020 2140#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2141 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&\r
2142 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)\r
2143 {\r
2144 ANALYZE_PRINTF ("protocol = RC5 or FDC\n");\r
2145 ANALYZE_PRINTF ("FDC start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2146 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,\r
2147 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);\r
2148 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2149 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
2150 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);\r
2151 memcpy_P (&irmp_param2, &fdc_param, sizeof (IRMP_PARAMETER));\r
2152 }\r
2153 else\r
2154#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
12948cf3 2155\r
6f750020 2156#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2157 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&\r
2158 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)\r
2159 {\r
2160 ANALYZE_PRINTF ("protocol = RC5 or RCCAR\n");\r
2161 ANALYZE_PRINTF ("RCCAR start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2162 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,\r
2163 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);\r
2164 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2165 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
2166 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);\r
2167 memcpy_P (&irmp_param2, &rccar_param, sizeof (IRMP_PARAMETER));\r
2168 }\r
2169 else\r
2170#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2171 {\r
1aee56bc 2172 ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n",\r
6f750020 2173 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
31c1f035 2174 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX,\r
1aee56bc 2175 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
31c1f035 2176 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX);\r
6f750020 2177 }\r
2178\r
46dd89b7 2179 irmp_param_p = (IRMP_PARAMETER *) &rc5_param;\r
504d9df9 2180 last_pause = irmp_pause_time;\r
4225a882 2181\r
31c1f035 2182 if ((irmp_pulse_time > RC5_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX) ||\r
2183 (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX))\r
4225a882 2184 {\r
504d9df9 2185 last_value = 0;\r
4225a882 2186 rc5_cmd_bit6 = 1<<6;\r
2187 }\r
2188 else\r
2189 {\r
504d9df9 2190 last_value = 1;\r
4225a882 2191 }\r
2192 }\r
2193 else\r
2194#endif // IRMP_SUPPORT_RC5_PROTOCOL == 1\r
2195\r
2196#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
2197 if ( (irmp_pulse_time >= DENON_PULSE_LEN_MIN && irmp_pulse_time <= DENON_PULSE_LEN_MAX) &&\r
2198 ((irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) ||\r
2199 (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)))\r
2200 { // it's DENON\r
48664931 2201 ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",\r
4225a882 2202 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,\r
2203 DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX,\r
2204 DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX);\r
46dd89b7 2205 irmp_param_p = (IRMP_PARAMETER *) &denon_param;\r
4225a882 2206 }\r
2207 else\r
2208#endif // IRMP_SUPPORT_DENON_PROTOCOL == 1\r
2209\r
beda975f 2210#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
2211 if ( (irmp_pulse_time >= THOMSON_PULSE_LEN_MIN && irmp_pulse_time <= THOMSON_PULSE_LEN_MAX) &&\r
2212 ((irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) ||\r
2213 (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)))\r
2214 { // it's THOMSON\r
2215 ANALYZE_PRINTF ("protocol = THOMSON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",\r
2216 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX,\r
2217 THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX,\r
2218 THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX);\r
2219 irmp_param_p = (IRMP_PARAMETER *) &thomson_param;\r
2220 }\r
2221 else\r
2222#endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
2223\r
4225a882 2224#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2225 if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX &&\r
2226 irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX)\r
2227 { // it's RC6\r
48664931 2228 ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2229 RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX,\r
2230 RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2231 irmp_param_p = (IRMP_PARAMETER *) &rc6_param;\r
504d9df9 2232 last_pause = 0;\r
c7a47e89 2233 last_value = 1;\r
4225a882 2234 }\r
2235 else\r
2236#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2237\r
2238#if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1\r
2239 if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX &&\r
2240 irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2241 { // it's RECS80EXT\r
48664931 2242 ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2243 RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX,\r
2244 RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2245 irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param;\r
4225a882 2246 }\r
2247 else\r
2248#endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1\r
2249\r
2250#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1\r
2251 if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX &&\r
2252 irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX)\r
46dd89b7 2253 { // it's NUBERT\r
48664931 2254 ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
4225a882 2255 NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX,\r
2256 NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX);\r
46dd89b7 2257 irmp_param_p = (IRMP_PARAMETER *) &nubert_param;\r
4225a882 2258 }\r
2259 else\r
2260#endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1\r
2261\r
504d9df9 2262#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
2263 if (irmp_pulse_time >= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX &&\r
2264 irmp_pause_time >= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX)\r
46dd89b7 2265 { // it's BANG_OLUFSEN\r
48664931 2266 ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n");\r
2267 ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
504d9df9 2268 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,\r
2269 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);\r
48664931 2270 ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
504d9df9 2271 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,\r
2272 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);\r
48664931 2273 ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
504d9df9 2274 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,\r
2275 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);\r
48664931 2276 ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
504d9df9 2277 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,\r
2278 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);\r
46dd89b7 2279 irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param;\r
504d9df9 2280 last_value = 0;\r
2281 }\r
2282 else\r
2283#endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
2284\r
89e8cafb 2285#if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
2286 if (irmp_pulse_time >= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX &&\r
2287 irmp_pause_time >= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX)\r
592411d1 2288 { // it's GRUNDIG\r
48664931 2289 ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
89e8cafb 2290 GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX,\r
2291 GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX);\r
592411d1 2292 irmp_param_p = (IRMP_PARAMETER *) &grundig_param;\r
2293 last_pause = irmp_pause_time;\r
2294 last_value = 1;\r
2295 }\r
2296 else\r
89e8cafb 2297#endif // IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
592411d1 2298\r
12948cf3 2299#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
2300 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 2301 (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 2302 ((irmp_pause_time >= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX) || \r
31c1f035 2303 (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 2304 { // it's RUWIDO or SIEMENS\r
2305 ANALYZE_PRINTF ("protocol = RUWIDO, start bit timings: pulse: %3d - %3d or %3d - %3d, pause: %3d - %3d or %3d - %3d\n",\r
2306 SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,\r
31c1f035 2307 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,\r
12948cf3 2308 SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX,\r
31c1f035 2309 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX);\r
12948cf3 2310 irmp_param_p = (IRMP_PARAMETER *) &ruwido_param;\r
a7054daf 2311 last_pause = irmp_pause_time;\r
2312 last_value = 1;\r
2313 }\r
2314 else\r
12948cf3 2315#endif // IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
2316\r
48664931 2317#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2318 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&\r
2319 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)\r
eaaf80c3 2320 {\r
48664931 2321 ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2322 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,\r
2323 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);\r
2324 irmp_param_p = (IRMP_PARAMETER *) &fdc_param;\r
eaaf80c3 2325 }\r
2326 else\r
48664931 2327#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
12948cf3 2328\r
9e16d699 2329#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2330 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&\r
2331 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)\r
2332 {\r
48664931 2333 ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
9e16d699 2334 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,\r
2335 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);\r
2336 irmp_param_p = (IRMP_PARAMETER *) &rccar_param;\r
2337 }\r
2338 else\r
2339#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
89e8cafb 2340\r
111d6191 2341#if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1\r
2342 if (irmp_pulse_time >= KATHREIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_START_BIT_PULSE_LEN_MAX &&\r
2343 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)\r
2344 { // it's KATHREIN\r
2345 ANALYZE_PRINTF ("protocol = KATHREIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2346 KATHREIN_START_BIT_PULSE_LEN_MIN, KATHREIN_START_BIT_PULSE_LEN_MAX,\r
2347 KATHREIN_START_BIT_PAUSE_LEN_MIN, KATHREIN_START_BIT_PAUSE_LEN_MAX);\r
2348 irmp_param_p = (IRMP_PARAMETER *) &kathrein_param;\r
2349 }\r
2350 else\r
2351#endif // IRMP_SUPPORT_KATHREIN_PROTOCOL == 1\r
2352\r
deba2a0a 2353#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1\r
2354 if (irmp_pulse_time >= NETBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NETBOX_START_BIT_PULSE_LEN_MAX &&\r
2355 irmp_pause_time >= NETBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NETBOX_START_BIT_PAUSE_LEN_MAX)\r
2356 { // it's NETBOX\r
2357 ANALYZE_PRINTF ("protocol = NETBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2358 NETBOX_START_BIT_PULSE_LEN_MIN, NETBOX_START_BIT_PULSE_LEN_MAX,\r
2359 NETBOX_START_BIT_PAUSE_LEN_MIN, NETBOX_START_BIT_PAUSE_LEN_MAX);\r
2360 irmp_param_p = (IRMP_PARAMETER *) &netbox_param;\r
2361 }\r
2362 else\r
2363#endif // IRMP_SUPPORT_NETBOX_PROTOCOL == 1\r
2364\r
f50e01e7 2365#if IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
2366 if (irmp_pulse_time >= LEGO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= LEGO_START_BIT_PULSE_LEN_MAX &&\r
2367 irmp_pause_time >= LEGO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= LEGO_START_BIT_PAUSE_LEN_MAX)\r
2368 {\r
2369 ANALYZE_PRINTF ("protocol = LEGO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
2370 LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX,\r
2371 LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX);\r
2372 irmp_param_p = (IRMP_PARAMETER *) &lego_param;\r
2373 }\r
2374 else\r
93ba2e01 2375#endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
f50e01e7 2376\r
4225a882 2377 {\r
48664931 2378 ANALYZE_PRINTF ("protocol = UNKNOWN\n");\r
1f54e86c 2379// irmp_busy_flag = FALSE;\r
4225a882 2380 irmp_start_bit_detected = 0; // wait for another start bit...\r
2381 }\r
2382\r
2383 if (irmp_start_bit_detected)\r
2384 {\r
46dd89b7 2385 memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER));\r
2386\r
48664931 2387#ifdef ANALYZE\r
77f488bb 2388 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
2389 {\r
48664931 2390 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max);\r
2391 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max);\r
77f488bb 2392 }\r
2393 else\r
2394 {\r
48664931 2395 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max,\r
31c1f035 2396 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max);\r
48664931 2397 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max,\r
31c1f035 2398 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max);\r
77f488bb 2399 }\r
46dd89b7 2400\r
6f750020 2401#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
2402 if (irmp_param2.protocol)\r
2403 {\r
2404 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param2.pulse_0_len_min, irmp_param2.pulse_0_len_max);\r
2405 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param2.pause_0_len_min, irmp_param2.pause_0_len_max);\r
2406 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param2.pulse_1_len_min, irmp_param2.pulse_1_len_max);\r
2407 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param2.pause_1_len_min, irmp_param2.pause_1_len_max);\r
2408 }\r
2409#endif\r
2410\r
d823e852 2411\r
504d9df9 2412#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
4225a882 2413 if (irmp_param.protocol == IRMP_RC6_PROTOCOL)\r
2414 {\r
48664931 2415 ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX);\r
4225a882 2416 }\r
504d9df9 2417#endif\r
77f488bb 2418\r
2419 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
2420 {\r
93ba2e01 2421 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
2422 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max);\r
2423 }\r
2424 else\r
2425 {\r
2426 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max,\r
2427 2 * irmp_param.pulse_0_len_min, 2 * irmp_param.pulse_0_len_max);\r
2428 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max,\r
2429 2 * irmp_param.pause_0_len_min, 2 * irmp_param.pause_0_len_max);\r
77f488bb 2430 }\r
46dd89b7 2431\r
504d9df9 2432#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
2433 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)\r
2434 {\r
48664931 2435 ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
2436 ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX);\r
504d9df9 2437 }\r
2438#endif\r
2439\r
48664931 2440 ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param.command_offset);\r
2441 ANALYZE_PRINTF ("command_len: %3d\n", irmp_param.command_end - irmp_param.command_offset);\r
2442 ANALYZE_PRINTF ("complete_len: %3d\n", irmp_param.complete_len);\r
2443 ANALYZE_PRINTF ("stop_bit: %3d\n", irmp_param.stop_bit);\r
2444#endif // ANALYZE\r
4225a882 2445 }\r
2446\r
2447 irmp_bit = 0;\r
2448\r
77f488bb 2449#if IRMP_SUPPORT_MANCHESTER == 1\r
12948cf3 2450 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&\r
2451 irmp_param.protocol != IRMP_RUWIDO_PROTOCOL && // Manchester, but not RUWIDO\r
2452 irmp_param.protocol != IRMP_RC6_PROTOCOL) // Manchester, but not RC6\r
4225a882 2453 {\r
31c1f035 2454 if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max)\r
4225a882 2455 {\r
48664931 2456 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
2457 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
2458 ANALYZE_NEWLINE ();\r
77f488bb 2459 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1);\r
592411d1 2460 }\r
6f750020 2461 else if (! last_value) // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)\r
592411d1 2462 {\r
48664931 2463 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
592411d1 2464\r
48664931 2465 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
2466 ANALYZE_NEWLINE ();\r
77f488bb 2467 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0);\r
a7054daf 2468 }\r
2469 }\r
2470 else\r
77f488bb 2471#endif // IRMP_SUPPORT_MANCHESTER == 1\r
a7054daf 2472\r
deba2a0a 2473#if IRMP_SUPPORT_SERIAL == 1\r
2474 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)\r
2475 {\r
2476 ; // do nothing\r
2477 }\r
2478 else\r
2479#endif // IRMP_SUPPORT_SERIAL == 1\r
2480\r
2481\r
4225a882 2482#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
2483 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)\r
2484 {\r
48664931 2485 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
4225a882 2486\r
2487 if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)\r
2488 { // pause timings correct for "1"?\r
48664931 2489 ANALYZE_PUTCHAR ('1'); // yes, store 1\r
2490 ANALYZE_NEWLINE ();\r
4225a882 2491 irmp_store_bit (1);\r
2492 }\r
2493 else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)\r
2494 { // pause timings correct for "0"?\r
48664931 2495 ANALYZE_PUTCHAR ('0'); // yes, store 0\r
2496 ANALYZE_NEWLINE ();\r
4225a882 2497 irmp_store_bit (0);\r
2498 }\r
2499 }\r
881dbf79 2500 else\r
4225a882 2501#endif // IRMP_SUPPORT_DENON_PROTOCOL == 1\r
beda975f 2502#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
2503 if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL)\r
2504 {\r
2505 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
2506\r
2507 if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX)\r
2508 { // pause timings correct for "1"?\r
2509 ANALYZE_PUTCHAR ('1'); // yes, store 1\r
2510 ANALYZE_NEWLINE ();\r
2511 irmp_store_bit (1);\r
2512 }\r
2513 else // if (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)\r
2514 { // pause timings correct for "0"?\r
2515 ANALYZE_PUTCHAR ('0'); // yes, store 0\r
2516 ANALYZE_NEWLINE ();\r
2517 irmp_store_bit (0);\r
2518 }\r
2519 }\r
2520 else\r
2521#endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
881dbf79 2522 {\r
2523 ; // else do nothing\r
2524 }\r
4225a882 2525\r
2526 irmp_pulse_time = 1; // set counter to 1, not 0\r
2527 irmp_pause_time = 0;\r
2528 wait_for_start_space = 0;\r
2529 }\r
2530 }\r
2531 else if (wait_for_space) // the data section....\r
2532 { // counting the time of darkness....\r
2533 uint8_t got_light = FALSE;\r
2534\r
2535 if (irmp_input) // still dark?\r
2536 { // yes...\r
2537 if (irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 1)\r
2538 {\r
a42d1ee6 2539 if (\r
2540#if IRMP_SUPPORT_MANCHESTER == 1\r
2541 (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) ||\r
2542#endif\r
2543#if IRMP_SUPPORT_SERIAL == 1\r
deba2a0a 2544 (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) ||\r
a42d1ee6 2545#endif\r
1aee56bc 2546 (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max))\r
4225a882 2547 {\r
48664931 2548#ifdef ANALYZE\r
77f488bb 2549 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
4225a882 2550 {\r
48664931 2551 ANALYZE_PRINTF ("stop bit detected\n");\r
4225a882 2552 }\r
2553#endif\r
2554 irmp_param.stop_bit = 0;\r
2555 }\r
2556 else\r
2557 {\r
93ba2e01 2558 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
2559 irmp_bit, irmp_pulse_time, irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
4225a882 2560\r
1f54e86c 2561// irmp_busy_flag = FALSE;\r
4225a882 2562 irmp_start_bit_detected = 0; // wait for another start bit...\r
2563 irmp_pulse_time = 0;\r
2564 irmp_pause_time = 0;\r
2565 }\r
2566 }\r
2567 else\r
2568 {\r
9547ee89 2569 irmp_pause_time++; // increment counter\r
4225a882 2570\r
2571#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
9547ee89 2572 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && // Sony has a variable number of bits:\r
2573 irmp_pause_time > SIRCS_PAUSE_LEN_MAX && // minimum is 12\r
2574 irmp_bit >= 12 - 1) // pause too long?\r
2575 { // yes, break and close this frame\r
2576 irmp_param.complete_len = irmp_bit + 1; // set new complete length\r
2577 got_light = TRUE; // this is a lie, but helps (generates stop bit)\r
2578 irmp_tmp_address |= (irmp_bit - SIRCS_MINIMUM_DATA_LEN + 1) << 8; // new: store number of additional bits in upper byte of address!\r
2579 irmp_param.command_end = irmp_param.command_offset + irmp_bit + 1; // correct command length\r
2580 irmp_pause_time = SIRCS_PAUSE_LEN_MAX - 1; // correct pause length\r
4225a882 2581 }\r
2582 else\r
2583#endif\r
deba2a0a 2584#if IRMP_SUPPORT_SERIAL == 1\r
a42d1ee6 2585 // NETBOX generates no stop bit, here is the timeout condition:\r
deba2a0a 2586 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) && irmp_param.protocol == IRMP_NETBOX_PROTOCOL &&\r
a42d1ee6 2587 irmp_pause_time >= NETBOX_PULSE_LEN * (NETBOX_COMPLETE_DATA_LEN - irmp_bit))\r
deba2a0a 2588 {\r
2589 got_light = TRUE; // this is a lie, but helps (generates stop bit)\r
2590 }\r
2591 else\r
2592#endif\r
89e8cafb 2593#if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
77f488bb 2594 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit)\r
d155e9ab 2595 {\r
89e8cafb 2596 if (irmp_pause_time > IR60_TIMEOUT_LEN && irmp_bit == 6)\r
2597 {\r
2598 ANALYZE_PRINTF ("Switching to IR60 protocol\n");\r
2599 got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
2600 irmp_param.stop_bit = TRUE; // set flag\r
2601\r
2602 irmp_param.protocol = IRMP_IR60_PROTOCOL; // change protocol\r
2603 irmp_param.complete_len = IR60_COMPLETE_DATA_LEN; // correct complete len\r
2604 irmp_param.address_offset = IR60_ADDRESS_OFFSET;\r
2605 irmp_param.address_end = IR60_ADDRESS_OFFSET + IR60_ADDRESS_LEN;\r
2606 irmp_param.command_offset = IR60_COMMAND_OFFSET;\r
2607 irmp_param.command_end = IR60_COMMAND_OFFSET + IR60_COMMAND_LEN;\r
2608\r
2609 irmp_tmp_command <<= 1;\r
2610 irmp_tmp_command |= first_bit;\r
2611 }\r
31c1f035 2612 else if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2)\r
77f488bb 2613 { // special manchester decoder\r
2614 irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len\r
2615 got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
2616 irmp_param.stop_bit = TRUE; // set flag\r
2617 }\r
2618 else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN)\r
d155e9ab 2619 {\r
48664931 2620 ANALYZE_PRINTF ("Switching to NOKIA protocol\n");\r
77f488bb 2621 irmp_param.protocol = IRMP_NOKIA_PROTOCOL; // change protocol\r
2622 irmp_param.address_offset = NOKIA_ADDRESS_OFFSET;\r
2623 irmp_param.address_end = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN;\r
2624 irmp_param.command_offset = NOKIA_COMMAND_OFFSET;\r
2625 irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN;\r
2626\r
2627 if (irmp_tmp_command & 0x300)\r
2628 {\r
2629 irmp_tmp_address = (irmp_tmp_command >> 8);\r
2630 irmp_tmp_command &= 0xFF;\r
2631 }\r
d155e9ab 2632 }\r
2633 }\r
2634 else\r
2635#endif\r
12948cf3 2636#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
2637 if (irmp_param.protocol == IRMP_RUWIDO_PROTOCOL && !irmp_param.stop_bit)\r
2638 {\r
31c1f035 2639 if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= RUWIDO_COMPLETE_DATA_LEN - 2)\r
12948cf3 2640 { // special manchester decoder\r
2641 irmp_param.complete_len = RUWIDO_COMPLETE_DATA_LEN; // correct complete len\r
2642 got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
2643 irmp_param.stop_bit = TRUE; // set flag\r
2644 }\r
2645 else if (irmp_bit >= RUWIDO_COMPLETE_DATA_LEN)\r
2646 {\r
2647 ANALYZE_PRINTF ("Switching to SIEMENS protocol\n");\r
2648 irmp_param.protocol = IRMP_SIEMENS_PROTOCOL; // change protocol\r
2649 irmp_param.address_offset = SIEMENS_ADDRESS_OFFSET;\r
2650 irmp_param.address_end = SIEMENS_ADDRESS_OFFSET + SIEMENS_ADDRESS_LEN;\r
2651 irmp_param.command_offset = SIEMENS_COMMAND_OFFSET;\r
2652 irmp_param.command_end = SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN;\r
2653\r
2654 // 76543210\r
2655 // RUWIDO: AAAAAAAAACCCCCCCp\r
2656 // SIEMENS: AAAAAAAAAAACCCCCCCCCCp\r
2657 irmp_tmp_address <<= 2;\r
2658 irmp_tmp_address |= (irmp_tmp_command >> 6);\r
2659 irmp_tmp_command &= 0x003F;\r
2660 irmp_tmp_command <<= 4;\r
2661 irmp_tmp_command |= last_value;\r
2662 }\r
2663 }\r
2664 else\r
2665#endif\r
77f488bb 2666#if IRMP_SUPPORT_MANCHESTER == 1\r
2667 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&\r
31c1f035 2668 irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit)\r
77f488bb 2669 { // special manchester decoder\r
a7054daf 2670 got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
2671 irmp_param.stop_bit = TRUE; // set flag\r
2672 }\r
2673 else\r
77f488bb 2674#endif // IRMP_SUPPORT_MANCHESTER == 1\r
504d9df9 2675 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?\r
4225a882 2676 { // yes...\r
2677 if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0)\r
2678 {\r
2679 irmp_bit++;\r
2680 }\r
770a1a9d 2681#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2682 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit\r
2683 {\r
93ba2e01 2684 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);\r
770a1a9d 2685 irmp_param.stop_bit = TRUE; // set flag\r
2686 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol\r
2687 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17\r
2688 irmp_tmp_command = (irmp_tmp_address >> 4); // set command: upper 12 bits are command bits\r
2689 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits\r
2690 irmp_start_bit_detected = 1; // tricky: don't wait for another start bit...\r
2691 }\r
2692#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
35213800 2693\r
2694#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
2695#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
2696 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 32) // it was a NEC stop bit\r
2697 {\r
2698 ANALYZE_PRINTF ("Switching to NEC protocol\n");\r
2699 irmp_param.stop_bit = TRUE; // set flag\r
2700 irmp_param.protocol = IRMP_NEC_PROTOCOL; // switch protocol\r
2701 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17\r
2702\r
2703 // 0123456789ABC0123456789ABC0123456701234567\r
2704 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc\r
2705 // NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc\r
2706 irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 12;\r
2707 irmp_tmp_command = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10);\r
2708 }\r
2709#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
2710#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
93ba2e01 2711 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit\r
35213800 2712 {\r
93ba2e01 2713 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);\r
35213800 2714 irmp_param.stop_bit = TRUE; // set flag\r
2715 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol\r
2716 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17\r
2717\r
2718 // 0123456789ABC0123456789ABC0123456701234567\r
2719 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc\r
2720 // JVC: AAAACCCCCCCCCCCC\r
2721 irmp_tmp_command = (irmp_tmp_address >> 4) | (irmp_tmp_address2 << 9); // set command: upper 12 bits are command bits\r
2722 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits\r
2723 }\r
2724#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
2725#endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
4225a882 2726 else\r
2727 {\r
48664931 2728 ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);\r
2729 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
4225a882 2730\r
1f54e86c 2731// irmp_busy_flag = FALSE;\r
4225a882 2732 irmp_start_bit_detected = 0; // wait for another start bit...\r
2733 irmp_pulse_time = 0;\r
2734 irmp_pause_time = 0;\r
2735 }\r
2736 }\r
2737 }\r
2738 }\r
2739 else\r
2740 { // got light now!\r
2741 got_light = TRUE;\r
2742 }\r
2743\r
2744 if (got_light)\r
2745 {\r
48664931 2746 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
4225a882 2747\r
77f488bb 2748#if IRMP_SUPPORT_MANCHESTER == 1\r
d823e852 2749 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester\r
4225a882 2750 {\r
31c1f035 2751#if 1\r
2752 if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max */)\r
2753#else // better, but some IR-RCs use asymmetric timings :-/\r
2754 if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max &&\r
2755 irmp_pause_time <= 2 * irmp_param.pause_1_len_max)\r
fc80d688 2756#endif\r
4225a882 2757 {\r
c7a47e89 2758#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2759 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit\r
4225a882 2760 {\r
c7a47e89 2761 ANALYZE_PUTCHAR ('T');\r
2762 if (irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode 6A\r
2763 {\r
2764 irmp_store_bit (1);\r
2765 last_value = 1;\r
2766 }\r
2767 else // RC6 mode 0\r
2768 {\r
2769 irmp_store_bit (0);\r
2770 last_value = 0;\r
2771 }\r
2772 ANALYZE_NEWLINE ();\r
4225a882 2773 }\r
c7a47e89 2774 else\r
2775#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2776 {\r
2777 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
2778 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 );\r
4225a882 2779\r
c7a47e89 2780#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2781 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit\r
2782 {\r
2783 ANALYZE_PUTCHAR ('T');\r
2784 irmp_store_bit (1);\r
2785\r
31c1f035 2786 if (irmp_pause_time > 2 * irmp_param.pause_1_len_max)\r
c7a47e89 2787 {\r
2788 last_value = 0;\r
2789 }\r
2790 else\r
2791 {\r
2792 last_value = 1;\r
2793 }\r
2794 ANALYZE_NEWLINE ();\r
2795 }\r
2796 else\r
77f488bb 2797#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
c7a47e89 2798 {\r
2799 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
2800 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 );\r
6f750020 2801#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
c7a47e89 2802 if (! irmp_param2.protocol)\r
6f750020 2803#endif\r
c7a47e89 2804 {\r
2805 ANALYZE_NEWLINE ();\r
2806 }\r
2807 last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0;\r
2808 }\r
6f750020 2809 }\r
592411d1 2810 }\r
31c1f035 2811 else if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max\r
2812 /* && irmp_pause_time <= 2 * irmp_param.pause_1_len_max */)\r
592411d1 2813 {\r
77f488bb 2814 uint8_t manchester_value;\r
592411d1 2815\r
31c1f035 2816 if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max)\r
592411d1 2817 {\r
77f488bb 2818 manchester_value = last_value ? 0 : 1;\r
2819 last_value = manchester_value;\r
592411d1 2820 }\r
2821 else\r
2822 {\r
77f488bb 2823 manchester_value = last_value;\r
592411d1 2824 }\r
2825\r
48664931 2826 ANALYZE_PUTCHAR (manchester_value + '0');\r
c7a47e89 2827\r
6f750020 2828#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)\r
2829 if (! irmp_param2.protocol)\r
2830#endif\r
2831 {\r
2832 ANALYZE_NEWLINE ();\r
2833 }\r
c7a47e89 2834\r
2835#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2836 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 1) // RC6 mode != 0 ???\r
2837 {\r
2838 ANALYZE_PRINTF ("Switching to RC6A protocol\n");\r
2839 irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG;\r
2840 irmp_param.address_offset = 5;\r
2841 irmp_param.address_end = irmp_param.address_offset + 15;\r
2842 irmp_param.command_offset = irmp_param.address_end + 1; // skip 1 system bit, changes like a toggle bit\r
2843 irmp_param.command_end = irmp_param.command_offset + 16 - 1;\r
9547ee89 2844 irmp_tmp_address = 0;\r
c7a47e89 2845 }\r
2846#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
2847\r
77f488bb 2848 irmp_store_bit (manchester_value);\r
a7054daf 2849 }\r
6f750020 2850 else\r
2851 {\r
2852#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2853 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL &&\r
2854 irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX &&\r
2855 ((irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) ||\r
2856 (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)))\r
2857 {\r
2858 ANALYZE_PUTCHAR ('?');\r
d823e852 2859 irmp_param.protocol = 0; // switch to FDC, see below\r
6f750020 2860 }\r
2861 else\r
2862#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2863#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2864 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL &&\r
2865 irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX &&\r
2866 ((irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) ||\r
2867 (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)))\r
2868 {\r
2869 ANALYZE_PUTCHAR ('?');\r
d823e852 2870 irmp_param.protocol = 0; // switch to RCCAR, see below\r
6f750020 2871 }\r
2872 else\r
2873#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2874 {\r
2875 ANALYZE_PUTCHAR ('?');\r
2876 ANALYZE_NEWLINE ();\r
c7a47e89 2877 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 2878 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 2879// irmp_busy_flag = FALSE;\r
6f750020 2880 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
2881 irmp_pause_time = 0;\r
2882 }\r
2883 }\r
2884\r
2885#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2886 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX)\r
2887 {\r
2888 if (irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX)\r
2889 {\r
2890 ANALYZE_PRINTF (" 1 (FDC)\n");\r
2891 irmp_store_bit2 (1);\r
2892 }\r
2893 else if (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)\r
2894 {\r
2895 ANALYZE_PRINTF (" 0 (FDC)\n");\r
2896 irmp_store_bit2 (0);\r
2897 }\r
2898\r
2899 if (! irmp_param.protocol)\r
2900 {\r
2901 ANALYZE_PRINTF ("Switching to FDC protocol\n");\r
2902 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));\r
2903 irmp_param2.protocol = 0;\r
2904 irmp_tmp_address = irmp_tmp_address2;\r
2905 irmp_tmp_command = irmp_tmp_command2;\r
2906 }\r
2907 }\r
2908#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
2909#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
2910 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX)\r
2911 {\r
2912 if (irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX)\r
2913 {\r
2914 ANALYZE_PRINTF (" 1 (RCCAR)\n");\r
2915 irmp_store_bit2 (1);\r
2916 }\r
2917 else if (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)\r
2918 {\r
2919 ANALYZE_PRINTF (" 0 (RCCAR)\n");\r
2920 irmp_store_bit2 (0);\r
2921 }\r
2922\r
2923 if (! irmp_param.protocol)\r
2924 {\r
2925 ANALYZE_PRINTF ("Switching to RCCAR protocol\n");\r
2926 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));\r
2927 irmp_param2.protocol = 0;\r
2928 irmp_tmp_address = irmp_tmp_address2;\r
2929 irmp_tmp_command = irmp_tmp_command2;\r
2930 }\r
2931 }\r
2932#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
a7054daf 2933\r
77f488bb 2934 last_pause = irmp_pause_time;\r
2935 wait_for_space = 0;\r
a7054daf 2936 }\r
2937 else\r
77f488bb 2938#endif // IRMP_SUPPORT_MANCHESTER == 1\r
2939\r
deba2a0a 2940#if IRMP_SUPPORT_SERIAL == 1\r
2941 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)\r
2942 {\r
2943 while (irmp_bit < irmp_param.complete_len && irmp_pulse_time > irmp_param.pulse_1_len_max)\r
2944 {\r
2945 ANALYZE_PUTCHAR ('1');\r
2946 irmp_store_bit (1);\r
2947\r
2948 if (irmp_pulse_time >= irmp_param.pulse_1_len_min)\r
2949 {\r
2950 irmp_pulse_time -= irmp_param.pulse_1_len_min;\r
2951 }\r
2952 else\r
2953 {\r
2954 irmp_pulse_time = 0;\r
2955 }\r
2956 }\r
2957\r
2958 while (irmp_bit < irmp_param.complete_len && irmp_pause_time > irmp_param.pause_1_len_max)\r
2959 {\r
2960 ANALYZE_PUTCHAR ('0');\r
2961 irmp_store_bit (0);\r
2962\r
2963 if (irmp_pause_time >= irmp_param.pause_1_len_min)\r
2964 {\r
2965 irmp_pause_time -= irmp_param.pause_1_len_min;\r
2966 }\r
2967 else\r
2968 {\r
2969 irmp_pause_time = 0;\r
2970 }\r
2971 }\r
2972 ANALYZE_NEWLINE ();\r
2973 wait_for_space = 0;\r
2974 }\r
2975 else\r
2976#endif // IRMP_SUPPORT_SERIAL == 1\r
a7054daf 2977\r
4225a882 2978#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
2979 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit\r
2980 {\r
2981 if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX &&\r
2982 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)\r
2983 {\r
48664931 2984 ANALYZE_PRINTF ("SYNC\n");\r
4225a882 2985 wait_for_space = 0;\r
2986 irmp_tmp_id = 0;\r
2987 irmp_bit++;\r
2988 }\r
2989 else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX)\r
2990 {\r
5b437ff6 2991 irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL;\r
2992 irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET;\r
2993 irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN;\r
2994 irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN;\r
2995\r
4225a882 2996 if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX)\r
2997 {\r
48664931 2998 ANALYZE_PUTCHAR ('1');\r
2999 ANALYZE_NEWLINE ();\r
4225a882 3000 irmp_store_bit (1);\r
3001 wait_for_space = 0;\r
3002 }\r
3003 else\r
3004 {\r
48664931 3005 ANALYZE_PUTCHAR ('0');\r
3006 ANALYZE_NEWLINE ();\r
4225a882 3007 irmp_store_bit (0);\r
3008 wait_for_space = 0;\r
3009 }\r
3010\r
48664931 3011 ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n");\r
4225a882 3012 }\r
3013 else\r
3014 { // timing incorrect!\r
48664931 3015 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
3016 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3017// irmp_busy_flag = FALSE;\r
504d9df9 3018 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
4225a882 3019 irmp_pause_time = 0;\r
3020 }\r
4225a882 3021 }\r
3022 else\r
3023#endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL\r
3024\r
fc80d688 3025#if IRMP_SUPPORT_NEC16_PROTOCOL\r
35213800 3026#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
3027 if (irmp_param.protocol == IRMP_NEC42_PROTOCOL &&\r
3028#else // IRMP_SUPPORT_NEC_PROTOCOL instead\r
3029 if (irmp_param.protocol == IRMP_NEC_PROTOCOL &&\r
3030#endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
3031 irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)\r
fc80d688 3032 {\r
3033 ANALYZE_PRINTF ("Switching to NEC16 protocol\n");\r
7644ac04 3034 irmp_param.protocol = IRMP_NEC16_PROTOCOL;\r
35213800 3035 irmp_param.address_offset = NEC16_ADDRESS_OFFSET;\r
3036 irmp_param.address_end = NEC16_ADDRESS_OFFSET + NEC16_ADDRESS_LEN;\r
3037 irmp_param.command_offset = NEC16_COMMAND_OFFSET;\r
3038 irmp_param.command_end = NEC16_COMMAND_OFFSET + NEC16_COMMAND_LEN;\r
3039 irmp_param.complete_len = NEC16_COMPLETE_DATA_LEN;\r
fc80d688 3040 wait_for_space = 0;\r
3041 }\r
3042 else\r
3043#endif // IRMP_SUPPORT_NEC16_PROTOCOL\r
3044\r
504d9df9 3045#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
3046 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)\r
3047 {\r
3048 if (irmp_pulse_time >= BANG_OLUFSEN_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_PULSE_LEN_MAX)\r
3049 {\r
46dd89b7 3050 if (irmp_bit == 1) // Bang & Olufsen: 3rd bit\r
504d9df9 3051 {\r
3052 if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX)\r
3053 {\r
48664931 3054 ANALYZE_PRINTF ("3rd start bit\n");\r
504d9df9 3055 wait_for_space = 0;\r
504d9df9 3056 irmp_bit++;\r
3057 }\r
3058 else\r
d155e9ab 3059 { // timing incorrect!\r
48664931 3060 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
3061 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3062// irmp_busy_flag = FALSE;\r
46dd89b7 3063 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
504d9df9 3064 irmp_pause_time = 0;\r
3065 }\r
504d9df9 3066 }\r
46dd89b7 3067 else if (irmp_bit == 19) // Bang & Olufsen: trailer bit\r
504d9df9 3068 {\r
3069 if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX)\r
3070 {\r
48664931 3071 ANALYZE_PRINTF ("trailer bit\n");\r
504d9df9 3072 wait_for_space = 0;\r
504d9df9 3073 irmp_bit++;\r
3074 }\r
3075 else\r
46dd89b7 3076 { // timing incorrect!\r
48664931 3077 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
3078 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3079// irmp_busy_flag = FALSE;\r
46dd89b7 3080 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
504d9df9 3081 irmp_pause_time = 0;\r
3082 }\r
504d9df9 3083 }\r
3084 else\r
3085 {\r
46dd89b7 3086 if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX)\r
3087 { // pulse & pause timings correct for "1"?\r
48664931 3088 ANALYZE_PUTCHAR ('1');\r
3089 ANALYZE_NEWLINE ();\r
504d9df9 3090 irmp_store_bit (1);\r
3091 last_value = 1;\r
3092 wait_for_space = 0;\r
3093 }\r
46dd89b7 3094 else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX)\r
3095 { // pulse & pause timings correct for "0"?\r
48664931 3096 ANALYZE_PUTCHAR ('0');\r
3097 ANALYZE_NEWLINE ();\r
504d9df9 3098 irmp_store_bit (0);\r
3099 last_value = 0;\r
3100 wait_for_space = 0;\r
3101 }\r
3102 else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX)\r
3103 {\r
48664931 3104 ANALYZE_PUTCHAR (last_value + '0');\r
3105 ANALYZE_NEWLINE ();\r
504d9df9 3106 irmp_store_bit (last_value);\r
3107 wait_for_space = 0;\r
3108 }\r
3109 else\r
46dd89b7 3110 { // timing incorrect!\r
48664931 3111 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
3112 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3113// irmp_busy_flag = FALSE;\r
46dd89b7 3114 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
504d9df9 3115 irmp_pause_time = 0;\r
3116 }\r
3117 }\r
3118 }\r
3119 else\r
46dd89b7 3120 { // timing incorrect!\r
48664931 3121 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
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 else\r
3129#endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL\r
3130\r
4225a882 3131 if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max &&\r
3132 irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)\r
3133 { // pulse & pause timings correct for "1"?\r
48664931 3134 ANALYZE_PUTCHAR ('1');\r
3135 ANALYZE_NEWLINE ();\r
4225a882 3136 irmp_store_bit (1);\r
3137 wait_for_space = 0;\r
3138 }\r
3139 else if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max &&\r
3140 irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max)\r
3141 { // pulse & pause timings correct for "0"?\r
48664931 3142 ANALYZE_PUTCHAR ('0');\r
3143 ANALYZE_NEWLINE ();\r
4225a882 3144 irmp_store_bit (0);\r
3145 wait_for_space = 0;\r
3146 }\r
3147 else\r
111d6191 3148#if IRMP_SUPPORT_KATHREIN_PROTOCOL\r
3149\r
3150 if (irmp_param.protocol == IRMP_KATHREIN_PROTOCOL &&\r
3151 irmp_pulse_time >= KATHREIN_1_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_1_PULSE_LEN_MAX &&\r
3152 (((irmp_bit == 8 || irmp_bit == 6) &&\r
3153 irmp_pause_time >= KATHREIN_SYNC_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_SYNC_BIT_PAUSE_LEN_MAX) ||\r
3154 (irmp_bit == 12 &&\r
3155 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)))\r
3156\r
3157 {\r
3158 if (irmp_bit == 8)\r
3159 {\r
3160 irmp_bit++;\r
3161 ANALYZE_PUTCHAR ('S');\r
3162 ANALYZE_NEWLINE ();\r
111d6191 3163 irmp_tmp_command <<= 1;\r
3164 }\r
3165 else\r
3166 {\r
3167 ANALYZE_PUTCHAR ('S');\r
3168 ANALYZE_NEWLINE ();\r
3169 irmp_store_bit (1);\r
3170 }\r
3171 wait_for_space = 0;\r
3172 }\r
3173 else\r
3174#endif // IRMP_SUPPORT_KATHREIN_PROTOCOL\r
4225a882 3175 { // timing incorrect!\r
48664931 3176 ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
3177 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
1f54e86c 3178// irmp_busy_flag = FALSE;\r
4225a882 3179 irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
3180 irmp_pause_time = 0;\r
3181 }\r
3182\r
3183 irmp_pulse_time = 1; // set counter to 1, not 0\r
3184 }\r
3185 }\r
3186 else\r
3187 { // counting the pulse length ...\r
d155e9ab 3188 if (! irmp_input) // still light?\r
4225a882 3189 { // yes...\r
3190 irmp_pulse_time++; // increment counter\r
3191 }\r
3192 else\r
3193 { // now it's dark!\r
3194 wait_for_space = 1; // let's count the time (see above)\r
3195 irmp_pause_time = 1; // set pause counter to 1, not 0\r
3196 }\r
3197 }\r
3198\r
881dbf79 3199 if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received?\r
4225a882 3200 {\r
c7a47e89 3201 if (last_irmp_command == irmp_tmp_command && repetition_len < AUTO_FRAME_REPETITION_LEN)\r
592411d1 3202 {\r
3203 repetition_frame_number++;\r
3204 }\r
3205 else\r
4225a882 3206 {\r
592411d1 3207 repetition_frame_number = 0;\r
3208 }\r
3209\r
3210#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
3211 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame\r
3212 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2))\r
3213 {\r
48664931 3214 ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
c7a47e89 3215 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
3216 repetition_len = 0;\r
592411d1 3217 }\r
3218 else\r
3219#endif\r
3220\r
770a1a9d 3221#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
3222 // if KASEIKYO protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame\r
3223 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1)\r
3224 {\r
3225 ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
c7a47e89 3226 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
3227 repetition_len = 0;\r
770a1a9d 3228 }\r
3229 else\r
3230#endif\r
3231\r
592411d1 3232#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
3233 // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame\r
3234 if (irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL && (repetition_frame_number & 0x01))\r
3235 {\r
48664931 3236 ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
c7a47e89 3237 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
3238 repetition_len = 0;\r
592411d1 3239 }\r
3240 else\r
3241#endif\r
3242\r
3243#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1\r
d155e9ab 3244 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame\r
592411d1 3245 if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01))\r
3246 {\r
48664931 3247 ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
c7a47e89 3248 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
3249 repetition_len = 0;\r
4225a882 3250 }\r
3251 else\r
592411d1 3252#endif\r
3253\r
4225a882 3254 {\r
c7a47e89 3255 ANALYZE_PRINTF ("%8d code detected, length = %d\n", time_counter, irmp_bit);\r
4225a882 3256 irmp_ir_detected = TRUE;\r
3257\r
3258#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
3259 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)\r
3260 { // check for repetition frame\r
3261 if ((~irmp_tmp_command & 0x3FF) == last_irmp_denon_command) // command bits must be inverted\r
3262 {\r
3263 irmp_tmp_command = last_irmp_denon_command; // use command received before!\r
3264\r
3265 irmp_protocol = irmp_param.protocol; // store protocol\r
3266 irmp_address = irmp_tmp_address; // store address\r
3267 irmp_command = irmp_tmp_command ; // store command\r
3268 }\r
3269 else\r
3270 {\r
48664931 3271 ANALYZE_PRINTF ("waiting for inverted command repetition\n");\r
4225a882 3272 irmp_ir_detected = FALSE;\r
3273 last_irmp_denon_command = irmp_tmp_command;\r
3274 }\r
3275 }\r
3276 else\r
3277#endif // IRMP_SUPPORT_DENON_PROTOCOL\r
592411d1 3278\r
3279#if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1\r
d155e9ab 3280 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff)\r
3281 { // Grundig start frame?\r
48664931 3282 ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");\r
592411d1 3283 irmp_ir_detected = FALSE;\r
592411d1 3284 }\r
3285 else\r
d155e9ab 3286#endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL\r
3287\r
3288#if IRMP_SUPPORT_NOKIA_PROTOCOL == 1\r
3289 if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe)\r
3290 { // Nokia start frame?\r
48664931 3291 ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n");\r
d155e9ab 3292 irmp_ir_detected = FALSE;\r
3293 }\r
3294 else\r
3295#endif // IRMP_SUPPORT_NOKIA_PROTOCOL\r
4225a882 3296 {\r
cb8474cc 3297#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
3298 if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame\r
3299 {\r
c7a47e89 3300 if (repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)\r
6db2522c 3301 {\r
c7a47e89 3302 ANALYZE_PRINTF ("Detected NEC repetition frame, repetition_len = %d\n", repetition_len);\r
6db2522c 3303 irmp_tmp_address = last_irmp_address; // address is last address\r
3304 irmp_tmp_command = last_irmp_command; // command is last command\r
3305 irmp_flags |= IRMP_FLAG_REPETITION;\r
c7a47e89 3306 repetition_len = 0;\r
6db2522c 3307 }\r
3308 else\r
3309 {\r
c7a47e89 3310 ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, repetition_len = %d > %d\n",\r
3311 repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);\r
6db2522c 3312 irmp_ir_detected = FALSE;\r
3313 }\r
cb8474cc 3314 }\r
4225a882 3315#endif // IRMP_SUPPORT_NEC_PROTOCOL\r
770a1a9d 3316\r
3317#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
3318 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)\r
3319 {\r
3320 uint8_t xor;\r
3321 // ANALYZE_PRINTF ("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",\r
3322 // xor_check[0], xor_check[1], xor_check[2], xor_check[3], xor_check[4], xor_check[5]);\r
3323\r
3324 xor = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4);\r
3325\r
3326 if (xor != (xor_check[2] & 0x0F))\r
3327 {\r
3328 ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor, xor_check[2] & 0x0F);\r
3329 irmp_ir_detected = FALSE;\r
3330 }\r
3331\r
3332 xor = xor_check[2] ^ xor_check[3] ^ xor_check[4];\r
3333\r
3334 if (xor != xor_check[5])\r
3335 {\r
3336 ANALYZE_PRINTF ("error 4: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, xor_check[5]);\r
3337 irmp_ir_detected = FALSE;\r
3338 }\r
3339 }\r
3340#endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
3341\r
c7a47e89 3342#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
3343 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6?\r
3344 {\r
3345 irmp_protocol = IRMP_RC6A_PROTOCOL;\r
3346 }\r
3347 else\r
3348#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
3349\r
4225a882 3350 irmp_protocol = irmp_param.protocol;\r
d823e852 3351\r
3352#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
3353 if (irmp_param.protocol == IRMP_FDC_PROTOCOL)\r
3354 {\r
3355 if (irmp_tmp_command & 0x000F) // released key?\r
3356 {\r
3357 irmp_tmp_command = (irmp_tmp_command >> 4) | 0x80; // yes, set bit 7\r
3358 }\r
3359 else\r
3360 {\r
3361 irmp_tmp_command >>= 4; // no, it's a pressed key\r
3362 }\r
3363 irmp_tmp_command |= (irmp_tmp_address << 2) & 0x0F00; // 000000CCCCAAAAAA -> 0000CCCC00000000\r
3364 irmp_tmp_address &= 0x003F;\r
3365 }\r
3366#endif\r
3367\r
4225a882 3368 irmp_address = irmp_tmp_address; // store address\r
3369#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
03780b34 3370 if (irmp_param.protocol == IRMP_NEC_PROTOCOL)\r
3371 {\r
3372 last_irmp_address = irmp_tmp_address; // store as last address, too\r
3373 }\r
4225a882 3374#endif\r
3375\r
3376#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
6f750020 3377 if (irmp_param.protocol == IRMP_RC5_PROTOCOL)\r
3378 {\r
3379 irmp_tmp_command |= rc5_cmd_bit6; // store bit 6\r
3380 }\r
4225a882 3381#endif\r
3382 irmp_command = irmp_tmp_command; // store command\r
3383\r
3384#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
3385 irmp_id = irmp_tmp_id;\r
3386#endif\r
3387 }\r
3388 }\r
3389\r
3390 if (irmp_ir_detected)\r
3391 {\r
03780b34 3392 if (last_irmp_command == irmp_tmp_command &&\r
3393 last_irmp_address == irmp_tmp_address &&\r
c7a47e89 3394 repetition_len < IRMP_KEY_REPETITION_LEN)\r
4225a882 3395 {\r
3396 irmp_flags |= IRMP_FLAG_REPETITION;\r
3397 }\r
3398\r
3399 last_irmp_address = irmp_tmp_address; // store as last address, too\r
3400 last_irmp_command = irmp_tmp_command; // store as last command, too\r
3401\r
c7a47e89 3402 repetition_len = 0;\r
4225a882 3403 }\r
879b06c2 3404 else\r
3405 {\r
48664931 3406 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
879b06c2 3407 }\r
4225a882 3408\r
1f54e86c 3409// irmp_busy_flag = FALSE;\r
4225a882 3410 irmp_start_bit_detected = 0; // and wait for next start bit\r
3411 irmp_tmp_command = 0;\r
3412 irmp_pulse_time = 0;\r
3413 irmp_pause_time = 0;\r
770a1a9d 3414\r
3415#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
3416 if (irmp_protocol == IRMP_JVC_PROTOCOL) // the stop bit of JVC frame is also start bit of next frame\r
3417 { // set pulse time here!\r
3418 irmp_pulse_time = ((uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME));\r
3419 }\r
3420#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
4225a882 3421 }\r
3422 }\r
3423 }\r
879b06c2 3424 return (irmp_ir_detected);\r
4225a882 3425}\r
3426\r
48664931 3427#ifdef ANALYZE\r
4225a882 3428\r
2eab5ec9 3429/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
3430 * main functions - for Unix/Linux + Windows only!\r
3431 *\r
3432 * AVR: see main.c!\r
3433 *\r
3434 * Compile it under linux with:\r
3435 * cc irmp.c -o irmp\r
3436 *\r
3437 * usage: ./irmp [-v|-s|-a|-l|-p] < file\r
3438 *\r
3439 * options:\r
3440 * -v verbose\r
3441 * -s silent\r
3442 * -a analyze\r
3443 * -l list pulse/pauses\r
3444 * -p print timings\r
3445 *---------------------------------------------------------------------------------------------------------------------------------------------------\r
3446 */\r
4225a882 3447\r
fef942f6 3448static void\r
3449print_timings (void)\r
3450{\r
c7a47e89 3451 printf ("IRMP_TIMEOUT_LEN: %d [%d byte(s)]\n", IRMP_TIMEOUT_LEN, sizeof (PAUSE_LEN));\r
2eab5ec9 3452 printf ("IRMP_KEY_REPETITION_LEN %d\n", IRMP_KEY_REPETITION_LEN);\r
3453 puts ("");\r
6f750020 3454 printf ("PROTOCOL S S-PULSE S-PAUSE PULSE-0 PAUSE-0 PULSE-1 PAUSE-1\n");\r
fef942f6 3455 printf ("====================================================================================\n");\r
6f750020 3456 printf ("SIRCS 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3457 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
3458 SIRCS_0_PULSE_LEN_MIN, SIRCS_0_PULSE_LEN_MAX, SIRCS_PAUSE_LEN_MIN, SIRCS_PAUSE_LEN_MAX,\r
3459 SIRCS_1_PULSE_LEN_MIN, SIRCS_1_PULSE_LEN_MAX, SIRCS_PAUSE_LEN_MIN, SIRCS_PAUSE_LEN_MAX);\r
3460\r
3461 printf ("NEC 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3462 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
3463 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX,\r
3464 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_1_PAUSE_LEN_MIN, NEC_1_PAUSE_LEN_MAX);\r
3465\r
3466 printf ("NEC (rep) 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3467 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
3468 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX,\r
3469 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_1_PAUSE_LEN_MIN, NEC_1_PAUSE_LEN_MAX);\r
3470\r
3471 printf ("SAMSUNG 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3472 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
3473 SAMSUNG_PULSE_LEN_MIN, SAMSUNG_PULSE_LEN_MAX, SAMSUNG_0_PAUSE_LEN_MIN, SAMSUNG_0_PAUSE_LEN_MAX,\r
3474 SAMSUNG_PULSE_LEN_MIN, SAMSUNG_PULSE_LEN_MAX, SAMSUNG_1_PAUSE_LEN_MIN, SAMSUNG_1_PAUSE_LEN_MAX);\r
3475\r
3476 printf ("MATSUSHITA 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3477 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
3478 MATSUSHITA_PULSE_LEN_MIN, MATSUSHITA_PULSE_LEN_MAX, MATSUSHITA_0_PAUSE_LEN_MIN, MATSUSHITA_0_PAUSE_LEN_MAX,\r
3479 MATSUSHITA_PULSE_LEN_MIN, MATSUSHITA_PULSE_LEN_MAX, MATSUSHITA_1_PAUSE_LEN_MIN, MATSUSHITA_1_PAUSE_LEN_MAX);\r
3480\r
3481 printf ("KASEIKYO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3482 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
3483 KASEIKYO_PULSE_LEN_MIN, KASEIKYO_PULSE_LEN_MAX, KASEIKYO_0_PAUSE_LEN_MIN, KASEIKYO_0_PAUSE_LEN_MAX,\r
3484 KASEIKYO_PULSE_LEN_MIN, KASEIKYO_PULSE_LEN_MAX, KASEIKYO_1_PAUSE_LEN_MIN, KASEIKYO_1_PAUSE_LEN_MAX);\r
3485\r
3486 printf ("RECS80 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3487 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
3488 RECS80_PULSE_LEN_MIN, RECS80_PULSE_LEN_MAX, RECS80_0_PAUSE_LEN_MIN, RECS80_0_PAUSE_LEN_MAX,\r
3489 RECS80_PULSE_LEN_MIN, RECS80_PULSE_LEN_MAX, RECS80_1_PAUSE_LEN_MIN, RECS80_1_PAUSE_LEN_MAX);\r
3490\r
3491 printf ("RC5 1 %3d - %3d %3d - %3d %3d - %3d\n",\r
3492 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
3493 RC5_BIT_LEN_MIN, RC5_BIT_LEN_MAX);\r
3494\r
3495 printf ("DENON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3496 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,\r
3497 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX,\r
3498 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX);\r
3499\r
beda975f 3500 printf ("THOMSON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3501 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX,\r
3502 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX,\r
3503 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX);\r
3504\r
c7a47e89 3505 printf ("RC6 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
6f750020 3506 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 3507 RC6_BIT_PULSE_LEN_MIN, RC6_BIT_PULSE_LEN_MAX, RC6_BIT_PAUSE_LEN_MIN, RC6_BIT_PAUSE_LEN_MAX);\r
6f750020 3508\r
3509 printf ("RECS80EXT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3510 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
3511 RECS80EXT_PULSE_LEN_MIN, RECS80EXT_PULSE_LEN_MAX, RECS80EXT_0_PAUSE_LEN_MIN, RECS80EXT_0_PAUSE_LEN_MAX,\r
3512 RECS80EXT_PULSE_LEN_MIN, RECS80EXT_PULSE_LEN_MAX, RECS80EXT_1_PAUSE_LEN_MIN, RECS80EXT_1_PAUSE_LEN_MAX);\r
3513\r
3514 printf ("NUBERT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3515 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
3516 NUBERT_0_PULSE_LEN_MIN, NUBERT_0_PULSE_LEN_MAX, NUBERT_0_PAUSE_LEN_MIN, NUBERT_0_PAUSE_LEN_MAX,\r
3517 NUBERT_1_PULSE_LEN_MIN, NUBERT_1_PULSE_LEN_MAX, NUBERT_1_PAUSE_LEN_MIN, NUBERT_1_PAUSE_LEN_MAX);\r
3518\r
3519 printf ("BANG_OLUFSEN 1 %3d - %3d %3d - %3d\n",\r
3520 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,\r
3521 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);\r
3522\r
2eab5ec9 3523 printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n",\r
3524 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,\r
3525 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);\r
3526\r
6f750020 3527 printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n",\r
3528 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,\r
3529 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);\r
3530\r
3531 printf ("BANG_OLUFSEN 4 %3d - %3d %3d - %3d\n",\r
3532 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,\r
3533 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);\r
3534\r
3535 printf ("BANG_OLUFSEN - %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3536 BANG_OLUFSEN_PULSE_LEN_MIN, BANG_OLUFSEN_PULSE_LEN_MAX, BANG_OLUFSEN_0_PAUSE_LEN_MIN, BANG_OLUFSEN_0_PAUSE_LEN_MAX,\r
3537 BANG_OLUFSEN_PULSE_LEN_MIN, BANG_OLUFSEN_PULSE_LEN_MAX, BANG_OLUFSEN_1_PAUSE_LEN_MIN, BANG_OLUFSEN_1_PAUSE_LEN_MAX);\r
3538\r
3539 printf ("GRUNDIG/NOKIA 1 %3d - %3d %3d - %3d %3d - %3d\n",\r
89e8cafb 3540 GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX,\r
3541 GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX,\r
3542 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_BIT_LEN_MAX);\r
6f750020 3543\r
12948cf3 3544 printf ("SIEMENS/RUWIDO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3545 SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,\r
3546 SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX,\r
3547 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX,\r
3548 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX,\r
31c1f035 3549 2 * SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX,\r
3550 2 * SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX);\r
6f750020 3551\r
3552 printf ("FDC 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3553 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
3554 FDC_PULSE_LEN_MIN, FDC_PULSE_LEN_MAX, FDC_0_PAUSE_LEN_MIN, FDC_0_PAUSE_LEN_MAX,\r
3555 FDC_PULSE_LEN_MIN, FDC_PULSE_LEN_MAX, FDC_1_PAUSE_LEN_MIN, FDC_1_PAUSE_LEN_MAX);\r
3556\r
3557 printf ("RCCAR 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3558 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
3559 RCCAR_PULSE_LEN_MIN, RCCAR_PULSE_LEN_MAX, RCCAR_0_PAUSE_LEN_MIN, RCCAR_0_PAUSE_LEN_MAX,\r
3560 RCCAR_PULSE_LEN_MIN, RCCAR_PULSE_LEN_MAX, RCCAR_1_PAUSE_LEN_MIN, RCCAR_1_PAUSE_LEN_MAX);\r
9405f84a 3561\r
3562 printf ("NIKON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3563 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
3564 NIKON_PULSE_LEN_MIN, NIKON_PULSE_LEN_MAX, NIKON_0_PAUSE_LEN_MIN, NIKON_0_PAUSE_LEN_MAX,\r
3565 NIKON_PULSE_LEN_MIN, NIKON_PULSE_LEN_MAX, NIKON_1_PAUSE_LEN_MIN, NIKON_1_PAUSE_LEN_MAX);\r
f50e01e7 3566\r
3567 printf ("LEGO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
3568 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
3569 LEGO_PULSE_LEN_MIN, LEGO_PULSE_LEN_MAX, LEGO_0_PAUSE_LEN_MIN, LEGO_0_PAUSE_LEN_MAX,\r
3570 LEGO_PULSE_LEN_MIN, LEGO_PULSE_LEN_MAX, LEGO_1_PAUSE_LEN_MIN, LEGO_1_PAUSE_LEN_MAX);\r
3571\r
fef942f6 3572}\r
3573\r
77f488bb 3574void\r
48664931 3575print_spectrum (char * text, int * buf, int is_pulse)\r
77f488bb 3576{\r
3577 int i;\r
3578 int j;\r
48664931 3579 int min;\r
3580 int max;\r
3581 int max_value = 0;\r
77f488bb 3582 int value;\r
3583 int sum = 0;\r
3584 int counter = 0;\r
3585 double average = 0;\r
48664931 3586 double tolerance;\r
77f488bb 3587\r
48664931 3588 puts ("-------------------------------------------------------------------------------");\r
77f488bb 3589 printf ("%s:\n", text);\r
3590\r
3591 for (i = 0; i < 256; i++)\r
3592 {\r
48664931 3593 if (buf[i] > max_value)\r
77f488bb 3594 {\r
48664931 3595 max_value = buf[i];\r
77f488bb 3596 }\r
3597 }\r
3598\r
53c11f07 3599 for (i = 1; i < 100; i++)\r
77f488bb 3600 {\r
3601 if (buf[i] > 0)\r
3602 {\r
3603 printf ("%3d ", i);\r
48664931 3604 value = (buf[i] * 60) / max_value;\r
77f488bb 3605\r
3606 for (j = 0; j < value; j++)\r
3607 {\r
3608 putchar ('o');\r
3609 }\r
3610 printf (" %d\n", buf[i]);\r
3611\r
3612 sum += i * buf[i];\r
3613 counter += buf[i];\r
3614 }\r
3615 else\r
3616 {\r
48664931 3617 max = i - 1;\r
3618\r
77f488bb 3619 if (counter > 0)\r
3620 {\r
3621 average = (float) sum / (float) counter;\r
48664931 3622\r
3623 if (is_pulse)\r
3624 {\r
3625 printf ("pulse ");\r
3626 }\r
3627 else\r
3628 {\r
3629 printf ("pause ");\r
3630 }\r
3631\r
3632 printf ("avg: %4.1f=%6.1f us, ", average, (1000000. * average) / (float) F_INTERRUPTS);\r
3633 printf ("min: %2d=%6.1f us, ", min, (1000000. * min) / (float) F_INTERRUPTS);\r
3634 printf ("max: %2d=%6.1f us, ", max, (1000000. * max) / (float) F_INTERRUPTS);\r
3635\r
3636 tolerance = (max - average);\r
3637\r
3638 if (average - min > tolerance)\r
3639 {\r
3640 tolerance = average - min;\r
3641 }\r
3642\r
3643 tolerance = tolerance * 100 / average;\r
3644 printf ("tol: %4.1f%%\n", tolerance);\r
77f488bb 3645 }\r
48664931 3646\r
77f488bb 3647 counter = 0;\r
3648 sum = 0;\r
48664931 3649 min = i + 1;\r
77f488bb 3650 }\r
3651 }\r
3652}\r
3653\r
d823e852 3654#define STATE_LEFT_SHIFT 0x01\r
3655#define STATE_RIGHT_SHIFT 0x02\r
3656#define STATE_LEFT_CTRL 0x04\r
3657#define STATE_LEFT_ALT 0x08\r
3658#define STATE_RIGHT_ALT 0x10\r
3659\r
3660#define KEY_ESCAPE 0x1B // keycode = 0x006e\r
3661#define KEY_MENUE 0x80 // keycode = 0x0070\r
3662#define KEY_BACK 0x81 // keycode = 0x0071\r
3663#define KEY_FORWARD 0x82 // keycode = 0x0072\r
3664#define KEY_ADDRESS 0x83 // keycode = 0x0073\r
3665#define KEY_WINDOW 0x84 // keycode = 0x0074\r
3666#define KEY_1ST_PAGE 0x85 // keycode = 0x0075\r
3667#define KEY_STOP 0x86 // keycode = 0x0076\r
3668#define KEY_MAIL 0x87 // keycode = 0x0077\r
3669#define KEY_FAVORITES 0x88 // keycode = 0x0078\r
c6ade1d2 3670#define KEY_NEW_PAGE 0x89 // keycode = 0x0079\r
3671#define KEY_SETUP 0x8A // keycode = 0x007a\r
3672#define KEY_FONT 0x8B // keycode = 0x007b\r
3673#define KEY_PRINT 0x8C // keycode = 0x007c\r
3674#define KEY_ON_OFF 0x8E // keycode = 0x007c\r
3675\r
3676#define KEY_INSERT 0x90 // keycode = 0x004b\r
3677#define KEY_DELETE 0x91 // keycode = 0x004c\r
3678#define KEY_LEFT 0x92 // keycode = 0x004f\r
3679#define KEY_HOME 0x93 // keycode = 0x0050\r
3680#define KEY_END 0x94 // keycode = 0x0051\r
3681#define KEY_UP 0x95 // keycode = 0x0053\r
3682#define KEY_DOWN 0x96 // keycode = 0x0054\r
3683#define KEY_PAGE_UP 0x97 // keycode = 0x0055\r
3684#define KEY_PAGE_DOWN 0x98 // keycode = 0x0056\r
3685#define KEY_RIGHT 0x99 // keycode = 0x0059\r
3686#define KEY_MOUSE_1 0x9E // keycode = 0x0400\r
3687#define KEY_MOUSE_2 0x9F // keycode = 0x0800\r
d823e852 3688\r
3689static uint8_t\r
3690get_fdc_key (uint16_t cmd)\r
3691{\r
3692 static uint8_t key_table[128] =\r
3693 {\r
3694 // 0 1 2 3 4 5 6 7 8 9 A B C D E F\r
3695