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