1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp.c - infrared multi-protocol decoder, supports several remote control protocols
4 * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de
6 * $Id: irmp.c,v 1.24 2010/05/16 21:58:13 fm Exp $
10 * Typical manufacturers:
13 * NEC - NEC, Yamaha, Canon, Tevion, Harman/Kardon, Hitachi, JVC, Pioneer, Toshiba, Xoro, Orion, and many other Japanese manufacturers
16 * MATSUSHITA - Matsushita
17 * KASEIKYO - Panasonic, Denon & other Japanese manufacturers (members of "Japan's Association for Electric Home Application")
18 * RECS80 - Philips, Nokia, Thomson, Nordmende, Telefunken, Saba
19 * RC5 - Philips and other European manufacturers
21 * RC6 - Philips and other European manufacturers
23 * NUBERT - Nubert Subwoofer System
24 * B&O - Bang & Olufsen
25 * PANASONIC - Panasonic (older, yet not implemented)
28 *---------------------------------------------------------------------------------------------------------------------------------------------------
33 * frame: 1 start bit + 12-20 data bits + no stop bit
34 * data: 7 command bits + 5 address bits + 0 to 8 additional bits
36 * start bit: data "0": data "1": stop bit:
37 * -----------------_________ ------_____ ------------______
38 * 2400us 600us 600us 600us 1200us 600 us no stop bit
40 *---------------------------------------------------------------------------------------------------------------------------------------------------
43 * -------------------------
45 * frame: 1 start bit + 32 data bits + 1 stop bit
46 * data NEC: 8 address bits + 8 inverted address bits + 8 command bits + 8 inverted command bits
47 * data extended NEC: 16 address bits + 8 command bits + 8 inverted command bits
49 * start bit: data "0": data "1": stop bit:
50 * -----------------_________ ------______ ------________________ ------______....
51 * 9000us 4500us 560us 560us 560us 1690 us 560us
56 * -----------------_________------______ .... ~100ms Pause, then repeat
59 *---------------------------------------------------------------------------------------------------------------------------------------------------
64 * frame: 1 start bit + 16 data(1) bits + 1 sync bit + additional 20 data(2) bits + 1 stop bit
65 * data(1): 16 address bits
66 * data(2): 4 ID bits + 8 command bits + 8 inverted command bits
68 * start bit: data "0": data "1": sync bit: stop bit:
69 * ----------______________ ------______ ------________________ ------______________ ------______....
70 * 4500us 4500us 550us 450us 550us 1450us 550us 4500us 550us
72 *---------------------------------------------------------------------------------------------------------------------------------------------------
77 * frame: 1 start bit + 32 data bits + 1 stop bit
78 * data: 16 address bits + 16 command bits
80 * start bit: data "0": data "1": stop bit:
81 * ----------______________ ------______ ------________________ ------______....
82 * 4500us 4500us 550us 450us 550us 1450us 550us
84 *---------------------------------------------------------------------------------------------------------------------------------------------------
89 * frame: 1 start bit + 24 data bits + 1 stop bit
90 * data: 6 custom bits + 6 command bits + 12 address bits
92 * start bit: data "0": data "1": stop bit:
93 * ----------_________ ------______ ------________________ ------______....
94 * 3488us 3488us 872us 872us 872us 2616us 872us
96 *---------------------------------------------------------------------------------------------------------------------------------------------------
101 * frame: 1 start bit + 48 data bits + 1 stop bit
102 * data: 16 manufacturer bits + 4 parity bits + 4 genre1 bits + 4 genre2 bits + 10 command bits + 2 id bits + 8 parity bits
104 * start bit: data "0": data "1": stop bit:
105 * ----------______ ------______ ------________________ ------______....
106 * 3380us 1690us 423us 423us 423us 1269us 423us
108 *---------------------------------------------------------------------------------------------------------------------------------------------------
113 * frame: 2 start bits + 10 data bits + 1 stop bit
114 * data: 1 toggle bit + 3 address bits + 6 command bits
116 * start bit: data "0": data "1": stop bit:
117 * -----_____________________ -----____________ -----______________ ------_______....
118 * 158us 7432us 158us 4902us 158us 7432us 158us
120 *---------------------------------------------------------------------------------------------------------------------------------------------------
125 * frame: 2 start bits + 11 data bits + 1 stop bit
126 * data: 1 toggle bit + 4 address bits + 6 command bits
128 * start bit: data "0": data "1": stop bit:
129 * -----_____________________ -----____________ -----______________ ------_______....
130 * 158us 3637us 158us 4902us 158us 7432us 158us
132 *---------------------------------------------------------------------------------------------------------------------------------------------------
137 * RC5 frame: 2 start bits + 12 data bits + no stop bit
138 * RC5 data: 1 toggle bit + 5 address bits + 6 command bits
139 * RC5X frame: 1 start bit + 13 data bits + no stop bit
140 * RC5X data: 1 inverted command bit + 1 toggle bit + 5 address bits + 6 command bits
142 * start bit: data "0": data "1":
143 * ______----- ------______ ______------
144 * 889us 889us 889us 889us 889us 889us
146 *---------------------------------------------------------------------------------------------------------------------------------------------------
151 * frame: 0 start bits + 16 data bits + stop bit + 65ms pause + 16 inverted data bits + stop bit
152 * data: 5 address bits + 10 command bits
154 * data "0": data "1":
155 * ------________________ ------______________
156 * 275us 1050us 275us 1900us
158 *---------------------------------------------------------------------------------------------------------------------------------------------------
163 * RC6 frame: 1 start bit + 1 bit "1" + 3 mode bits + 1 toggle bit + 16 data bits + 2666 µs pause
164 * RC6 data: 8 address bits + 8 command bits
166 * start bit toggle bit "0": toggle bit "1": data/mode "0": data/mode "1":
167 * ____________------- _______------- -------_______ _______------- -------_______
168 * 2666us 889us 889us 889us 889us 889us 444us 444us 444us 444us
170 *---------------------------------------------------------------------------------------------------------------------------------------------------
175 * frame: 1 start bit + 32 data bits + 1 stop bit
176 * data: 16 address bits + 11100000 + 8 command bits
178 * start bit: data "0": data "1": stop bit:
179 * -----------------_________ ------______ ------________________ ------______....
180 * 9000us 4500us 560us 560us 560us 1690 us 560us
182 *---------------------------------------------------------------------------------------------------------------------------------------------------
184 * NUBERT (subwoofer system)
185 * -------------------------
187 * frame: 1 start bit + 10 data bits + 1 stop bit
188 * data: 0 address bits + 10 command bits ?
190 * start bit: data "0": data "1": stop bit:
191 * ----------_____ ------______ ------________________ ------______....
192 * 1340us 340us 500us 1300us 1340us 340us 500us
194 *---------------------------------------------------------------------------------------------------------------------------------------------------
199 * frame: 4 start bits + 16 data bits + 1 trailer bit + 1 stop bit
200 * data: 0 address bits + 16 command bits
202 * 1st start bit: 2nd start bit: 3rd start bit: 4th start bit:
203 * -----________ -----________ -----_____________ -----________
204 * 210us 3000us 210us 3000us 210us 15000us 210us 3000us
206 * data "0": data "1": data "repeat bit": trailer bit: stop bit:
207 * -----________ -----_____________ -----___________ -----_____________ -----____...
208 * 210us 3000us 210us 9000us 210us 6000us 210us 12000us 210us
210 *---------------------------------------------------------------------------------------------------------------------------------------------------
215 * frame: 1 start packet + n info packets + 1 stop packet
216 * packet: 1 pre bit + 1 start bit + 9 data bits + no stop bit
217 * data of start packet: 9 x 1
218 * data of info packet: 9 command bits
219 * data of stop packet: 9 x 1
221 * pre bit: start bit data "0": data "1":
222 * ------____________ ------______ ______------ ------______
223 * 528us 2639us 528us 528us 528us 528us 528us 528us
225 *---------------------------------------------------------------------------------------------------------------------------------------------------
227 * PANASONIC (older protocol, yet not implemented, see also MATSUSHITA, timing very similar)
228 * -----------------------------------------------------------------------------------------
230 * frame: 1 start bit + 22 data bits + 1 stop bit
231 * 22 data bits = 5 custom bits + 6 data bits + 5 inverted custom bits + 6 inverted data bits
233 * European version: T = 456us
234 * USA & Canada version: T = 422us
236 * start bit: data "0": data "1": stop bit:
237 * 8T 8T 2T 2T 2T 6T 2T
238 * -------------____________ ------_____ ------_____________ ------_______....
239 * 3648us 3648us 912us 912us 912us 2736us 912us (Europe)
240 * 3376us 3376us 844us 844us 844us 2532us 844us (US)
242 *---------------------------------------------------------------------------------------------------------------------------------------------------
244 * This program is free software; you can redistribute it and/or modify
245 * it under the terms of the GNU General Public License as published by
246 * the Free Software Foundation; either version 2 of the License, or
247 * (at your option) any later version.
248 *---------------------------------------------------------------------------------------------------------------------------------------------------
251 #if defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC Compiler instead of AVR
252 #define PIC_CCS_COMPILER
255 #ifdef unix // test on linux/unix
260 #include <inttypes.h>
264 #define memcpy_P memcpy
271 typedef unsigned char uint8_t;
272 typedef unsigned short uint16_t;
275 #define memcpy_P memcpy
281 #ifdef PIC_CCS_COMPILER
284 typedef unsigned int8
uint8_t;
285 typedef unsigned int16
uint16_t;
287 #define memcpy_P memcpy
291 #include <inttypes.h>
295 #include <util/delay.h>
296 #include <avr/pgmspace.h>
298 #endif // PIC_CCS_COMPILER
305 #include "irmpconfig.h"
307 #define IRMP_TIMEOUT_TIME 16500.0e-6 // timeout after 16.5 ms darkness
308 #define IRMP_TIMEOUT_LEN (uint8_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)
309 #define IRMP_REPETITION_TIME (uint16_t)(F_INTERRUPTS * 100.0e-3 + 0.5) // autodetect key repetition within 100 msec
311 #define MIN_TOLERANCE_00 1.0 // -0%
312 #define MAX_TOLERANCE_00 1.0 // +0%
314 #define MIN_TOLERANCE_05 0.95 // -5%
315 #define MAX_TOLERANCE_05 1.05 // +5%
317 #define MIN_TOLERANCE_10 0.9 // -10%
318 #define MAX_TOLERANCE_10 1.1 // +10%
320 #define MIN_TOLERANCE_15 0.85 // -15%
321 #define MAX_TOLERANCE_15 1.15 // +15%
323 #define MIN_TOLERANCE_20 0.8 // -20%
324 #define MAX_TOLERANCE_20 1.2 // +20%
326 #define MIN_TOLERANCE_30 0.7 // -30%
327 #define MAX_TOLERANCE_30 1.3 // +30%
329 #define MIN_TOLERANCE_40 0.6 // -40%
330 #define MAX_TOLERANCE_40 1.4 // +40%
332 #define MIN_TOLERANCE_50 0.5 // -50%
333 #define MAX_TOLERANCE_50 1.5 // +50%
335 #define MIN_TOLERANCE_60 0.4 // -60%
336 #define MAX_TOLERANCE_60 1.6 // +60%
338 #define SIRCS_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
339 #define SIRCS_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
340 #define SIRCS_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
341 #define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) // only 5% to avoid conflict with RC6
342 #define SIRCS_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
343 #define SIRCS_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
344 #define SIRCS_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
345 #define SIRCS_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
346 #define SIRCS_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
347 #define SIRCS_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
349 #define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
350 #define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
351 #define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
352 #define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
353 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
354 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
355 #define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
356 #define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
357 #define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
358 #define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
359 #define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
360 #define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
362 #define SAMSUNG_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
363 #define SAMSUNG_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
364 #define SAMSUNG_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
365 #define SAMSUNG_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
366 #define SAMSUNG_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
367 #define SAMSUNG_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
368 #define SAMSUNG_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
369 #define SAMSUNG_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
370 #define SAMSUNG_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
371 #define SAMSUNG_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
373 #define MATSUSHITA_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
374 #define MATSUSHITA_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
375 #define MATSUSHITA_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
376 #define MATSUSHITA_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
377 #define MATSUSHITA_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
378 #define MATSUSHITA_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
379 #define MATSUSHITA_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
380 #define MATSUSHITA_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
381 #define MATSUSHITA_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
382 #define MATSUSHITA_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
384 #define KASEIKYO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
385 #define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
386 #define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
387 #define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
388 #define KASEIKYO_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
389 #define KASEIKYO_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_60 + 0.5) + 1)
390 #define KASEIKYO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
391 #define KASEIKYO_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
392 #define KASEIKYO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
393 #define KASEIKYO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
395 #define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)
396 #define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
397 #define RECS80_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
398 #define RECS80_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
399 #define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
400 #define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
401 #define RECS80_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
402 #define RECS80_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
403 #define RECS80_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
404 #define RECS80_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
406 #define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
407 #define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
408 #define RC5_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
409 #define RC5_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
411 #define DENON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
412 #define DENON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
413 #define DENON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
414 #define DENON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
415 #define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
416 #define DENON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
418 #define RC6_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
419 #define RC6_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
420 #define RC6_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
421 #define RC6_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
422 #define RC6_TOGGLE_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
423 #define RC6_TOGGLE_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
424 #define RC6_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
425 #define RC6_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
427 #define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)
428 #define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_00 + 0.5) + 1)
429 #define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
430 #define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
431 #define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
432 #define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
433 #define RECS80EXT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
434 #define RECS80EXT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
435 #define RECS80EXT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
436 #define RECS80EXT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
438 #define NUBERT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
439 #define NUBERT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
440 #define NUBERT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
441 #define NUBERT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
442 #define NUBERT_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
443 #define NUBERT_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
444 #define NUBERT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
445 #define NUBERT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
446 #define NUBERT_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
447 #define NUBERT_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
448 #define NUBERT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
449 #define NUBERT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
451 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
452 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
453 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
454 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
455 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
456 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
457 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
458 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
459 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
460 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
461 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
462 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
463 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
464 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
465 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
466 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
467 #define BANG_OLUFSEN_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
468 #define BANG_OLUFSEN_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
469 #define BANG_OLUFSEN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
470 #define BANG_OLUFSEN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
471 #define BANG_OLUFSEN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
472 #define BANG_OLUFSEN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
473 #define BANG_OLUFSEN_R_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
474 #define BANG_OLUFSEN_R_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
475 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
476 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
478 #define GRUNDIG_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
479 #define GRUNDIG_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
480 #define GRUNDIG_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
481 #define GRUNDIG_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
482 #define GRUNDIG_PRE_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_PRE_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) + 1)
483 #define GRUNDIG_PRE_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_PRE_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
485 #define AUTO_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_REPETITION_TIME + 0.5) // use uint16_t!
488 #define DEBUG_PUTCHAR(a) { if (! silent) { putchar (a); } }
489 #define DEBUG_PRINTF(...) { if (! silent) { printf (__VA_ARGS__); } }
491 static int time_counter
;
493 #define DEBUG_PUTCHAR(a)
494 #define DEBUG_PRINTF(...)
497 #if IRMP_LOGGING == 1
498 #define irmp_logIsr(x) irmp_logIr((x) ? 1:0)
499 #define UART_BAUD 9600L
501 // calculate real baud rate:
502 #define UBRR_VAL ((F_CPU + UART_BAUD * 8) / (UART_BAUD * 16) - 1) // round
503 #define BAUD_REAL (F_CPU / (16 * (UBRR_VAL + 1))) // real baudrate
506 #if ((BAUD_REAL * 1000) / UART_BAUD - 1000) > 10
507 # error Error of baud rate of RS232 UARTx is more than 1%. That is too high!
510 #else // not CODEVISION
512 #define BAUD_ERROR ((BAUD_REAL * 1000) / UART_BAUD - 1000) // error in promille
514 #if ((BAUD_ERROR > 10) || (-BAUD_ERROR < 10))
515 # error Error of baud rate of RS232 UARTx is more than 1%. That is too high!
520 /*---------------------------------------------------------------------------------------------------------------------------------------------------
522 * @details Initializes UART
523 *---------------------------------------------------------------------------------------------------------------------------------------------------
526 irmp_uart_init (void)
528 UCSR0B
|= (1<<TXEN0
); // activate UART0 TX
529 UBRR0H
= UBRR_VAL
>> 8; // store baudrate (upper byte)
530 UBRR0L
= UBRR_VAL
& 0xFF; // store baudrate (lower byte)
533 /*---------------------------------------------------------------------------------------------------------------------------------------------------
535 * @details Sends character
536 * @param ch character to be transmitted
537 *---------------------------------------------------------------------------------------------------------------------------------------------------
540 irmp_uart_putc (unsigned char ch
)
542 while (!(UCSR0A
& (1<<UDRE0
)))
550 /*---------------------------------------------------------------------------------------------------------------------------------------------------
552 *---------------------------------------------------------------------------------------------------------------------------------------------------
554 #define c_startcycles 2 // min count of zeros before start of logging
555 #define c_endBits 1000 // log buffer size
556 #define c_datalen 700 // number of sequenced highbits to detect end
559 irmp_logIr (uint8_t val
)
561 static uint8_t s_data
[c_datalen
]; // logging buffer
562 static uint16_t s_dataIdx
; // number of written bits
563 static uint8_t s_startcycles
; // current number of start-zeros
564 static uint16_t s_ctr
; // counts sequenced highbits - to detect end
566 if ((val
== 0) && (s_startcycles
< c_startcycles
) && !s_dataIdx
) // prevent that single random zeros init logging
574 if ( (val
== 0) // start or continue logging on "0"
575 || ((val
== 1) && (s_dataIdx
!= 0))) // "1" cannot init logging
578 { // set or clear bit in bitarray
579 s_data
[(s_dataIdx
/ 8)] |= (1<<(s_dataIdx
% 8));
583 s_data
[(s_dataIdx
/ 8)] &= ~(1<<(s_dataIdx
% 8));
589 { // if high received then look at log-stop condition
592 if (s_ctr
> c_endBits
)
593 { // if stop condition (200 sequenced ones) meets, output on uart
596 for (i
= 0; i
< c_startcycles
; ++i
)
598 irmp_uart_putc ('0'); // the ignored starting zeros
601 for (i
= 0;i
< (s_dataIdx
- c_endBits
+ 20) / 8; ++i
) // transform bitset into uart chars
603 uint8_t d
= s_data
[i
];
608 irmp_uart_putc ((d
& 1) + '0');
613 irmp_uart_putc ('\n');
626 #define irmp_logIsr(x)
631 uint8_t protocol
; // ir protocol
632 uint8_t pulse_1_len_min
; // minimum length of pulse with bit value 1
633 uint8_t pulse_1_len_max
; // maximum length of pulse with bit value 1
634 uint8_t pause_1_len_min
; // minimum length of pause with bit value 1
635 uint8_t pause_1_len_max
; // maximum length of pause with bit value 1
636 uint8_t pulse_0_len_min
; // minimum length of pulse with bit value 0
637 uint8_t pulse_0_len_max
; // maximum length of pulse with bit value 0
638 uint8_t pause_0_len_min
; // minimum length of pause with bit value 0
639 uint8_t pause_0_len_max
; // maximum length of pause with bit value 0
640 uint8_t address_offset
; // address offset
641 uint8_t address_end
; // end of address
642 uint8_t command_offset
; // command offset
643 uint8_t command_end
; // end of command
644 uint8_t complete_len
; // complete length of frame
645 uint8_t stop_bit
; // flag: frame has stop bit
646 uint8_t lsb_first
; // flag: LSB first
649 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
651 static PROGMEM IRMP_PARAMETER sircs_param
=
654 SIRCS_1_PULSE_LEN_MIN
,
655 SIRCS_1_PULSE_LEN_MAX
,
658 SIRCS_0_PULSE_LEN_MIN
,
659 SIRCS_0_PULSE_LEN_MAX
,
662 SIRCS_ADDRESS_OFFSET
,
663 SIRCS_ADDRESS_OFFSET
+ SIRCS_ADDRESS_LEN
,
664 SIRCS_COMMAND_OFFSET
,
665 SIRCS_COMMAND_OFFSET
+ SIRCS_COMMAND_LEN
,
666 SIRCS_COMPLETE_DATA_LEN
,
673 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
675 static PROGMEM IRMP_PARAMETER nec_param
=
687 NEC_ADDRESS_OFFSET
+ NEC_ADDRESS_LEN
,
689 NEC_COMMAND_OFFSET
+ NEC_COMMAND_LEN
,
690 NEC_COMPLETE_DATA_LEN
,
695 static PROGMEM IRMP_PARAMETER nec_rep_param
=
717 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
719 static PROGMEM IRMP_PARAMETER samsung_param
=
721 IRMP_SAMSUNG_PROTOCOL
,
722 SAMSUNG_PULSE_LEN_MIN
,
723 SAMSUNG_PULSE_LEN_MAX
,
724 SAMSUNG_1_PAUSE_LEN_MIN
,
725 SAMSUNG_1_PAUSE_LEN_MAX
,
726 SAMSUNG_PULSE_LEN_MIN
,
727 SAMSUNG_PULSE_LEN_MAX
,
728 SAMSUNG_0_PAUSE_LEN_MIN
,
729 SAMSUNG_0_PAUSE_LEN_MAX
,
730 SAMSUNG_ADDRESS_OFFSET
,
731 SAMSUNG_ADDRESS_OFFSET
+ SAMSUNG_ADDRESS_LEN
,
732 SAMSUNG_COMMAND_OFFSET
,
733 SAMSUNG_COMMAND_OFFSET
+ SAMSUNG_COMMAND_LEN
,
734 SAMSUNG_COMPLETE_DATA_LEN
,
741 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
743 static PROGMEM IRMP_PARAMETER matsushita_param
=
745 IRMP_MATSUSHITA_PROTOCOL
,
746 MATSUSHITA_PULSE_LEN_MIN
,
747 MATSUSHITA_PULSE_LEN_MAX
,
748 MATSUSHITA_1_PAUSE_LEN_MIN
,
749 MATSUSHITA_1_PAUSE_LEN_MAX
,
750 MATSUSHITA_PULSE_LEN_MIN
,
751 MATSUSHITA_PULSE_LEN_MAX
,
752 MATSUSHITA_0_PAUSE_LEN_MIN
,
753 MATSUSHITA_0_PAUSE_LEN_MAX
,
754 MATSUSHITA_ADDRESS_OFFSET
,
755 MATSUSHITA_ADDRESS_OFFSET
+ MATSUSHITA_ADDRESS_LEN
,
756 MATSUSHITA_COMMAND_OFFSET
,
757 MATSUSHITA_COMMAND_OFFSET
+ MATSUSHITA_COMMAND_LEN
,
758 MATSUSHITA_COMPLETE_DATA_LEN
,
765 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
767 static PROGMEM IRMP_PARAMETER kaseikyo_param
=
769 IRMP_KASEIKYO_PROTOCOL
,
770 KASEIKYO_PULSE_LEN_MIN
,
771 KASEIKYO_PULSE_LEN_MAX
,
772 KASEIKYO_1_PAUSE_LEN_MIN
,
773 KASEIKYO_1_PAUSE_LEN_MAX
,
774 KASEIKYO_PULSE_LEN_MIN
,
775 KASEIKYO_PULSE_LEN_MAX
,
776 KASEIKYO_0_PAUSE_LEN_MIN
,
777 KASEIKYO_0_PAUSE_LEN_MAX
,
778 KASEIKYO_ADDRESS_OFFSET
,
779 KASEIKYO_ADDRESS_OFFSET
+ KASEIKYO_ADDRESS_LEN
,
780 KASEIKYO_COMMAND_OFFSET
,
781 KASEIKYO_COMMAND_OFFSET
+ KASEIKYO_COMMAND_LEN
,
782 KASEIKYO_COMPLETE_DATA_LEN
,
789 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
791 static PROGMEM IRMP_PARAMETER recs80_param
=
793 IRMP_RECS80_PROTOCOL
,
794 RECS80_PULSE_LEN_MIN
,
795 RECS80_PULSE_LEN_MAX
,
796 RECS80_1_PAUSE_LEN_MIN
,
797 RECS80_1_PAUSE_LEN_MAX
,
798 RECS80_PULSE_LEN_MIN
,
799 RECS80_PULSE_LEN_MAX
,
800 RECS80_0_PAUSE_LEN_MIN
,
801 RECS80_0_PAUSE_LEN_MAX
,
802 RECS80_ADDRESS_OFFSET
,
803 RECS80_ADDRESS_OFFSET
+ RECS80_ADDRESS_LEN
,
804 RECS80_COMMAND_OFFSET
,
805 RECS80_COMMAND_OFFSET
+ RECS80_COMMAND_LEN
,
806 RECS80_COMPLETE_DATA_LEN
,
813 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
815 static PROGMEM IRMP_PARAMETER rc5_param
=
822 1, // tricky: use this as stop bit length
827 RC5_ADDRESS_OFFSET
+ RC5_ADDRESS_LEN
,
829 RC5_COMMAND_OFFSET
+ RC5_COMMAND_LEN
,
830 RC5_COMPLETE_DATA_LEN
,
837 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
839 static PROGMEM IRMP_PARAMETER denon_param
=
844 DENON_1_PAUSE_LEN_MIN
,
845 DENON_1_PAUSE_LEN_MAX
,
848 DENON_0_PAUSE_LEN_MIN
,
849 DENON_0_PAUSE_LEN_MAX
,
850 DENON_ADDRESS_OFFSET
,
851 DENON_ADDRESS_OFFSET
+ DENON_ADDRESS_LEN
,
852 DENON_COMMAND_OFFSET
,
853 DENON_COMMAND_OFFSET
+ DENON_COMMAND_LEN
,
854 DENON_COMPLETE_DATA_LEN
,
861 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
863 static PROGMEM IRMP_PARAMETER rc6_param
=
870 1, // tricky: use this as stop bit length
875 RC6_ADDRESS_OFFSET
+ RC6_ADDRESS_LEN
,
877 RC6_COMMAND_OFFSET
+ RC6_COMMAND_LEN
,
878 RC6_COMPLETE_DATA_LEN_SHORT
,
885 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
887 static PROGMEM IRMP_PARAMETER recs80ext_param
=
889 IRMP_RECS80EXT_PROTOCOL
,
890 RECS80EXT_PULSE_LEN_MIN
,
891 RECS80EXT_PULSE_LEN_MAX
,
892 RECS80EXT_1_PAUSE_LEN_MIN
,
893 RECS80EXT_1_PAUSE_LEN_MAX
,
894 RECS80EXT_PULSE_LEN_MIN
,
895 RECS80EXT_PULSE_LEN_MAX
,
896 RECS80EXT_0_PAUSE_LEN_MIN
,
897 RECS80EXT_0_PAUSE_LEN_MAX
,
898 RECS80EXT_ADDRESS_OFFSET
,
899 RECS80EXT_ADDRESS_OFFSET
+ RECS80EXT_ADDRESS_LEN
,
900 RECS80EXT_COMMAND_OFFSET
,
901 RECS80EXT_COMMAND_OFFSET
+ RECS80EXT_COMMAND_LEN
,
902 RECS80EXT_COMPLETE_DATA_LEN
,
909 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
911 static PROGMEM IRMP_PARAMETER nubert_param
=
913 IRMP_NUBERT_PROTOCOL
,
914 NUBERT_1_PULSE_LEN_MIN
,
915 NUBERT_1_PULSE_LEN_MAX
,
916 NUBERT_1_PAUSE_LEN_MIN
,
917 NUBERT_1_PAUSE_LEN_MAX
,
918 NUBERT_0_PULSE_LEN_MIN
,
919 NUBERT_0_PULSE_LEN_MAX
,
920 NUBERT_0_PAUSE_LEN_MIN
,
921 NUBERT_0_PAUSE_LEN_MAX
,
922 NUBERT_ADDRESS_OFFSET
,
923 NUBERT_ADDRESS_OFFSET
+ NUBERT_ADDRESS_LEN
,
924 NUBERT_COMMAND_OFFSET
,
925 NUBERT_COMMAND_OFFSET
+ NUBERT_COMMAND_LEN
,
926 NUBERT_COMPLETE_DATA_LEN
,
933 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
935 static PROGMEM IRMP_PARAMETER bang_olufsen_param
=
937 IRMP_BANG_OLUFSEN_PROTOCOL
,
938 BANG_OLUFSEN_PULSE_LEN_MIN
,
939 BANG_OLUFSEN_PULSE_LEN_MAX
,
940 BANG_OLUFSEN_1_PAUSE_LEN_MIN
,
941 BANG_OLUFSEN_1_PAUSE_LEN_MAX
,
942 BANG_OLUFSEN_PULSE_LEN_MIN
,
943 BANG_OLUFSEN_PULSE_LEN_MAX
,
944 BANG_OLUFSEN_0_PAUSE_LEN_MIN
,
945 BANG_OLUFSEN_0_PAUSE_LEN_MAX
,
946 BANG_OLUFSEN_ADDRESS_OFFSET
,
947 BANG_OLUFSEN_ADDRESS_OFFSET
+ BANG_OLUFSEN_ADDRESS_LEN
,
948 BANG_OLUFSEN_COMMAND_OFFSET
,
949 BANG_OLUFSEN_COMMAND_OFFSET
+ BANG_OLUFSEN_COMMAND_LEN
,
950 BANG_OLUFSEN_COMPLETE_DATA_LEN
,
951 BANG_OLUFSEN_STOP_BIT
,
957 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
959 static PROGMEM IRMP_PARAMETER grundig_param
=
961 IRMP_GRUNDIG_PROTOCOL
,
966 1, // tricky: use this as stop bit length
970 GRUNDIG_ADDRESS_OFFSET
,
971 GRUNDIG_ADDRESS_OFFSET
+ GRUNDIG_ADDRESS_LEN
,
972 GRUNDIG_COMMAND_OFFSET
,
973 GRUNDIG_COMMAND_OFFSET
+ GRUNDIG_COMMAND_LEN
,
974 GRUNDIG_COMPLETE_DATA_LEN
,
981 static uint8_t irmp_bit
; // current bit position
982 static IRMP_PARAMETER irmp_param
;
984 static volatile uint8_t irmp_ir_detected
;
985 static volatile uint8_t irmp_protocol
;
986 static volatile uint16_t irmp_address
;
987 static volatile uint16_t irmp_command
;
988 static volatile uint16_t irmp_id
; // only used for SAMSUNG protocol
989 static volatile uint8_t irmp_flags
;
992 static uint8_t IRMP_PIN
;
995 /*---------------------------------------------------------------------------------------------------------------------------------------------------
996 * Initialize IRMP decoder
997 * @details Configures IRMP input pin
998 *---------------------------------------------------------------------------------------------------------------------------------------------------
1004 #ifndef PIC_CCS_COMPILER
1005 IRMP_PORT
&= ~(1<<IRMP_BIT
); // deactivate pullup
1006 IRMP_DDR
&= ~(1<<IRMP_BIT
); // set pin to input
1007 #endif // PIC_CCS_COMPILER
1009 #if IRMP_LOGGING == 1
1014 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1016 * @details gets decoded IRMP data
1017 * @param pointer in order to store IRMP data
1018 * @return TRUE: successful, FALSE: failed
1019 *---------------------------------------------------------------------------------------------------------------------------------------------------
1022 irmp_get_data (IRMP_DATA
* irmp_data_p
)
1024 uint8_t rtc
= FALSE
;
1026 if (irmp_ir_detected
)
1028 switch (irmp_protocol
)
1030 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1031 case IRMP_SAMSUNG_PROTOCOL
:
1032 if ((irmp_command
>> 8) == (~irmp_command
& 0x00FF))
1034 irmp_command
&= 0xff;
1035 irmp_command
|= irmp_id
<< 8;
1040 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1041 case IRMP_NEC_PROTOCOL
:
1042 if ((irmp_command
>> 8) == (~irmp_command
& 0x00FF))
1044 irmp_command
&= 0xff;
1047 else if ((irmp_command
& 0xFF00) == 0xD100)
1049 DEBUG_PRINTF ("Switching to APPLE protocol\n");
1050 irmp_protocol
= IRMP_APPLE_PROTOCOL
;
1051 irmp_command
&= 0xff;
1062 irmp_data_p
->protocol
= irmp_protocol
;
1063 irmp_data_p
->address
= irmp_address
;
1064 irmp_data_p
->command
= irmp_command
;
1065 irmp_data_p
->flags
= irmp_flags
;
1071 irmp_ir_detected
= FALSE
;
1077 // these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR()
1078 static uint16_t irmp_tmp_address
; // ir address
1079 static uint16_t irmp_tmp_command
; // ir command
1080 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1081 static uint16_t irmp_tmp_id
; // ir id (only SAMSUNG)
1084 static uint8_t irmp_bit
; // current bit position
1086 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1088 * @details store bit in temp address or temp command
1089 * @param value to store: 0 or 1
1090 *---------------------------------------------------------------------------------------------------------------------------------------------------
1093 irmp_store_bit (uint8_t value
)
1095 if (irmp_bit
>= irmp_param
.address_offset
&& irmp_bit
< irmp_param
.address_end
)
1097 if (irmp_param
.lsb_first
)
1099 irmp_tmp_address
|= (((uint16_t) (value
)) << (irmp_bit
- irmp_param
.address_offset
)); // CV wants cast
1103 irmp_tmp_address
<<= 1;
1104 irmp_tmp_address
|= value
;
1107 else if (irmp_bit
>= irmp_param
.command_offset
&& irmp_bit
< irmp_param
.command_end
)
1109 if (irmp_param
.lsb_first
)
1111 irmp_tmp_command
|= (((uint16_t) (value
)) << (irmp_bit
- irmp_param
.command_offset
)); // CV wants cast
1115 irmp_tmp_command
<<= 1;
1116 irmp_tmp_command
|= value
;
1119 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1120 else if (irmp_param
.protocol
== IRMP_SAMSUNG_PROTOCOL
&& irmp_bit
>= SAMSUNG_ID_OFFSET
&& irmp_bit
< SAMSUNG_ID_OFFSET
+ SAMSUNG_ID_LEN
)
1122 irmp_tmp_id
|= (((uint16_t) (value
)) << (irmp_bit
- SAMSUNG_ID_OFFSET
)); // store with LSB first
1128 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1130 * @details ISR routine, called 10000 times per second
1131 *---------------------------------------------------------------------------------------------------------------------------------------------------
1136 static uint8_t irmp_start_bit_detected
; // flag: start bit detected
1137 static uint8_t wait_for_space
; // flag: wait for data bit space
1138 static uint8_t wait_for_start_space
; // flag: wait for start bit space
1139 static uint8_t irmp_pulse_time
; // count bit time for pulse
1140 static uint8_t irmp_pause_time
; // count bit time for pause
1141 static uint16_t last_irmp_address
= 0xFFFF; // save last irmp address to recognize key repetition
1142 static uint16_t last_irmp_command
= 0xFFFF; // save last irmp command to recognize key repetition
1143 static uint16_t repetition_counter
; // SIRCS repeats frame 2-5 times with 45 ms pause
1144 static uint8_t repetition_frame_number
;
1145 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1146 static uint16_t last_irmp_denon_command
; // save last irmp command to recognize DENON frame repetition
1148 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1149 static uint8_t rc5_cmd_bit6
; // bit 6 of RC5 command is the inverted 2nd start bit
1151 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1
1152 static uint8_t last_pause
; // last pause value
1154 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1155 static uint8_t last_value
; // last bit value
1157 uint8_t irmp_input
; // input value
1163 irmp_input
= input(IRMP_PIN
);
1165 irmp_logIsr(irmp_input
); // log ir signal, if IRMP_LOGGING defined
1167 if (! irmp_ir_detected
) // ir code already detected?
1169 if (! irmp_start_bit_detected
) // start bit detected?
1171 if (!irmp_input
) // receiving burst?
1173 irmp_pulse_time
++; // increment counter
1177 if (irmp_pulse_time
) // it's dark....
1178 { // set flags for counting the time of darkness...
1179 irmp_start_bit_detected
= 1;
1180 wait_for_start_space
= 1;
1182 irmp_tmp_command
= 0;
1183 irmp_tmp_address
= 0;
1185 irmp_pause_time
= 1; // 1st pause: set to 1, not to 0!
1186 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1187 rc5_cmd_bit6
= 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame!
1192 repetition_counter
++;
1198 if (wait_for_start_space
) // we have received start bit...
1199 { // ...and are counting the time of darkness
1200 if (irmp_input
) // still dark?
1202 irmp_pause_time
++; // increment counter
1204 if (irmp_pause_time
> IRMP_TIMEOUT_LEN
) // timeout?
1206 DEBUG_PRINTF ("error 1: pause after start bit %d too long: %d\n", irmp_pulse_time
, irmp_pause_time
);
1207 irmp_start_bit_detected
= 0; // reset flags, let's wait for another start bit
1208 irmp_pulse_time
= 0;
1209 irmp_pause_time
= 0;
1213 { // receiving first data pulse!
1214 IRMP_PARAMETER
* irmp_param_p
= (IRMP_PARAMETER
*) 0;
1216 DEBUG_PRINTF ("start-bit: pulse = %d, pause = %d\n", irmp_pulse_time
, irmp_pause_time
);
1218 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1219 if (irmp_pulse_time
>= SIRCS_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= SIRCS_START_BIT_PULSE_LEN_MAX
&&
1220 irmp_pause_time
>= SIRCS_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SIRCS_START_BIT_PAUSE_LEN_MAX
)
1222 DEBUG_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1223 SIRCS_START_BIT_PULSE_LEN_MIN
, SIRCS_START_BIT_PULSE_LEN_MAX
,
1224 SIRCS_START_BIT_PAUSE_LEN_MIN
, SIRCS_START_BIT_PAUSE_LEN_MAX
);
1225 irmp_param_p
= (IRMP_PARAMETER
*) (IRMP_PARAMETER
*) &sircs_param
;
1228 #endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1230 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1231 if (irmp_pulse_time
>= NEC_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NEC_START_BIT_PULSE_LEN_MAX
&&
1232 irmp_pause_time
>= NEC_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NEC_START_BIT_PAUSE_LEN_MAX
)
1234 DEBUG_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1235 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
,
1236 NEC_START_BIT_PAUSE_LEN_MIN
, NEC_START_BIT_PAUSE_LEN_MAX
);
1237 irmp_param_p
= (IRMP_PARAMETER
*) &nec_param
;
1239 else if (irmp_pulse_time
>= NEC_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NEC_START_BIT_PULSE_LEN_MAX
&&
1240 irmp_pause_time
>= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX
)
1242 DEBUG_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1243 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
,
1244 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN
, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX
);
1246 irmp_param_p
= (IRMP_PARAMETER
*) &nec_rep_param
;
1249 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
1251 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1252 if (irmp_pulse_time
>= SAMSUNG_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_START_BIT_PULSE_LEN_MAX
&&
1253 irmp_pause_time
>= SAMSUNG_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_START_BIT_PAUSE_LEN_MAX
)
1255 DEBUG_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1256 SAMSUNG_START_BIT_PULSE_LEN_MIN
, SAMSUNG_START_BIT_PULSE_LEN_MAX
,
1257 SAMSUNG_START_BIT_PAUSE_LEN_MIN
, SAMSUNG_START_BIT_PAUSE_LEN_MAX
);
1258 irmp_param_p
= (IRMP_PARAMETER
*) &samsung_param
;
1261 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1263 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
1264 if (irmp_pulse_time
>= MATSUSHITA_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= MATSUSHITA_START_BIT_PULSE_LEN_MAX
&&
1265 irmp_pause_time
>= MATSUSHITA_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= MATSUSHITA_START_BIT_PAUSE_LEN_MAX
)
1266 { // it's MATSUSHITA
1267 DEBUG_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1268 MATSUSHITA_START_BIT_PULSE_LEN_MIN
, MATSUSHITA_START_BIT_PULSE_LEN_MAX
,
1269 MATSUSHITA_START_BIT_PAUSE_LEN_MIN
, MATSUSHITA_START_BIT_PAUSE_LEN_MAX
);
1270 irmp_param_p
= (IRMP_PARAMETER
*) &matsushita_param
;
1273 #endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
1275 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1276 if (irmp_pulse_time
>= KASEIKYO_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= KASEIKYO_START_BIT_PULSE_LEN_MAX
&&
1277 irmp_pause_time
>= KASEIKYO_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= KASEIKYO_START_BIT_PAUSE_LEN_MAX
)
1279 DEBUG_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1280 KASEIKYO_START_BIT_PULSE_LEN_MIN
, KASEIKYO_START_BIT_PULSE_LEN_MAX
,
1281 KASEIKYO_START_BIT_PAUSE_LEN_MIN
, KASEIKYO_START_BIT_PAUSE_LEN_MAX
);
1282 irmp_param_p
= (IRMP_PARAMETER
*) &kaseikyo_param
;
1285 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1287 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
1288 if (irmp_pulse_time
>= RECS80_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RECS80_START_BIT_PULSE_LEN_MAX
&&
1289 irmp_pause_time
>= RECS80_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RECS80_START_BIT_PAUSE_LEN_MAX
)
1291 DEBUG_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1292 RECS80_START_BIT_PULSE_LEN_MIN
, RECS80_START_BIT_PULSE_LEN_MAX
,
1293 RECS80_START_BIT_PAUSE_LEN_MIN
, RECS80_START_BIT_PAUSE_LEN_MAX
);
1294 irmp_param_p
= (IRMP_PARAMETER
*) &recs80_param
;
1297 #endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1
1299 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1300 if (((irmp_pulse_time
>= RC5_START_BIT_LEN_MIN
&& irmp_pulse_time
<= RC5_START_BIT_LEN_MAX
) ||
1301 (irmp_pulse_time
>= 2 * RC5_START_BIT_LEN_MIN
&& irmp_pulse_time
<= 2 * RC5_START_BIT_LEN_MAX
)) &&
1302 ((irmp_pause_time
>= RC5_START_BIT_LEN_MIN
&& irmp_pause_time
<= RC5_START_BIT_LEN_MAX
) ||
1303 (irmp_pause_time
>= 2 * RC5_START_BIT_LEN_MIN
&& irmp_pause_time
<= 2 * RC5_START_BIT_LEN_MAX
)))
1305 DEBUG_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1306 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
,
1307 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
);
1308 irmp_param_p
= (IRMP_PARAMETER
*) &rc5_param
;
1309 last_pause
= irmp_pause_time
;
1311 if ((irmp_pulse_time
> RC5_START_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * RC5_START_BIT_LEN_MAX
) ||
1312 (irmp_pause_time
> RC5_START_BIT_LEN_MAX
&& irmp_pause_time
<= 2 * RC5_START_BIT_LEN_MAX
))
1315 rc5_cmd_bit6
= 1<<6;
1323 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1
1325 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1326 if ( (irmp_pulse_time
>= DENON_PULSE_LEN_MIN
&& irmp_pulse_time
<= DENON_PULSE_LEN_MAX
) &&
1327 ((irmp_pause_time
>= DENON_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_1_PAUSE_LEN_MAX
) ||
1328 (irmp_pause_time
>= DENON_0_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_0_PAUSE_LEN_MAX
)))
1330 DEBUG_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
1331 DENON_PULSE_LEN_MIN
, DENON_PULSE_LEN_MAX
,
1332 DENON_1_PAUSE_LEN_MIN
, DENON_1_PAUSE_LEN_MAX
,
1333 DENON_0_PAUSE_LEN_MIN
, DENON_0_PAUSE_LEN_MAX
);
1334 irmp_param_p
= (IRMP_PARAMETER
*) &denon_param
;
1337 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
1339 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1340 if (irmp_pulse_time
>= RC6_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RC6_START_BIT_PULSE_LEN_MAX
&&
1341 irmp_pause_time
>= RC6_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RC6_START_BIT_PAUSE_LEN_MAX
)
1343 DEBUG_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1344 RC6_START_BIT_PULSE_LEN_MIN
, RC6_START_BIT_PULSE_LEN_MAX
,
1345 RC6_START_BIT_PAUSE_LEN_MIN
, RC6_START_BIT_PAUSE_LEN_MAX
);
1346 irmp_param_p
= (IRMP_PARAMETER
*) &rc6_param
;
1351 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
1353 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
1354 if (irmp_pulse_time
>= RECS80EXT_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RECS80EXT_START_BIT_PULSE_LEN_MAX
&&
1355 irmp_pause_time
>= RECS80EXT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RECS80EXT_START_BIT_PAUSE_LEN_MAX
)
1357 DEBUG_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1358 RECS80EXT_START_BIT_PULSE_LEN_MIN
, RECS80EXT_START_BIT_PULSE_LEN_MAX
,
1359 RECS80EXT_START_BIT_PAUSE_LEN_MIN
, RECS80EXT_START_BIT_PAUSE_LEN_MAX
);
1360 irmp_param_p
= (IRMP_PARAMETER
*) &recs80ext_param
;
1363 #endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
1365 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1366 if (irmp_pulse_time
>= NUBERT_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NUBERT_START_BIT_PULSE_LEN_MAX
&&
1367 irmp_pause_time
>= NUBERT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NUBERT_START_BIT_PAUSE_LEN_MAX
)
1369 DEBUG_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1370 NUBERT_START_BIT_PULSE_LEN_MIN
, NUBERT_START_BIT_PULSE_LEN_MAX
,
1371 NUBERT_START_BIT_PAUSE_LEN_MIN
, NUBERT_START_BIT_PAUSE_LEN_MAX
);
1372 irmp_param_p
= (IRMP_PARAMETER
*) &nubert_param
;
1375 #endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1377 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1378 if (irmp_pulse_time
>= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN
&& irmp_pulse_time
<= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX
&&
1379 irmp_pause_time
>= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX
)
1380 { // it's BANG_OLUFSEN
1381 DEBUG_PRINTF ("protocol = BANG_OLUFSEN\n");
1382 DEBUG_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1383 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX
,
1384 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX
);
1385 DEBUG_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1386 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX
,
1387 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX
);
1388 DEBUG_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1389 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX
,
1390 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX
);
1391 DEBUG_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1392 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX
,
1393 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX
);
1394 irmp_param_p
= (IRMP_PARAMETER
*) &bang_olufsen_param
;
1398 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1400 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
1401 if (irmp_pulse_time
>= GRUNDIG_START_BIT_LEN_MIN
&& irmp_pulse_time
<= GRUNDIG_START_BIT_LEN_MAX
&&
1402 irmp_pause_time
>= GRUNDIG_PRE_PAUSE_LEN_MIN
&& irmp_pause_time
<= GRUNDIG_PRE_PAUSE_LEN_MAX
)
1404 DEBUG_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1405 GRUNDIG_START_BIT_LEN_MIN
, GRUNDIG_START_BIT_LEN_MAX
,
1406 GRUNDIG_PRE_PAUSE_LEN_MIN
, GRUNDIG_PRE_PAUSE_LEN_MAX
);
1407 irmp_param_p
= (IRMP_PARAMETER
*) &grundig_param
;
1408 last_pause
= irmp_pause_time
;
1412 #endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
1415 DEBUG_PRINTF ("protocol = UNKNOWN\n");
1416 irmp_start_bit_detected
= 0; // wait for another start bit...
1419 if (irmp_start_bit_detected
)
1421 memcpy_P (&irmp_param
, irmp_param_p
, sizeof (IRMP_PARAMETER
));
1423 DEBUG_PRINTF ("pulse_1: %3d - %3d\n", irmp_param
.pulse_1_len_min
, irmp_param
.pulse_1_len_max
);
1424 DEBUG_PRINTF ("pause_1: %3d - %3d\n", irmp_param
.pause_1_len_min
, irmp_param
.pause_1_len_max
);
1426 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1427 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
)
1429 DEBUG_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN
, RC6_TOGGLE_BIT_LEN_MAX
);
1432 DEBUG_PRINTF ("pulse_0: %3d - %3d\n", irmp_param
.pulse_0_len_min
, irmp_param
.pulse_0_len_max
);
1433 DEBUG_PRINTF ("pause_0: %3d - %3d\n", irmp_param
.pause_0_len_min
, irmp_param
.pause_0_len_max
);
1435 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1436 if (irmp_param
.protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
1438 DEBUG_PRINTF ("pulse_r: %3d - %3d\n", irmp_param
.pulse_0_len_min
, irmp_param
.pulse_0_len_max
);
1439 DEBUG_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN
, BANG_OLUFSEN_R_PAUSE_LEN_MAX
);
1443 DEBUG_PRINTF ("command_offset: %2d\n", irmp_param
.command_offset
);
1444 DEBUG_PRINTF ("command_len: %3d\n", irmp_param
.command_end
- irmp_param
.command_offset
);
1445 DEBUG_PRINTF ("complete_len: %3d\n", irmp_param
.complete_len
);
1446 DEBUG_PRINTF ("stop_bit: %3d\n", irmp_param
.stop_bit
);
1451 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1452 if (irmp_param
.protocol
== IRMP_RC5_PROTOCOL
)
1454 if (irmp_pause_time
> RC5_START_BIT_LEN_MAX
&& irmp_pause_time
<= 2 * RC5_START_BIT_LEN_MAX
)
1456 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1457 DEBUG_PUTCHAR ('1');
1458 DEBUG_PUTCHAR ('\n');
1461 else if (! last_value
)
1463 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1464 DEBUG_PUTCHAR ('0');
1465 DEBUG_PUTCHAR ('\n');
1470 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1
1472 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
1473 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
)
1475 if (irmp_pause_time
> GRUNDIG_START_BIT_LEN_MAX
&& irmp_pause_time
<= 2 * GRUNDIG_START_BIT_LEN_MAX
)
1477 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1478 DEBUG_PUTCHAR ('0');
1479 DEBUG_PUTCHAR ('\n');
1482 else if (! last_value
)
1484 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1485 DEBUG_PUTCHAR ('1');
1486 DEBUG_PUTCHAR ('\n');
1491 #endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
1493 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1494 if (irmp_param
.protocol
== IRMP_DENON_PROTOCOL
)
1496 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1498 if (irmp_pause_time
>= DENON_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_1_PAUSE_LEN_MAX
)
1499 { // pause timings correct for "1"?
1500 DEBUG_PUTCHAR ('1'); // yes, store 1
1501 DEBUG_PUTCHAR ('\n');
1504 else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)
1505 { // pause timings correct for "0"?
1506 DEBUG_PUTCHAR ('0'); // yes, store 0
1507 DEBUG_PUTCHAR ('\n');
1511 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
1513 irmp_pulse_time
= 1; // set counter to 1, not 0
1514 irmp_pause_time
= 0;
1515 wait_for_start_space
= 0;
1518 else if (wait_for_space
) // the data section....
1519 { // counting the time of darkness....
1520 uint8_t got_light
= FALSE
;
1522 if (irmp_input
) // still dark?
1524 if (irmp_bit
== irmp_param
.complete_len
&& irmp_param
.stop_bit
== 1)
1526 if (irmp_pulse_time
>= irmp_param
.pulse_0_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_0_len_max
)
1529 if (irmp_param
.protocol
!= IRMP_RC5_PROTOCOL
)
1531 DEBUG_PRINTF ("stop bit detected\n");
1534 irmp_param
.stop_bit
= 0;
1538 DEBUG_PRINTF ("stop bit timing wrong\n");
1540 irmp_start_bit_detected
= 0; // wait for another start bit...
1541 irmp_pulse_time
= 0;
1542 irmp_pause_time
= 0;
1547 irmp_pause_time
++; // increment counter
1549 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1550 if (irmp_param
.protocol
== IRMP_SIRCS_PROTOCOL
&& // Sony has a variable number of bits:
1551 irmp_pause_time
> SIRCS_PAUSE_LEN_MAX
&& // minimum is 12
1552 irmp_bit
>= 12 - 1) // pause too long?
1553 { // yes, break and close this frame
1554 irmp_param
.complete_len
= irmp_bit
+ 1; // set new complete length
1555 got_light
= TRUE
; // this is a lie, but helps (generates stop bit)
1556 irmp_param
.command_end
= irmp_param
.command_offset
+ irmp_bit
+ 1; // correct command length
1557 irmp_pause_time
= SIRCS_PAUSE_LEN_MAX
- 1; // correct pause length
1561 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1562 if (irmp_param
.protocol
== IRMP_RC5_PROTOCOL
&&
1563 irmp_pause_time
> 2 * RC5_BIT_LEN_MAX
&& irmp_bit
>= RC5_COMPLETE_DATA_LEN
- 2 && !irmp_param
.stop_bit
)
1564 { // special rc5 decoder
1565 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1566 irmp_param
.stop_bit
= TRUE
; // set flag
1570 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1571 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
&&
1572 irmp_pause_time
> 2 * RC6_BIT_LEN_MAX
&& irmp_bit
>= irmp_param
.complete_len
- 2 && !irmp_param
.stop_bit
)
1573 { // special rc6 decoder
1574 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1575 irmp_param
.stop_bit
= TRUE
; // set flag
1579 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
1580 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
&&
1581 irmp_pause_time
> 2 * GRUNDIG_BIT_LEN_MAX
&& irmp_bit
>= GRUNDIG_COMPLETE_DATA_LEN
- 2 && !irmp_param
.stop_bit
)
1582 { // special rc5 decoder
1583 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1584 irmp_param
.stop_bit
= TRUE
; // set flag
1588 if (irmp_pause_time
> IRMP_TIMEOUT_LEN
) // timeout?
1590 if (irmp_bit
== irmp_param
.complete_len
- 1 && irmp_param
.stop_bit
== 0)
1596 DEBUG_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time
, irmp_bit
);
1598 irmp_start_bit_detected
= 0; // wait for another start bit...
1599 irmp_pulse_time
= 0;
1600 irmp_pause_time
= 0;
1612 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1614 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1615 if (irmp_param
.protocol
== IRMP_RC5_PROTOCOL
) // special rc5 decoder
1617 if (irmp_pulse_time
> RC5_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * RC5_BIT_LEN_MAX
)
1619 DEBUG_PUTCHAR ('1');
1621 DEBUG_PUTCHAR ('0');
1622 DEBUG_PUTCHAR ('\n');
1627 else // if (irmp_pulse_time >= RC5_BIT_LEN_MIN && irmp_pulse_time <= RC5_BIT_LEN_MAX)
1631 if (last_pause
> RC5_BIT_LEN_MAX
&& last_pause
<= 2 * RC5_BIT_LEN_MAX
)
1633 rc5_value
= last_value
? 0 : 1;
1634 last_value
= rc5_value
;
1638 rc5_value
= last_value
;
1641 DEBUG_PUTCHAR (rc5_value
+ '0');
1642 DEBUG_PUTCHAR ('\n');
1643 irmp_store_bit (rc5_value
);
1646 last_pause
= irmp_pause_time
;
1652 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
1653 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
) // special Grundig decoder
1655 if (irmp_pulse_time
> GRUNDIG_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * GRUNDIG_BIT_LEN_MAX
)
1657 DEBUG_PUTCHAR ('0');
1659 DEBUG_PUTCHAR ('1');
1660 DEBUG_PUTCHAR ('\n');
1665 else // if (irmp_pulse_time >= GRUNDIG_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_BIT_LEN_MAX)
1667 uint8_t grundig_value
;
1669 if (last_pause
> GRUNDIG_BIT_LEN_MAX
&& last_pause
<= 2 * GRUNDIG_BIT_LEN_MAX
)
1671 grundig_value
= last_value
? 0 : 1;
1672 last_value
= grundig_value
;
1676 grundig_value
= last_value
;
1679 DEBUG_PUTCHAR (grundig_value
+ '0');
1680 DEBUG_PUTCHAR ('\n');
1681 irmp_store_bit (grundig_value
);
1684 last_pause
= irmp_pause_time
;
1690 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1691 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
) // special rc6 decoder
1694 { // handle toggle bit, which is 2 times longer than other bits
1698 if (irmp_pulse_time
> RC6_TOGGLE_BIT_LEN_MAX
&& irmp_pause_time
> RC6_TOGGLE_BIT_LEN_MAX
)
1700 DEBUG_PUTCHAR ('1');
1704 DEBUG_PUTCHAR ('0');
1707 DEBUG_PUTCHAR ('\n');
1711 if (irmp_pulse_time
> RC6_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * RC6_BIT_LEN_MAX
)
1713 DEBUG_PUTCHAR ('0');
1715 DEBUG_PUTCHAR ('1');
1716 DEBUG_PUTCHAR ('\n');
1720 else // if (irmp_pulse_time >= RC6_BIT_LEN_MIN && irmp_pulse_time <= RC6_BIT_LEN_MAX)
1724 if (last_pause
> RC6_BIT_LEN_MAX
&& last_pause
<= 2 * RC6_BIT_LEN_MAX
)
1726 rc5_value
= last_value
? 0 : 1;
1727 last_value
= rc5_value
;
1731 rc5_value
= last_value
;
1734 if (irmp_bit
== 1 && rc5_value
== 0)
1736 irmp_param
.complete_len
= RC6_COMPLETE_DATA_LEN_LONG
;
1739 DEBUG_PUTCHAR (rc5_value
+ '0');
1740 DEBUG_PUTCHAR ('\n');
1741 irmp_store_bit (rc5_value
);
1744 last_pause
= irmp_pause_time
;
1751 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
1753 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1754 if (irmp_param
.protocol
== IRMP_SAMSUNG_PROTOCOL
&& irmp_bit
== 16) // Samsung: 16th bit
1756 if (irmp_pulse_time
>= SAMSUNG_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_PULSE_LEN_MAX
&&
1757 irmp_pause_time
>= SAMSUNG_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_START_BIT_PAUSE_LEN_MAX
)
1759 DEBUG_PRINTF ("SYNC\n");
1764 else if (irmp_pulse_time
>= SAMSUNG_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_PULSE_LEN_MAX
)
1766 if (irmp_pause_time
>= SAMSUNG_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_1_PAUSE_LEN_MAX
)
1768 DEBUG_PUTCHAR ('1');
1769 DEBUG_PUTCHAR ('\n');
1775 DEBUG_PUTCHAR ('0');
1776 DEBUG_PUTCHAR ('\n');
1781 DEBUG_PRINTF ("Switching to SAMSUNG32 protocol\n");
1783 irmp_param
.protocol
= IRMP_SAMSUNG32_PROTOCOL
;
1784 irmp_param
.command_offset
= SAMSUNG32_COMMAND_OFFSET
;
1785 irmp_param
.command_end
= SAMSUNG32_COMMAND_OFFSET
+ SAMSUNG32_COMMAND_LEN
;
1786 irmp_param
.complete_len
= SAMSUNG32_COMPLETE_DATA_LEN
;
1789 { // timing incorrect!
1790 DEBUG_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1791 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
1792 irmp_pause_time
= 0;
1796 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL
1798 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1799 if (irmp_param
.protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
1801 if (irmp_pulse_time
>= BANG_OLUFSEN_PULSE_LEN_MIN
&& irmp_pulse_time
<= BANG_OLUFSEN_PULSE_LEN_MAX
)
1803 if (irmp_bit
== 1) // Bang & Olufsen: 3rd bit
1805 if (irmp_pause_time
>= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX
)
1807 DEBUG_PRINTF ("3rd start bit\n");
1813 { // timing incorrect!
1814 DEBUG_PRINTF ("error 3a B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1815 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
1816 irmp_pause_time
= 0;
1819 else if (irmp_bit
== 19) // Bang & Olufsen: trailer bit
1821 if (irmp_pause_time
>= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX
)
1823 DEBUG_PRINTF ("trailer bit\n");
1829 { // timing incorrect!
1830 DEBUG_PRINTF ("error 3b B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1831 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
1832 irmp_pause_time
= 0;
1837 if (irmp_pause_time
>= BANG_OLUFSEN_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_1_PAUSE_LEN_MAX
)
1838 { // pulse & pause timings correct for "1"?
1839 DEBUG_PUTCHAR ('1');
1840 DEBUG_PUTCHAR ('\n');
1845 else if (irmp_pause_time
>= BANG_OLUFSEN_0_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_0_PAUSE_LEN_MAX
)
1846 { // pulse & pause timings correct for "0"?
1847 DEBUG_PUTCHAR ('0');
1848 DEBUG_PUTCHAR ('\n');
1853 else if (irmp_pause_time
>= BANG_OLUFSEN_R_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_R_PAUSE_LEN_MAX
)
1855 DEBUG_PUTCHAR (last_value
+ '0');
1856 DEBUG_PUTCHAR ('\n');
1857 irmp_store_bit (last_value
);
1861 { // timing incorrect!
1862 DEBUG_PRINTF ("error 3c B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1863 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
1864 irmp_pause_time
= 0;
1869 { // timing incorrect!
1870 DEBUG_PRINTF ("error 3d B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1871 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
1872 irmp_pause_time
= 0;
1876 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL
1878 if (irmp_pulse_time
>= irmp_param
.pulse_1_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_1_len_max
&&
1879 irmp_pause_time
>= irmp_param
.pause_1_len_min
&& irmp_pause_time
<= irmp_param
.pause_1_len_max
)
1880 { // pulse & pause timings correct for "1"?
1881 DEBUG_PUTCHAR ('1');
1882 DEBUG_PUTCHAR ('\n');
1886 else if (irmp_pulse_time
>= irmp_param
.pulse_0_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_0_len_max
&&
1887 irmp_pause_time
>= irmp_param
.pause_0_len_min
&& irmp_pause_time
<= irmp_param
.pause_0_len_max
)
1888 { // pulse & pause timings correct for "0"?
1889 DEBUG_PUTCHAR ('0');
1890 DEBUG_PUTCHAR ('\n');
1895 { // timing incorrect!
1896 DEBUG_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1897 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
1898 irmp_pause_time
= 0;
1901 irmp_pulse_time
= 1; // set counter to 1, not 0
1905 { // counting the pulse length ...
1906 if (!irmp_input
) // still light?
1908 irmp_pulse_time
++; // increment counter
1912 wait_for_space
= 1; // let's count the time (see above)
1913 irmp_pause_time
= 1; // set pause counter to 1, not 0
1917 if (irmp_bit
== irmp_param
.complete_len
&& irmp_param
.stop_bit
== 0) // enough bits received?
1919 if (last_irmp_command
== irmp_tmp_command
&& repetition_counter
< AUTO_REPETITION_LEN
)
1921 repetition_frame_number
++;
1925 repetition_frame_number
= 0;
1928 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1929 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame
1930 if (irmp_param
.protocol
== IRMP_SIRCS_PROTOCOL
&& (repetition_frame_number
== 1 || repetition_frame_number
== 2))
1932 DEBUG_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
1933 repetition_frame_number
+ 1, repetition_counter
, AUTO_REPETITION_LEN
);
1934 repetition_counter
= 0;
1939 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1940 // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
1941 if (irmp_param
.protocol
== IRMP_SAMSUNG32_PROTOCOL
&& (repetition_frame_number
& 0x01))
1943 DEBUG_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
1944 repetition_frame_number
+ 1, repetition_counter
, AUTO_REPETITION_LEN
);
1945 repetition_counter
= 0;
1950 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1951 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore it.
1952 if (irmp_param
.protocol
== IRMP_NUBERT_PROTOCOL
&& (repetition_frame_number
& 0x01))
1954 DEBUG_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
1955 repetition_frame_number
+ 1, repetition_counter
, AUTO_REPETITION_LEN
);
1956 repetition_counter
= 0;
1962 DEBUG_PRINTF ("code detected, length = %d\n", irmp_bit
);
1963 irmp_ir_detected
= TRUE
;
1965 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1966 if (irmp_param
.protocol
== IRMP_DENON_PROTOCOL
)
1967 { // check for repetition frame
1968 if ((~irmp_tmp_command
& 0x3FF) == last_irmp_denon_command
) // command bits must be inverted
1970 irmp_tmp_command
= last_irmp_denon_command
; // use command received before!
1972 irmp_protocol
= irmp_param
.protocol
; // store protocol
1973 irmp_address
= irmp_tmp_address
; // store address
1974 irmp_command
= irmp_tmp_command
; // store command
1978 DEBUG_PRINTF ("waiting for inverted command repetition\n");
1979 irmp_ir_detected
= FALSE
;
1980 last_irmp_denon_command
= irmp_tmp_command
;
1984 #endif // IRMP_SUPPORT_DENON_PROTOCOL
1986 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
1987 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
&& irmp_tmp_command
== 0x01ff) // only start frame?
1989 DEBUG_PRINTF ("Detected start frame, ignoring it\n");
1990 irmp_ir_detected
= FALSE
;
1991 // last_irmp_grundig_command = irmp_tmp_command;
1994 #endif // IRMP_SUPPORT_DENON_PROTOCOL
1996 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1997 if (irmp_param
.protocol
== IRMP_NEC_PROTOCOL
&& irmp_bit
== 0) // repetition frame
1999 irmp_tmp_address
= last_irmp_address
; // address is last address
2000 irmp_tmp_command
= last_irmp_command
; // command is last command
2001 irmp_flags
|= IRMP_FLAG_REPETITION
;
2003 #endif // IRMP_SUPPORT_NEC_PROTOCOL
2004 irmp_protocol
= irmp_param
.protocol
;
2005 irmp_address
= irmp_tmp_address
; // store address
2006 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2007 last_irmp_address
= irmp_tmp_address
; // store as last address, too
2010 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
2011 irmp_tmp_command
|= rc5_cmd_bit6
; // store bit 6
2013 irmp_command
= irmp_tmp_command
; // store command
2015 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2016 irmp_id
= irmp_tmp_id
;
2021 if (irmp_ir_detected
)
2023 if (last_irmp_command
== irmp_command
&&
2024 last_irmp_address
== irmp_address
&&
2025 repetition_counter
< IRMP_REPETITION_TIME
)
2027 irmp_flags
|= IRMP_FLAG_REPETITION
;
2030 last_irmp_address
= irmp_tmp_address
; // store as last address, too
2031 last_irmp_command
= irmp_tmp_command
; // store as last command, too
2033 repetition_counter
= 0;
2036 irmp_start_bit_detected
= 0; // and wait for next start bit
2037 irmp_tmp_command
= 0;
2038 irmp_pulse_time
= 0;
2039 irmp_pause_time
= 0;
2047 // main function - for unix/linux + windows only!
2049 // Compile it under linux with:
2050 // cc irmp.c -o irmp
2052 // usage: ./irmp [-v|-s|-a] < file
2055 print_timings (void)
2057 printf ("PROTOCOL START BIT NO. START BIT PULSE START BIT PAUSE\n");
2058 printf ("====================================================================================\n");
2059 printf ("SIRCS 1 %3d - %3d %3d - %3d\n",
2060 SIRCS_START_BIT_PULSE_LEN_MIN
, SIRCS_START_BIT_PULSE_LEN_MAX
, SIRCS_START_BIT_PAUSE_LEN_MIN
, SIRCS_START_BIT_PAUSE_LEN_MAX
);
2061 printf ("NEC 1 %3d - %3d %3d - %3d\n",
2062 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
, NEC_START_BIT_PAUSE_LEN_MIN
, NEC_START_BIT_PAUSE_LEN_MAX
);
2063 printf ("NEC (rep) 1 %3d - %3d %3d - %3d\n",
2064 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
);
2065 printf ("SAMSUNG 1 %3d - %3d %3d - %3d\n",
2066 SAMSUNG_START_BIT_PULSE_LEN_MIN
, SAMSUNG_START_BIT_PULSE_LEN_MAX
, SAMSUNG_START_BIT_PAUSE_LEN_MIN
, SAMSUNG_START_BIT_PAUSE_LEN_MAX
);
2067 printf ("MATSUSHITA 1 %3d - %3d %3d - %3d\n",
2068 MATSUSHITA_START_BIT_PULSE_LEN_MIN
, MATSUSHITA_START_BIT_PULSE_LEN_MAX
, MATSUSHITA_START_BIT_PAUSE_LEN_MIN
, MATSUSHITA_START_BIT_PAUSE_LEN_MAX
);
2069 printf ("KASEIKYO 1 %3d - %3d %3d - %3d\n",
2070 KASEIKYO_START_BIT_PULSE_LEN_MIN
, KASEIKYO_START_BIT_PULSE_LEN_MAX
, KASEIKYO_START_BIT_PAUSE_LEN_MIN
, KASEIKYO_START_BIT_PAUSE_LEN_MAX
);
2071 printf ("RECS80 1 %3d - %3d %3d - %3d\n",
2072 RECS80_START_BIT_PULSE_LEN_MIN
, RECS80_START_BIT_PULSE_LEN_MAX
, RECS80_START_BIT_PAUSE_LEN_MIN
, RECS80_START_BIT_PAUSE_LEN_MAX
);
2073 printf ("RC5 1 %3d - %3d %3d - %3d\n",
2074 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
, RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
);
2075 printf ("DENON 1 %3d - %3d %3d - %3d or %3d - %3d\n",
2076 DENON_PULSE_LEN_MIN
, DENON_PULSE_LEN_MAX
, DENON_1_PAUSE_LEN_MIN
, DENON_1_PAUSE_LEN_MAX
, DENON_0_PAUSE_LEN_MIN
, DENON_0_PAUSE_LEN_MAX
);
2077 printf ("RC6 1 %3d - %3d %3d - %3d\n",
2078 RC6_START_BIT_PULSE_LEN_MIN
, RC6_START_BIT_PULSE_LEN_MAX
, RC6_START_BIT_PAUSE_LEN_MIN
, RC6_START_BIT_PAUSE_LEN_MAX
);
2079 printf ("RECS80EXT 1 %3d - %3d %3d - %3d\n",
2080 RECS80EXT_START_BIT_PULSE_LEN_MIN
, RECS80EXT_START_BIT_PULSE_LEN_MAX
, RECS80EXT_START_BIT_PAUSE_LEN_MIN
, RECS80EXT_START_BIT_PAUSE_LEN_MAX
);
2081 printf ("NUBERT 1 %3d - %3d %3d - %3d\n",
2082 NUBERT_START_BIT_PULSE_LEN_MIN
, NUBERT_START_BIT_PULSE_LEN_MAX
, NUBERT_START_BIT_PAUSE_LEN_MIN
, NUBERT_START_BIT_PAUSE_LEN_MAX
);
2083 printf ("BANG_OLUFSEN 1 %3d - %3d %3d - %3d\n",
2084 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX
, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX
);
2085 printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n",
2086 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX
, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX
);
2087 printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n",
2088 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX
, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX
);
2089 printf ("BANG_OLUFSEN 4 %3d - %3d %3d - %3d\n",
2090 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX
, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX
);
2091 printf ("GRUNDIG 1 %3d - %3d %3d - %3d\n",
2092 GRUNDIG_START_BIT_LEN_MIN
, GRUNDIG_START_BIT_LEN_MAX
, GRUNDIG_PRE_PAUSE_LEN_MIN
, GRUNDIG_PRE_PAUSE_LEN_MAX
);
2096 main (int argc
, char ** argv
)
2099 int verbose
= FALSE
;
2100 int analyze
= FALSE
;
2106 int min_pulse_long
= 100000;
2107 int max_pulse_long
= 0;
2108 int sum_pulses_long
= 0;
2109 int n_pulses_long
= 0;
2111 int min_pulse_short
= 100000;
2112 int max_pulse_short
= 0;
2113 int sum_pulses_short
= 0;
2114 int n_pulses_short
= 0;
2116 int min_pause_long
= 100000;
2117 int max_pause_long
= 0;
2118 int sum_pauses_long
= 0;
2119 int n_pauses_long
= 0;
2121 int min_pause_short
= 100000;
2122 int max_pause_short
= 0;
2123 int sum_pauses_short
= 0;
2124 int n_pauses_short
= 0;
2126 int min_start_pulse
= 100000;
2127 int max_start_pulse
= 0;
2128 int sum_start_pulses
= 0;
2129 int n_start_pulses
= 0;
2131 int min_start_pause
= 100000;
2132 int max_start_pause
= 0;
2133 int sum_start_pauses
= 0;
2134 int n_start_pauses
= 0;
2136 int first_pulse
= TRUE
;
2137 int first_pause
= TRUE
;
2139 IRMP_DATA irmp_data
;
2143 if (! strcmp (argv
[1], "-v"))
2147 else if (! strcmp (argv
[1], "-a"))
2152 else if (! strcmp (argv
[1], "-s"))
2156 else if (! strcmp (argv
[1], "-p"))
2165 while ((ch
= getchar ()) != EOF
)
2167 if (ch
== '_' || ch
== '0')
2171 if (verbose
&& pause
> 0)
2173 printf ("pause: %d\n", pause
);
2177 if (min_start_pause
> pause
)
2179 min_start_pause
= pause
;
2181 if (max_start_pause
< pause
)
2183 max_start_pause
= pause
;
2186 sum_start_pauses
+= pause
;
2187 first_pause
= FALSE
;
2193 if (pause
> 100) // perhaps repetition frame follows
2200 if (min_pause_long
> pause
)
2202 min_pause_long
= pause
;
2204 if (max_pause_long
< pause
)
2206 max_pause_long
= pause
;
2209 sum_pauses_long
+= pause
;
2214 if (min_pause_short
> pause
)
2216 min_pause_short
= pause
;
2218 if (max_pause_short
< pause
)
2220 max_pause_short
= pause
;
2223 sum_pauses_short
+= pause
;
2232 else if (ch
== 0xaf || ch
== '-' || ch
== '1')
2238 printf ("pulse: %d ", pulse
);
2242 if (min_start_pulse
> pulse
)
2244 min_start_pulse
= pulse
;
2246 if (max_start_pulse
< pulse
)
2248 max_start_pulse
= pulse
;
2251 sum_start_pulses
+= pulse
;
2252 first_pulse
= FALSE
;
2258 if (min_pulse_long
> pulse
)
2260 min_pulse_long
= pulse
;
2262 if (max_pulse_long
< pulse
)
2264 max_pulse_long
= pulse
;
2267 sum_pulses_long
+= pulse
;
2271 if (min_pulse_short
> pulse
)
2273 min_pulse_short
= pulse
;
2275 if (max_pulse_short
< pulse
)
2277 max_pulse_short
= pulse
;
2280 sum_pulses_short
+= pulse
;
2289 else if (ch
== '\n')
2293 if (verbose
&& pause
> 0)
2295 printf ("pause: %d\n", pause
);
2301 for (i
= 0; i
< 8000; i
++) // newline: long pause of 800 msec
2311 puts ("-------------------------------------------------------------------");
2314 while ((ch
= getchar()) != '\n' && ch
!= EOF
)
2316 if (ch
!= '\r') // ignore CR in DOS/Windows files
2331 if (irmp_get_data (&irmp_data
))
2333 printf ("protcol = %d, address = 0x%04x, code = 0x%04x, flags = 0x%02x\n",
2334 irmp_data
.protocol
, irmp_data
.address
, irmp_data
.command
, irmp_data
.flags
);
2340 printf ("\nSTATITSTICS:\n");
2341 printf ("---------------------------------\n");
2342 printf ("number of start pulses: %d\n", n_start_pulses
);
2343 printf ("minimum start pulse length: %d usec\n", (1000000 * min_start_pulse
) / F_INTERRUPTS
);
2344 printf ("maximum start pulse length: %d usec\n", (1000000 * max_start_pulse
) / F_INTERRUPTS
);
2345 if (n_start_pulses
> 0)
2347 printf ("average start pulse length: %d usec\n", ((1000000 * sum_start_pulses
) / n_start_pulses
) / F_INTERRUPTS
);
2350 printf ("number of start pauses: %d\n", n_start_pauses
);
2351 if (n_start_pauses
> 0)
2353 printf ("minimum start pause length: %d usec\n", (1000000 * min_start_pause
) / F_INTERRUPTS
);
2354 printf ("maximum start pause length: %d usec\n", (1000000 * max_start_pause
) / F_INTERRUPTS
);
2355 printf ("average start pause length: %d usec\n", ((1000000 * sum_start_pauses
) / n_start_pauses
) / F_INTERRUPTS
);
2358 printf ("number of long pulses: %d\n", n_pulses_long
);
2359 if (n_pulses_long
> 0)
2361 printf ("minimum long pulse length: %d usec\n", (1000000 * min_pulse_long
) / F_INTERRUPTS
);
2362 printf ("maximum long pulse length: %d usec\n", (1000000 * max_pulse_long
) / F_INTERRUPTS
);
2363 printf ("average long pulse length: %d usec\n", ((1000000 * sum_pulses_long
) / n_pulses_long
) / F_INTERRUPTS
);
2366 printf ("number of short pulses: %d\n", n_pulses_short
);
2367 if (n_pulses_short
> 0)
2369 printf ("minimum short pulse length: %d usec\n", (1000000 * min_pulse_short
) / F_INTERRUPTS
);
2370 printf ("maximum short pulse length: %d usec\n", (1000000 * max_pulse_short
) / F_INTERRUPTS
);
2371 printf ("average short pulse length: %d usec\n", ((1000000 * sum_pulses_short
) / n_pulses_short
) / F_INTERRUPTS
);
2375 printf ("number of long pauses: %d\n", n_pauses_long
);
2376 if (n_pauses_long
> 0)
2378 printf ("minimum long pause length: %d usec\n", (1000000 * min_pause_long
) / F_INTERRUPTS
);
2379 printf ("maximum long pause length: %d usec\n", (1000000 * max_pause_long
) / F_INTERRUPTS
);
2380 printf ("average long pause length: %d usec\n", ((1000000 * sum_pauses_long
) / n_pauses_long
) / F_INTERRUPTS
);
2383 printf ("number of short pauses: %d\n", n_pauses_short
);
2384 if (n_pauses_short
> 0)
2386 printf ("minimum short pause length: %d usec\n", (1000000 * min_pause_short
) / F_INTERRUPTS
);
2387 printf ("maximum short pause length: %d usec\n", (1000000 * max_pause_short
) / F_INTERRUPTS
);
2388 printf ("average short pause length: %d usec\n", ((1000000 * sum_pauses_short
) / n_pauses_short
) / F_INTERRUPTS
);