]>
Commit | Line | Data |
---|---|---|
4225a882 | 1 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r |
2 | * @file irsnd.c\r | |
3 | *\r | |
f50e01e7 | 4 | * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de\r |
4225a882 | 5 | *\r |
7644ac04 | 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 | |
5481e9cd | 15 | *\r |
4225a882 | 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 | |
c7a47e89 | 37 | #include <stdlib.h>\r |
38 | #include <string.h>\r | |
39 | \r | |
4225a882 | 40 | #define F_CPU 8000000L\r |
31c1f035 | 41 | typedef unsigned char uint8_t;\r |
42 | typedef unsigned short uint16_t;\r | |
4225a882 | 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 | |
46dd89b7 | 62 | #include "irsndconfig.h"\r |
4225a882 | 63 | #include "irsnd.h"\r |
64 | \r | |
f50e01e7 | 65 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r |
1f54e86c | 66 | * ATtiny pin definition of OC0A / OC0B\r |
67 | * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B\r | |
f50e01e7 | 68 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r |
69 | */\r | |
1f54e86c | 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 | |
7644ac04 | 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 | |
1f54e86c | 89 | #if IRSND_OCx == IRSND_OC0A // OC0A\r |
f50e01e7 | 90 | #define IRSND_PORT PORTB // port B\r |
91 | #define IRSND_DDR DDRB // ddr B\r | |
1f54e86c | 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 | |
f50e01e7 | 110 | \r |
111 | #elif defined (__AVR_ATmega16__) \\r | |
112 | || defined (__AVR_ATmega32__) // ATmega16|32 uses OC2 = PD7\r | |
1f54e86c | 113 | #if IRSND_OCx == IRSND_OC2 // OC2\r |
f50e01e7 | 114 | #define IRSND_PORT PORTD // port D\r |
115 | #define IRSND_DDR DDRD // ddr D\r | |
116 | #define IRSND_BIT 7 // OC2\r | |
1f54e86c | 117 | #else\r |
118 | #error Wrong value for IRSND_OCx, choose IRSND_OC2 in irsndconfig.h\r | |
119 | #endif // IRSND_OCx\r | |
f50e01e7 | 120 | \r |
1f54e86c | 121 | #elif defined (__AVR_ATmega162__) // ATmega162 uses OC2 = PB1 or OC0 = PB0\r |
122 | #if IRSND_OCx == IRSND_OC2 // OC2\r | |
f50e01e7 | 123 | #define IRSND_PORT PORTB // port B\r |
124 | #define IRSND_DDR DDRB // ddr B\r | |
125 | #define IRSND_BIT 1 // OC2\r | |
1f54e86c | 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 | |
f50e01e7 | 133 | \r |
134 | #elif defined (__AVR_ATmega164__) \\r | |
135 | || defined (__AVR_ATmega324__) \\r | |
136 | || defined (__AVR_ATmega644__) \\r | |
137 | || defined (__AVR_ATmega644P__) \\r | |
1f54e86c | 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 | |
f50e01e7 | 140 | #define IRSND_PORT PORTD // port D\r |
141 | #define IRSND_DDR DDRD // ddr D\r | |
142 | #define IRSND_BIT 7 // OC2A\r | |
1f54e86c | 143 | #elif IRSND_OCx == IRSND_OC2B // OC2B\r |
f50e01e7 | 144 | #define IRSND_PORT PORTD // port D\r |
145 | #define IRSND_DDR DDRD // ddr D\r | |
146 | #define IRSND_BIT 6 // OC2B\r | |
1f54e86c | 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 | |
f50e01e7 | 155 | #else\r |
1f54e86c | 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 | |
f50e01e7 | 158 | \r |
159 | #elif defined (__AVR_ATmega48__) \\r | |
160 | || defined (__AVR_ATmega88__) \\r | |
7644ac04 | 161 | || defined (__AVR_ATmega88P__) \\r |
f50e01e7 | 162 | || defined (__AVR_ATmega168__) \\r |
1f54e86c | 163 | || defined (__AVR_ATmega168P__) \\r |
7644ac04 | 164 | || defined (__AVR_ATmega328P__) // ATmega48|88|168|168|328 uses OC2A = PB3 or OC2B = PD3 or OC0A = PD6 or OC0B = PD5\r |
1f54e86c | 165 | #if IRSND_OCx == IRSND_OC2A // OC2A\r |
f50e01e7 | 166 | #define IRSND_PORT PORTB // port B\r |
167 | #define IRSND_DDR DDRB // ddr B\r | |
168 | #define IRSND_BIT 3 // OC2A\r | |
1f54e86c | 169 | #elif IRSND_OCx == IRSND_OC2B // OC2B\r |
f50e01e7 | 170 | #define IRSND_PORT PORTD // port D\r |
171 | #define IRSND_DDR DDRD // ddr D\r | |
172 | #define IRSND_BIT 3 // OC2B\r | |
1f54e86c | 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 | |
f50e01e7 | 181 | #else\r |
1f54e86c | 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 | |
f50e01e7 | 184 | \r |
185 | #else\r | |
186 | #if !defined (unix) && !defined (WIN32)\r | |
1f54e86c | 187 | #error mikrocontroller not defined, please fill in definitions here.\r |
f50e01e7 | 188 | #endif // unix, WIN32\r |
189 | #endif // __AVR...\r | |
190 | \r | |
9405f84a | 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 | |
f50e01e7 | 197 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r |
198 | * IR timings\r | |
199 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
200 | */\r | |
4225a882 | 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 | |
a7054daf | 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 | |
4225a882 | 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 | |
a7054daf | 211 | #define NEC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME + 0.5)\r |
4225a882 | 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 | |
a7054daf | 215 | #define NEC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r |
4225a882 | 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 | |
a7054daf | 222 | #define SAMSUNG_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SAMSUNG_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r |
4225a882 | 223 | \r |
a7054daf | 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 | |
5b437ff6 | 226 | \r |
4225a882 | 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 | |
a7054daf | 232 | #define MATSUSHITA_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * MATSUSHITA_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r |
4225a882 | 233 | \r |
770a1a9d | 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 | |
4225a882 | 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 | |
a7054daf | 247 | #define RECS80_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r |
4225a882 | 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 | |
a7054daf | 251 | #define RC5_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC5_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r |
4225a882 | 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 | |
a7054daf | 257 | #define RC6_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC6_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r |
4225a882 | 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 | |
a7054daf | 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 | |
4225a882 | 264 | \r |
beda975f | 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 | |
4225a882 | 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 | |
a7054daf | 276 | #define RECS80EXT_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RECS80EXT_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r |
4225a882 | 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 | |
a7054daf | 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 | |
4225a882 | 286 | \r |
5481e9cd | 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 | |
a7054daf | 298 | #define BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BANG_OLUFSEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r |
5481e9cd | 299 | \r |
89e8cafb | 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 | |
a7054daf | 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 | |
89e8cafb | 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 |
a7054daf | 305 | \r |
02ccdb69 | 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 | |
5b437ff6 | 309 | \r |
4225a882 | 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 | |
5481e9cd | 315 | #define IRSND_FREQ_455_KHZ (uint8_t) ((F_CPU / 455000 / 2) - 1)\r |
4225a882 | 316 | \r |
48664931 | 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 | |
b5ea7869 | 323 | \r |
c7c9a4a1 | 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 | |
c7a47e89 | 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 | |
9405f84a | 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 | |
f50e01e7 | 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 | |
9405f84a | 354 | \r |
4225a882 | 355 | static volatile uint8_t irsnd_busy;\r |
356 | static volatile uint8_t irsnd_protocol;\r | |
d155e9ab | 357 | static volatile uint8_t irsnd_buffer[6];\r |
a7054daf | 358 | static volatile uint8_t irsnd_repeat;\r |
4225a882 | 359 | static volatile uint8_t irsnd_is_on = FALSE;\r |
360 | \r | |
f50e01e7 | 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 | |
4225a882 | 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 | |
1f54e86c | 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 | |
f50e01e7 | 379 | TCCR2A |= (1<<COM2A0)|(1<<WGM21); // toggle OC2A on compare match, clear Timer 2 at compare match OCR2A\r |
1f54e86c | 380 | #elif IRSND_OCx == IRSND_OC2B // use OC2B\r |
f50e01e7 | 381 | TCCR2A |= (1<<COM2B0)|(1<<WGM21); // toggle OC2B on compare match, clear Timer 2 at compare match OCR2A (yes: A, not B!)\r |
1f54e86c | 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 | |
4225a882 | 391 | #endif // DEBUG\r |
f50e01e7 | 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 | |
4225a882 | 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 | |
1f54e86c | 415 | #if IRSND_OCx == IRSND_OC2 // use OC2\r |
f50e01e7 | 416 | TCCR2 &= ~(1<<COM20); // normal port operation, OC2 disconnected.\r |
1f54e86c | 417 | #elif IRSND_OCx == IRSND_OC2A // use OC2A\r |
f50e01e7 | 418 | TCCR2A &= ~(1<<COM2A0); // normal port operation, OC2A disconnected.\r |
1f54e86c | 419 | #elif IRSND_OCx == IRSND_OC2B // use OC2B\r |
f50e01e7 | 420 | TCCR2A &= ~(1<<COM2B0); // normal port operation, OC2B disconnected.\r |
1f54e86c | 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 | |
f50e01e7 | 430 | IRSND_PORT &= ~(1<<IRSND_BIT); // set IRSND_BIT to low\r |
4225a882 | 431 | #endif // DEBUG\r |
f50e01e7 | 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 | |
4225a882 | 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 | |
1f54e86c | 453 | #if IRSND_OCx == IRSND_OC2\r |
f50e01e7 | 454 | OCR2 = freq; // use register OCR2 for OC2\r |
1f54e86c | 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 | |
f50e01e7 | 458 | OCR2A = freq; // use register OCR2A for OC2A and OC2B!\r |
1f54e86c | 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 | |
f50e01e7 | 467 | #endif\r |
4225a882 | 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 | |
1f54e86c | 483 | #if IRSND_OCx == IRSND_OC2 // use OC2\r |
4225a882 | 484 | TCCR2 = (1<<WGM21); // CTC mode\r |
485 | TCCR2 |= (1<<CS20); // 0x01, start Timer 2, no prescaling\r | |
1f54e86c | 486 | #elif IRSND_OCx == IRSND_OC2A || IRSND_OCx == IRSND_OC2B // use OC2A or OC2B\r |
4225a882 | 487 | TCCR2A = (1<<WGM21); // CTC mode\r |
488 | TCCR2B |= (1<<CS20); // 0x01, start Timer 2, no prescaling\r | |
1f54e86c | 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 | |
4225a882 | 498 | \r |
499 | irsnd_set_freq (IRSND_FREQ_36_KHZ); // default frequency\r | |
500 | #endif // DEBUG\r | |
501 | }\r | |
502 | \r | |
f50e01e7 | 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 | |
4225a882 | 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 | |
9547ee89 | 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 | |
4225a882 | 540 | uint8_t\r |
879b06c2 | 541 | irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait)\r |
4225a882 | 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 | |
9547ee89 | 551 | #endif\r |
779fbc81 | 552 | #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1\r |
9547ee89 | 553 | static uint8_t toggle_bit_rc6;\r |
beda975f | 554 | #endif\r |
555 | #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1\r | |
556 | static uint8_t toggle_bit_thomson;\r | |
4225a882 | 557 | #endif\r |
558 | uint16_t address;\r | |
559 | uint16_t command;\r | |
560 | \r | |
879b06c2 | 561 | if (do_wait)\r |
4225a882 | 562 | {\r |
879b06c2 | 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 | |
4225a882 | 571 | }\r |
572 | \r | |
573 | irsnd_protocol = irmp_data_p->protocol;\r | |
beda975f | 574 | irsnd_repeat = irmp_data_p->flags & IRSND_REPETITION_MASK;\r |
4225a882 | 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 | |
9547ee89 | 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 | |
4225a882 | 596 | \r |
9547ee89 | 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 | |
4225a882 | 608 | irsnd_busy = TRUE;\r |
609 | break;\r | |
610 | }\r | |
611 | #endif\r | |
612 | #if IRSND_SUPPORT_NEC_PROTOCOL == 1\r | |
46dd89b7 | 613 | case IRMP_APPLE_PROTOCOL:\r |
c7a47e89 | 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 | |
7644ac04 | 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 | |
c7a47e89 | 627 | irsnd_busy = TRUE;\r |
628 | break;\r | |
629 | }\r | |
630 | case IRMP_NEC_PROTOCOL:\r | |
4225a882 | 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 | |
4225a882 | 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 | |
7644ac04 | 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 | |
46dd89b7 | 648 | \r |
7644ac04 | 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 | |
4225a882 | 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 | |
4225a882 | 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 | |
4225a882 | 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 | |
4225a882 | 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 | |
770a1a9d | 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 | |
4225a882 | 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 | |
4225a882 | 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 | |
4225a882 | 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 | |
4225a882 | 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 | |
9547ee89 | 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 | |
4225a882 | 796 | #if IRSND_SUPPORT_DENON_PROTOCOL == 1\r |
797 | case IRMP_DENON_PROTOCOL:\r | |
798 | {\r | |
d155e9ab | 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 | |
4225a882 | 803 | irsnd_busy = TRUE;\r |
804 | break;\r | |
805 | }\r | |
806 | #endif\r | |
beda975f | 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 | |
4225a882 | 818 | #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1\r |
819 | case IRMP_NUBERT_PROTOCOL:\r | |
820 | {\r | |
4225a882 | 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 | |
5481e9cd | 826 | #endif\r |
827 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r | |
828 | case IRMP_BANG_OLUFSEN_PROTOCOL:\r | |
829 | {\r | |
5481e9cd | 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 | |
4225a882 | 836 | #endif\r |
5b437ff6 | 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 | |
d155e9ab | 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 | |
5b437ff6 | 863 | \r |
864 | irsnd_busy = TRUE;\r | |
865 | break;\r | |
866 | }\r | |
867 | #endif\r | |
a7054daf | 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 | |
9405f84a | 873 | irsnd_buffer[2] = (irmp_data_p->command << 3) | ((~irmp_data_p->command & 0x01) << 2); // CCCCCc\r |
874 | \r | |
a7054daf | 875 | irsnd_busy = TRUE;\r |
876 | break;\r | |
877 | }\r | |
b5ea7869 | 878 | #endif\r |
48664931 | 879 | #if IRSND_SUPPORT_FDC_PROTOCOL == 1\r |
880 | case IRMP_FDC_PROTOCOL:\r | |
b5ea7869 | 881 | {\r |
48664931 | 882 | address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN);\r |
883 | command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN);\r | |
b5ea7869 | 884 | \r |
c7c9a4a1 | 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 | |
b5ea7869 | 903 | irsnd_busy = TRUE;\r |
904 | break;\r | |
905 | }\r | |
a7054daf | 906 | #endif\r |
c7a47e89 | 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 | |
9405f84a | 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 | |
f50e01e7 | 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 | |
9405f84a | 940 | #endif\r |
4225a882 | 941 | default:\r |
942 | {\r | |
943 | break;\r | |
944 | }\r | |
945 | }\r | |
946 | \r | |
947 | return irsnd_busy;\r | |
948 | }\r | |
949 | \r | |
beda975f | 950 | void\r |
951 | irsnd_stop (void)\r | |
952 | {\r | |
acf7fb44 | 953 | irsnd_repeat = 0;\r |
beda975f | 954 | }\r |
955 | \r | |
4225a882 | 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 | |
9405f84a | 966 | static IRSND_PAUSE_LEN pause_counter;\r |
4225a882 | 967 | static uint8_t startbit_pulse_len;\r |
9405f84a | 968 | static IRSND_PAUSE_LEN startbit_pause_len;\r |
4225a882 | 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 | |
acf7fb44 | 976 | static uint8_t n_repeat_frames; // number of repetition frames\r |
a7054daf | 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 | |
a7054daf | 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 | |
5481e9cd | 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 | |
9405f84a | 988 | static IRSND_PAUSE_LEN pause_len = 0xFF;\r |
4225a882 | 989 | \r |
990 | if (irsnd_busy)\r | |
991 | {\r | |
992 | if (current_bit == 0xFF && new_frame) // start of transmission...\r | |
993 | {\r | |
a7054daf | 994 | if (auto_repetition_counter > 0)\r |
4225a882 | 995 | {\r |
a7054daf | 996 | auto_repetition_pause_counter++;\r |
4225a882 | 997 | \r |
a7054daf | 998 | if (auto_repetition_pause_counter >= auto_repetition_pause_len)\r |
4225a882 | 999 | {\r |
a7054daf | 1000 | auto_repetition_pause_counter = 0;\r |
4225a882 | 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 | |
a7054daf | 1007 | else if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig info frame\r |
5b437ff6 | 1008 | {\r |
1009 | current_bit = 15;\r | |
1010 | complete_data_len = 16 + GRUNDIG_COMPLETE_DATA_LEN;\r | |
1011 | }\r | |
a7054daf | 1012 | else if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia info frame\r |
d155e9ab | 1013 | {\r |
a7054daf | 1014 | if (auto_repetition_counter + 1 < n_auto_repetitions)\r |
d155e9ab | 1015 | {\r |
1016 | current_bit = 23;\r | |
1017 | complete_data_len = 24 + NOKIA_COMPLETE_DATA_LEN;\r | |
1018 | }\r | |
a7054daf | 1019 | else // nokia stop frame\r |
d155e9ab | 1020 | {\r |
1021 | current_bit = 0xFF;\r | |
1022 | complete_data_len = NOKIA_COMPLETE_DATA_LEN;\r | |
1023 | }\r | |
1024 | }\r | |
4225a882 | 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 | |
beda975f | 1041 | #if 0\r |
a7054daf | 1042 | else if (repeat_counter > 0 && packet_repeat_pause_counter < repeat_frame_pause_len)\r |
beda975f | 1043 | #else\r |
1044 | else if (packet_repeat_pause_counter < repeat_frame_pause_len)\r | |
1045 | #endif\r | |
a7054daf | 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 | |
4225a882 | 1061 | else\r |
1062 | {\r | |
a7054daf | 1063 | n_repeat_frames = irsnd_repeat;\r |
beda975f | 1064 | \r |
1065 | if (n_repeat_frames == IRSND_ENDLESS_REPETITION)\r | |
1066 | {\r | |
1067 | n_repeat_frames = 255;\r | |
1068 | }\r | |
1069 | \r | |
a7054daf | 1070 | packet_repeat_pause_counter = 0;\r |
1071 | pulse_counter = 0;\r | |
1072 | pause_counter = 0;\r | |
5481e9cd | 1073 | \r |
4225a882 | 1074 | switch (irsnd_protocol)\r |
1075 | {\r | |
1076 | #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r | |
1077 | case IRMP_SIRCS_PROTOCOL:\r | |
1078 | {\r | |
a7054daf | 1079 | startbit_pulse_len = SIRCS_START_BIT_PULSE_LEN;\r |
53c11f07 | 1080 | startbit_pause_len = SIRCS_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1081 | pulse_1_len = SIRCS_1_PULSE_LEN;\r |
53c11f07 | 1082 | pause_1_len = SIRCS_PAUSE_LEN - 1;\r |
a7054daf | 1083 | pulse_0_len = SIRCS_0_PULSE_LEN;\r |
53c11f07 | 1084 | pause_0_len = SIRCS_PAUSE_LEN - 1;\r |
a7054daf | 1085 | has_stop_bit = SIRCS_STOP_BIT;\r |
9547ee89 | 1086 | complete_data_len = SIRCS_MINIMUM_DATA_LEN + sircs_additional_bitlen;\r |
a7054daf | 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 | |
4225a882 | 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 | |
a7054daf | 1097 | startbit_pulse_len = NEC_START_BIT_PULSE_LEN;\r |
1098 | \r | |
1099 | if (repeat_counter > 0)\r | |
1100 | {\r | |
53c11f07 | 1101 | startbit_pause_len = NEC_REPEAT_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1102 | complete_data_len = 0;\r |
1103 | }\r | |
1104 | else\r | |
1105 | {\r | |
53c11f07 | 1106 | startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1107 | complete_data_len = NEC_COMPLETE_DATA_LEN;\r |
1108 | }\r | |
1109 | \r | |
1110 | pulse_1_len = NEC_PULSE_LEN;\r | |
53c11f07 | 1111 | pause_1_len = NEC_1_PAUSE_LEN - 1;\r |
a7054daf | 1112 | pulse_0_len = NEC_PULSE_LEN;\r |
53c11f07 | 1113 | pause_0_len = NEC_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
4225a882 | 1118 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r |
1119 | break;\r | |
1120 | }\r | |
1121 | #endif\r | |
7644ac04 | 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 | |
4225a882 | 1158 | #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1\r |
1159 | case IRMP_SAMSUNG_PROTOCOL:\r | |
1160 | {\r | |
a7054daf | 1161 | startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN;\r |
53c11f07 | 1162 | startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1163 | pulse_1_len = SAMSUNG_PULSE_LEN;\r |
53c11f07 | 1164 | pause_1_len = SAMSUNG_1_PAUSE_LEN - 1;\r |
a7054daf | 1165 | pulse_0_len = SAMSUNG_PULSE_LEN;\r |
53c11f07 | 1166 | pause_0_len = SAMSUNG_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
4225a882 | 1172 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r |
1173 | break;\r | |
1174 | }\r | |
1175 | \r | |
1176 | case IRMP_SAMSUNG32_PROTOCOL:\r | |
1177 | {\r | |
a7054daf | 1178 | startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN;\r |
53c11f07 | 1179 | startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1180 | pulse_1_len = SAMSUNG_PULSE_LEN;\r |
53c11f07 | 1181 | pause_1_len = SAMSUNG_1_PAUSE_LEN - 1;\r |
a7054daf | 1182 | pulse_0_len = SAMSUNG_PULSE_LEN;\r |
53c11f07 | 1183 | pause_0_len = SAMSUNG_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
4225a882 | 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 | |
a7054daf | 1196 | startbit_pulse_len = MATSUSHITA_START_BIT_PULSE_LEN;\r |
53c11f07 | 1197 | startbit_pause_len = MATSUSHITA_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1198 | pulse_1_len = MATSUSHITA_PULSE_LEN;\r |
53c11f07 | 1199 | pause_1_len = MATSUSHITA_1_PAUSE_LEN - 1;\r |
a7054daf | 1200 | pulse_0_len = MATSUSHITA_PULSE_LEN;\r |
53c11f07 | 1201 | pause_0_len = MATSUSHITA_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
4225a882 | 1207 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r |
1208 | break;\r | |
1209 | }\r | |
1210 | #endif\r | |
770a1a9d | 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 | |
53c11f07 | 1215 | startbit_pause_len = KASEIKYO_START_BIT_PAUSE_LEN - 1;\r |
770a1a9d | 1216 | pulse_1_len = KASEIKYO_PULSE_LEN;\r |
53c11f07 | 1217 | pause_1_len = KASEIKYO_1_PAUSE_LEN - 1;\r |
770a1a9d | 1218 | pulse_0_len = KASEIKYO_PULSE_LEN;\r |
53c11f07 | 1219 | pause_0_len = KASEIKYO_0_PAUSE_LEN - 1;\r |
770a1a9d | 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 | |
4225a882 | 1229 | #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r |
1230 | case IRMP_RECS80_PROTOCOL:\r | |
1231 | {\r | |
a7054daf | 1232 | startbit_pulse_len = RECS80_START_BIT_PULSE_LEN;\r |
53c11f07 | 1233 | startbit_pause_len = RECS80_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1234 | pulse_1_len = RECS80_PULSE_LEN;\r |
53c11f07 | 1235 | pause_1_len = RECS80_1_PAUSE_LEN - 1;\r |
a7054daf | 1236 | pulse_0_len = RECS80_PULSE_LEN;\r |
53c11f07 | 1237 | pause_0_len = RECS80_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
4225a882 | 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 | |
a7054daf | 1250 | startbit_pulse_len = RECS80EXT_START_BIT_PULSE_LEN;\r |
53c11f07 | 1251 | startbit_pause_len = RECS80EXT_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1252 | pulse_1_len = RECS80EXT_PULSE_LEN;\r |
53c11f07 | 1253 | pause_1_len = RECS80EXT_1_PAUSE_LEN - 1;\r |
a7054daf | 1254 | pulse_0_len = RECS80EXT_PULSE_LEN;\r |
53c11f07 | 1255 | pause_0_len = RECS80EXT_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
4225a882 | 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 | |
a7054daf | 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 | |
4225a882 | 1277 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r |
1278 | break;\r | |
1279 | }\r | |
1280 | #endif\r | |
9547ee89 | 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 | |
53c11f07 | 1285 | startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1;\r |
9547ee89 | 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 | |
53c11f07 | 1301 | startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1;\r |
9547ee89 | 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 | |
4225a882 | 1313 | #if IRSND_SUPPORT_DENON_PROTOCOL == 1\r |
1314 | case IRMP_DENON_PROTOCOL:\r | |
1315 | {\r | |
a7054daf | 1316 | startbit_pulse_len = 0x00;\r |
1317 | startbit_pause_len = 0x00;\r | |
1318 | pulse_1_len = DENON_PULSE_LEN;\r | |
53c11f07 | 1319 | pause_1_len = DENON_1_PAUSE_LEN - 1;\r |
a7054daf | 1320 | pulse_0_len = DENON_PULSE_LEN;\r |
53c11f07 | 1321 | pause_0_len = DENON_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
779fbc81 | 1327 | irsnd_set_freq (IRSND_FREQ_36_KHZ); // in theory 32kHz, in practice 36kHz is better\r |
4225a882 | 1328 | break;\r |
1329 | }\r | |
1330 | #endif\r | |
beda975f | 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 | |
4225a882 | 1349 | #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1\r |
1350 | case IRMP_NUBERT_PROTOCOL:\r | |
1351 | {\r | |
a7054daf | 1352 | startbit_pulse_len = NUBERT_START_BIT_PULSE_LEN;\r |
53c11f07 | 1353 | startbit_pause_len = NUBERT_START_BIT_PAUSE_LEN - 1;\r |
a7054daf | 1354 | pulse_1_len = NUBERT_1_PULSE_LEN;\r |
53c11f07 | 1355 | pause_1_len = NUBERT_1_PAUSE_LEN - 1;\r |
a7054daf | 1356 | pulse_0_len = NUBERT_0_PULSE_LEN;\r |
53c11f07 | 1357 | pause_0_len = NUBERT_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
4225a882 | 1363 | irsnd_set_freq (IRSND_FREQ_36_KHZ);\r |
1364 | break;\r | |
1365 | }\r | |
5481e9cd | 1366 | #endif\r |
1367 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r | |
1368 | case IRMP_BANG_OLUFSEN_PROTOCOL:\r | |
1369 | {\r | |
a7054daf | 1370 | startbit_pulse_len = BANG_OLUFSEN_START_BIT1_PULSE_LEN;\r |
53c11f07 | 1371 | startbit_pause_len = BANG_OLUFSEN_START_BIT1_PAUSE_LEN - 1;\r |
a7054daf | 1372 | pulse_1_len = BANG_OLUFSEN_PULSE_LEN;\r |
53c11f07 | 1373 | pause_1_len = BANG_OLUFSEN_1_PAUSE_LEN - 1;\r |
a7054daf | 1374 | pulse_0_len = BANG_OLUFSEN_PULSE_LEN;\r |
53c11f07 | 1375 | pause_0_len = BANG_OLUFSEN_0_PAUSE_LEN - 1;\r |
a7054daf | 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 | |
5481e9cd | 1382 | irsnd_set_freq (IRSND_FREQ_455_KHZ);\r |
1383 | break;\r | |
1384 | }\r | |
5b437ff6 | 1385 | #endif\r |
1386 | #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1\r | |
1387 | case IRMP_GRUNDIG_PROTOCOL:\r | |
1388 | {\r | |
89e8cafb | 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 | |
a7054daf | 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 | |
89e8cafb | 1397 | repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause\r |
d155e9ab | 1398 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r |
a7054daf | 1399 | \r |
d155e9ab | 1400 | break;\r |
1401 | }\r | |
1402 | #endif\r | |
1403 | #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r | |
1404 | case IRMP_NOKIA_PROTOCOL:\r | |
1405 | {\r | |
89e8cafb | 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 | |
a7054daf | 1411 | complete_data_len = NOKIA_COMPLETE_DATA_LEN;\r |
f50e01e7 | 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 | |
d155e9ab | 1415 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r |
5b437ff6 | 1416 | break;\r |
1417 | }\r | |
a7054daf | 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 | |
02ccdb69 | 1426 | has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT;\r |
a7054daf | 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 | |
b5ea7869 | 1434 | #endif\r |
48664931 | 1435 | #if IRSND_SUPPORT_FDC_PROTOCOL == 1\r |
1436 | case IRMP_FDC_PROTOCOL:\r | |
b5ea7869 | 1437 | {\r |
48664931 | 1438 | startbit_pulse_len = FDC_START_BIT_PULSE_LEN;\r |
53c11f07 | 1439 | startbit_pause_len = FDC_START_BIT_PAUSE_LEN - 1;\r |
48664931 | 1440 | complete_data_len = FDC_COMPLETE_DATA_LEN;\r |
1441 | pulse_1_len = FDC_PULSE_LEN;\r | |
53c11f07 | 1442 | pause_1_len = FDC_1_PAUSE_LEN - 1;\r |
48664931 | 1443 | pulse_0_len = FDC_PULSE_LEN;\r |
53c11f07 | 1444 | pause_0_len = FDC_0_PAUSE_LEN - 1;\r |
48664931 | 1445 | has_stop_bit = FDC_STOP_BIT;\r |
b5ea7869 | 1446 | n_auto_repetitions = 1; // 1 frame\r |
1447 | auto_repetition_pause_len = 0;\r | |
48664931 | 1448 | repeat_frame_pause_len = FDC_FRAME_REPEAT_PAUSE_LEN;\r |
b5ea7869 | 1449 | irsnd_set_freq (IRSND_FREQ_38_KHZ);\r |
1450 | break;\r | |
1451 | }\r | |
c7c9a4a1 | 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 | |
53c11f07 | 1457 | startbit_pause_len = RCCAR_START_BIT_PAUSE_LEN - 1;\r |
c7c9a4a1 | 1458 | complete_data_len = RCCAR_COMPLETE_DATA_LEN;\r |
1459 | pulse_1_len = RCCAR_PULSE_LEN;\r | |
53c11f07 | 1460 | pause_1_len = RCCAR_1_PAUSE_LEN - 1;\r |
c7c9a4a1 | 1461 | pulse_0_len = RCCAR_PULSE_LEN;\r |
53c11f07 | 1462 | pause_0_len = RCCAR_0_PAUSE_LEN - 1;\r |
c7c9a4a1 | 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 | |
4225a882 | 1470 | #endif\r |
c7a47e89 | 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 | |
53c11f07 | 1480 | startbit_pause_len = JVC_START_BIT_PAUSE_LEN - 1;\r |
c7a47e89 | 1481 | complete_data_len = JVC_COMPLETE_DATA_LEN;\r |
1482 | pulse_1_len = JVC_PULSE_LEN;\r | |
53c11f07 | 1483 | pause_1_len = JVC_1_PAUSE_LEN - 1;\r |
c7a47e89 | 1484 | pulse_0_len = JVC_PULSE_LEN;\r |
53c11f07 | 1485 | pause_0_len = JVC_0_PAUSE_LEN - 1;\r |
c7a47e89 | 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 | |
9405f84a | 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 | |
53c11f07 | 1499 | startbit_pause_len = 271 - 1; // NIKON_START_BIT_PAUSE_LEN;\r |
9405f84a | 1500 | complete_data_len = NIKON_COMPLETE_DATA_LEN;\r |
1501 | pulse_1_len = NIKON_PULSE_LEN;\r | |
53c11f07 | 1502 | pause_1_len = NIKON_1_PAUSE_LEN - 1;\r |
9405f84a | 1503 | pulse_0_len = NIKON_PULSE_LEN;\r |
53c11f07 | 1504 | pause_0_len = NIKON_0_PAUSE_LEN - 1;\r |
9405f84a | 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 | |
f50e01e7 | 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 | |
4225a882 | 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 | |
a7054daf | 1544 | \r |
4225a882 | 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 | |
7644ac04 | 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 | |
4225a882 | 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 | |
770a1a9d | 1566 | #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1\r |
1567 | case IRMP_KASEIKYO_PROTOCOL:\r | |
1568 | #endif\r | |
4225a882 | 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 | |
beda975f | 1578 | #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1\r |
1579 | case IRMP_THOMSON_PROTOCOL:\r | |
1580 | #endif\r | |
4225a882 | 1581 | #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1\r |
1582 | case IRMP_NUBERT_PROTOCOL:\r | |
5481e9cd | 1583 | #endif\r |
1584 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r | |
1585 | case IRMP_BANG_OLUFSEN_PROTOCOL:\r | |
4225a882 | 1586 | #endif\r |
c7c9a4a1 | 1587 | #if IRSND_SUPPORT_FDC_PROTOCOL == 1\r |
48664931 | 1588 | case IRMP_FDC_PROTOCOL:\r |
b5ea7869 | 1589 | #endif\r |
c7c9a4a1 | 1590 | #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1\r |
1591 | case IRMP_RCCAR_PROTOCOL:\r | |
1592 | #endif\r | |
c7a47e89 | 1593 | #if IRSND_SUPPORT_JVC_PROTOCOL == 1\r |
1594 | case IRMP_JVC_PROTOCOL:\r | |
1595 | #endif\r | |
9405f84a | 1596 | #if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r |
1597 | case IRMP_NIKON_PROTOCOL:\r | |
1598 | #endif\r | |
f50e01e7 | 1599 | #if IRSND_SUPPORT_LEGO_PROTOCOL == 1\r |
1600 | case IRMP_LEGO_PROTOCOL:\r | |
1601 | #endif\r | |
a7054daf | 1602 | \r |
1603 | \r | |
7644ac04 | 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 | |
770a1a9d | 1606 | IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \\r |
c7a47e89 | 1607 | IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || \\r |
beda975f | 1608 | IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1 \r |
4225a882 | 1609 | {\r |
5481e9cd | 1610 | if (pulse_counter == 0)\r |
4225a882 | 1611 | {\r |
5481e9cd | 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 | |
4225a882 | 1618 | {\r |
5481e9cd | 1619 | #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1\r |
1620 | if (irsnd_protocol == IRMP_SAMSUNG_PROTOCOL)\r | |
4225a882 | 1621 | {\r |
5481e9cd | 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 | |
53c11f07 | 1626 | (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1);\r |
5481e9cd | 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 | |
53c11f07 | 1631 | pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1;\r |
5481e9cd | 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 | |
53c11f07 | 1639 | (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1);\r |
5481e9cd | 1640 | }\r |
4225a882 | 1641 | }\r |
5481e9cd | 1642 | else\r |
1643 | #endif\r | |
1644 | \r | |
7644ac04 | 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 | |
5481e9cd | 1671 | #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r |
1672 | if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL)\r | |
4225a882 | 1673 | {\r |
5481e9cd | 1674 | if (current_bit == 0) // send 2nd start bit\r |
1675 | {\r | |
1676 | pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN;\r | |
53c11f07 | 1677 | pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1;\r |
5481e9cd | 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 | |
53c11f07 | 1682 | pause_len = BANG_OLUFSEN_START_BIT3_PAUSE_LEN - 1;\r |
5481e9cd | 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 | |
53c11f07 | 1687 | pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1;\r |
5481e9cd | 1688 | }\r |
1689 | else if (current_bit == 19) // send trailer bit\r | |
1690 | {\r | |
1691 | pulse_len = BANG_OLUFSEN_PULSE_LEN;\r | |
53c11f07 | 1692 | pause_len = BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN - 1;\r |
5481e9cd | 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 | |
53c11f07 | 1701 | pause_len = BANG_OLUFSEN_R_PAUSE_LEN - 1;\r |
5481e9cd | 1702 | }\r |
1703 | else\r | |
1704 | {\r | |
53c11f07 | 1705 | pause_len = cur_bit_value ? (BANG_OLUFSEN_1_PAUSE_LEN - 1) : (BANG_OLUFSEN_0_PAUSE_LEN - 1);\r |
5481e9cd | 1706 | last_bit_value = cur_bit_value;\r |
1707 | }\r | |
1708 | }\r | |
4225a882 | 1709 | }\r |
5481e9cd | 1710 | else\r |
1711 | #endif\r | |
1712 | if (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8))))\r | |
4225a882 | 1713 | {\r |
5481e9cd | 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 | |
4225a882 | 1721 | }\r |
1722 | }\r | |
5481e9cd | 1723 | else if (has_stop_bit) // send stop bit\r |
4225a882 | 1724 | {\r |
1725 | pulse_len = pulse_0_len;\r | |
4225a882 | 1726 | \r |
a7054daf | 1727 | if (auto_repetition_counter < n_auto_repetitions)\r |
5481e9cd | 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 | |
4225a882 | 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 | |
a7054daf | 1761 | auto_repetition_counter++;\r |
4225a882 | 1762 | \r |
a7054daf | 1763 | if (auto_repetition_counter == n_auto_repetitions)\r |
4225a882 | 1764 | {\r |
1765 | irsnd_busy = FALSE;\r | |
a7054daf | 1766 | auto_repetition_counter = 0;\r |
4225a882 | 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 | |
a7054daf | 1776 | #endif\r |
1777 | \r | |
4225a882 | 1778 | #if IRSND_SUPPORT_RC5_PROTOCOL == 1\r |
1779 | case IRMP_RC5_PROTOCOL:\r | |
a7054daf | 1780 | #endif\r |
9547ee89 | 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 | |
a7054daf | 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 | |
4225a882 | 1796 | \r |
9547ee89 | 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 | |
a7054daf | 1799 | {\r |
1800 | if (pulse_counter == pulse_len && pause_counter == pause_len)\r | |
4225a882 | 1801 | {\r |
a7054daf | 1802 | current_bit++;\r |
4225a882 | 1803 | \r |
a7054daf | 1804 | if (current_bit >= complete_data_len)\r |
4225a882 | 1805 | {\r |
a7054daf | 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 | |
4225a882 | 1810 | {\r |
a7054daf | 1811 | auto_repetition_counter++;\r |
1812 | \r | |
1813 | if (repeat_counter > 0)\r | |
1814 | { // set 117 msec pause time\r | |
89e8cafb | 1815 | auto_repetition_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN;\r |
a7054daf | 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 | |
4225a882 | 1828 | }\r |
a7054daf | 1829 | else\r |
1830 | #endif\r | |
4225a882 | 1831 | {\r |
a7054daf | 1832 | irsnd_busy = FALSE;\r |
4225a882 | 1833 | }\r |
4225a882 | 1834 | \r |
4225a882 | 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 | |
5b437ff6 | 1842 | \r |
a7054daf | 1843 | if (! new_frame)\r |
5b437ff6 | 1844 | {\r |
a7054daf | 1845 | uint8_t first_pulse;\r |
5b437ff6 | 1846 | \r |
a7054daf | 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 | |
5b437ff6 | 1849 | {\r |
a7054daf | 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 | |
5b437ff6 | 1853 | {\r |
a7054daf | 1854 | pulse_len = startbit_pulse_len;\r |
1855 | pause_len = startbit_pause_len;\r | |
1856 | first_pulse = TRUE;\r | |
5b437ff6 | 1857 | }\r |
a7054daf | 1858 | else // send n'th bit\r |
5b437ff6 | 1859 | {\r |
89e8cafb | 1860 | pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r |
1861 | pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r | |
a7054daf | 1862 | first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE;\r |
5b437ff6 | 1863 | }\r |
5b437ff6 | 1864 | }\r |
9547ee89 | 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 | |
a7054daf | 1867 | #endif\r |
5b437ff6 | 1868 | {\r |
a7054daf | 1869 | if (current_bit == 0xFF) // 1 start bit\r |
1870 | {\r | |
9547ee89 | 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 | |
a7054daf | 1878 | first_pulse = TRUE;\r |
1879 | }\r | |
1880 | else // send n'th bit\r | |
1881 | {\r | |
9547ee89 | 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 | |
a7054daf | 1910 | first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE;\r |
1911 | }\r | |
5b437ff6 | 1912 | \r |
a7054daf | 1913 | if (irsnd_protocol == IRMP_RC5_PROTOCOL)\r |
1914 | {\r | |
1915 | first_pulse = first_pulse ? FALSE : TRUE;\r | |
1916 | }\r | |
1917 | }\r | |
5b437ff6 | 1918 | \r |
1919 | if (first_pulse)\r | |
1920 | {\r | |
a7054daf | 1921 | if (pulse_counter < pulse_len)\r |
5b437ff6 | 1922 | {\r |
1923 | if (pulse_counter == 0)\r | |
1924 | {\r | |
1925 | irsnd_on ();\r | |
1926 | }\r | |
1927 | pulse_counter++;\r | |
1928 | }\r | |
a7054daf | 1929 | else // if (pause_counter < pause_len)\r |
5b437ff6 | 1930 | {\r |
1931 | if (pause_counter == 0)\r | |
1932 | {\r | |
1933 | irsnd_off ();\r | |
1934 | }\r | |
1935 | pause_counter++;\r | |
1936 | }\r | |
5b437ff6 | 1937 | }\r |
1938 | else\r | |
1939 | {\r | |
a7054daf | 1940 | if (pause_counter < pause_len)\r |
5b437ff6 | 1941 | {\r |
1942 | if (pause_counter == 0)\r | |
1943 | {\r | |
1944 | irsnd_off ();\r | |
1945 | }\r | |
1946 | pause_counter++;\r | |
1947 | }\r | |
a7054daf | 1948 | else // if (pulse_counter < pulse_len)\r |
5b437ff6 | 1949 | {\r |
1950 | if (pulse_counter == 0)\r | |
1951 | {\r | |
1952 | irsnd_on ();\r | |
1953 | }\r | |
1954 | pulse_counter++;\r | |
1955 | }\r | |
5b437ff6 | 1956 | }\r |
1957 | }\r | |
1958 | break;\r | |
1959 | }\r | |
9547ee89 | 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 | |
5b437ff6 | 1962 | \r |
4225a882 | 1963 | default:\r |
1964 | {\r | |
1965 | irsnd_busy = FALSE;\r | |
1966 | break;\r | |
1967 | }\r | |
1968 | }\r | |
1969 | }\r | |
a7054daf | 1970 | \r |
1971 | if (! irsnd_busy)\r | |
1972 | {\r | |
1973 | if (repeat_counter < n_repeat_frames)\r | |
1974 | {\r | |
c7c9a4a1 | 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 | |
a7054daf | 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 | |
4225a882 | 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 | |
4225a882 | 2019 | int protocol;\r |
2020 | int address;\r | |
2021 | int command;\r | |
4225a882 | 2022 | IRMP_DATA irmp_data;\r |
2023 | \r | |
a7054daf | 2024 | if (argc != 4 && argc != 5)\r |
4225a882 | 2025 | {\r |
a7054daf | 2026 | fprintf (stderr, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv[0]);\r |
4225a882 | 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 | |
a7054daf | 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 | |
4225a882 | 2047 | irsnd_init ();\r |
2048 | \r | |
879b06c2 | 2049 | (void) irsnd_send_data (&irmp_data, TRUE);\r |
4225a882 | 2050 | \r |
a7054daf | 2051 | while (irsnd_busy)\r |
2052 | {\r | |
2053 | irsnd_ISR ();\r | |
2054 | }\r | |
beda975f | 2055 | \r |
a7054daf | 2056 | for (idx = 0; idx < 20; idx++)\r |
2057 | {\r | |
2058 | irsnd_ISR ();\r | |
4225a882 | 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 |