Rev 733 | Rev 814 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 733 | Rev 734 | ||
|---|---|---|---|
| Line 134... | Line 134... | ||
| 134 | * @return |
134 | * @return |
| 135 | * IR_OK if data expanded successfully, one of several errormessages if not |
135 | * IR_OK if data expanded successfully, one of several errormessages if not |
| 136 | */ |
136 | */ |
| 137 | int8_t expandSIRC(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
137 | int8_t expandSIRC(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
| 138 | //TODO: Implement this function. |
138 | //TODO: Implement this function. |
| - | 139 | buf[0] = IR_SIRC_ST_BIT; |
|
| - | 140 | buf[1] = IR_SIRC_LOW;//start pulse finished |
|
| - | 141 | ||
| - | 142 | ||
| - | 143 | ||
| 139 | return IR_NOT_CORRECT_DATA; |
144 | return IR_NOT_CORRECT_DATA; |
| 140 | } |
145 | } |
| 141 | 146 | ||
| 142 | 147 | ||
| 143 | #if (IR_PROTOCOLS_USE_RC5) |
148 | #if (IR_PROTOCOLS_USE_RC5) |
| 144 | /** |
149 | /** |
| 145 | * Test data on RC5 protocol |
150 | * Test data on RC5 protocol |
| 146 | * http://www.sbprojects.com/knowledge/ir/rc5.htm |
151 | * http://www.sbprojects.com/knowledge/ir/rc5.htm |
| 147 | * |
152 | * |
| 148 | * @param buf |
153 | * @param buf |
| 149 | * Pointer to buffer to where to data to parse is stored |
154 | * Pointer to buffer to where to data to parse is stored |
| 150 | * @param len |
155 | * @param len |
| 151 | * Length of the data |
156 | * Length of the data |
| 152 | * @param proto |
157 | * @param proto |
| Line 159... | Line 164... | ||
| 159 | uint16_t rawbits = 0; |
164 | uint16_t rawbits = 0; |
| 160 | 165 | ||
| 161 | for (uint8_t i = 0; i<len; i++) { |
166 | for (uint8_t i = 0; i<len; i++) { |
| 162 | //halfbitscnt&1==1 in the middle of bits |
167 | //halfbitscnt&1==1 in the middle of bits |
| 163 | //i&1==0 positive flank |
168 | //i&1==0 positive flank |
| 164 | 169 | ||
| 165 | if ((halfbitscnt&1)==1 && (i&1)==0) { /* in the middle of bit AND a positve flank */ |
170 | if ((halfbitscnt&1)==1 && (i&1)==0) { /* in the middle of bit AND a positve flank */ |
| 166 | rawbits |= (1<<(13-(halfbitscnt>>1))); |
171 | rawbits |= (1<<(13-(halfbitscnt>>1))); |
| 167 | } |
172 | } |
| 168 | 173 | ||
| 169 | if (buf[i] > IR_RC5_HALF_BIT - IR_RC5_HALF_BIT/IR_RC5_TOL_DIV && buf[i] < IR_RC5_HALF_BIT + IR_RC5_HALF_BIT/IR_RC5_TOL_DIV) { |
174 | if (buf[i] > IR_RC5_HALF_BIT - IR_RC5_HALF_BIT/IR_RC5_TOL_DIV && buf[i] < IR_RC5_HALF_BIT + IR_RC5_HALF_BIT/IR_RC5_TOL_DIV) { |
| Line 202... | Line 207... | ||
| 202 | * IR_OK if data expanded successfully, one of several errormessages if not |
207 | * IR_OK if data expanded successfully, one of several errormessages if not |
| 203 | */ |
208 | */ |
| 204 | int8_t expandRC5(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
209 | int8_t expandRC5(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
| 205 | uint8_t tempadress; |
210 | uint8_t tempadress; |
| 206 | uint8_t tempcommand; |
211 | uint8_t tempcommand; |
| 207 | uint8_t previousBit; |
212 | uint8_t previousBit; |
| 208 | uint16_t tempdata; |
213 | uint16_t tempdata; |
| 209 | 214 | ||
| 210 | /* Set up startbit */ |
215 | /* Set up startbit */ |
| 211 | buf[0] = 0; // no start-one |
216 | buf[0] = 0; // no start-one |
| 212 | buf[1] = IR_RC5_HALF_BIT; |
217 | buf[1] = IR_RC5_HALF_BIT; |
| Line 245... | Line 250... | ||
| 245 | if (previousBit == 1){//11 |
250 | if (previousBit == 1){//11 |
| 246 | buf[*len] = IR_RC5_HALF_BIT; |
251 | buf[*len] = IR_RC5_HALF_BIT; |
| 247 | buf[*len+1] = IR_RC5_HALF_BIT; |
252 | buf[*len+1] = IR_RC5_HALF_BIT; |
| 248 | *len = *len + 2; |
253 | *len = *len + 2; |
| 249 | } else {//01 |
254 | } else {//01 |
| 250 | buf[*len-1] = IR_RC5_BIT; |
255 | buf[*len-1] = IR_RC5_BIT; |
| 251 | buf[*len] = IR_RC5_HALF_BIT; |
256 | buf[*len] = IR_RC5_HALF_BIT; |
| 252 | *len = *len + 1; |
257 | *len = *len + 1; |
| 253 | } |
258 | } |
| 254 | previousBit = 1; |
259 | previousBit = 1; |
| 255 | } else {//10 |
260 | } else {//10 |
| 256 | if (previousBit == 1){ |
261 | if (previousBit == 1){ |
| 257 | buf[*len-1] = IR_RC5_BIT; |
262 | buf[*len-1] = IR_RC5_BIT; |
| 258 | buf[*len] = IR_RC5_HALF_BIT; |
263 | buf[*len] = IR_RC5_HALF_BIT; |
| 259 | *len = *len + 1; |
264 | *len = *len + 1; |
| 260 | } else {//00 |
265 | } else {//00 |
| 261 | buf[*len] = IR_RC5_HALF_BIT; |
266 | buf[*len] = IR_RC5_HALF_BIT; |
| 262 | buf[*len+1] = IR_RC5_HALF_BIT; |
267 | buf[*len+1] = IR_RC5_HALF_BIT; |
| 263 | *len = *len + 2; |
268 | *len = *len + 2; |
| 264 | } |
269 | } |
| 265 | previousBit = 0; |
270 | previousBit = 0; |
| 266 | } |
271 | } |
| 267 | } |
272 | } |
| 268 | */ |
273 | */ |
| 269 | 274 | ||
| 270 | tempadress = tempadress<<2; |
275 | tempadress = tempadress<<2; |
| 271 | 276 | ||
| 272 | for(uint8_t i = 0; i < 5; i++) { |
277 | for(uint8_t i = 0; i < 5; i++) { |
| 273 | tempadress = tempadress<<1; |
278 | tempadress = tempadress<<1; |
| 274 | //temptemp = tempadress&0xA0; |
279 | //temptemp = tempadress&0xA0; |
| 275 | if (((tempadress&(0xA0))>>7)==1){ |
280 | if (((tempadress&(0xA0))>>7)==1){ |
| 276 | if (previousBit == 1){//11 |
281 | if (previousBit == 1){//11 |
| 277 | buf[*len] = IR_RC5_HALF_BIT; |
282 | buf[*len] = IR_RC5_HALF_BIT; |
| 278 | buf[*len+1] = IR_RC5_HALF_BIT; |
283 | buf[*len+1] = IR_RC5_HALF_BIT; |
| 279 | *len = *len + 2; |
284 | *len = *len + 2; |
| 280 | } else {//01 |
285 | } else {//01 |
| 281 | buf[*len-1] = IR_RC5_BIT; |
286 | buf[*len-1] = IR_RC5_BIT; |
| 282 | buf[*len] = IR_RC5_HALF_BIT; |
287 | buf[*len] = IR_RC5_HALF_BIT; |
| 283 | *len = *len + 1; |
288 | *len = *len + 1; |
| 284 | } |
289 | } |
| 285 | previousBit = 1; |
290 | previousBit = 1; |
| 286 | } else {//10 |
291 | } else {//10 |
| 287 | if (previousBit == 1){ |
292 | if (previousBit == 1){ |
| 288 | buf[*len-1] = IR_RC5_BIT; |
293 | buf[*len-1] = IR_RC5_BIT; |
| 289 | buf[*len] = IR_RC5_HALF_BIT; |
294 | buf[*len] = IR_RC5_HALF_BIT; |
| 290 | *len = *len + 1; |
295 | *len = *len + 1; |
| 291 | } else {//00 |
296 | } else {//00 |
| 292 | buf[*len] = IR_RC5_HALF_BIT; |
297 | buf[*len] = IR_RC5_HALF_BIT; |
| 293 | buf[*len+1] = IR_RC5_HALF_BIT; |
298 | buf[*len+1] = IR_RC5_HALF_BIT; |
| 294 | *len = *len + 2; |
299 | *len = *len + 2; |
| 295 | } |
300 | } |
| 296 | previousBit = 0; |
301 | previousBit = 0; |
| 297 | } |
302 | } |
| 298 | } |
303 | } |
| 299 | 304 | ||
| 300 | 305 | ||
| 301 | tempcommand = tempcommand << 1; |
306 | tempcommand = tempcommand << 1; |
| 302 | 307 | ||
| 303 | for(uint8_t i = 0; i < 6; i++) { |
308 | for(uint8_t i = 0; i < 6; i++) { |
| 304 | tempcommand = tempcommand<<1; |
309 | tempcommand = tempcommand<<1; |
| 305 | //temptemp = tempadress&0xA0; |
310 | //temptemp = tempadress&0xA0; |
| 306 | if (((tempcommand&(0xA0))>>7)==1){ |
311 | if (((tempcommand&(0xA0))>>7)==1){ |
| 307 | if (previousBit == 1){//11 |
312 | if (previousBit == 1){//11 |
| 308 | buf[*len] = IR_RC5_HALF_BIT; |
313 | buf[*len] = IR_RC5_HALF_BIT; |
| 309 | buf[*len+1] = IR_RC5_HALF_BIT; |
314 | buf[*len+1] = IR_RC5_HALF_BIT; |
| 310 | *len = *len + 2; |
315 | *len = *len + 2; |
| 311 | } else {//01 |
316 | } else {//01 |
| 312 | buf[*len-1] = IR_RC5_BIT; |
317 | buf[*len-1] = IR_RC5_BIT; |
| 313 | buf[*len] = IR_RC5_HALF_BIT; |
318 | buf[*len] = IR_RC5_HALF_BIT; |
| Line 336... | Line 341... | ||
| 336 | 341 | ||
| 337 | 342 | ||
| 338 | #if (IR_PROTOCOLS_USE_SHARP) |
343 | #if (IR_PROTOCOLS_USE_SHARP) |
| 339 | /** |
344 | /** |
| 340 | * Test data on SHARP protocol |
345 | * Test data on SHARP protocol |
| 341 | * http://www.sbprojects.com/knowledge/ir/sharp.htm |
346 | * http://www.sbprojects.com/knowledge/ir/sharp.htm |
| 342 | * |
347 | * |
| 343 | * @param buf |
348 | * @param buf |
| 344 | * Pointer to buffer to where to data to parse is stored |
349 | * Pointer to buffer to where to data to parse is stored |
| 345 | * @param len |
350 | * @param len |
| 346 | * Length of the data |
351 | * Length of the data |
| 347 | * @param proto |
352 | * @param proto |
| 348 | * Pointer to protocol information |
353 | * Pointer to protocol information |
| 349 | * @return |
354 | * @return |
| 350 | * IR_OK if data parsed successfully, one of several errormessages if not |
355 | * IR_OK if data parsed successfully, one of several errormessages if not |
| 351 | */ |
356 | */ |
| 352 | int8_t parseSharp(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) { |
357 | int8_t parseSharp(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) { |
| 353 | /* parse buf[], max is len */ |
358 | /* parse buf[], max is len */ |
| 354 | 359 | ||
| 355 | /* check if we have correct amount of data */ |
360 | /* check if we have correct amount of data */ |
| 356 | if (len != 31) { |
361 | if (len != 31) { |
| 357 | return IR_NOT_CORRECT_DATA; |
362 | return IR_NOT_CORRECT_DATA; |
| 358 | } |
363 | } |
| 359 | 364 | ||
| 360 | uint16_t rawbits=0; |
365 | uint16_t rawbits=0; |
| 361 | 366 | ||
| 362 | for (uint8_t i = 1; i < len; i++) { |
367 | for (uint8_t i = 1; i < len; i++) { |
| 363 | if ((i&1) == 1) { /* if odd, ir-pause */ |
368 | if ((i&1) == 1) { /* if odd, ir-pause */ |
| 364 | /* check length of pause between bits */ |
369 | /* check length of pause between bits */ |
| Line 370... | Line 375... | ||
| 370 | } else { |
375 | } else { |
| 371 | return IR_NOT_CORRECT_DATA; |
376 | return IR_NOT_CORRECT_DATA; |
| 372 | } |
377 | } |
| 373 | } else { /* if even, ir-bit */ |
378 | } else { /* if even, ir-bit */ |
| 374 | if (buf[i] > IR_SHARP_HIGH + IR_SHARP_HIGH/IR_SHARP_TOL_DIV || buf[i] < IR_SHARP_HIGH - IR_SHARP_HIGH/IR_SHARP_TOL_DIV) { |
379 | if (buf[i] > IR_SHARP_HIGH + IR_SHARP_HIGH/IR_SHARP_TOL_DIV || buf[i] < IR_SHARP_HIGH - IR_SHARP_HIGH/IR_SHARP_TOL_DIV) { |
| 375 | return IR_NOT_CORRECT_DATA; |
380 | return IR_NOT_CORRECT_DATA; |
| 376 | } |
381 | } |
| 377 | } |
382 | } |
| 378 | } |
383 | } |
| 379 | 384 | ||
| 380 | proto->protocol=IR_PROTO_SHARP; |
385 | proto->protocol=IR_PROTO_SHARP; |
| 381 | proto->timeout=IR_SHARP_TIMEOUT; |
386 | proto->timeout=IR_SHARP_TIMEOUT; |
| 382 | proto->data=rawbits; |
387 | proto->data=rawbits; |
| 383 | return IR_OK; |
388 | return IR_OK; |
| 384 | } |
389 | } |
| 385 | #endif |
390 | #endif |
| 386 | 391 | ||
| 387 | /** |
392 | /** |
| 388 | * Expand data from Sharp protocol |
393 | * Expand data from Sharp protocol |
| 389 | * http://www.sbprojects.com/knowledge/ir/sharp.htm |
394 | * http://www.sbprojects.com/knowledge/ir/sharp.htm |
| 390 | * |
395 | * |
| 391 | * @param buf |
396 | * @param buf |
| 392 | * Pointer to buffer to store the expanded data |
397 | * Pointer to buffer to store the expanded data |
| 393 | * @param len |
398 | * @param len |
| 394 | * Pointer to length of the data |
399 | * Pointer to length of the data |
| 395 | * @param proto |
400 | * @param proto |
| 396 | * Pointer to protocol information |
401 | * Pointer to protocol information |
| 397 | * @return |
402 | * @return |
| 398 | * IR_OK if data expanded successfully, one of several errormessages if not |
403 | * IR_OK if data expanded successfully, one of several errormessages if not |
| 399 | */ |
404 | */ |
| 400 | int8_t expandSharp(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
405 | int8_t expandSharp(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
| 401 | //TODO: Implement this function. |
406 | //TODO: Implement this function. |
| 402 | return IR_NOT_CORRECT_DATA; |
407 | return IR_NOT_CORRECT_DATA; |
| 403 | } |
408 | } |
| 404 | 409 | ||
| 405 | 410 | ||
| 406 | #if (IR_PROTOCOLS_USE_NEC) |
411 | #if (IR_PROTOCOLS_USE_NEC) |
| 407 | /** |
412 | /** |
| 408 | * Test data on NEC protocol |
413 | * Test data on NEC protocol |
| 409 | * http://www.sbprojects.com/knowledge/ir/nec.htm |
414 | * http://www.sbprojects.com/knowledge/ir/nec.htm |
| Line 416... | Line 421... | ||
| 416 | * Pointer to protocol information |
421 | * Pointer to protocol information |
| 417 | * @return |
422 | * @return |
| 418 | * IR_OK if data parsed successfully, one of several errormessages if not |
423 | * IR_OK if data parsed successfully, one of several errormessages if not |
| 419 | */ |
424 | */ |
| 420 | int8_t parseNEC(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) { |
425 | int8_t parseNEC(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) { |
| 421 | /* parse buf[], max is len */ |
426 | /* parse buf[], max is len */ |
| 422 | 427 | ||
| 423 | /* check if we have correct amount of data */ |
428 | /* check if we have correct amount of data */ |
| 424 | if (len != 67) { |
429 | if (len != 67) { |
| 425 | return IR_NOT_CORRECT_DATA; |
430 | return IR_NOT_CORRECT_DATA; |
| 426 | } |
431 | } |
| Line 430... | Line 435... | ||
| 430 | return IR_NOT_CORRECT_DATA; |
435 | return IR_NOT_CORRECT_DATA; |
| 431 | } |
436 | } |
| 432 | 437 | ||
| 433 | /* check pause after startbit */ |
438 | /* check pause after startbit */ |
| 434 | if (buf[1] > IR_NEC_ST_PAUSE + IR_NEC_ST_PAUSE/IR_NEC_TOL_DIV || buf[1] < IR_NEC_ST_PAUSE - IR_NEC_ST_PAUSE/IR_NEC_TOL_DIV) { |
439 | if (buf[1] > IR_NEC_ST_PAUSE + IR_NEC_ST_PAUSE/IR_NEC_TOL_DIV || buf[1] < IR_NEC_ST_PAUSE - IR_NEC_ST_PAUSE/IR_NEC_TOL_DIV) { |
| 435 | return IR_NOT_CORRECT_DATA; |
440 | return IR_NOT_CORRECT_DATA; |
| 436 | } |
441 | } |
| 437 | 442 | ||
| 438 | uint32_t rawbits = 0; |
443 | uint32_t rawbits = 0; |
| 439 | 444 | ||
| 440 | for (uint8_t i = 3; i < len; i++) { |
445 | for (uint8_t i = 3; i < len; i++) { |
| 441 | if ((i&1) == 1) { /* if odd, ir-pause */ |
446 | if ((i&1) == 1) { /* if odd, ir-pause */ |
| 442 | /* check length of pause between bits */ |
447 | /* check length of pause between bits */ |
| 443 | if (buf[i] > IR_NEC_LOW_ONE - IR_NEC_LOW_ONE/IR_NEC_TOL_DIV && buf[i] < IR_NEC_LOW_ONE + IR_NEC_LOW_ONE/IR_NEC_TOL_DIV) { |
448 | if (buf[i] > IR_NEC_LOW_ONE - IR_NEC_LOW_ONE/IR_NEC_TOL_DIV && buf[i] < IR_NEC_LOW_ONE + IR_NEC_LOW_ONE/IR_NEC_TOL_DIV) { |
| Line 449... | Line 454... | ||
| 449 | return IR_NOT_CORRECT_DATA; |
454 | return IR_NOT_CORRECT_DATA; |
| 450 | } |
455 | } |
| 451 | } else { /* if even, ir-bit */ |
456 | } else { /* if even, ir-bit */ |
| 452 | if (buf[i] > IR_NEC_HIGH + IR_NEC_HIGH/IR_NEC_TOL_DIV || buf[i] < IR_NEC_HIGH - IR_NEC_HIGH/IR_NEC_TOL_DIV) { |
457 | if (buf[i] > IR_NEC_HIGH + IR_NEC_HIGH/IR_NEC_TOL_DIV || buf[i] < IR_NEC_HIGH - IR_NEC_HIGH/IR_NEC_TOL_DIV) { |
| 453 | return IR_NOT_CORRECT_DATA; |
458 | return IR_NOT_CORRECT_DATA; |
| 454 | } |
459 | } |
| 455 | } |
460 | } |
| 456 | } |
461 | } |
| 457 | 462 | ||
| 458 | proto->protocol=IR_PROTO_NEC; |
463 | proto->protocol=IR_PROTO_NEC; |
| 459 | proto->timeout=IR_NEC_TIMEOUT; |
464 | proto->timeout=IR_NEC_TIMEOUT; |
| 460 | proto->data=rawbits; |
465 | proto->data=rawbits; |
| 461 | return IR_OK; |
466 | return IR_OK; |
| Line 487... | Line 492... | ||
| 487 | if ((i&1) == 1) { /* if odd, ir-pause */ |
492 | if ((i&1) == 1) { /* if odd, ir-pause */ |
| 488 | if ((proto->data>>(i>>1))&1) { |
493 | if ((proto->data>>(i>>1))&1) { |
| 489 | buf[i+2] = IR_NEC_LOW_ONE; |
494 | buf[i+2] = IR_NEC_LOW_ONE; |
| 490 | } else { |
495 | } else { |
| 491 | buf[i+2] = IR_NEC_LOW_ZERO; |
496 | buf[i+2] = IR_NEC_LOW_ZERO; |
| 492 | } |
497 | } |
| 493 | } else { /* if even, ir-bit */ |
498 | } else { /* if even, ir-bit */ |
| 494 | buf[i+2] = IR_NEC_HIGH; |
499 | buf[i+2] = IR_NEC_HIGH; |
| 495 | } |
500 | } |
| 496 | } |
501 | } |
| 497 | proto->timeout=IR_NEC_TIMEOUT; |
502 | proto->timeout=IR_NEC_TIMEOUT; |
| 498 | } else { |
503 | } else { |
| Line 559... | Line 564... | ||
| 559 | } |
564 | } |
| 560 | } |
565 | } |
| 561 | } |
566 | } |
| 562 | 567 | ||
| 563 | proto->protocol=IR_PROTO_SAMS; |
568 | proto->protocol=IR_PROTO_SAMS; |
| 564 | proto->timeout=IR_SAMS_TIMEOUT; |
569 | proto->timeout=IR_SAMS_TIMEOUT; |
| 565 | proto->data=rawbits; |
570 | proto->data=rawbits; |
| 566 | return IR_OK; |
571 | return IR_OK; |
| 567 | } |
572 | } |
| 568 | #endif |
573 | #endif |
| 569 | 574 | ||
| Line 574... | Line 579... | ||
| 574 | * |
579 | * |
| 575 | * @param buf |
580 | * @param buf |
| 576 | * Pointer to buffer to store the expanded data |
581 | * Pointer to buffer to store the expanded data |
| 577 | * @param len |
582 | * @param len |
| 578 | * Pointer to length of the data |
583 | * Pointer to length of the data |
| 579 | * @param proto |
584 | * @param proto |
| 580 | * Pointer to protocol information |
585 | * Pointer to protocol information |
| 581 | * @return |
586 | * @return |
| 582 | * IR_OK if data expanded successfully, one of several errormessages if not |
587 | * IR_OK if data expanded successfully, one of several errormessages if not |
| 583 | */ |
588 | */ |
| 584 | int8_t expandSamsung(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
589 | int8_t expandSamsung(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
| 585 | /* Set up startbit */ |
590 | /* Set up startbit */ |
| 586 | buf[0] = IR_SAMS_ST_BIT; |
591 | buf[0] = IR_SAMS_ST_BIT; |
| Line 593... | Line 598... | ||
| 593 | } else { |
598 | } else { |
| 594 | buf[i+2] = IR_SAMS_LOW_ZERO; |
599 | buf[i+2] = IR_SAMS_LOW_ZERO; |
| 595 | } |
600 | } |
| 596 | } else { /* if even, ir-bit */ |
601 | } else { /* if even, ir-bit */ |
| 597 | buf[i+2] = IR_SAMS_HIGH; |
602 | buf[i+2] = IR_SAMS_HIGH; |
| 598 | } |
603 | } |
| 599 | } |
604 | } |
| 600 | 605 | ||
| 601 | *len = 67; |
606 | *len = 67; |
| 602 | 607 | ||
| 603 | proto->modfreq=(((F_CPU/2000)/IR_SAMS_F_MOD) -1); |
608 | proto->modfreq=(((F_CPU/2000)/IR_SAMS_F_MOD) -1); |
| 604 | proto->timeout=IR_SAMS_TIMEOUT; |
609 | proto->timeout=IR_SAMS_TIMEOUT; |
| 605 | proto->repeats=IR_SAMS_REPS; |
610 | proto->repeats=IR_SAMS_REPS; |
| 606 | return IR_OK; |
611 | return IR_OK; |
| 607 | } |
612 | } |
| 608 | 613 | ||
| 609 | #if (IR_PROTOCOLS_USE_MARANTZ) |
614 | #if (IR_PROTOCOLS_USE_MARANTZ) |
| 610 | /** |
615 | /** |
| 611 | * Test data on Marantz protocol |
616 | * Test data on Marantz protocol |
| 612 | * Reverse-Engineered by Noddan, very similar to RC-5. |
617 | * Reverse-Engineered by Noddan, very similar to RC-5. |
| 613 | * Not tested with odd adresses since I have no remote that sends them. |
618 | * Not tested with odd adresses since I have no remote that sends them. |
| Line 631... | Line 636... | ||
| 631 | //halfbitscnt&1==1 in the middle of bits |
636 | //halfbitscnt&1==1 in the middle of bits |
| 632 | //i&1==0 positive flank |
637 | //i&1==0 positive flank |
| 633 | 638 | ||
| 634 | if ((halfbitscnt&1)==1 && (i&1)==0) { /* in the middle of bit AND a positve flank */ |
639 | if ((halfbitscnt&1)==1 && (i&1)==0) { /* in the middle of bit AND a positve flank */ |
| 635 | rawbits |= (uint32_t)1<<(19-(halfbitscnt>>1)); |
640 | rawbits |= (uint32_t)1<<(19-(halfbitscnt>>1)); |
| 636 | } |
641 | } |
| 637 | 642 | ||
| 638 | if (buf[i] > |
643 | if (buf[i] > IR_MARANTZ_HALF_BIT - IR_MARANTZ_HALF_BIT/IR_MARANTZ_TOL_DIV && buf[i] < IR_MARANTZ_HALF_BIT + IR_MARANTZ_HALF_BIT/IR_MARANTZ_TOL_DIV) { |
| 639 | halfbitscnt += 1; |
644 | halfbitscnt += 1; |
| 640 | } else if (buf[i] > |
645 | } else if (buf[i] > IR_MARANTZ_BIT - IR_MARANTZ_BIT/IR_MARANTZ_TOL_DIV && buf[i] < IR_MARANTZ_BIT + IR_MARANTZ_BIT/IR_MARANTZ_TOL_DIV) { |
| 641 | halfbitscnt += 2; |
646 | halfbitscnt += 2; |
| 642 | } else if (buf[i] > |
647 | } else if (buf[i] > IR_MARANTZ_BIT - IR_MARANTZ_BIT/IR_MARANTZ_TOL_DIV && buf[i] < 5*IR_MARANTZ_HALF_BIT + IR_MARANTZ_BIT/IR_MARANTZ_TOL_DIV) { |
| 643 | halfbitscnt += 1; //It seems to work, not entirely sure of the purpose of this long zero though. |
648 | halfbitscnt += 1; //It seems to work, not entirely sure of the purpose of this long zero though. |
| 644 | } else { |
649 | } else { |
| 645 | return IR_NOT_CORRECT_DATA; |
650 | return IR_NOT_CORRECT_DATA; |
| 646 | } |
651 | } |
| 647 | 652 | ||
| 648 | } |
653 | } |
| 649 | 654 | ||
| 650 | //rawbits = (uint32_t)1<<17; |
655 | //rawbits = (uint32_t)1<<17; |
| 651 | proto->protocol=IR_PROTO_MARANTZ; |
656 | proto->protocol=IR_PROTO_MARANTZ; |
| 652 | proto->timeout= |
657 | proto->timeout=IR_MARANTZ_TIMEOUT; |
| 653 | //support RC5-extended keeping second startbit |
658 | //support RC5-extended keeping second startbit |
| 654 | //remove togglebit |
659 | //remove togglebit |
| 655 | //proto->data = rawbits&0x37ff; |
660 | //proto->data = rawbits&0x37ff; |
| 656 | proto->data = rawbits&0x0001ffff; |
661 | proto->data = rawbits&0x0001ffff; |
| 657 | 662 | ||
| Line 671... | Line 676... | ||
| 671 | * IR_OK if data expanded successfully, one of several errormessages if not |
676 | * IR_OK if data expanded successfully, one of several errormessages if not |
| 672 | */ |
677 | */ |
| 673 | int8_t expandMarantz(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
678 | int8_t expandMarantz(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) { |
| 674 | uint8_t previousBit; |
679 | uint8_t previousBit; |
| 675 | uint32_t tempdata; |
680 | uint32_t tempdata; |
| 676 | 681 | ||
| 677 | /* Set up startbits */ |
682 | /* Set up startbits */ |
| 678 | buf[0] = |
683 | buf[0] = IR_MARANTZ_HALF_BIT;//first start bit |
| 679 | buf[1] = |
684 | buf[1] = IR_MARANTZ_HALF_BIT; |
| 680 | buf[2] = |
685 | buf[2] = IR_MARANTZ_HALF_BIT;//second start bit |
| 681 | //TODO: Toggle bit should be better, not hard-coded |
686 | //TODO: Toggle bit should be better, not hard-coded |
| 682 | buf[3] = |
687 | buf[3] = IR_MARANTZ_HALF_BIT; |
| 683 | buf[4] = |
688 | buf[4] = IR_MARANTZ_HALF_BIT;//toggle bit |
| 684 | *len=5; |
689 | *len=5; |
| 685 | previousBit = 1; |
690 | previousBit = 1; |
| 686 | 691 | ||
| 687 | tempdata = (uint32_t)(proto->data)<<14; |
692 | tempdata = (uint32_t)(proto->data)<<14; |
| 688 | 693 | ||
| 689 | for(uint8_t i = 0; i < 17; i++) { |
694 | for(uint8_t i = 0; i < 17; i++) { |
| 690 | tempdata = (uint32_t)tempdata<<1; |
695 | tempdata = (uint32_t)tempdata<<1; |
| 691 | 696 | ||
| 692 | if (((uint32_t)tempdata>>31)==1){ |
697 | if (((uint32_t)tempdata>>31)==1){ |
| 693 | if (previousBit == 1){//11 |
698 | if (previousBit == 1){//11 |
| 694 | buf[*len] = |
699 | buf[*len] = IR_MARANTZ_HALF_BIT; |
| 695 | buf[*len+1] = |
700 | buf[*len+1] = IR_MARANTZ_HALF_BIT; |
| 696 | *len = *len + 2; |
701 | *len = *len + 2; |
| 697 | } else {//01 |
702 | } else {//01 |
| 698 | buf[*len-1] = |
703 | buf[*len-1] = IR_MARANTZ_BIT; |
| 699 | buf[*len] = |
704 | buf[*len] = IR_MARANTZ_HALF_BIT; |
| 700 | *len = *len + 1; |
705 | *len = *len + 1; |
| 701 | } |
706 | } |
| 702 | previousBit = 1; |
707 | previousBit = 1; |
| 703 | } else { |
708 | } else { |
| 704 | if (previousBit == 1){//10 |
709 | if (previousBit == 1){//10 |
| 705 | buf[*len-1] = |
710 | buf[*len-1] = IR_MARANTZ_BIT; |
| 706 | buf[*len] = |
711 | buf[*len] = IR_MARANTZ_HALF_BIT; |
| 707 | *len = *len + 1; |
712 | *len = *len + 1; |
| 708 | } else {//00 |
713 | } else {//00 |
| 709 | buf[*len] = |
714 | buf[*len] = IR_MARANTZ_HALF_BIT; |
| 710 | if (i==4){ |
715 | if (i==4){ |
| 711 | buf[*len+1] = |
716 | buf[*len+1] = IR_MARANTZ_HALF_BIT*5; |
| 712 | } else { |
717 | } else { |
| 713 | buf[*len+1] = |
718 | buf[*len+1] = IR_MARANTZ_HALF_BIT; |
| 714 | } |
719 | } |
| 715 | 720 | ||
| 716 | *len = *len + 2; |
721 | *len = *len + 2; |
| 717 | } |
722 | } |
| 718 | previousBit = 0; |
723 | previousBit = 0; |
| 719 | } |
724 | } |
| 720 | } |
725 | } |
| 721 | //make sure that we finish high by removing the last zero if needed |
726 | //make sure that we finish high by removing the last zero if needed |
| 722 | if (*len%2 == 0){ |
727 | if (*len%2 == 0){ |
| 723 | *len = *len - 1; |
728 | *len = *len - 1; |
| 724 | } |
729 | } |
| 725 | 730 | ||
| 726 | proto->modfreq=(((F_CPU/2000)/ |
731 | proto->modfreq=(((F_CPU/2000)/IR_MARANTZ_F_MOD) -1); |
| 727 | proto->timeout= |
732 | proto->timeout=IR_MARANTZ_TIMEOUT; |
| 728 | proto->repeats= |
733 | proto->repeats=IR_MARANTZ_REPS; |
| 729 | return IR_OK; |
734 | return IR_OK; |
| 730 | } |
735 | } |
| 731 | 736 | ||
| 732 | 737 | ||
| 733 | #endif |
738 | #endif |