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