]>
Commit | Line | Data |
---|---|---|
1 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
2 | * @file irsnd.c\r | |
3 | *\r | |
4 | * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de\r | |
5 | *\r | |
6 | * Supported mikrocontrollers:\r | |
7 | *\r | |
8 | * ATtiny84, ATtiny85\r | |
9 | * ATmega8, ATmega16, ATmega32\r | |
10 | * ATmega162\r | |
11 | * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284\r | |
12 | * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P\r | |
13 | *\r | |
14 | * $Id: irsnd.c,v 1.40 2011/09/09 11:59:40 fm Exp $\r | |
15 | *\r | |
16 | * This program is free software; you can redistribute it and/or modify\r | |
17 | * it under the terms of the GNU General Public License as published by\r | |
18 | * the Free Software Foundation; either version 2 of the License, or\r | |
19 | * (at your option) any later version.\r | |
20 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
21 | */\r | |
22 | \r | |
23 | #ifdef unix // test/debug on linux/unix\r | |
24 | #include <stdio.h>\r | |
25 | #include <unistd.h>\r | |
26 | #include <stdlib.h>\r | |
27 | #include <string.h>\r | |
28 | #include <inttypes.h>\r | |
29 | \r | |
30 | #define DEBUG\r | |
31 | #define F_CPU 8000000L\r | |
32 | \r | |
33 | #else // not unix:\r | |
34 | \r | |
35 | #ifdef WIN32 // test/debug on windows\r | |
36 | #include <stdio.h>\r | |
37 | #include <stdlib.h>\r | |
38 | #include <string.h>\r | |
39 | \r | |
40 | #define F_CPU 8000000L\r | |
41 | typedef unsigned char uint8_t;\r | |
42 | typedef unsigned short uint16_t;\r | |
43 | #define DEBUG\r | |
44 | \r | |
45 | #else\r | |
46 | \r | |
47 | #ifdef CODEVISION\r | |
48 | #define COM2A0 6\r | |
49 | #define WGM21 1\r | |
50 | #define CS20 0\r | |
51 | #else\r | |
52 | #include <inttypes.h>\r | |
53 | #include <avr/io.h>\r | |
54 | #include <util/delay.h>\r | |
55 | #include <avr/pgmspace.h>\r | |
56 | #endif // CODEVISION\r | |
57 | \r | |
58 | #endif // WIN32\r | |
59 | #endif // unix\r | |
60 | \r | |
61 | #include "irmp.h"\r | |
62 | #include "irsndconfig.h"\r | |
63 | #include "irsnd.h"\r | |
64 | \r | |
65 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
66 | * ATtiny pin definition of OC0A / OC0B\r | |
67 | * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B\r | |
68 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
69 | */\r | |
70 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
71 | * ATtiny pin definition of OC0A / OC0B\r | |
72 | * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B\r | |
73 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
74 | */\r | |
75 | #if defined (__AVR_ATtiny84__) // ATtiny85 uses OC0A = PB2 or OC0B = PA7\r | |
76 | #if IRSND_OCx == IRSND_OC0A // OC0A\r | |
77 | #define IRSND_PORT PORTB // port B\r | |
78 | #define IRSND_DDR DDRB // ddr B\r | |
79 | #define IRSND_BIT 2 // OC0A\r | |
80 | #elif IRSND_OCx == IRSND_OC0B // OC0B\r | |
81 | #define IRSND_PORT PORTA // port A\r | |
82 | #define IRSND_DDR DDRA // ddr A\r | |
83 | #define IRSND_BIT 7 // OC0B\r | |
84 | #else\r | |
85 | #error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h\r | |
86 | #endif // IRSND_OCx\r | |
87 | \r | |
88 | #elif defined (__AVR_ATtiny85__) // ATtiny85 uses OC0A = PB0 or OC0B = PB1\r | |
89 | #if IRSND_OCx == IRSND_OC0A // OC0A\r | |
90 | #define IRSND_PORT PORTB // port B\r | |
91 | #define IRSND_DDR DDRB // ddr B\r | |
92 | #define IRSND_BIT 0 // OC0A\r | |
93 | #elif IRSND_OCx == IRSND_OC0B // OC0B\r | |
94 | #define IRSND_PORT PORTB // port B\r | |
95 | #define IRSND_DDR DDRB // ddr B\r | |
96 | #define IRSND_BIT 1 // OC0B\r | |
97 | #else\r | |
98 | #error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h\r | |
99 | #endif // IRSND_OCx\r | |
100 | \r | |
101 | #elif defined (__AVR_ATmega8__) // ATmega8 uses only OC2 = PB3\r | |
102 | #if IRSND_OCx == IRSND_OC2 // OC0A\r | |
103 | #define IRSND_PORT PORTB // port B\r | |
104 | #define IRSND_DDR DDRB // ddr B\r | |
105 | #define IRSND_BIT 3 // OC0A\r | |
106 | #else\r | |
107 | #error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h\r | |
108 | #endif // IRSND_OCx\r | |
109 | \r | |
110 | \r | |
111 | #elif defined (__AVR_ATmega16__) \\r | |
112 | || defined (__AVR_ATmega32__) // ATmega16|32 uses OC2 = PD7\r | |
113 | #if IRSND_OCx == IRSND_OC2 // OC2\r | |
114 | #define IRSND_PORT PORTD // port D\r | |
115 | #define IRSND_DDR DDRD // ddr D\r | |
116 | #define IRSND_BIT 7 // OC2\r | |
117 | #else\r | |
118 | #error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h\r | |
119 | #endif // IRSND_OCx\r | |
120 | \r | |
121 | #elif defined (__AVR_ATmega162__) // ATmega162 uses OC2 = PB1 or OC0 = PB0\r | |
122 | #if IRSND_OCx == IRSND_OC2 // OC2\r | |
123 | #define IRSND_PORT PORTB // port B\r | |
124 | #define IRSND_DDR DDRB // ddr B\r | |
125 | #define IRSND_BIT 1 // OC2\r | |
126 | #elif IRSND_OCx == IRSND_OC0 // OC0\r | |
127 | #define IRSND_PORT PORTB // port B\r | |
128 | #define IRSND_DDR DDRB // ddr B\r | |
129 | #define IRSND_BIT 0 // OC0\r | |
130 | #else\r | |
131 | #error Wrong value for IRSND_OCx, choose IRSND_OC2 or IRSND_OC0 in irsndconfig.h\r | |
132 | #endif // IRSND_OCx\r | |
133 | \r | |
134 | #elif defined (__AVR_ATmega164__) \\r | |
135 | || defined (__AVR_ATmega324__) \\r | |
136 | || defined (__AVR_ATmega644__) \\r | |
137 | || defined (__AVR_ATmega644P__) \\r | |
138 | || defined (__AVR_ATmega1284__) // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4\r | |
139 | #if IRSND_OCx == IRSND_OC2A // OC2A\r | |
140 | #define IRSND_PORT PORTD // port D\r | |
141 | #define IRSND_DDR DDRD // ddr D\r | |
142 | #define IRSND_BIT 7 // OC2A\r | |
143 | #elif IRSND_OCx == IRSND_OC2B // OC2B\r | |
144 | #define IRSND_PORT PORTD // port D\r | |
145 | #define IRSND_DDR DDRD // ddr D\r | |
146 | #define IRSND_BIT 6 // OC2B\r | |
147 | #elif IRSND_OCx == IRSND_OC0A // OC0A\r | |
148 | #define IRSND_PORT PORTB // port B\r | |
149 | #define IRSND_DDR DDRB // ddr B\r | |
150 | #define IRSND_BIT 3 // OC0A\r | |
151 | #elif IRSND_OCx == IRSND_OC0B // OC0B\r | |
152 | #define IRSND_PORT PORTB // port B\r | |
153 | #define IRSND_DDR DDRB // ddr B\r | |
154 | #define IRSND_BIT 4 // OC0B\r | |
155 | #else\r | |
156 | #error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h\r | |
157 | #endif // IRSND_OCx\r | |
158 | \r | |
159 | #elif defined (__AVR_ATmega48__) \\r | |
160 | || defined (__AVR_ATmega88__) \\r | |
161 | || defined (__AVR_ATmega88P__) \\r | |
162 | || defined (__AVR_ATmega168__) \\r | |
163 | || defined (__AVR_ATmega168P__) \\r | |
164 | || defined (__AVR_ATmega328P__) // ATmega48|88|168|168|328 uses OC2A = PB3 or OC2B = PD3 or OC0A = PD6 or OC0B = PD5\r | |
165 | #if IRSND_OCx == IRSND_OC2A // OC2A\r | |
166 | #define IRSND_PORT PORTB // port B\r | |
167 | #define IRSND_DDR DDRB // ddr B\r | |
168 | #define IRSND_BIT 3 // OC2A\r | |
169 | #elif IRSND_OCx == IRSND_OC2B // OC2B\r | |
170 | #define IRSND_PORT PORTD // port D\r | |
171 | #define IRSND_DDR DDRD // ddr D\r | |
172 | #define IRSND_BIT 3 // OC2B\r | |
173 | #elif IRSND_OCx == IRSND_OC0A // OC0A\r | |
174 | #define IRSND_PORT PORTB // port B\r | |
175 | #define IRSND_DDR DDRB // ddr B\r | |
176 | #define IRSND_BIT 6 // OC0A\r | |
177 | #elif IRSND_OCx == IRSND_OC0B // OC0B\r | |
178 | #define IRSND_PORT PORTD // port D\r | |
179 | #define IRSND_DDR DDRD // ddr D\r | |
180 | #define IRSND_BIT 5 // OC0B\r | |
181 | #else\r | |
182 | #error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h\r | |
183 | #endif // IRSND_OCx\r | |
184 | \r | |
185 | #else\r | |
186 | #if !defined (unix) && !defined (WIN32)\r | |
187 | #error mikrocontroller not defined, please fill in definitions here.\r | |
188 | #endif // unix, WIN32\r | |
189 | #endif // __AVR...\r | |
190 | \r | |
191 | #if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r | |
192 | typedef uint16_t IRSND_PAUSE_LEN;\r | |
193 | #else\r | |
194 | typedef uint8_t IRSND_PAUSE_LEN;\r | |
195 | #endif\r | |
196 | \r | |
197 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
198 | * IR timings\r | |
199 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
200 | */\r | |
201 | #define SIRCS_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME + 0.5)\r | |
202 | #define SIRCS_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME + 0.5)\r | |
203 | #define SIRCS_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME + 0.5)\r | |
204 | #define SIRCS_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME + 0.5)\r | |
205 | #define SIRCS_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME + 0.5)\r | |
206 | #define SIRCS_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r | |
207 | #define SIRCS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIRCS_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
208 | \r | |
209 | #define NEC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME + 0.5)\r | |
210 | #define NEC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME + 0.5)\r | |
211 | #define NEC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME + 0.5)\r | |
212 | #define NEC_PULSE_LEN (uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME + 0.5)\r | |
213 | #define NEC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME + 0.5)\r | |
214 | #define NEC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME + 0.5)\r | |
215 | #define NEC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
216 | \r | |
217 | #define SAMSUNG_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME + 0.5)\r | |
218 | #define SAMSUNG_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME + 0.5)\r | |
219 | #define SAMSUNG_PULSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME + 0.5)\r | |
220 | #define SAMSUNG_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME + 0.5)\r | |
221 | #define SAMSUNG_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME + 0.5)\r | |
222 | #define SAMSUNG_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
223 | \r | |
224 | #define SAMSUNG32_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r | |
225 | #define SAMSUNG32_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG32_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
226 | \r | |
227 | #define MATSUSHITA_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME + 0.5)\r | |
228 | #define MATSUSHITA_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME + 0.5)\r | |
229 | #define MATSUSHITA_PULSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME + 0.5)\r | |
230 | #define MATSUSHITA_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME + 0.5)\r | |
231 | #define MATSUSHITA_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME + 0.5)\r | |
232 | #define MATSUSHITA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * MATSUSHITA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
233 | \r | |
234 | #define KASEIKYO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME + 0.5)\r | |
235 | #define KASEIKYO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME + 0.5)\r | |
236 | #define KASEIKYO_PULSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME + 0.5)\r | |
237 | #define KASEIKYO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME + 0.5)\r | |
238 | #define KASEIKYO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME + 0.5)\r | |
239 | #define KASEIKYO_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r | |
240 | #define KASEIKYO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
241 | \r | |
242 | #define RECS80_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME + 0.5)\r | |
243 | #define RECS80_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME + 0.5)\r | |
244 | #define RECS80_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME + 0.5)\r | |
245 | #define RECS80_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME + 0.5)\r | |
246 | #define RECS80_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME + 0.5)\r | |
247 | #define RECS80_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
248 | \r | |
249 | #define RC5_START_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5)\r | |
250 | #define RC5_BIT_LEN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME + 0.5)\r | |
251 | #define RC5_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC5_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
252 | \r | |
253 | #define RC6_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME + 0.5)\r | |
254 | #define RC6_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME + 0.5)\r | |
255 | #define RC6_TOGGLE_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME + 0.5)\r | |
256 | #define RC6_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_BIT_TIME + 0.5)\r | |
257 | #define RC6_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC6_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
258 | \r | |
259 | #define DENON_PULSE_LEN (uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME + 0.5)\r | |
260 | #define DENON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME + 0.5)\r | |
261 | #define DENON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME + 0.5)\r | |
262 | #define DENON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r | |
263 | #define DENON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * DENON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
264 | \r | |
265 | #define THOMSON_PULSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME + 0.5)\r | |
266 | #define THOMSON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME + 0.5)\r | |
267 | #define THOMSON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME + 0.5)\r | |
268 | #define THOMSON_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * THOMSON_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r | |
269 | #define THOMSON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * THOMSON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
270 | \r | |
271 | #define RECS80EXT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME + 0.5)\r | |
272 | #define RECS80EXT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME + 0.5)\r | |
273 | #define RECS80EXT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME + 0.5)\r | |
274 | #define RECS80EXT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME + 0.5)\r | |
275 | #define RECS80EXT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME + 0.5)\r | |
276 | #define RECS80EXT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80EXT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
277 | \r | |
278 | #define NUBERT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME + 0.5)\r | |
279 | #define NUBERT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME + 0.5)\r | |
280 | #define NUBERT_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME + 0.5)\r | |
281 | #define NUBERT_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME + 0.5)\r | |
282 | #define NUBERT_0_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME + 0.5)\r | |
283 | #define NUBERT_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME + 0.5)\r | |
284 | #define NUBERT_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r | |
285 | #define NUBERT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NUBERT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
286 | \r | |
287 | #define BANG_OLUFSEN_START_BIT1_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME + 0.5)\r | |
288 | #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME + 0.5)\r | |
289 | #define BANG_OLUFSEN_START_BIT2_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME + 0.5)\r | |
290 | #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME + 0.5)\r | |
291 | #define BANG_OLUFSEN_START_BIT3_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME + 0.5)\r | |
292 | #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME + 0.5)\r | |
293 | #define BANG_OLUFSEN_PULSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME + 0.5)\r | |
294 | #define BANG_OLUFSEN_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME + 0.5)\r | |
295 | #define BANG_OLUFSEN_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME + 0.5)\r | |
296 | #define BANG_OLUFSEN_R_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME + 0.5)\r | |
297 | #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME + 0.5)\r | |
298 | #define BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BANG_OLUFSEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
299 | \r | |
300 | #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME + 0.5)\r | |
301 | #define GRUNDIG_NOKIA_IR60_BIT_LEN (uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME + 0.5)\r | |
302 | #define GRUNDIG_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r | |
303 | #define NOKIA_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NOKIA_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r | |
304 | #define GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
305 | \r | |
306 | #define SIEMENS_START_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME + 0.5)\r | |
307 | #define SIEMENS_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME + 0.5)\r | |
308 | #define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
309 | \r | |
310 | #define IRSND_FREQ_32_KHZ (uint8_t) ((F_CPU / 32000 / 2) - 1)\r | |
311 | #define IRSND_FREQ_36_KHZ (uint8_t) ((F_CPU / 36000 / 2) - 1)\r | |
312 | #define IRSND_FREQ_38_KHZ (uint8_t) ((F_CPU / 38000 / 2) - 1)\r | |
313 | #define IRSND_FREQ_40_KHZ (uint8_t) ((F_CPU / 40000 / 2) - 1)\r | |
314 | #define IRSND_FREQ_56_KHZ (uint8_t) ((F_CPU / 56000 / 2) - 1)\r | |
315 | #define IRSND_FREQ_455_KHZ (uint8_t) ((F_CPU / 455000 / 2) - 1)\r | |
316 | \r | |
317 | #define FDC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME + 0.5)\r | |
318 | #define FDC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME + 0.5)\r | |
319 | #define FDC_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME + 0.5)\r | |
320 | #define FDC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME + 0.5)\r | |
321 | #define FDC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME + 0.5)\r | |
322 | #define FDC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * FDC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
323 | \r | |
324 | #define RCCAR_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME + 0.5)\r | |
325 | #define RCCAR_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME + 0.5)\r | |
326 | #define RCCAR_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME + 0.5)\r | |
327 | #define RCCAR_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME + 0.5)\r | |
328 | #define RCCAR_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME + 0.5)\r | |
329 | #define RCCAR_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RCCAR_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
330 | \r | |
331 | #define JVC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME + 0.5)\r | |
332 | #define JVC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PAUSE_TIME + 0.5)\r | |
333 | #define JVC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_REPEAT_START_BIT_PAUSE_TIME + 0.5)\r | |
334 | #define JVC_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME + 0.5)\r | |
335 | #define JVC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME + 0.5)\r | |
336 | #define JVC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME + 0.5)\r | |
337 | #define JVC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
338 | \r | |
339 | #define NIKON_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME + 0.5)\r | |
340 | #define NIKON_START_BIT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME + 0.5)\r | |
341 | #define NIKON_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME + 0.5)\r | |
342 | #define NIKON_PULSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME + 0.5)\r | |
343 | #define NIKON_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME + 0.5)\r | |
344 | #define NIKON_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME + 0.5)\r | |
345 | #define NIKON_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
346 | \r | |
347 | #define LEGO_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME + 0.5)\r | |
348 | #define LEGO_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME + 0.5)\r | |
349 | #define LEGO_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_REPEAT_START_BIT_PAUSE_TIME + 0.5)\r | |
350 | #define LEGO_PULSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_PULSE_TIME + 0.5)\r | |
351 | #define LEGO_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME + 0.5)\r | |
352 | #define LEGO_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME + 0.5)\r | |
353 | #define LEGO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * LEGO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r | |
354 | \r | |
355 | static volatile uint8_t irsnd_busy;\r | |
356 | static volatile uint8_t irsnd_protocol;\r | |
357 | static volatile uint8_t irsnd_buffer[6];\r | |
358 | static volatile uint8_t irsnd_repeat;\r | |
359 | static volatile uint8_t irsnd_is_on = FALSE;\r | |
360 | \r | |
361 | #if IRSND_USE_CALLBACK == 1\r | |
362 | static void (*irsnd_callback_ptr) (uint8_t);\r | |
363 | #endif // IRSND_USE_CALLBACK == 1\r | |
364 | \r | |
365 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
366 | * Switch PWM on\r | |
367 | * @details Switches PWM on with a narrow spike on all 3 channels -> leds glowing\r | |
368 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
369 | */\r | |
370 | static void\r | |
371 | irsnd_on (void)\r | |
372 | {\r | |
373 | if (! irsnd_is_on)\r | |
374 | {\r | |
375 | #ifndef DEBUG\r | |
376 | #if IRSND_OCx == IRSND_OC2 // use OC2\r | |
377 | TCCR2 |= (1<<COM20)|(1<<WGM21); // toggle OC2 on compare match, clear Timer 2 at compare match OCR2\r | |
378 | #elif IRSND_OCx == IRSND_OC2A // use OC2A\r | |
379 | TCCR2A |= (1<<COM2A0)|(1<<WGM21); // toggle OC2A on compare match, clear Timer 2 at compare match OCR2A\r | |
380 | #elif IRSND_OCx == IRSND_OC2B // use OC2B\r | |
381 | TCCR2A |= (1<<COM2B0)|(1<<WGM21); // toggle OC2B on compare match, clear Timer 2 at compare match OCR2A (yes: A, not B!)\r | |
382 | #elif IRSND_OCx == IRSND_OC0 // use OC0\r | |
383 | TCCR0 |= (1<<COM00)|(1<<WGM01); // toggle OC0 on compare match, clear Timer 0 at compare match OCR0\r | |
384 | #elif IRSND_OCx == IRSND_OC0A // use OC0A\r | |
385 | TCCR0A |= (1<<COM0A0)|(1<<WGM01); // toggle OC0A on compare match, clear Timer 0 at compare match OCR0A\r | |
386 | #elif IRSND_OCx == IRSND_OC0B // use OC0B\r | |
387 | TCCR0A |= (1<<COM0B0)|(1<<WGM01); // toggle OC0B on compare match, clear Timer 0 at compare match OCR0A (yes: A, not B!)\r | |
388 | #else\r | |
389 | #error wrong value of IRSND_OCx\r | |
390 | #endif // IRSND_OCx\r | |
391 | #endif // DEBUG\r | |
392 | \r | |
393 | #if IRSND_USE_CALLBACK == 1\r | |
394 | if (irsnd_callback_ptr)\r | |
395 | {\r | |
396 | (*irsnd_callback_ptr) (TRUE);\r | |
397 | }\r | |
398 | #endif // IRSND_USE_CALLBACK == 1\r | |
399 | \r | |
400 | irsnd_is_on = TRUE;\r | |
401 | }\r | |
402 | }\r | |
403 | \r | |
404 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
405 | * Switch PWM off\r | |
406 | * @details Switches PWM off\r | |
407 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
408 | */\r | |
409 | static void\r | |
410 | irsnd_off (void)\r | |
411 | {\r | |
412 | if (irsnd_is_on)\r | |
413 | {\r | |
414 | #ifndef DEBUG\r | |
415 | #if IRSND_OCx == IRSND_OC2 // use OC2\r | |
416 | TCCR2 &= ~(1<<COM20); // normal port operation, OC2 disconnected.\r | |
417 | #elif IRSND_OCx == IRSND_OC2A // use OC2A\r | |
418 | TCCR2A &= ~(1<<COM2A0); // normal port operation, OC2A disconnected.\r | |
419 | #elif IRSND_OCx == IRSND_OC2B // use OC2B\r | |
420 | TCCR2A &= ~(1<<COM2B0); // normal port operation, OC2B disconnected.\r | |
421 | #elif IRSND_OCx == IRSND_OC0 // use OC0\r | |
422 | TCCR0 &= ~(1<<COM00); // normal port operation, OC0 disconnected.\r | |
423 | #elif IRSND_OCx == IRSND_OC0A // use OC0A\r | |
424 | TCCR0A &= ~(1<<COM0A0); // normal port operation, OC0A disconnected.\r | |
425 | #elif IRSND_OCx == IRSND_OC0B // use OC0B\r | |
426 | TCCR0A &= ~(1<<COM0B0); // normal port operation, OC0B disconnected.\r | |
427 | #else\r | |
428 | #error wrong value of IRSND_OCx\r | |
429 | #endif // IRSND_OCx\r | |
430 | IRSND_PORT &= ~(1<<IRSND_BIT); // set IRSND_BIT to low\r | |
431 | #endif // DEBUG\r | |
432 | \r | |
433 | #if IRSND_USE_CALLBACK == 1\r | |
434 | if (irsnd_callback_ptr)\r | |
435 | {\r | |
436 | (*irsnd_callback_ptr) (FALSE);\r | |
437 | }\r | |
438 | #endif // IRSND_USE_CALLBACK == 1\r | |
439 | \r | |
440 | irsnd_is_on = FALSE;\r | |
441 | }\r | |
442 | }\r | |
443 | \r | |
444 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
445 | * Set PWM frequency\r | |
446 | * @details sets pwm frequency\r | |
447 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
448 | */\r | |
449 | static void\r | |
450 | irsnd_set_freq (uint8_t freq)\r | |
451 | {\r | |
452 | #ifndef DEBUG\r | |
453 | #if IRSND_OCx == IRSND_OC2\r | |
454 | OCR2 = freq; // use register OCR2 for OC2\r | |
455 | #elif IRSND_OCx == IRSND_OC2A // use OC2A\r | |
456 | OCR2A = freq; // use register OCR2A for OC2A and OC2B!\r | |
457 | #elif IRSND_OCx == IRSND_OC2B // use OC2B\r | |
458 | OCR2A = freq; // use register OCR2A for OC2A and OC2B!\r | |
459 | #elif IRSND_OCx == IRSND_OC0 // use OC0\r | |
460 | OCR0 = freq; // use register OCR2 for OC2\r | |
461 | #elif IRSND_OCx == IRSND_OC0A // use OC0A\r | |
462 | OCR0A = freq; // use register OCR0A for OC0A and OC0B!\r | |
463 | #elif IRSND_OCx == IRSND_OC0B // use OC0B\r | |
464 | OCR0A = freq; // use register OCR0A for OC0A and OC0B!\r | |
465 | #else\r | |
466 | #error wrong value of IRSND_OCx\r | |
467 | #endif\r | |
468 | #endif // DEBUG\r | |
469 | }\r | |
470 | \r | |
471 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
472 | * Initialize the PWM\r | |
473 | * @details Configures 0CR0A, 0CR0B and 0CR2B as PWM channels\r | |
474 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
475 | */\r | |
476 | void\r | |
477 | irsnd_init (void)\r | |
478 | {\r | |
479 | #ifndef DEBUG\r | |
480 | IRSND_PORT &= ~(1<<IRSND_BIT); // set IRSND_BIT to low\r | |
481 | IRSND_DDR |= (1<<IRSND_BIT); // set IRSND_BIT to output\r | |
482 | \r | |
483 | #if IRSND_OCx == IRSND_OC2 // use OC2\r | |
484 | TCCR2 = (1<<WGM21); // CTC mode\r | |
485 | TCCR2 |= (1<<CS20); // 0x01, start Timer 2, no prescaling\r | |
486 | #elif IRSND_OCx == IRSND_OC2A || IRSND_OCx == IRSND_OC2B // use OC2A or OC2B\r | |
487 | TCCR2A = (1<<WGM21); // CTC mode\r | |
488 | TCCR2B |= (1<<CS20); // 0x01, start Timer 2, no prescaling\r | |
489 | #elif IRSND_OCx == IRSND_OC0 // use OC0\r | |
490 | TCCR0 = (1<<WGM01); // CTC mode\r | |
491 | TCCR0 |= (1<<CS00); // 0x01, start Timer 0, no prescaling\r | |
492 | #elif IRSND_OCx == IRSND_OC0A || IRSND_OCx == IRSND_OC0B // use OC0A or OC0B\r | |
493 | TCCR0A = (1<<WGM01); // CTC mode\r | |
494 | TCCR0B |= (1<<CS00); // 0x01, start Timer 0, no prescaling\r | |
495 | #else\r | |
496 | #error wrong value of IRSND_OCx\r | |
497 | #endif\r | |
498 | \r | |
499 | irsnd_set_freq (IRSND_FREQ_36_KHZ); // default frequency\r | |
500 | #endif // DEBUG\r | |
501 | }\r | |
502 | \r | |
503 | #if IRSND_USE_CALLBACK == 1\r | |
504 | void\r | |
505 | irsnd_set_callback_ptr (void (*cb)(uint8_t))\r | |
506 | {\r | |
507 | irsnd_callback_ptr = cb;\r | |
508 | }\r | |
509 | #endif // IRSND_USE_CALLBACK == 1\r | |
510 | \r | |
511 | uint8_t\r | |
512 | irsnd_is_busy (void)\r | |
513 | {\r | |
514 | return irsnd_busy;\r | |
515 | }\r | |
516 | \r | |
517 | static uint16_t\r | |
518 | bitsrevervse (uint16_t x, uint8_t len)\r | |
519 | {\r | |
520 | uint16_t xx = 0;\r | |
521 | \r | |
522 | while(len)\r | |
523 | {\r | |
524 | xx <<= 1;\r | |
525 | if (x & 1)\r | |
526 | {\r | |
527 | xx |= 1;\r | |
528 | }\r | |
529 | x >>= 1;\r | |
530 | len--;\r | |
531 | }\r | |
532 | return xx;\r | |
533 | }\r | |
534 | \r | |
535 | \r | |
536 | #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r | |
537 | static uint8_t sircs_additional_bitlen;\r | |
538 | #endif // IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r | |
539 | \r | |
540 | uint8_t\r | |
541 | irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait)\r | |
542 | {\r | |
543 | #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r | |
544 | static uint8_t toggle_bit_recs80;\r | |
545 | #endif\r | |
546 | #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1\r | |
547 | static uint8_t toggle_bit_recs80ext;\r | |
548 | #endif\r | |
549 | #if IRSND_SUPPORT_RC5_PROTOCOL == 1\r | |
550 | static uint8_t toggle_bit_rc5;\r | |
551 | #endif\r | |
552 | #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1\r | |
553 | static uint8_t toggle_bit_rc6;\r | |
554 | #endif\r | |
555 | #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1\r | |
556 | static uint8_t toggle_bit_thomson;\r | |
557 | #endif\r | |
558 | uint16_t address;\r | |
559 | uint16_t command;\r | |
560 | \r | |
561 | if (do_wait)\r | |
562 | {\r | |
563 | while (irsnd_busy)\r | |
564 | {\r | |
565 | // do nothing;\r | |
566 | }\r | |
567 | }\r | |
568 | else if (irsnd_busy)\r | |
569 | {\r | |
570 | return (FALSE);\r | |
571 | }\r | |
572 | \r | |
573 | irsnd_protocol = irmp_data_p->protocol;\r | |
574 | irsnd_repeat = irmp_data_p->flags & IRSND_REPETITION_MASK;\r | |
575 | \r | |
576 | switch (irsnd_protocol)\r | |
577 | {\r | |
578 | #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r | |
579 | case IRMP_SIRCS_PROTOCOL:\r | |
580 | {\r | |
581 | uint8_t sircs_additional_command_len;\r | |
582 | uint8_t sircs_additional_address_len;\r | |
583 | \r | |
584 | sircs_additional_bitlen = (irmp_data_p->address & 0xFF00) >> 8; // additional bitlen\r | |
585 | \r | |
586 | if (sircs_additional_bitlen > 15 - SIRCS_MINIMUM_DATA_LEN)\r | |
587 | {\r | |
588 | sircs_additional_command_len = 15 - SIRCS_MINIMUM_DATA_LEN;\r | |
589 | sircs_additional_address_len = sircs_additional_bitlen - (15 - SIRCS_MINIMUM_DATA_LEN);\r | |
590 | }\r | |
591 | else\r | |
592 | {\r | |
593 | sircs_additional_command_len = sircs_additional_bitlen;\r | |
594 | sircs_additional_address_len = 0;\r | |
595 | }\r | |
596 | \r | |
597 | command = bitsrevervse (irmp_data_p->command, 15);\r | |
598 | \r | |
599 | irsnd_buffer[0] = (command & 0x7F80) >> 7; // CCCCCCCC\r | |
600 | irsnd_buffer[1] = (command & 0x007F) << 1; // CCCC****\r | |
601 | \r | |
602 | if (sircs_additional_address_len > 0)\r | |
603 | {\r | |
604 | address = bitsrevervse (irmp_data_p->address, 5);\r | |
605 | irsnd_buffer[1] |= (address & 0x0010) >> 4;\r | |
606 | irsnd_buffer[2] = (address & 0x000F) << 4;\r | |
607 | }\r | |
608 | irsnd_busy = TRUE;\r | |
609 | break;\r | |
610 | }\r | |
611 | #endif\r | |
612 | #if IRSND_SUPPORT_NEC_PROTOCOL == 1\r | |
613 | case IRMP_APPLE_PROTOCOL:\r | |
614 | {\r | |
615 | command = irmp_data_p->command | (irmp_data_p->address << 8); // store address as ID in upper byte of command\r | |
616 | address = 0x87EE; // set fixed NEC-lookalike address (customer ID of apple)\r | |
617 | \r | |
618 | address = bitsrevervse (address, NEC_ADDRESS_LEN);\r | |
619 | command = bitsrevervse (command, NEC_COMMAND_LEN);\r | |
620 | \r | |
621 | irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with id instead of inverted command\r | |
622 | \r | |
623 | irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r | |
624 | irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r | |
625 | irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC\r | |
626 | irsnd_buffer[3] = 0x8B; // 10001011 (id)\r | |
627 | irsnd_busy = TRUE;\r | |
628 | break;\r | |
629 | }\r | |
630 | case IRMP_NEC_PROTOCOL:\r | |
631 | {\r | |
632 | address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN);\r | |
633 | command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN);\r | |
634 | \r | |
635 | irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r | |
636 | irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r | |
637 | irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC\r | |
638 | irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc\r | |
639 | irsnd_busy = TRUE;\r | |
640 | break;\r | |
641 | }\r | |
642 | #endif\r | |
643 | #if IRSND_SUPPORT_NEC16_PROTOCOL == 1\r | |
644 | case IRMP_NEC16_PROTOCOL:\r | |
645 | {\r | |
646 | address = bitsrevervse (irmp_data_p->address, NEC16_ADDRESS_LEN);\r | |
647 | command = bitsrevervse (irmp_data_p->command, NEC16_COMMAND_LEN);\r | |
648 | \r | |
649 | irsnd_buffer[0] = (address & 0x00FF); // AAAAAAAA\r | |
650 | irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC\r | |
651 | irsnd_busy = TRUE;\r | |
652 | break;\r | |
653 | }\r | |
654 | #endif\r | |
655 | #if IRSND_SUPPORT_NEC42_PROTOCOL == 1\r | |
656 | case IRMP_NEC42_PROTOCOL:\r | |
657 | {\r | |
658 | address = bitsrevervse (irmp_data_p->address, NEC42_ADDRESS_LEN);\r | |
659 | command = bitsrevervse (irmp_data_p->command, NEC42_COMMAND_LEN);\r | |
660 | \r | |
661 | irsnd_buffer[0] = ( (address & 0x1FE0) >> 5); // AAAAAAAA\r | |
662 | irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // AAAAAaaa\r | |
663 | irsnd_buffer[2] = ((~address & 0x03FC) >> 2); // aaaaaaaa\r | |
664 | irsnd_buffer[3] = ((~address & 0x0003) << 6) | ( (command & 0x00FC) >> 2); // aaCCCCCC\r | |
665 | irsnd_buffer[4] = ( (command & 0x0003) << 6) | ((~command & 0x00FC) >> 2); // CCcccccc\r | |
666 | irsnd_buffer[5] = ((~command & 0x0003) << 6); // cc\r | |
667 | irsnd_busy = TRUE;\r | |
668 | break;\r | |
669 | }\r | |
670 | #endif\r | |
671 | #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1\r | |
672 | case IRMP_SAMSUNG_PROTOCOL:\r | |
673 | {\r | |
674 | address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN);\r | |
675 | command = bitsrevervse (irmp_data_p->command, SAMSUNG_COMMAND_LEN);\r | |
676 | \r | |
677 | irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r | |
678 | irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r | |
679 | irsnd_buffer[2] = (command & 0x00F0) | ((command & 0xF000) >> 12); // IIIICCCC\r | |
680 | irsnd_buffer[3] = ((command & 0x0F00) >> 4) | ((~(command & 0xF000) >> 12) & 0x0F); // CCCCcccc\r | |
681 | irsnd_buffer[4] = (~(command & 0x0F00) >> 4) & 0xF0; // cccc0000\r | |
682 | irsnd_busy = TRUE;\r | |
683 | break;\r | |
684 | }\r | |
685 | case IRMP_SAMSUNG32_PROTOCOL:\r | |
686 | {\r | |
687 | address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN);\r | |
688 | command = bitsrevervse (irmp_data_p->command, SAMSUNG32_COMMAND_LEN);\r | |
689 | \r | |
690 | irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r | |
691 | irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r | |
692 | irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC\r | |
693 | irsnd_buffer[3] = (command & 0x00FF); // CCCCCCCC\r | |
694 | irsnd_busy = TRUE;\r | |
695 | break;\r | |
696 | }\r | |
697 | #endif\r | |
698 | #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1\r | |
699 | case IRMP_MATSUSHITA_PROTOCOL:\r | |
700 | {\r | |
701 | address = bitsrevervse (irmp_data_p->address, MATSUSHITA_ADDRESS_LEN);\r | |
702 | command = bitsrevervse (irmp_data_p->command, MATSUSHITA_COMMAND_LEN);\r | |
703 | \r | |
704 | irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC\r | |
705 | irsnd_buffer[1] = ((command & 0x000F) << 4) | ((address & 0x0F00) >> 8); // CCCCAAAA\r | |
706 | irsnd_buffer[2] = (address & 0x00FF); // AAAAAAAA\r | |
707 | irsnd_busy = TRUE;\r | |
708 | break;\r | |
709 | }\r | |
710 | #endif\r | |
711 | #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1\r | |
712 | case IRMP_KASEIKYO_PROTOCOL:\r | |
713 | {\r | |
714 | uint8_t xor;\r | |
715 | \r | |
716 | address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN);\r | |
717 | command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4);\r | |
718 | \r | |
719 | xor = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F;\r | |
720 | \r | |
721 | irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r | |
722 | irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r | |
723 | irsnd_buffer[2] = xor << 4 | (command & 0x000F); // XXXXCCCC\r | |
724 | irsnd_buffer[3] = 0 | (command & 0xF000) >> 12; // 0000CCCC\r | |
725 | irsnd_buffer[4] = (command & 0x0FF0) >> 4; // CCCCCCCC\r | |
726 | \r | |
727 | xor = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4];\r | |
728 | \r | |
729 | irsnd_buffer[5] = xor;\r | |
730 | irsnd_busy = TRUE;\r | |
731 | break;\r | |
732 | }\r | |
733 | #endif\r | |
734 | #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r | |
735 | case IRMP_RECS80_PROTOCOL:\r | |
736 | {\r | |
737 | toggle_bit_recs80 = toggle_bit_recs80 ? 0x00 : 0x40;\r | |
738 | \r | |
739 | irsnd_buffer[0] = 0x80 | toggle_bit_recs80 | ((irmp_data_p->address & 0x0007) << 3) |\r | |
740 | ((irmp_data_p->command & 0x0038) >> 3); // STAAACCC\r | |
741 | irsnd_buffer[1] = (irmp_data_p->command & 0x07) << 5; // CCC00000\r | |
742 | irsnd_busy = TRUE;\r | |
743 | break;\r | |
744 | }\r | |
745 | #endif\r | |
746 | #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1\r | |
747 | case IRMP_RECS80EXT_PROTOCOL:\r | |
748 | {\r | |
749 | toggle_bit_recs80ext = toggle_bit_recs80ext ? 0x00 : 0x40;\r | |
750 | \r | |
751 | irsnd_buffer[0] = 0x80 | toggle_bit_recs80ext | ((irmp_data_p->address & 0x000F) << 2) |\r | |
752 | ((irmp_data_p->command & 0x0030) >> 4); // STAAAACC\r | |
753 | irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC0000\r | |
754 | irsnd_busy = TRUE;\r | |
755 | break;\r | |
756 | }\r | |
757 | #endif\r | |
758 | #if IRSND_SUPPORT_RC5_PROTOCOL == 1\r | |
759 | case IRMP_RC5_PROTOCOL:\r | |
760 | {\r | |
761 | toggle_bit_rc5 = toggle_bit_rc5 ? 0x00 : 0x40;\r | |
762 | \r | |
763 | irsnd_buffer[0] = ((irmp_data_p->command & 0x40) ? 0x00 : 0x80) | toggle_bit_rc5 |\r | |
764 | ((irmp_data_p->address & 0x001F) << 1) | ((irmp_data_p->command & 0x20) >> 5); // CTAAAAAC\r | |
765 | irsnd_buffer[1] = (irmp_data_p->command & 0x1F) << 3; // CCCCC000\r | |
766 | irsnd_busy = TRUE;\r | |
767 | break;\r | |
768 | }\r | |
769 | #endif\r | |
770 | #if IRSND_SUPPORT_RC6_PROTOCOL == 1\r | |
771 | case IRMP_RC6_PROTOCOL:\r | |
772 | {\r | |
773 | toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08;\r | |
774 | \r | |
775 | irsnd_buffer[0] = 0x80 | toggle_bit_rc6 | ((irmp_data_p->address & 0x00E0) >> 5); // 1MMMTAAA, MMM = 000\r | |
776 | irsnd_buffer[1] = ((irmp_data_p->address & 0x001F) << 3) | ((irmp_data_p->command & 0xE0) >> 5); // AAAAACCC\r | |
777 | irsnd_buffer[2] = (irmp_data_p->command & 0x1F) << 3; // CCCCC\r | |
778 | irsnd_busy = TRUE;\r | |
779 | break;\r | |
780 | }\r | |
781 | #endif\r | |
782 | #if IRSND_SUPPORT_RC6A_PROTOCOL == 1\r | |
783 | case IRMP_RC6A_PROTOCOL:\r | |
784 | {\r | |
785 | toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08;\r | |
786 | \r | |
787 | irsnd_buffer[0] = 0x80 | 0x60 | ((irmp_data_p->address & 0x3000) >> 12); // 1MMMT0AA, MMM = 110\r | |
788 | irsnd_buffer[1] = ((irmp_data_p->address & 0x0FFF) >> 4) ; // AAAAAAAA\r | |
789 | irsnd_buffer[2] = ((irmp_data_p->address & 0x000F) << 4) | ((irmp_data_p->command & 0xF000) >> 12) | toggle_bit_rc6; // AAAACCCC\r | |
790 | irsnd_buffer[3] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC\r | |
791 | irsnd_buffer[4] = (irmp_data_p->command & 0x000F) << 4; // CCCC\r | |
792 | irsnd_busy = TRUE;\r | |
793 | break;\r | |
794 | }\r | |
795 | #endif\r | |
796 | #if IRSND_SUPPORT_DENON_PROTOCOL == 1\r | |
797 | case IRMP_DENON_PROTOCOL:\r | |
798 | {\r | |
799 | irsnd_buffer[0] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x0380) >> 7); // AAAAACCC (1st frame)\r | |
800 | irsnd_buffer[1] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC\r | |
801 | irsnd_buffer[2] = ((irmp_data_p->address & 0x1F) << 3) | (((~irmp_data_p->command) & 0x0380) >> 7); // AAAAACCC (2nd frame)\r | |
802 | irsnd_buffer[3] = (~(irmp_data_p->command) & 0x7F) << 1; // CCCCCCC\r | |
803 | irsnd_busy = TRUE;\r | |
804 | break;\r | |
805 | }\r | |
806 | #endif\r | |
807 | #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1\r | |
808 | case IRMP_THOMSON_PROTOCOL:\r | |
809 | {\r | |
810 | toggle_bit_thomson = toggle_bit_thomson ? 0x00 : 0x08;\r | |
811 | \r | |
812 | irsnd_buffer[0] = ((irmp_data_p->address & 0x0F) << 4) | toggle_bit_thomson | ((irmp_data_p->command & 0x0070) >> 4); // AAAATCCC (1st frame)\r | |
813 | irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC\r | |
814 | irsnd_busy = TRUE;\r | |
815 | break;\r | |
816 | }\r | |
817 | #endif\r | |
818 | #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1\r | |
819 | case IRMP_NUBERT_PROTOCOL:\r | |
820 | {\r | |
821 | irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC\r | |
822 | irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000\r | |
823 | irsnd_busy = TRUE;\r | |
824 | break;\r | |
825 | }\r | |
826 | #endif\r | |
827 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r | |
828 | case IRMP_BANG_OLUFSEN_PROTOCOL:\r | |
829 | {\r | |
830 | irsnd_buffer[0] = irmp_data_p->command >> 11; // SXSCCCCC\r | |
831 | irsnd_buffer[1] = irmp_data_p->command >> 3; // CCCCCCCC\r | |
832 | irsnd_buffer[2] = (irmp_data_p->command & 0x0007) << 5; // CCC00000\r | |
833 | irsnd_busy = TRUE;\r | |
834 | break;\r | |
835 | }\r | |
836 | #endif\r | |
837 | #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1\r | |
838 | case IRMP_GRUNDIG_PROTOCOL:\r | |
839 | {\r | |
840 | command = bitsrevervse (irmp_data_p->command, GRUNDIG_COMMAND_LEN);\r | |
841 | \r | |
842 | irsnd_buffer[0] = 0xFF; // S1111111 (1st frame)\r | |
843 | irsnd_buffer[1] = 0xC0; // 11\r | |
844 | irsnd_buffer[2] = 0x80 | (command >> 2); // SCCCCCCC (2nd frame)\r | |
845 | irsnd_buffer[3] = (command << 6) & 0xC0; // CC\r | |
846 | \r | |
847 | irsnd_busy = TRUE;\r | |
848 | break;\r | |
849 | }\r | |
850 | #endif\r | |
851 | #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r | |
852 | case IRMP_NOKIA_PROTOCOL:\r | |
853 | {\r | |
854 | address = bitsrevervse (irmp_data_p->address, NOKIA_ADDRESS_LEN);\r | |
855 | command = bitsrevervse (irmp_data_p->command, NOKIA_COMMAND_LEN);\r | |
856 | \r | |
857 | irsnd_buffer[0] = 0xBF; // S0111111 (1st + 3rd frame)\r | |
858 | irsnd_buffer[1] = 0xFF; // 11111111\r | |
859 | irsnd_buffer[2] = 0x80; // 1\r | |
860 | irsnd_buffer[3] = 0x80 | command >> 1; // SCCCCCCC (2nd frame)\r | |
861 | irsnd_buffer[4] = (command << 7) | (address >> 1); // CAAAAAAA\r | |
862 | irsnd_buffer[5] = (address << 7); // A\r | |
863 | \r | |
864 | irsnd_busy = TRUE;\r | |
865 | break;\r | |
866 | }\r | |
867 | #endif\r | |
868 | #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1\r | |
869 | case IRMP_SIEMENS_PROTOCOL:\r | |
870 | {\r | |
871 | irsnd_buffer[0] = ((irmp_data_p->address & 0x0FFF) >> 5); // SAAAAAAA\r | |
872 | irsnd_buffer[1] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x7F) >> 5); // AAAAA0CC\r | |
873 | irsnd_buffer[2] = (irmp_data_p->command << 3) | ((~irmp_data_p->command & 0x01) << 2); // CCCCCc\r | |
874 | \r | |
875 | irsnd_busy = TRUE;\r | |
876 | break;\r | |
877 | }\r | |
878 | #endif\r | |
879 | #if IRSND_SUPPORT_FDC_PROTOCOL == 1\r | |
880 | case IRMP_FDC_PROTOCOL:\r | |
881 | {\r | |
882 | address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN);\r | |
883 | command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN);\r | |
884 | \r | |
885 | irsnd_buffer[0] = (address & 0xFF); // AAAAAAAA\r | |
886 | irsnd_buffer[1] = 0; // 00000000\r | |
887 | irsnd_buffer[2] = 0; // 0000RRRR\r | |
888 | irsnd_buffer[3] = (command & 0xFF); // CCCCCCCC\r | |
889 | irsnd_buffer[4] = ~(command & 0xFF); // cccccccc\r | |
890 | irsnd_busy = TRUE;\r | |
891 | break;\r | |
892 | }\r | |
893 | #endif\r | |
894 | #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1\r | |
895 | case IRMP_RCCAR_PROTOCOL:\r | |
896 | {\r | |
897 | address = bitsrevervse (irmp_data_p->address, 2); // A0 A1\r | |
898 | command = bitsrevervse (irmp_data_p->command, RCCAR_COMMAND_LEN - 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V\r | |
899 | \r | |
900 | irsnd_buffer[0] = ((command & 0x06) << 5) | ((address & 0x0003) << 4) | ((command & 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3\r | |
901 | irsnd_buffer[1] = ((command & 0x78) << 1) | ((command & 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0\r | |
902 | \r | |
903 | irsnd_busy = TRUE;\r | |
904 | break;\r | |
905 | }\r | |
906 | #endif\r | |
907 | #if IRSND_SUPPORT_JVC_PROTOCOL == 1\r | |
908 | case IRMP_JVC_PROTOCOL:\r | |
909 | {\r | |
910 | address = bitsrevervse (irmp_data_p->address, JVC_ADDRESS_LEN);\r | |
911 | command = bitsrevervse (irmp_data_p->command, JVC_COMMAND_LEN);\r | |
912 | \r | |
913 | irsnd_buffer[0] = ((address & 0x000F) << 4) | (command & 0x0F00) >> 8; // AAAACCCC\r | |
914 | irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC\r | |
915 | \r | |
916 | irsnd_busy = TRUE;\r | |
917 | break;\r | |
918 | }\r | |
919 | #endif\r | |
920 | #if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r | |
921 | case IRMP_NIKON_PROTOCOL:\r | |
922 | {\r | |
923 | irsnd_buffer[0] = (irmp_data_p->command & 0x0003) << 6; // CC\r | |
924 | irsnd_busy = TRUE;\r | |
925 | break;\r | |
926 | }\r | |
927 | #endif\r | |
928 | #if IRSND_SUPPORT_LEGO_PROTOCOL == 1\r | |
929 | case IRMP_LEGO_PROTOCOL:\r | |
930 | {\r | |
931 | uint8_t crc = 0x0F ^ ((irmp_data_p->command & 0x0F00) >> 8) ^ ((irmp_data_p->command & 0x00F0) >> 4) ^ (irmp_data_p->command & 0x000F);\r | |
932 | \r | |
933 | irsnd_buffer[0] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC\r | |
934 | irsnd_buffer[1] = ((irmp_data_p->command & 0x000F) << 4) | crc; // CCCCcccc\r | |
935 | \r | |
936 | irsnd_protocol = IRMP_LEGO_PROTOCOL;\r | |
937 | irsnd_busy = TRUE;\r | |
938 | break;\r | |
939 | }\r | |
940 | #endif\r | |
941 | default:\r | |
942 | {\r | |
943 | break;\r | |
944 | }\r | |
945 | }\r | |
946 | \r | |
947 | return irsnd_busy;\r | |
948 | }\r | |
949 | \r | |
950 | void\r | |
951 | irsnd_stop (void)\r | |
952 | {\r | |
953 | irsnd_repeat = 0;\r | |
954 | }\r | |
955 | \r | |
956 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
957 | * ISR routine\r | |
958 | * @details ISR routine, called 10000 times per second\r | |
959 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
960 | */\r | |
961 | uint8_t\r | |
962 | irsnd_ISR (void)\r | |
963 | {\r | |
964 | static uint8_t current_bit = 0xFF;\r | |
965 | static uint8_t pulse_counter;\r | |
966 | static IRSND_PAUSE_LEN pause_counter;\r | |
967 | static uint8_t startbit_pulse_len;\r | |
968 | static IRSND_PAUSE_LEN startbit_pause_len;\r | |
969 | static uint8_t pulse_1_len;\r | |
970 | static uint8_t pause_1_len;\r | |
971 | static uint8_t pulse_0_len;\r | |
972 | static uint8_t pause_0_len;\r | |
973 | static uint8_t has_stop_bit;\r | |
974 | static uint8_t new_frame = TRUE;\r | |
975 | static uint8_t complete_data_len;\r | |
976 | static uint8_t n_repeat_frames; // number of repetition frames\r | |
977 | static uint8_t n_auto_repetitions; // number of auto_repetitions\r | |
978 | static uint8_t auto_repetition_counter; // auto_repetition counter\r | |
979 | static uint16_t auto_repetition_pause_len; // pause before auto_repetition, uint16_t!\r | |
980 | static uint16_t auto_repetition_pause_counter; // pause before auto_repetition, uint16_t!\r | |
981 | static uint8_t repeat_counter; // repeat counter\r | |
982 | static uint16_t repeat_frame_pause_len; // pause before repeat, uint16_t!\r | |
983 | static uint16_t packet_repeat_pause_counter; // pause before repeat, uint16_t!\r | |
984 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r | |
985 | static uint8_t last_bit_value;\r | |
986 | #endif\r | |
987 | static uint8_t pulse_len = 0xFF;\r | |
988 | static IRSND_PAUSE_LEN pause_len = 0xFF;\r | |
989 | \r | |
990 | if (irsnd_busy)\r | |
991 | {\r | |
992 | if (current_bit == 0xFF && new_frame) // start of transmission...\r | |
993 | {\r | |
994 | if (auto_repetition_counter > 0)\r | |
995 | {\r | |
996 | auto_repetition_pause_counter++;\r | |
997 | \r | |
998 | if (auto_repetition_pause_counter >= auto_repetition_pause_len)\r | |
999 | {\r | |
1000 | auto_repetition_pause_counter = 0;\r | |
1001 | \r | |
1002 | if (irsnd_protocol == IRMP_DENON_PROTOCOL)\r | |
1003 | {\r | |
1004 | current_bit = 16;\r | |
1005 | complete_data_len = 2 * DENON_COMPLETE_DATA_LEN + 1;\r | |
1006 | }\r | |
1007 | else if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig info frame\r | |
1008 | {\r | |
1009 | current_bit = 15;\r | |
1010 | complete_data_len = 16 + GRUNDIG_COMPLETE_DATA_LEN;\r | |
1011 | }\r | |
1012 | else if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia info frame\r | |
1013 | {\r | |
1014 | if (auto_repetition_counter + 1 < n_auto_repetitions)\r | |
1015 | {\r | |
1016 | current_bit = 23;\r | |
1017 | complete_data_len = 24 + NOKIA_COMPLETE_DATA_LEN;\r | |
1018 | }\r | |
1019 | else // nokia stop frame\r | |
1020 | {\r | |
1021 | current_bit = 0xFF;\r | |
1022 | complete_data_len = NOKIA_COMPLETE_DATA_LEN;\r | |
1023 | }\r | |
1024 | }\r | |
1025 | }\r | |
1026 | else\r | |
1027 | {\r | |
1028 | #ifdef DEBUG\r | |
1029 | if (irsnd_is_on)\r | |
1030 | {\r | |
1031 | putchar ('0');\r | |
1032 | }\r | |
1033 | else\r | |
1034 | {\r | |
1035 | putchar ('1');\r | |
1036 | }\r | |
1037 | #endif\r | |
1038 | return irsnd_busy;\r | |
1039 | }\r | |
1040 | }\r | |
1041 | #if 0\r | |
1042 | else if (repeat_counter > 0 && packet_repeat_pause_counter < repeat_frame_pause_len)\r | |
1043 | #else\r | |
1044 | else if (packet_repeat_pause_counter < repeat_frame_pause_len)\r | |
1045 | #endif\r | |
1046 | {\r | |
1047 | packet_repeat_pause_counter++;\r | |
1048 | \r | |
1049 | #ifdef DEBUG\r | |
1050 | if (irsnd_is_on)\r | |
1051 | {\r | |
1052 | putchar ('0');\r | |
1053 | }\r | |
1054 | else\r | |
1055 | {\r | |
1056 | putchar ('1');\r | |
1057 | }\r | |
1058 | #endif\r | |
1059 | return irsnd_busy;\r | |
1060 | }\r | |
1061 | else\r | |
1062 | {\r | |
1063 | n_repeat_frames = irsnd_repeat;\r | |
1064 | \r | |
1065 | if (n_repeat_frames == IRSND_ENDLESS_REPETITION)\r | |
1066 | {\r | |
1067 | n_repeat_frames = 255;\r | |
1068 | }\r | |
1069 | \r | |
1070 | packet_repeat_pause_counter = 0;\r | |
1071 | pulse_counter = 0;\r | |
1072 | pause_counter = 0;\r | |
1073 | \r | |
1074 | switch (irsnd_protocol)\r | |
1075 | {\r | |
1076 | #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r | |
1077 | case IRMP_SIRCS_PROTOCOL:\r | |
1078 | {\r | |
1079 | startbit_pulse_len = SIRCS_START_BIT_PULSE_LEN;\r | |
1080 | startbit_pause_len = SIRCS_START_BIT_PAUSE_LEN - 1;\r | |
1081 | pulse_1_len = SIRCS_1_PULSE_LEN;\r | |
1082 | pause_1_len = SIRCS_PAUSE_LEN - 1;\r | |
1083 | pulse_0_len = SIRCS_0_PULSE_LEN;\r | |
1084 | pause_0_len = SIRCS_PAUSE_LEN - 1;\r | |
1085 | has_stop_bit = SIRCS_STOP_BIT;\r | |
1086 | complete_data_len = SIRCS_MINIMUM_DATA_LEN + sircs_additional_bitlen;\r | |
1087 | n_auto_repetitions = (repeat_counter == 0) ? SIRCS_FRAMES : 1; // 3 frames auto repetition if first frame\r | |
1088 | auto_repetition_pause_len = SIRCS_AUTO_REPETITION_PAUSE_LEN; // 25ms pause\r | |
1089 | repeat_frame_pause_len = SIRCS_FRAME_REPEAT_PAUSE_LEN;\r | |
1090 | irsnd_set_freq (IRSND_FREQ_40_KHZ);\r | |
1091 | break;\r | |
1092 | }\r | |
1093 | #endif\r | |
1094 | #if IRSND_SUPPORT_NEC_PROTOCOL == 1\r | |
1095 | case IRMP_NEC_PROTOCOL:\r | |
1096 | {\r | |
1097 | startbit_pulse_len = NEC_START_BIT_PULSE_LEN;\r | |
1098 | \r | |
1099 | if (repeat_counter > 0)\r | |
1100 | {\r | |
1101 | startbit_pause_len = NEC_REPEAT_START_BIT_PAUSE_LEN - 1;\r | |
1102 | complete_data_len = 0;\r | |
1103 | }\r | |
1104 | else\r | |
1105 | {\r | |
1106 | startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1;\r | |
1107 | complete_data_len = NEC_COMPLETE_DATA_LEN;\r | |
1108 | }\r | |
1109 | \r | |
1110 | pulse_1_len = NEC_PULSE_LEN;\r | |
1111 | pause_1_len = NEC_1_PAUSE_LEN - 1;\r | |
1112 | pulse_0_len = NEC_PULSE_LEN;\r | |
1113 | pause_0_len = NEC_0_PAUSE_LEN - 1;\r | |
1114 | has_stop_bit = NEC_STOP_BIT;\r | |
1115 | n_auto_repetitions = 1; // 1 frame\r | |
1116 | auto_repetition_pause_len = 0;\r | |
1117 | repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN;\r | |
1118 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1119 | break;\r | |
1120 | }\r | |
1121 | #endif\r | |
1122 | #if IRSND_SUPPORT_NEC16_PROTOCOL == 1\r | |
1123 | case IRMP_NEC16_PROTOCOL:\r | |
1124 | {\r | |
1125 | startbit_pulse_len = NEC_START_BIT_PULSE_LEN;\r | |
1126 | startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1;\r | |
1127 | pulse_1_len = NEC_PULSE_LEN;\r | |
1128 | pause_1_len = NEC_1_PAUSE_LEN - 1;\r | |
1129 | pulse_0_len = NEC_PULSE_LEN;\r | |
1130 | pause_0_len = NEC_0_PAUSE_LEN - 1;\r | |
1131 | has_stop_bit = NEC_STOP_BIT;\r | |
1132 | complete_data_len = NEC16_COMPLETE_DATA_LEN + 1; // 1 more: sync bit\r | |
1133 | n_auto_repetitions = 1; // 1 frame\r | |
1134 | auto_repetition_pause_len = 0;\r | |
1135 | repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN;\r | |
1136 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1137 | break;\r | |
1138 | }\r | |
1139 | #endif\r | |
1140 | #if IRSND_SUPPORT_NEC42_PROTOCOL == 1\r | |
1141 | case IRMP_NEC42_PROTOCOL:\r | |
1142 | {\r | |
1143 | startbit_pulse_len = NEC_START_BIT_PULSE_LEN;\r | |
1144 | startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1;\r | |
1145 | pulse_1_len = NEC_PULSE_LEN;\r | |
1146 | pause_1_len = NEC_1_PAUSE_LEN - 1;\r | |
1147 | pulse_0_len = NEC_PULSE_LEN;\r | |
1148 | pause_0_len = NEC_0_PAUSE_LEN - 1;\r | |
1149 | has_stop_bit = NEC_STOP_BIT;\r | |
1150 | complete_data_len = NEC42_COMPLETE_DATA_LEN;\r | |
1151 | n_auto_repetitions = 1; // 1 frame\r | |
1152 | auto_repetition_pause_len = 0;\r | |
1153 | repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN;\r | |
1154 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1155 | break;\r | |
1156 | }\r | |
1157 | #endif\r | |
1158 | #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1\r | |
1159 | case IRMP_SAMSUNG_PROTOCOL:\r | |
1160 | {\r | |
1161 | startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN;\r | |
1162 | startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1;\r | |
1163 | pulse_1_len = SAMSUNG_PULSE_LEN;\r | |
1164 | pause_1_len = SAMSUNG_1_PAUSE_LEN - 1;\r | |
1165 | pulse_0_len = SAMSUNG_PULSE_LEN;\r | |
1166 | pause_0_len = SAMSUNG_0_PAUSE_LEN - 1;\r | |
1167 | has_stop_bit = SAMSUNG_STOP_BIT;\r | |
1168 | complete_data_len = SAMSUNG_COMPLETE_DATA_LEN;\r | |
1169 | n_auto_repetitions = 1; // 1 frame\r | |
1170 | auto_repetition_pause_len = 0;\r | |
1171 | repeat_frame_pause_len = SAMSUNG_FRAME_REPEAT_PAUSE_LEN;\r | |
1172 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1173 | break;\r | |
1174 | }\r | |
1175 | \r | |
1176 | case IRMP_SAMSUNG32_PROTOCOL:\r | |
1177 | {\r | |
1178 | startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN;\r | |
1179 | startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1;\r | |
1180 | pulse_1_len = SAMSUNG_PULSE_LEN;\r | |
1181 | pause_1_len = SAMSUNG_1_PAUSE_LEN - 1;\r | |
1182 | pulse_0_len = SAMSUNG_PULSE_LEN;\r | |
1183 | pause_0_len = SAMSUNG_0_PAUSE_LEN - 1;\r | |
1184 | has_stop_bit = SAMSUNG_STOP_BIT;\r | |
1185 | complete_data_len = SAMSUNG32_COMPLETE_DATA_LEN;\r | |
1186 | n_auto_repetitions = SAMSUNG32_FRAMES; // 2 frames\r | |
1187 | auto_repetition_pause_len = SAMSUNG32_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause\r | |
1188 | repeat_frame_pause_len = SAMSUNG32_FRAME_REPEAT_PAUSE_LEN;\r | |
1189 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1190 | break;\r | |
1191 | }\r | |
1192 | #endif\r | |
1193 | #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1\r | |
1194 | case IRMP_MATSUSHITA_PROTOCOL:\r | |
1195 | {\r | |
1196 | startbit_pulse_len = MATSUSHITA_START_BIT_PULSE_LEN;\r | |
1197 | startbit_pause_len = MATSUSHITA_START_BIT_PAUSE_LEN - 1;\r | |
1198 | pulse_1_len = MATSUSHITA_PULSE_LEN;\r | |
1199 | pause_1_len = MATSUSHITA_1_PAUSE_LEN - 1;\r | |
1200 | pulse_0_len = MATSUSHITA_PULSE_LEN;\r | |
1201 | pause_0_len = MATSUSHITA_0_PAUSE_LEN - 1;\r | |
1202 | has_stop_bit = MATSUSHITA_STOP_BIT;\r | |
1203 | complete_data_len = MATSUSHITA_COMPLETE_DATA_LEN;\r | |
1204 | n_auto_repetitions = 1; // 1 frame\r | |
1205 | auto_repetition_pause_len = 0;\r | |
1206 | repeat_frame_pause_len = MATSUSHITA_FRAME_REPEAT_PAUSE_LEN;\r | |
1207 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r | |
1208 | break;\r | |
1209 | }\r | |
1210 | #endif\r | |
1211 | #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1\r | |
1212 | case IRMP_KASEIKYO_PROTOCOL:\r | |
1213 | {\r | |
1214 | startbit_pulse_len = KASEIKYO_START_BIT_PULSE_LEN;\r | |
1215 | startbit_pause_len = KASEIKYO_START_BIT_PAUSE_LEN - 1;\r | |
1216 | pulse_1_len = KASEIKYO_PULSE_LEN;\r | |
1217 | pause_1_len = KASEIKYO_1_PAUSE_LEN - 1;\r | |
1218 | pulse_0_len = KASEIKYO_PULSE_LEN;\r | |
1219 | pause_0_len = KASEIKYO_0_PAUSE_LEN - 1;\r | |
1220 | has_stop_bit = KASEIKYO_STOP_BIT;\r | |
1221 | complete_data_len = KASEIKYO_COMPLETE_DATA_LEN;\r | |
1222 | n_auto_repetitions = (repeat_counter == 0) ? KASEIKYO_FRAMES : 1; // 2 frames auto repetition if first frame\r | |
1223 | auto_repetition_pause_len = KASEIKYO_AUTO_REPETITION_PAUSE_LEN; // 75 ms pause\r | |
1224 | repeat_frame_pause_len = KASEIKYO_FRAME_REPEAT_PAUSE_LEN;\r | |
1225 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1226 | break;\r | |
1227 | }\r | |
1228 | #endif\r | |
1229 | #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r | |
1230 | case IRMP_RECS80_PROTOCOL:\r | |
1231 | {\r | |
1232 | startbit_pulse_len = RECS80_START_BIT_PULSE_LEN;\r | |
1233 | startbit_pause_len = RECS80_START_BIT_PAUSE_LEN - 1;\r | |
1234 | pulse_1_len = RECS80_PULSE_LEN;\r | |
1235 | pause_1_len = RECS80_1_PAUSE_LEN - 1;\r | |
1236 | pulse_0_len = RECS80_PULSE_LEN;\r | |
1237 | pause_0_len = RECS80_0_PAUSE_LEN - 1;\r | |
1238 | has_stop_bit = RECS80_STOP_BIT;\r | |
1239 | complete_data_len = RECS80_COMPLETE_DATA_LEN;\r | |
1240 | n_auto_repetitions = 1; // 1 frame\r | |
1241 | auto_repetition_pause_len = 0;\r | |
1242 | repeat_frame_pause_len = RECS80_FRAME_REPEAT_PAUSE_LEN;\r | |
1243 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1244 | break;\r | |
1245 | }\r | |
1246 | #endif\r | |
1247 | #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1\r | |
1248 | case IRMP_RECS80EXT_PROTOCOL:\r | |
1249 | {\r | |
1250 | startbit_pulse_len = RECS80EXT_START_BIT_PULSE_LEN;\r | |
1251 | startbit_pause_len = RECS80EXT_START_BIT_PAUSE_LEN - 1;\r | |
1252 | pulse_1_len = RECS80EXT_PULSE_LEN;\r | |
1253 | pause_1_len = RECS80EXT_1_PAUSE_LEN - 1;\r | |
1254 | pulse_0_len = RECS80EXT_PULSE_LEN;\r | |
1255 | pause_0_len = RECS80EXT_0_PAUSE_LEN - 1;\r | |
1256 | has_stop_bit = RECS80EXT_STOP_BIT;\r | |
1257 | complete_data_len = RECS80EXT_COMPLETE_DATA_LEN;\r | |
1258 | n_auto_repetitions = 1; // 1 frame\r | |
1259 | auto_repetition_pause_len = 0;\r | |
1260 | repeat_frame_pause_len = RECS80EXT_FRAME_REPEAT_PAUSE_LEN;\r | |
1261 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1262 | break;\r | |
1263 | }\r | |
1264 | #endif\r | |
1265 | #if IRSND_SUPPORT_RC5_PROTOCOL == 1\r | |
1266 | case IRMP_RC5_PROTOCOL:\r | |
1267 | {\r | |
1268 | startbit_pulse_len = RC5_BIT_LEN;\r | |
1269 | startbit_pause_len = RC5_BIT_LEN;\r | |
1270 | pulse_len = RC5_BIT_LEN;\r | |
1271 | pause_len = RC5_BIT_LEN;\r | |
1272 | has_stop_bit = RC5_STOP_BIT;\r | |
1273 | complete_data_len = RC5_COMPLETE_DATA_LEN;\r | |
1274 | n_auto_repetitions = 1; // 1 frame\r | |
1275 | auto_repetition_pause_len = 0;\r | |
1276 | repeat_frame_pause_len = RC5_FRAME_REPEAT_PAUSE_LEN;\r | |
1277 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r | |
1278 | break;\r | |
1279 | }\r | |
1280 | #endif\r | |
1281 | #if IRSND_SUPPORT_RC6_PROTOCOL == 1\r | |
1282 | case IRMP_RC6_PROTOCOL:\r | |
1283 | {\r | |
1284 | startbit_pulse_len = RC6_START_BIT_PULSE_LEN;\r | |
1285 | startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1;\r | |
1286 | pulse_len = RC6_BIT_LEN;\r | |
1287 | pause_len = RC6_BIT_LEN;\r | |
1288 | has_stop_bit = RC6_STOP_BIT;\r | |
1289 | complete_data_len = RC6_COMPLETE_DATA_LEN_SHORT;\r | |
1290 | n_auto_repetitions = 1; // 1 frame\r | |
1291 | auto_repetition_pause_len = 0;\r | |
1292 | repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN;\r | |
1293 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r | |
1294 | break;\r | |
1295 | }\r | |
1296 | #endif\r | |
1297 | #if IRSND_SUPPORT_RC6A_PROTOCOL == 1\r | |
1298 | case IRMP_RC6A_PROTOCOL:\r | |
1299 | {\r | |
1300 | startbit_pulse_len = RC6_START_BIT_PULSE_LEN;\r | |
1301 | startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1;\r | |
1302 | pulse_len = RC6_BIT_LEN;\r | |
1303 | pause_len = RC6_BIT_LEN;\r | |
1304 | has_stop_bit = RC6_STOP_BIT;\r | |
1305 | complete_data_len = RC6_COMPLETE_DATA_LEN_LONG;\r | |
1306 | n_auto_repetitions = 1; // 1 frame\r | |
1307 | auto_repetition_pause_len = 0;\r | |
1308 | repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN;\r | |
1309 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r | |
1310 | break;\r | |
1311 | }\r | |
1312 | #endif\r | |
1313 | #if IRSND_SUPPORT_DENON_PROTOCOL == 1\r | |
1314 | case IRMP_DENON_PROTOCOL:\r | |
1315 | {\r | |
1316 | startbit_pulse_len = 0x00;\r | |
1317 | startbit_pause_len = 0x00;\r | |
1318 | pulse_1_len = DENON_PULSE_LEN;\r | |
1319 | pause_1_len = DENON_1_PAUSE_LEN - 1;\r | |
1320 | pulse_0_len = DENON_PULSE_LEN;\r | |
1321 | pause_0_len = DENON_0_PAUSE_LEN - 1;\r | |
1322 | has_stop_bit = DENON_STOP_BIT;\r | |
1323 | complete_data_len = DENON_COMPLETE_DATA_LEN;\r | |
1324 | n_auto_repetitions = DENON_FRAMES; // 2 frames, 2nd with inverted command\r | |
1325 | auto_repetition_pause_len = DENON_AUTO_REPETITION_PAUSE_LEN; // 65 ms pause after 1st frame\r | |
1326 | repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN;\r | |
1327 | irsnd_set_freq (IRSND_FREQ_36_KHZ); // in theory 32kHz, in practice 36kHz is better\r | |
1328 | break;\r | |
1329 | }\r | |
1330 | #endif\r | |
1331 | #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1\r | |
1332 | case IRMP_THOMSON_PROTOCOL:\r | |
1333 | {\r | |
1334 | startbit_pulse_len = 0x00;\r | |
1335 | startbit_pause_len = 0x00;\r | |
1336 | pulse_1_len = THOMSON_PULSE_LEN;\r | |
1337 | pause_1_len = THOMSON_1_PAUSE_LEN - 1;\r | |
1338 | pulse_0_len = THOMSON_PULSE_LEN;\r | |
1339 | pause_0_len = THOMSON_0_PAUSE_LEN - 1;\r | |
1340 | has_stop_bit = THOMSON_STOP_BIT;\r | |
1341 | complete_data_len = THOMSON_COMPLETE_DATA_LEN;\r | |
1342 | n_auto_repetitions = THOMSON_FRAMES; // only 1 frame\r | |
1343 | auto_repetition_pause_len = THOMSON_AUTO_REPETITION_PAUSE_LEN;\r | |
1344 | repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN;\r | |
1345 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1346 | break;\r | |
1347 | }\r | |
1348 | #endif\r | |
1349 | #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1\r | |
1350 | case IRMP_NUBERT_PROTOCOL:\r | |
1351 | {\r | |
1352 | startbit_pulse_len = NUBERT_START_BIT_PULSE_LEN;\r | |
1353 | startbit_pause_len = NUBERT_START_BIT_PAUSE_LEN - 1;\r | |
1354 | pulse_1_len = NUBERT_1_PULSE_LEN;\r | |
1355 | pause_1_len = NUBERT_1_PAUSE_LEN - 1;\r | |
1356 | pulse_0_len = NUBERT_0_PULSE_LEN;\r | |
1357 | pause_0_len = NUBERT_0_PAUSE_LEN - 1;\r | |
1358 | has_stop_bit = NUBERT_STOP_BIT;\r | |
1359 | complete_data_len = NUBERT_COMPLETE_DATA_LEN;\r | |
1360 | n_auto_repetitions = NUBERT_FRAMES; // 2 frames\r | |
1361 | auto_repetition_pause_len = NUBERT_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause\r | |
1362 | repeat_frame_pause_len = NUBERT_FRAME_REPEAT_PAUSE_LEN;\r | |
1363 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r | |
1364 | break;\r | |
1365 | }\r | |
1366 | #endif\r | |
1367 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r | |
1368 | case IRMP_BANG_OLUFSEN_PROTOCOL:\r | |
1369 | {\r | |
1370 | startbit_pulse_len = BANG_OLUFSEN_START_BIT1_PULSE_LEN;\r | |
1371 | startbit_pause_len = BANG_OLUFSEN_START_BIT1_PAUSE_LEN - 1;\r | |
1372 | pulse_1_len = BANG_OLUFSEN_PULSE_LEN;\r | |
1373 | pause_1_len = BANG_OLUFSEN_1_PAUSE_LEN - 1;\r | |
1374 | pulse_0_len = BANG_OLUFSEN_PULSE_LEN;\r | |
1375 | pause_0_len = BANG_OLUFSEN_0_PAUSE_LEN - 1;\r | |
1376 | has_stop_bit = BANG_OLUFSEN_STOP_BIT;\r | |
1377 | complete_data_len = BANG_OLUFSEN_COMPLETE_DATA_LEN;\r | |
1378 | n_auto_repetitions = 1; // 1 frame\r | |
1379 | auto_repetition_pause_len = 0;\r | |
1380 | repeat_frame_pause_len = BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN;\r | |
1381 | last_bit_value = 0;\r | |
1382 | irsnd_set_freq (IRSND_FREQ_455_KHZ);\r | |
1383 | break;\r | |
1384 | }\r | |
1385 | #endif\r | |
1386 | #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1\r | |
1387 | case IRMP_GRUNDIG_PROTOCOL:\r | |
1388 | {\r | |
1389 | startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
1390 | startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1;\r | |
1391 | pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
1392 | pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
1393 | has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT;\r | |
1394 | complete_data_len = GRUNDIG_COMPLETE_DATA_LEN;\r | |
1395 | n_auto_repetitions = GRUNDIG_FRAMES; // 2 frames\r | |
1396 | auto_repetition_pause_len = GRUNDIG_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause\r | |
1397 | repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause\r | |
1398 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1399 | \r | |
1400 | break;\r | |
1401 | }\r | |
1402 | #endif\r | |
1403 | #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r | |
1404 | case IRMP_NOKIA_PROTOCOL:\r | |
1405 | {\r | |
1406 | startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
1407 | startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1;\r | |
1408 | pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
1409 | pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
1410 | has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT;\r | |
1411 | complete_data_len = NOKIA_COMPLETE_DATA_LEN;\r | |
1412 | n_auto_repetitions = NOKIA_FRAMES; // 2 frames\r | |
1413 | auto_repetition_pause_len = NOKIA_AUTO_REPETITION_PAUSE_LEN; // 20 msec pause\r | |
1414 | repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause\r | |
1415 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1416 | break;\r | |
1417 | }\r | |
1418 | #endif\r | |
1419 | #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1\r | |
1420 | case IRMP_SIEMENS_PROTOCOL:\r | |
1421 | {\r | |
1422 | startbit_pulse_len = SIEMENS_BIT_LEN;\r | |
1423 | startbit_pause_len = SIEMENS_BIT_LEN;\r | |
1424 | pulse_len = SIEMENS_BIT_LEN;\r | |
1425 | pause_len = SIEMENS_BIT_LEN;\r | |
1426 | has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT;\r | |
1427 | complete_data_len = SIEMENS_COMPLETE_DATA_LEN - 1;\r | |
1428 | n_auto_repetitions = 1; // 1 frame\r | |
1429 | auto_repetition_pause_len = 0;\r | |
1430 | repeat_frame_pause_len = SIEMENS_FRAME_REPEAT_PAUSE_LEN;\r | |
1431 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r | |
1432 | break;\r | |
1433 | }\r | |
1434 | #endif\r | |
1435 | #if IRSND_SUPPORT_FDC_PROTOCOL == 1\r | |
1436 | case IRMP_FDC_PROTOCOL:\r | |
1437 | {\r | |
1438 | startbit_pulse_len = FDC_START_BIT_PULSE_LEN;\r | |
1439 | startbit_pause_len = FDC_START_BIT_PAUSE_LEN - 1;\r | |
1440 | complete_data_len = FDC_COMPLETE_DATA_LEN;\r | |
1441 | pulse_1_len = FDC_PULSE_LEN;\r | |
1442 | pause_1_len = FDC_1_PAUSE_LEN - 1;\r | |
1443 | pulse_0_len = FDC_PULSE_LEN;\r | |
1444 | pause_0_len = FDC_0_PAUSE_LEN - 1;\r | |
1445 | has_stop_bit = FDC_STOP_BIT;\r | |
1446 | n_auto_repetitions = 1; // 1 frame\r | |
1447 | auto_repetition_pause_len = 0;\r | |
1448 | repeat_frame_pause_len = FDC_FRAME_REPEAT_PAUSE_LEN;\r | |
1449 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1450 | break;\r | |
1451 | }\r | |
1452 | #endif\r | |
1453 | #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1\r | |
1454 | case IRMP_RCCAR_PROTOCOL:\r | |
1455 | {\r | |
1456 | startbit_pulse_len = RCCAR_START_BIT_PULSE_LEN;\r | |
1457 | startbit_pause_len = RCCAR_START_BIT_PAUSE_LEN - 1;\r | |
1458 | complete_data_len = RCCAR_COMPLETE_DATA_LEN;\r | |
1459 | pulse_1_len = RCCAR_PULSE_LEN;\r | |
1460 | pause_1_len = RCCAR_1_PAUSE_LEN - 1;\r | |
1461 | pulse_0_len = RCCAR_PULSE_LEN;\r | |
1462 | pause_0_len = RCCAR_0_PAUSE_LEN - 1;\r | |
1463 | has_stop_bit = RCCAR_STOP_BIT;\r | |
1464 | n_auto_repetitions = 1; // 1 frame\r | |
1465 | auto_repetition_pause_len = 0;\r | |
1466 | repeat_frame_pause_len = RCCAR_FRAME_REPEAT_PAUSE_LEN;\r | |
1467 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1468 | break;\r | |
1469 | }\r | |
1470 | #endif\r | |
1471 | #if IRSND_SUPPORT_JVC_PROTOCOL == 1\r | |
1472 | case IRMP_JVC_PROTOCOL:\r | |
1473 | {\r | |
1474 | if (repeat_counter != 0) // skip start bit if repetition frame\r | |
1475 | {\r | |
1476 | current_bit = 0;\r | |
1477 | }\r | |
1478 | \r | |
1479 | startbit_pulse_len = JVC_START_BIT_PULSE_LEN;\r | |
1480 | startbit_pause_len = JVC_START_BIT_PAUSE_LEN - 1;\r | |
1481 | complete_data_len = JVC_COMPLETE_DATA_LEN;\r | |
1482 | pulse_1_len = JVC_PULSE_LEN;\r | |
1483 | pause_1_len = JVC_1_PAUSE_LEN - 1;\r | |
1484 | pulse_0_len = JVC_PULSE_LEN;\r | |
1485 | pause_0_len = JVC_0_PAUSE_LEN - 1;\r | |
1486 | has_stop_bit = JVC_STOP_BIT;\r | |
1487 | n_auto_repetitions = 1; // 1 frame\r | |
1488 | auto_repetition_pause_len = 0;\r | |
1489 | repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN;\r | |
1490 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1491 | \r | |
1492 | break;\r | |
1493 | }\r | |
1494 | #endif\r | |
1495 | #if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r | |
1496 | case IRMP_NIKON_PROTOCOL:\r | |
1497 | {\r | |
1498 | startbit_pulse_len = NIKON_START_BIT_PULSE_LEN;\r | |
1499 | startbit_pause_len = 271 - 1; // NIKON_START_BIT_PAUSE_LEN;\r | |
1500 | complete_data_len = NIKON_COMPLETE_DATA_LEN;\r | |
1501 | pulse_1_len = NIKON_PULSE_LEN;\r | |
1502 | pause_1_len = NIKON_1_PAUSE_LEN - 1;\r | |
1503 | pulse_0_len = NIKON_PULSE_LEN;\r | |
1504 | pause_0_len = NIKON_0_PAUSE_LEN - 1;\r | |
1505 | has_stop_bit = NIKON_STOP_BIT;\r | |
1506 | n_auto_repetitions = 1; // 1 frame\r | |
1507 | auto_repetition_pause_len = 0;\r | |
1508 | repeat_frame_pause_len = NIKON_FRAME_REPEAT_PAUSE_LEN;\r | |
1509 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1510 | \r | |
1511 | break;\r | |
1512 | }\r | |
1513 | #endif\r | |
1514 | #if IRSND_SUPPORT_LEGO_PROTOCOL == 1\r | |
1515 | case IRMP_LEGO_PROTOCOL:\r | |
1516 | {\r | |
1517 | startbit_pulse_len = LEGO_START_BIT_PULSE_LEN;\r | |
1518 | startbit_pause_len = LEGO_START_BIT_PAUSE_LEN - 1;\r | |
1519 | complete_data_len = LEGO_COMPLETE_DATA_LEN;\r | |
1520 | pulse_1_len = LEGO_PULSE_LEN;\r | |
1521 | pause_1_len = LEGO_1_PAUSE_LEN - 1;\r | |
1522 | pulse_0_len = LEGO_PULSE_LEN;\r | |
1523 | pause_0_len = LEGO_0_PAUSE_LEN - 1;\r | |
1524 | has_stop_bit = LEGO_STOP_BIT;\r | |
1525 | n_auto_repetitions = 1; // 1 frame\r | |
1526 | auto_repetition_pause_len = 0;\r | |
1527 | repeat_frame_pause_len = LEGO_FRAME_REPEAT_PAUSE_LEN;\r | |
1528 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r | |
1529 | break;\r | |
1530 | }\r | |
1531 | #endif\r | |
1532 | default:\r | |
1533 | {\r | |
1534 | irsnd_busy = FALSE;\r | |
1535 | break;\r | |
1536 | }\r | |
1537 | }\r | |
1538 | }\r | |
1539 | }\r | |
1540 | \r | |
1541 | if (irsnd_busy)\r | |
1542 | {\r | |
1543 | new_frame = FALSE;\r | |
1544 | \r | |
1545 | switch (irsnd_protocol)\r | |
1546 | {\r | |
1547 | #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r | |
1548 | case IRMP_SIRCS_PROTOCOL:\r | |
1549 | #endif\r | |
1550 | #if IRSND_SUPPORT_NEC_PROTOCOL == 1\r | |
1551 | case IRMP_NEC_PROTOCOL:\r | |
1552 | #endif\r | |
1553 | #if IRSND_SUPPORT_NEC16_PROTOCOL == 1\r | |
1554 | case IRMP_NEC16_PROTOCOL:\r | |
1555 | #endif\r | |
1556 | #if IRSND_SUPPORT_NEC42_PROTOCOL == 1\r | |
1557 | case IRMP_NEC42_PROTOCOL:\r | |
1558 | #endif\r | |
1559 | #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1\r | |
1560 | case IRMP_SAMSUNG_PROTOCOL:\r | |
1561 | case IRMP_SAMSUNG32_PROTOCOL:\r | |
1562 | #endif\r | |
1563 | #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1\r | |
1564 | case IRMP_MATSUSHITA_PROTOCOL:\r | |
1565 | #endif\r | |
1566 | #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1\r | |
1567 | case IRMP_KASEIKYO_PROTOCOL:\r | |
1568 | #endif\r | |
1569 | #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r | |
1570 | case IRMP_RECS80_PROTOCOL:\r | |
1571 | #endif\r | |
1572 | #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1\r | |
1573 | case IRMP_RECS80EXT_PROTOCOL:\r | |
1574 | #endif\r | |
1575 | #if IRSND_SUPPORT_DENON_PROTOCOL == 1\r | |
1576 | case IRMP_DENON_PROTOCOL:\r | |
1577 | #endif\r | |
1578 | #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1\r | |
1579 | case IRMP_THOMSON_PROTOCOL:\r | |
1580 | #endif\r | |
1581 | #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1\r | |
1582 | case IRMP_NUBERT_PROTOCOL:\r | |
1583 | #endif\r | |
1584 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r | |
1585 | case IRMP_BANG_OLUFSEN_PROTOCOL:\r | |
1586 | #endif\r | |
1587 | #if IRSND_SUPPORT_FDC_PROTOCOL == 1\r | |
1588 | case IRMP_FDC_PROTOCOL:\r | |
1589 | #endif\r | |
1590 | #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1\r | |
1591 | case IRMP_RCCAR_PROTOCOL:\r | |
1592 | #endif\r | |
1593 | #if IRSND_SUPPORT_JVC_PROTOCOL == 1\r | |
1594 | case IRMP_JVC_PROTOCOL:\r | |
1595 | #endif\r | |
1596 | #if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r | |
1597 | case IRMP_NIKON_PROTOCOL:\r | |
1598 | #endif\r | |
1599 | #if IRSND_SUPPORT_LEGO_PROTOCOL == 1\r | |
1600 | case IRMP_LEGO_PROTOCOL:\r | |
1601 | #endif\r | |
1602 | \r | |
1603 | \r | |
1604 | #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_NEC16_PROTOCOL == 1 || IRSND_SUPPORT_NEC42_PROTOCOL == 1 || \\r | |
1605 | IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \\r | |
1606 | IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \\r | |
1607 | IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || \\r | |
1608 | IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1 \r | |
1609 | {\r | |
1610 | if (pulse_counter == 0)\r | |
1611 | {\r | |
1612 | if (current_bit == 0xFF) // send start bit\r | |
1613 | {\r | |
1614 | pulse_len = startbit_pulse_len;\r | |
1615 | pause_len = startbit_pause_len;\r | |
1616 | }\r | |
1617 | else if (current_bit < complete_data_len) // send n'th bit\r | |
1618 | {\r | |
1619 | #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1\r | |
1620 | if (irsnd_protocol == IRMP_SAMSUNG_PROTOCOL)\r | |
1621 | {\r | |
1622 | if (current_bit < SAMSUNG_ADDRESS_LEN) // send address bits\r | |
1623 | {\r | |
1624 | pulse_len = SAMSUNG_PULSE_LEN;\r | |
1625 | pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ?\r | |
1626 | (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1);\r | |
1627 | }\r | |
1628 | else if (current_bit == SAMSUNG_ADDRESS_LEN) // send SYNC bit (16th bit)\r | |
1629 | {\r | |
1630 | pulse_len = SAMSUNG_PULSE_LEN;\r | |
1631 | pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1;\r | |
1632 | }\r | |
1633 | else if (current_bit < SAMSUNG_COMPLETE_DATA_LEN) // send n'th bit\r | |
1634 | {\r | |
1635 | uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 !\r | |
1636 | \r | |
1637 | pulse_len = SAMSUNG_PULSE_LEN;\r | |
1638 | pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ?\r | |
1639 | (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1);\r | |
1640 | }\r | |
1641 | }\r | |
1642 | else\r | |
1643 | #endif\r | |
1644 | \r | |
1645 | #if IRSND_SUPPORT_NEC16_PROTOCOL == 1\r | |
1646 | if (irsnd_protocol == IRMP_NEC16_PROTOCOL)\r | |
1647 | {\r | |
1648 | if (current_bit < NEC16_ADDRESS_LEN) // send address bits\r | |
1649 | {\r | |
1650 | pulse_len = NEC_PULSE_LEN;\r | |
1651 | pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ?\r | |
1652 | (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1);\r | |
1653 | }\r | |
1654 | else if (current_bit == NEC16_ADDRESS_LEN) // send SYNC bit (8th bit)\r | |
1655 | {\r | |
1656 | pulse_len = NEC_PULSE_LEN;\r | |
1657 | pause_len = NEC_START_BIT_PAUSE_LEN - 1;\r | |
1658 | }\r | |
1659 | else if (current_bit < NEC16_COMPLETE_DATA_LEN + 1) // send n'th bit\r | |
1660 | {\r | |
1661 | uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 !\r | |
1662 | \r | |
1663 | pulse_len = NEC_PULSE_LEN;\r | |
1664 | pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ?\r | |
1665 | (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1);\r | |
1666 | }\r | |
1667 | }\r | |
1668 | else\r | |
1669 | #endif\r | |
1670 | \r | |
1671 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r | |
1672 | if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL)\r | |
1673 | {\r | |
1674 | if (current_bit == 0) // send 2nd start bit\r | |
1675 | {\r | |
1676 | pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN;\r | |
1677 | pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1;\r | |
1678 | }\r | |
1679 | else if (current_bit == 1) // send 3rd start bit\r | |
1680 | {\r | |
1681 | pulse_len = BANG_OLUFSEN_START_BIT3_PULSE_LEN;\r | |
1682 | pause_len = BANG_OLUFSEN_START_BIT3_PAUSE_LEN - 1;\r | |
1683 | }\r | |
1684 | else if (current_bit == 2) // send 4th start bit\r | |
1685 | {\r | |
1686 | pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN;\r | |
1687 | pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1;\r | |
1688 | }\r | |
1689 | else if (current_bit == 19) // send trailer bit\r | |
1690 | {\r | |
1691 | pulse_len = BANG_OLUFSEN_PULSE_LEN;\r | |
1692 | pause_len = BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN - 1;\r | |
1693 | }\r | |
1694 | else if (current_bit < BANG_OLUFSEN_COMPLETE_DATA_LEN) // send n'th bit\r | |
1695 | {\r | |
1696 | uint8_t cur_bit_value = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? 1 : 0;\r | |
1697 | pulse_len = BANG_OLUFSEN_PULSE_LEN;\r | |
1698 | \r | |
1699 | if (cur_bit_value == last_bit_value)\r | |
1700 | {\r | |
1701 | pause_len = BANG_OLUFSEN_R_PAUSE_LEN - 1;\r | |
1702 | }\r | |
1703 | else\r | |
1704 | {\r | |
1705 | pause_len = cur_bit_value ? (BANG_OLUFSEN_1_PAUSE_LEN - 1) : (BANG_OLUFSEN_0_PAUSE_LEN - 1);\r | |
1706 | last_bit_value = cur_bit_value;\r | |
1707 | }\r | |
1708 | }\r | |
1709 | }\r | |
1710 | else\r | |
1711 | #endif\r | |
1712 | if (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8))))\r | |
1713 | {\r | |
1714 | pulse_len = pulse_1_len;\r | |
1715 | pause_len = pause_1_len;\r | |
1716 | }\r | |
1717 | else\r | |
1718 | {\r | |
1719 | pulse_len = pulse_0_len;\r | |
1720 | pause_len = pause_0_len;\r | |
1721 | }\r | |
1722 | }\r | |
1723 | else if (has_stop_bit) // send stop bit\r | |
1724 | {\r | |
1725 | pulse_len = pulse_0_len;\r | |
1726 | \r | |
1727 | if (auto_repetition_counter < n_auto_repetitions)\r | |
1728 | {\r | |
1729 | pause_len = pause_0_len;\r | |
1730 | }\r | |
1731 | else\r | |
1732 | {\r | |
1733 | pause_len = 255; // last frame: pause of 255\r | |
1734 | }\r | |
1735 | }\r | |
1736 | }\r | |
1737 | \r | |
1738 | if (pulse_counter < pulse_len)\r | |
1739 | {\r | |
1740 | if (pulse_counter == 0)\r | |
1741 | {\r | |
1742 | irsnd_on ();\r | |
1743 | }\r | |
1744 | pulse_counter++;\r | |
1745 | }\r | |
1746 | else if (pause_counter < pause_len)\r | |
1747 | {\r | |
1748 | if (pause_counter == 0)\r | |
1749 | {\r | |
1750 | irsnd_off ();\r | |
1751 | }\r | |
1752 | pause_counter++;\r | |
1753 | }\r | |
1754 | else\r | |
1755 | {\r | |
1756 | current_bit++;\r | |
1757 | \r | |
1758 | if (current_bit >= complete_data_len + has_stop_bit)\r | |
1759 | {\r | |
1760 | current_bit = 0xFF;\r | |
1761 | auto_repetition_counter++;\r | |
1762 | \r | |
1763 | if (auto_repetition_counter == n_auto_repetitions)\r | |
1764 | {\r | |
1765 | irsnd_busy = FALSE;\r | |
1766 | auto_repetition_counter = 0;\r | |
1767 | }\r | |
1768 | new_frame = TRUE;\r | |
1769 | }\r | |
1770 | \r | |
1771 | pulse_counter = 0;\r | |
1772 | pause_counter = 0;\r | |
1773 | }\r | |
1774 | break;\r | |
1775 | }\r | |
1776 | #endif\r | |
1777 | \r | |
1778 | #if IRSND_SUPPORT_RC5_PROTOCOL == 1\r | |
1779 | case IRMP_RC5_PROTOCOL:\r | |
1780 | #endif\r | |
1781 | #if IRSND_SUPPORT_RC6_PROTOCOL == 1\r | |
1782 | case IRMP_RC6_PROTOCOL:\r | |
1783 | #endif\r | |
1784 | #if IRSND_SUPPORT_RC6A_PROTOCOL == 1\r | |
1785 | case IRMP_RC6A_PROTOCOL:\r | |
1786 | #endif\r | |
1787 | #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1\r | |
1788 | case IRMP_SIEMENS_PROTOCOL:\r | |
1789 | #endif\r | |
1790 | #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1\r | |
1791 | case IRMP_GRUNDIG_PROTOCOL:\r | |
1792 | #endif\r | |
1793 | #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r | |
1794 | case IRMP_NOKIA_PROTOCOL:\r | |
1795 | #endif\r | |
1796 | \r | |
1797 | #if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || \\r | |
1798 | IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r | |
1799 | {\r | |
1800 | if (pulse_counter == pulse_len && pause_counter == pause_len)\r | |
1801 | {\r | |
1802 | current_bit++;\r | |
1803 | \r | |
1804 | if (current_bit >= complete_data_len)\r | |
1805 | {\r | |
1806 | current_bit = 0xFF;\r | |
1807 | \r | |
1808 | #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r | |
1809 | if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL)\r | |
1810 | {\r | |
1811 | auto_repetition_counter++;\r | |
1812 | \r | |
1813 | if (repeat_counter > 0)\r | |
1814 | { // set 117 msec pause time\r | |
1815 | auto_repetition_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN;\r | |
1816 | }\r | |
1817 | \r | |
1818 | if (repeat_counter < n_repeat_frames) // tricky: repeat n info frames per auto repetition before sending last stop frame\r | |
1819 | {\r | |
1820 | n_auto_repetitions++; // increment number of auto repetitions\r | |
1821 | repeat_counter++;\r | |
1822 | }\r | |
1823 | else if (auto_repetition_counter == n_auto_repetitions)\r | |
1824 | {\r | |
1825 | irsnd_busy = FALSE;\r | |
1826 | auto_repetition_counter = 0;\r | |
1827 | }\r | |
1828 | }\r | |
1829 | else\r | |
1830 | #endif\r | |
1831 | {\r | |
1832 | irsnd_busy = FALSE;\r | |
1833 | }\r | |
1834 | \r | |
1835 | new_frame = TRUE;\r | |
1836 | irsnd_off ();\r | |
1837 | }\r | |
1838 | \r | |
1839 | pulse_counter = 0;\r | |
1840 | pause_counter = 0;\r | |
1841 | }\r | |
1842 | \r | |
1843 | if (! new_frame)\r | |
1844 | {\r | |
1845 | uint8_t first_pulse;\r | |
1846 | \r | |
1847 | #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r | |
1848 | if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL)\r | |
1849 | {\r | |
1850 | if (current_bit == 0xFF || // start bit of start-frame\r | |
1851 | (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL && current_bit == 15) || // start bit of info-frame (Grundig)\r | |
1852 | (irsnd_protocol == IRMP_NOKIA_PROTOCOL && (current_bit == 23 || current_bit == 47))) // start bit of info- or stop-frame (Nokia)\r | |
1853 | {\r | |
1854 | pulse_len = startbit_pulse_len;\r | |
1855 | pause_len = startbit_pause_len;\r | |
1856 | first_pulse = TRUE;\r | |
1857 | }\r | |
1858 | else // send n'th bit\r | |
1859 | {\r | |
1860 | pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
1861 | pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
1862 | first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE;\r | |
1863 | }\r | |
1864 | }\r | |
1865 | else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL ||\r | |
1866 | // irsnd_protocol == IRMP_SIEMENS_PROTOCOL)\r | |
1867 | #endif\r | |
1868 | {\r | |
1869 | if (current_bit == 0xFF) // 1 start bit\r | |
1870 | {\r | |
1871 | #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1\r | |
1872 | if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL)\r | |
1873 | {\r | |
1874 | pulse_len = startbit_pulse_len;\r | |
1875 | pause_len = startbit_pause_len;\r | |
1876 | }\r | |
1877 | #endif\r | |
1878 | first_pulse = TRUE;\r | |
1879 | }\r | |
1880 | else // send n'th bit\r | |
1881 | {\r | |
1882 | #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1\r | |
1883 | if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL)\r | |
1884 | {\r | |
1885 | pulse_len = RC6_BIT_LEN;\r | |
1886 | pause_len = RC6_BIT_LEN;\r | |
1887 | \r | |
1888 | if (irsnd_protocol == IRMP_RC6_PROTOCOL)\r | |
1889 | {\r | |
1890 | if (current_bit == 4) // toggle bit (double len)\r | |
1891 | {\r | |
1892 | pulse_len = 2 * RC6_BIT_LEN;\r | |
1893 | pause_len = 2 * RC6_BIT_LEN;\r | |
1894 | }\r | |
1895 | }\r | |
1896 | else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL)\r | |
1897 | {\r | |
1898 | if (current_bit == 4) // toggle bit (double len)\r | |
1899 | {\r | |
1900 | pulse_len = 2 * RC6_BIT_LEN + RC6_BIT_LEN; // hack!\r | |
1901 | pause_len = 2 * RC6_BIT_LEN;\r | |
1902 | }\r | |
1903 | else if (current_bit == 5) // toggle bit (double len)\r | |
1904 | {\r | |
1905 | pause_len = 2 * RC6_BIT_LEN;\r | |
1906 | }\r | |
1907 | }\r | |
1908 | }\r | |
1909 | #endif\r | |
1910 | first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE;\r | |
1911 | }\r | |
1912 | \r | |
1913 | if (irsnd_protocol == IRMP_RC5_PROTOCOL)\r | |
1914 | {\r | |
1915 | first_pulse = first_pulse ? FALSE : TRUE;\r | |
1916 | }\r | |
1917 | }\r | |
1918 | \r | |
1919 | if (first_pulse)\r | |
1920 | {\r | |
1921 | if (pulse_counter < pulse_len)\r | |
1922 | {\r | |
1923 | if (pulse_counter == 0)\r | |
1924 | {\r | |
1925 | irsnd_on ();\r | |
1926 | }\r | |
1927 | pulse_counter++;\r | |
1928 | }\r | |
1929 | else // if (pause_counter < pause_len)\r | |
1930 | {\r | |
1931 | if (pause_counter == 0)\r | |
1932 | {\r | |
1933 | irsnd_off ();\r | |
1934 | }\r | |
1935 | pause_counter++;\r | |
1936 | }\r | |
1937 | }\r | |
1938 | else\r | |
1939 | {\r | |
1940 | if (pause_counter < pause_len)\r | |
1941 | {\r | |
1942 | if (pause_counter == 0)\r | |
1943 | {\r | |
1944 | irsnd_off ();\r | |
1945 | }\r | |
1946 | pause_counter++;\r | |
1947 | }\r | |
1948 | else // if (pulse_counter < pulse_len)\r | |
1949 | {\r | |
1950 | if (pulse_counter == 0)\r | |
1951 | {\r | |
1952 | irsnd_on ();\r | |
1953 | }\r | |
1954 | pulse_counter++;\r | |
1955 | }\r | |
1956 | }\r | |
1957 | }\r | |
1958 | break;\r | |
1959 | }\r | |
1960 | #endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 ||\r | |
1961 | // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r | |
1962 | \r | |
1963 | default:\r | |
1964 | {\r | |
1965 | irsnd_busy = FALSE;\r | |
1966 | break;\r | |
1967 | }\r | |
1968 | }\r | |
1969 | }\r | |
1970 | \r | |
1971 | if (! irsnd_busy)\r | |
1972 | {\r | |
1973 | if (repeat_counter < n_repeat_frames)\r | |
1974 | {\r | |
1975 | #if IRSND_SUPPORT_FDC_PROTOCOL == 1\r | |
1976 | if (irsnd_protocol == IRMP_FDC_PROTOCOL)\r | |
1977 | {\r | |
1978 | irsnd_buffer[2] |= 0x0F;\r | |
1979 | }\r | |
1980 | #endif\r | |
1981 | repeat_counter++;\r | |
1982 | irsnd_busy = TRUE;\r | |
1983 | }\r | |
1984 | else\r | |
1985 | {\r | |
1986 | n_repeat_frames = 0;\r | |
1987 | repeat_counter = 0;\r | |
1988 | }\r | |
1989 | }\r | |
1990 | }\r | |
1991 | \r | |
1992 | #ifdef DEBUG\r | |
1993 | if (irsnd_is_on)\r | |
1994 | {\r | |
1995 | putchar ('0');\r | |
1996 | }\r | |
1997 | else\r | |
1998 | {\r | |
1999 | putchar ('1');\r | |
2000 | }\r | |
2001 | #endif\r | |
2002 | \r | |
2003 | return irsnd_busy;\r | |
2004 | }\r | |
2005 | \r | |
2006 | #ifdef DEBUG\r | |
2007 | \r | |
2008 | // main function - for unix/linux + windows only!\r | |
2009 | // AVR: see main.c!\r | |
2010 | // Compile it under linux with:\r | |
2011 | // cc irsnd.c -o irsnd\r | |
2012 | //\r | |
2013 | // usage: ./irsnd protocol hex-address hex-command >filename\r | |
2014 | \r | |
2015 | int\r | |
2016 | main (int argc, char ** argv)\r | |
2017 | {\r | |
2018 | int idx;\r | |
2019 | int protocol;\r | |
2020 | int address;\r | |
2021 | int command;\r | |
2022 | IRMP_DATA irmp_data;\r | |
2023 | \r | |
2024 | if (argc != 4 && argc != 5)\r | |
2025 | {\r | |
2026 | fprintf (stderr, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv[0]);\r | |
2027 | return 1;\r | |
2028 | }\r | |
2029 | \r | |
2030 | if (sscanf (argv[1], "%d", &protocol) == 1 &&\r | |
2031 | sscanf (argv[2], "%x", &address) == 1 &&\r | |
2032 | sscanf (argv[3], "%x", &command) == 1)\r | |
2033 | {\r | |
2034 | irmp_data.protocol = protocol;\r | |
2035 | irmp_data.address = address;\r | |
2036 | irmp_data.command = command;\r | |
2037 | \r | |
2038 | if (argc == 5)\r | |
2039 | {\r | |
2040 | irmp_data.flags = atoi (argv[4]);\r | |
2041 | }\r | |
2042 | else\r | |
2043 | {\r | |
2044 | irmp_data.flags = 0;\r | |
2045 | }\r | |
2046 | \r | |
2047 | irsnd_init ();\r | |
2048 | \r | |
2049 | (void) irsnd_send_data (&irmp_data, TRUE);\r | |
2050 | \r | |
2051 | while (irsnd_busy)\r | |
2052 | {\r | |
2053 | irsnd_ISR ();\r | |
2054 | }\r | |
2055 | \r | |
2056 | for (idx = 0; idx < 20; idx++)\r | |
2057 | {\r | |
2058 | irsnd_ISR ();\r | |
2059 | }\r | |
2060 | \r | |
2061 | putchar ('\n');\r | |
2062 | }\r | |
2063 | else\r | |
2064 | {\r | |
2065 | fprintf (stderr, "%s: wrong arguments\n", argv[0]);\r | |
2066 | return 1;\r | |
2067 | }\r | |
2068 | return 0;\r | |
2069 | }\r | |
2070 | \r | |
2071 | #endif // DEBUG\r |