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