Subversion Repositories HomeAutomation

Rev

Rev 732 | Rev 734 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 732 Rev 733
Line 1... Line 1...
1
/**
1
/**
2
 * IR receiver and transmitter protocols.
2
 * IR receiver and transmitter protocols.
3
 *
3
 *
4
 * @date    2006-12-10
4
 * @date    2006-12-10
5
 *
5
 *
6
 * @author  Anders Runeson, Andreas Fritiofson
6
 * @author  Anders Runeson, Andreas Fritiofson, Martin NordŽn
7
 *  
7
 *  
8
 */
8
 */
9
 
9
 
10
#include "protocols.h"
10
#include "protocols.h"
11
 
11
 
Line 205... Line 205...
205
    uint8_t tempadress;
205
    uint8_t tempadress;
206
    uint8_t tempcommand;
206
    uint8_t tempcommand;
207
    uint8_t previousBit;
207
    uint8_t previousBit;
208
    uint16_t tempdata;
208
    uint16_t tempdata;
209
   
209
   
210
    //TODO: Implement this function. Martin testar!
-
 
211
    /* Set up startbit */
210
    /* Set up startbit */
212
    buf[0] = 0; // no start-one
211
    buf[0] = 0; // no start-one
213
    buf[1] = IR_RC5_HALF_BIT;
212
    buf[1] = IR_RC5_HALF_BIT;
214
    buf[2] = IR_RC5_HALF_BIT;//first start bit
213
    buf[2] = IR_RC5_HALF_BIT;//first start bit
215
    buf[3] = IR_RC5_HALF_BIT;
214
    buf[3] = IR_RC5_HALF_BIT;
Line 229... Line 228...
229
    }
228
    }
230
           
229
           
231
    //let's start with the adress bits..
230
    //let's start with the adress bits..
232
    tempcommand = proto->data&(0b00111111);
231
    tempcommand = proto->data&(0b00111111);
233
    tempadress = (proto->data>>8)&(0b00011111);
232
    tempadress = (proto->data>>8)&(0b00011111);
234
   
-
 
-
 
233
    //TODO: This requires massive cleanup
235
   
234
   
236
    //tempdata = ((((uint16_t)(proto->data)&(0x3F)) + ((uint16_t)((proto->data>>8)&(0x1F))<<6)))<<5;
235
    //tempdata = ((((uint16_t)(proto->data)&(0x3F)) + ((uint16_t)((proto->data>>8)&(0x1F))<<6)))<<5;
237
   
236
   
238
    tempdata = (uint16_t)tempcommand + ((uint16_t)tempadress<<6);
237
    tempdata = (uint16_t)tempcommand + ((uint16_t)tempadress<<6);
239
    tempdata = tempdata<<5;
238
    tempdata = tempdata<<5;
240
   
239
   
241
    /*
240
    /*
242
    for(uint8_t ijag t = 0; i < 11; i++) {
241
    for(uint8_t ijag t = 0; i < 11; i++) {
243
        tempdata = tempdata<<1;
242
        tempdata = tempdata<<1;
244
        //temptemp = tempadress&0xA0;
243
        //temptemp = tempadress&0xA0;
245
        if (((tempdata&(0xA000))>>15)==1){
244
        if (((tempdata&(0xA000))>>15)==1){
Line 257... Line 256...
257
            if (previousBit == 1){
256
            if (previousBit == 1){
258
                buf[*len-1] = IR_RC5_BIT;
257
                buf[*len-1] = IR_RC5_BIT;
259
                buf[*len] = IR_RC5_HALF_BIT;
258
                buf[*len] = IR_RC5_HALF_BIT;
260
                *len = *len + 1;
259
                *len = *len + 1;
261
            } else {//00
260
            } else {//00
262
                buf[*len] = IR_RC5_HALF_BIT;
261
                buf[*len] = IR_RC5_HALF_BIT;
263
                buf[*len+1] = IR_RC5_HALF_BIT;
262
                buf[*len+1] = IR_RC5_HALF_BIT;
264
                *len = *len + 2;
263
                *len = *len + 2;
265
            }
264
            }
266
            previousBit = 0;
265
            previousBit = 0;
267
        }
266
        }
268
    }
267
    }
269
    */
268
    */
270
   
269
   
271
    tempadress = tempadress<<2;
270
    tempadress = tempadress<<2;
272
   
271
   
273
    for(uint8_t i = 0; i < 5; i++) {
272
    for(uint8_t i = 0; i < 5; i++) {
274
        tempadress = tempadress<<1;
273
        tempadress = tempadress<<1;
275
        //temptemp = tempadress&0xA0;
274
        //temptemp = tempadress&0xA0;
276
        if (((tempadress&(0xA0))>>7)==1){
275
        if (((tempadress&(0xA0))>>7)==1){
277
            if (previousBit == 1){//11
276
            if (previousBit == 1){//11
278
                buf[*len] = IR_RC5_HALF_BIT;
277
                buf[*len] = IR_RC5_HALF_BIT;
279
                buf[*len+1] = IR_RC5_HALF_BIT;
278
                buf[*len+1] = IR_RC5_HALF_BIT;
280
                *len = *len + 2;
279
                *len = *len + 2;
281
            } else {//01
280
            } else {//01
282
                buf[*len-1] = IR_RC5_BIT;
281
                buf[*len-1] = IR_RC5_BIT;
283
                buf[*len] = IR_RC5_HALF_BIT;
282
                buf[*len] = IR_RC5_HALF_BIT;
284
                *len = *len + 1;
283
                *len = *len + 1;
285
            }
284
            }
286
            previousBit = 1;
285
            previousBit = 1;
287
        } else {//10
286
        } else {//10
288
            if (previousBit == 1){
287
            if (previousBit == 1){
289
                buf[*len-1] = IR_RC5_BIT;
288
                buf[*len-1] = IR_RC5_BIT;
290
                buf[*len] = IR_RC5_HALF_BIT;
289
                buf[*len] = IR_RC5_HALF_BIT;
291
                *len = *len + 1;
290
                *len = *len + 1;
292
            } else {//00
291
            } else {//00
293
                buf[*len] = IR_RC5_HALF_BIT;
292
                buf[*len] = IR_RC5_HALF_BIT;
294
                buf[*len+1] = IR_RC5_HALF_BIT;
293
                buf[*len+1] = IR_RC5_HALF_BIT;
295
                *len = *len + 2;
294
                *len = *len + 2;
296
            }
295
            }
297
            previousBit = 0;
296
            previousBit = 0;
298
        }
297
        }
299
    }
298
    }
300
   
299
   
301
   
300
   
302
    tempcommand = tempcommand << 1;
301
    tempcommand = tempcommand << 1;
303
   
302
   
304
    for(uint8_t i = 0; i < 6; i++) {
303
    for(uint8_t i = 0; i < 6; i++) {
305
        tempcommand = tempcommand<<1;
304
        tempcommand = tempcommand<<1;
Line 308... Line 307...
308
            if (previousBit == 1){//11
307
            if (previousBit == 1){//11
309
                buf[*len] = IR_RC5_HALF_BIT;
308
                buf[*len] = IR_RC5_HALF_BIT;
310
                buf[*len+1] = IR_RC5_HALF_BIT;
309
                buf[*len+1] = IR_RC5_HALF_BIT;
311
                *len = *len + 2;
310
                *len = *len + 2;
312
            } else {//01
311
            } else {//01
313
                buf[*len-1] = IR_RC5_BIT;
312
                buf[*len-1] = IR_RC5_BIT;
314
                buf[*len] = IR_RC5_HALF_BIT;
313
                buf[*len] = IR_RC5_HALF_BIT;
315
                *len = *len + 1;
314
                *len = *len + 1;
316
            }
315
            }
317
            previousBit = 1;
316
            previousBit = 1;
318
        } else {//10
317
        } else {//10
319
            if (previousBit == 1){
318
            if (previousBit == 1){
320
                buf[*len-1] = IR_RC5_BIT;
319
                buf[*len-1] = IR_RC5_BIT;
321
                buf[*len] = IR_RC5_HALF_BIT;
320
                buf[*len] = IR_RC5_HALF_BIT;
322
                *len = *len + 1;
321
                *len = *len + 1;
323
            } else {//00
322
            } else {//00
324
                buf[*len] = IR_RC5_HALF_BIT;
323
                buf[*len] = IR_RC5_HALF_BIT;
325
                buf[*len+1] = IR_RC5_HALF_BIT;
324
                buf[*len+1] = IR_RC5_HALF_BIT;
326
                *len = *len + 2;
325
                *len = *len + 2;
Line 337... Line 336...
337
 
336
 
338
 
337
 
339
#if (IR_PROTOCOLS_USE_SHARP)
338
#if (IR_PROTOCOLS_USE_SHARP)
340
/**
339
/**
341
 * Test data on SHARP protocol
340
 * Test data on SHARP protocol
342
 * http://www.sbprojects.com/knowledge/ir/sharp.htm
341
 * http://www.sbprojects.com/knowledge/ir/sharp.htm
343
 *
342
 *
344
 * @param buf
343
 * @param buf
345
 *      Pointer to buffer to where to data to parse is stored
344
 *      Pointer to buffer to where to data to parse is stored
346
 * @param len
345
 * @param len
347
 *      Length of the data
346
 *      Length of the data
348
 * @param proto
347
 * @param proto
349
 *      Pointer to protocol information
348
 *      Pointer to protocol information
350
 * @return
349
 * @return
351
 *      IR_OK if data parsed successfully, one of several errormessages if not
350
 *      IR_OK if data parsed successfully, one of several errormessages if not
352
 */
351
 */
353
int8_t parseSharp(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
352
int8_t parseSharp(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
354
    /* parse buf[], max is len */
353
    /* parse buf[], max is len */
Line 374... Line 373...
374
        } else {            /* if even, ir-bit */
373
        } else {            /* if even, ir-bit */
375
            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) {
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) {
376
                return IR_NOT_CORRECT_DATA;
375
                return IR_NOT_CORRECT_DATA;
377
            }
376
            }
378
        }
377
        }
379
    }
378
    }
380
   
379
   
381
    proto->protocol=IR_PROTO_SHARP;
380
    proto->protocol=IR_PROTO_SHARP;
382
    proto->timeout=IR_SHARP_TIMEOUT;
381
    proto->timeout=IR_SHARP_TIMEOUT;
383
    proto->data=rawbits;
382
    proto->data=rawbits;
384
    return IR_OK;
383
    return IR_OK;
Line 398... Line 397...
398
 * @return
397
 * @return
399
 *      IR_OK if data expanded successfully, one of several errormessages if not
398
 *      IR_OK if data expanded successfully, one of several errormessages if not
400
 */
399
 */
401
int8_t expandSharp(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) {
400
int8_t expandSharp(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) {
402
    //TODO: Implement this function.
401
    //TODO: Implement this function.
403
    return IR_NOT_CORRECT_DATA;
402
    return IR_NOT_CORRECT_DATA;
404
}
403
}
405
 
404
 
406
 
405
 
407
#if (IR_PROTOCOLS_USE_NEC)
406
#if (IR_PROTOCOLS_USE_NEC)
408
/**
407
/**
409
 * Test data on NEC protocol
408
 * Test data on NEC protocol
410
 * http://www.sbprojects.com/knowledge/ir/nec.htm
409
 * http://www.sbprojects.com/knowledge/ir/nec.htm
411
 *
410
 *
Line 421... Line 420...
421
int8_t parseNEC(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
420
int8_t parseNEC(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
422
    /* parse buf[], max is len */
421
    /* parse buf[], max is len */
423
 
422
 
424
    /* check if we have correct amount of data */
423
    /* check if we have correct amount of data */
425
    if (len != 67) {
424
    if (len != 67) {
426
        return IR_NOT_CORRECT_DATA;
425
        return IR_NOT_CORRECT_DATA;
427
    }
426
    }
428
   
427
   
429
    /* check startbit */
428
    /* check startbit */
430
    if (buf[0] > IR_NEC_ST_BIT + IR_NEC_ST_BIT/IR_NEC_TOL_DIV || buf[0] < IR_NEC_ST_BIT - IR_NEC_ST_BIT/IR_NEC_TOL_DIV) {
429
    if (buf[0] > IR_NEC_ST_BIT + IR_NEC_ST_BIT/IR_NEC_TOL_DIV || buf[0] < IR_NEC_ST_BIT - IR_NEC_ST_BIT/IR_NEC_TOL_DIV) {
431
        return IR_NOT_CORRECT_DATA;
430
        return IR_NOT_CORRECT_DATA;
432
    }
431
    }
Line 450... Line 449...
450
                return IR_NOT_CORRECT_DATA;
449
                return IR_NOT_CORRECT_DATA;
451
            }
450
            }
452
        } else {            /* if even, ir-bit */
451
        } else {            /* if even, ir-bit */
453
            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) {
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) {
454
                return IR_NOT_CORRECT_DATA;
453
                return IR_NOT_CORRECT_DATA;
455
            }
454
            }
456
        }
455
        }
457
    }
456
    }
458
 
457
 
459
    proto->protocol=IR_PROTO_NEC;
458
    proto->protocol=IR_PROTO_NEC;
460
    proto->timeout=IR_NEC_TIMEOUT;
459
    proto->timeout=IR_NEC_TIMEOUT;
461
    proto->data=rawbits;   
460
    proto->data=rawbits;   
462
    return IR_OK;
461
    return IR_OK;
463
}
462
}
464
#endif
463
#endif
465
 
464
 
466
/**
465
/**
467
 * Expand data from NEC protocol
466
 * Expand data from NEC protocol
468
 * http://www.sbprojects.com/knowledge/ir/nec.htm
467
 * http://www.sbprojects.com/knowledge/ir/nec.htm
469
 *
468
 *
470
 * @param buf
469
 * @param buf
471
 *      Pointer to buffer to store the expanded data
470
 *      Pointer to buffer to store the expanded data
Line 488... Line 487...
488
            if ((i&1) == 1) {       /* if odd, ir-pause */
487
            if ((i&1) == 1) {       /* if odd, ir-pause */
489
                if ((proto->data>>(i>>1))&1) {
488
                if ((proto->data>>(i>>1))&1) {
490
                    buf[i+2] = IR_NEC_LOW_ONE;
489
                    buf[i+2] = IR_NEC_LOW_ONE;
491
                } else {
490
                } else {
492
                    buf[i+2] = IR_NEC_LOW_ZERO;
491
                    buf[i+2] = IR_NEC_LOW_ZERO;
493
                }
492
                }
494
            } else {            /* if even, ir-bit */
493
            } else {            /* if even, ir-bit */
495
                buf[i+2] = IR_NEC_HIGH;
494
                buf[i+2] = IR_NEC_HIGH;
496
            }
495
            }
497
        }
496
        }
498
        proto->timeout=IR_NEC_TIMEOUT;
497
        proto->timeout=IR_NEC_TIMEOUT;
Line 509... Line 508...
509
 
508
 
510
 
509
 
511
#if (IR_PROTOCOLS_USE_SAMSUNG)
510
#if (IR_PROTOCOLS_USE_SAMSUNG)
512
/**
511
/**
513
 * Test data on Samsung protocol
512
 * Test data on Samsung protocol
514
 * Very much like NEC, different start bit/pause lengths etc.
513
 * Very much like NEC, different start bit/pause lengths etc.
515
 * http://www.sbprojects.com/knowledge/ir/nec.htm
514
 * http://www.sbprojects.com/knowledge/ir/nec.htm
516
 *
515
 *
517
 * @param buf
516
 * @param buf
518
 *      Pointer to buffer to where to data to parse is stored
517
 *      Pointer to buffer to where to data to parse is stored
519
 * @param len
518
 * @param len
520
 *      Length of the data
519
 *      Length of the data
521
 * @param proto
520
 * @param proto
522
 *      Pointer to protocol information
521
 *      Pointer to protocol information
523
 * @return
522
 * @return
524
 *      IR_OK if data parsed successfully, one of several errormessages if not
523
 *      IR_OK if data parsed successfully, one of several errormessages if not
Line 536... Line 535...
536
        return IR_NOT_CORRECT_DATA;
535
        return IR_NOT_CORRECT_DATA;
537
    }
536
    }
538
 
537
 
539
    /* check pause after startbit */
538
    /* check pause after startbit */
540
    if (buf[1] > IR_SAMS_ST_PAUSE + IR_SAMS_ST_PAUSE/IR_SAMS_TOL_DIV || buf[1] < IR_SAMS_ST_PAUSE - IR_SAMS_ST_PAUSE/IR_SAMS_TOL_DIV) {
539
    if (buf[1] > IR_SAMS_ST_PAUSE + IR_SAMS_ST_PAUSE/IR_SAMS_TOL_DIV || buf[1] < IR_SAMS_ST_PAUSE - IR_SAMS_ST_PAUSE/IR_SAMS_TOL_DIV) {
541
        return IR_NOT_CORRECT_DATA;
540
        return IR_NOT_CORRECT_DATA;
542
    }
541
    }
543
 
542
 
544
    uint32_t rawbits = 0;
543
    uint32_t rawbits = 0;
545
   
544
   
546
    for (uint8_t i = 3; i < len; i++) {
545
    for (uint8_t i = 3; i < len; i++) {
Line 550... Line 549...
550
                /* write a one */
549
                /* write a one */
551
                rawbits |= 1UL<<((i-3)>>1);
550
                rawbits |= 1UL<<((i-3)>>1);
552
            } else if (buf[i] > IR_SAMS_LOW_ZERO - IR_SAMS_LOW_ZERO/IR_SAMS_TOL_DIV && buf[i] < IR_SAMS_LOW_ZERO + IR_SAMS_LOW_ZERO/IR_SAMS_TOL_DIV) {
551
            } else if (buf[i] > IR_SAMS_LOW_ZERO - IR_SAMS_LOW_ZERO/IR_SAMS_TOL_DIV && buf[i] < IR_SAMS_LOW_ZERO + IR_SAMS_LOW_ZERO/IR_SAMS_TOL_DIV) {
553
                /* do nothing, a zero is already in rawbits */
552
                /* do nothing, a zero is already in rawbits */
554
            } else {
553
            } else {
555
                return IR_NOT_CORRECT_DATA;
554
                return IR_NOT_CORRECT_DATA;
556
            }
555
            }
557
        } else {            /* if even, ir-bit */
556
        } else {            /* if even, ir-bit */
558
            if (buf[i] > IR_SAMS_HIGH + IR_SAMS_HIGH/IR_SAMS_TOL_DIV || buf[i] < IR_SAMS_HIGH - IR_SAMS_HIGH/IR_SAMS_TOL_DIV) {
557
            if (buf[i] > IR_SAMS_HIGH + IR_SAMS_HIGH/IR_SAMS_TOL_DIV || buf[i] < IR_SAMS_HIGH - IR_SAMS_HIGH/IR_SAMS_TOL_DIV) {
559
                return IR_NOT_CORRECT_DATA;
558
                return IR_NOT_CORRECT_DATA;
560
            }
559
            }
Line 570... Line 569...
570
 
569
 
571
/**
570
/**
572
 * Expand data from Samsung protocol
571
 * Expand data from Samsung protocol
573
 * Very much like NEC, different start bit/pause lengths etc.
572
 * Very much like NEC, different start bit/pause lengths etc.
574
 * http://www.sbprojects.com/knowledge/ir/nec.htm
573
 * http://www.sbprojects.com/knowledge/ir/nec.htm
575
 *
574
 *
576
 * @param buf
575
 * @param buf
577
 *      Pointer to buffer to store the expanded data
576
 *      Pointer to buffer to store the expanded data
578
 * @param len
577
 * @param len
579
 *      Pointer to length of the data
578
 *      Pointer to length of the data
580
 * @param proto
579
 * @param proto
581
 *      Pointer to protocol information
580
 *      Pointer to protocol information
Line 658... Line 657...
658
   
657
   
659
    return IR_OK;
658
    return IR_OK;
660
}
659
}
661
 
660
 
662
/**
661
/**
663
 * Expand data from Marantz
662
 * Expand data from Marantz. Written by Martin NordŽn
664
 *
663
 *
665
 * @param buf
664
 * @param buf
666
 *      Pointer to buffer to store the expanded data
665
 *      Pointer to buffer to store the expanded data
667
 * @param len
666
 * @param len
668
 *      Pointer to length of the data
667
 *      Pointer to length of the data
Line 672... Line 671...
672
 *      IR_OK if data expanded successfully, one of several errormessages if not
671
 *      IR_OK if data expanded successfully, one of several errormessages if not
673
 */
672
 */
674
int8_t expandMarantz(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) {
673
int8_t expandMarantz(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) {
675
    uint8_t previousBit;
674
    uint8_t previousBit;
676
    uint32_t tempdata;
675
    uint32_t tempdata;
677
    uint32_t tempvariabel; //bra att ha eftersom jag inte har koll pŒ alla typecastingar
-
 
678
   
676
   
679
    //TODO: Implement this function. Martin testar!
-
 
680
    /* Set up startbits */
677
    /* Set up startbits */
681
    buf[0] = IR_RC5_HALF_BIT;//first start bit
678
    buf[0] = IR_RC5_HALF_BIT;//first start bit
682
    buf[1] = IR_RC5_HALF_BIT;
679
    buf[1] = IR_RC5_HALF_BIT;
683
    buf[2] = IR_RC5_HALF_BIT;//second start bit
680
    buf[2] = IR_RC5_HALF_BIT;//second start bit
684
    //TODO: Toggle bit should be better, not hard-coded
681
    //TODO: Toggle bit should be better, not hard-coded
685
    buf[3] = IR_RC5_HALF_BIT;
682
    buf[3] = IR_RC5_HALF_BIT;
686
    buf[4] = IR_RC5_HALF_BIT;//toggle bit
683
    buf[4] = IR_RC5_HALF_BIT;//toggle bit
687
    *len=5;
684
    *len=5;
688
    previousBit = 1;
685
    previousBit = 1;
689
   
686
   
690
    tempdata = proto->data;
687
    tempdata = (uint32_t)(proto->data)<<14;
691
   
688
       
692
    tempdata = (uint32_t)tempdata<<14; //MSB at position 32. 
-
 
693
   
-
 
694
    for(uint8_t ij = 0; ij < 17; ij++) {
689
    for(uint8_t i = 0; i < 17; i++) {
695
        tempdata = (uint32_t)tempdata<<1;
690
        tempdata = (uint32_t)tempdata<<1;
696
        tempvariabel = (uint32_t)tempdata&(0x8000);
-
 
697
        tempvariabel = (uint32_t)tempdata>>31;
-
 
-
 
691
 
698
        if ((uint32_t)tempvariabel==1){
692
        if (((uint32_t)tempdata>>31)==1){
699
            if (previousBit == 1){//11
693
            if (previousBit == 1){//11
700
                buf[*len] = IR_RC5_HALF_BIT;
694
                buf[*len] = IR_RC5_HALF_BIT;
701
                buf[*len+1] = IR_RC5_HALF_BIT;
695
                buf[*len+1] = IR_RC5_HALF_BIT;
702
                *len = *len + 2;
696
                *len = *len + 2;
703
            } else {//01
697
            } else {//01
Line 711... Line 705...
711
                buf[*len-1] = IR_RC5_BIT;
705
                buf[*len-1] = IR_RC5_BIT;
712
                buf[*len] = IR_RC5_HALF_BIT;
706
                buf[*len] = IR_RC5_HALF_BIT;
713
                *len = *len + 1;
707
                *len = *len + 1;
714
            } else {//00
708
            } else {//00
715
                buf[*len] = IR_RC5_HALF_BIT;
709
                buf[*len] = IR_RC5_HALF_BIT;
716
                if (ij==4){
710
                if (i==4){
717
                    buf[*len+1] = IR_RC5_HALF_BIT*5;
711
                    buf[*len+1] = IR_RC5_HALF_BIT*5;
718
                } else {
712
                } else {
719
                    buf[*len+1] = IR_RC5_HALF_BIT;
713
                    buf[*len+1] = IR_RC5_HALF_BIT;
720
                }
714
                }
721
               
715