Rev 1871 | Rev 1893 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1871 | Rev 1875 | ||
|---|---|---|---|
| Line 587... | Line 587... | ||
| 587 | eeprom_write_word_crc(EEDATA16.ch2_modfreq, sns_irTransceive_BaseFrq/38000UL, WITHOUT_CRC); |
587 | eeprom_write_word_crc(EEDATA16.ch2_modfreq, sns_irTransceive_BaseFrq/38000UL, WITHOUT_CRC); |
| 588 | EEDATA_UPDATE_CRC; |
588 | EEDATA_UPDATE_CRC; |
| 589 | } |
589 | } |
| 590 | #endif |
590 | #endif |
| 591 | 591 | ||
| 592 |
|
592 | /*gpio_clr_pin(EXP_K); |
| 593 |
|
593 | gpio_set_out(EXP_K); |
| 594 |
|
594 | gpio_clr_pin(EXP_J); |
| 595 |
|
595 | gpio_set_out(EXP_J); |
| - | 596 | gpio_clr_pin(EXP_H); |
|
| - | 597 | gpio_set_out(EXP_H);*/ |
|
| 596 | } |
598 | } |
| 597 | 599 | ||
| 598 | void sns_irTransceive_Process(void) |
600 | void sns_irTransceive_Process(void) |
| 599 | { |
601 | { |
| 600 | for (uint8_t channel=0; channel < IR_SUPPORTED_NUM_CHANNELS; channel++) |
602 | for (uint8_t channel=0; channel < IR_SUPPORTED_NUM_CHANNELS; channel++) |
| Line 606... | Line 608... | ||
| 606 | case sns_irTransceive_STATE_IDLE: |
608 | case sns_irTransceive_STATE_IDLE: |
| 607 | { |
609 | { |
| 608 | if (irRxChannel[channel].proto.protocol != IR_PROTO_UNKNOWN) { |
610 | if (irRxChannel[channel].proto.protocol != IR_PROTO_UNKNOWN) { |
| 609 | /* Send button release command on CAN */ |
611 | /* Send button release command on CAN */ |
| 610 | irTxMsg.Data[0] = 0xf&CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_RELEASED; |
612 | irTxMsg.Data[0] = 0xf&CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_RELEASED; |
| 611 | irTxMsg.Data[0] |= channel<<4; |
613 | irTxMsg.Data[0] |= channel<<4; |
| 612 | irTxMsg.Data[1] = irRxChannel[channel].proto.protocol; |
614 | irTxMsg.Data[1] = irRxChannel[channel].proto.protocol; |
| 613 | irTxMsg.Data[2] = (irRxChannel[channel].proto.data>>24)&0xff; |
615 | irTxMsg.Data[2] = (irRxChannel[channel].proto.data>>24)&0xff; |
| 614 | irTxMsg.Data[3] = (irRxChannel[channel].proto.data>>16)&0xff; |
616 | irTxMsg.Data[3] = (irRxChannel[channel].proto.data>>16)&0xff; |
| 615 | irTxMsg.Data[4] = (irRxChannel[channel].proto.data>>8)&0xff; |
617 | irTxMsg.Data[4] = (irRxChannel[channel].proto.data>>8)&0xff; |
| 616 | irTxMsg.Data[5] = irRxChannel[channel].proto.data&0xff; |
618 | irTxMsg.Data[5] = irRxChannel[channel].proto.data&0xff; |
| 617 | 619 | ||
| 618 | StdCan_Put(&irTxMsg); |
620 | StdCan_Put(&irTxMsg); |
| 619 | } |
621 | } |
| 620 | irRxChannel[channel].state = sns_irTransceive_STATE_START_RECEIVE; |
622 | irRxChannel[channel].state = sns_irTransceive_STATE_START_RECEIVE; |
| 621 | break; |
623 | break; |
| 622 | } |
624 | } |
| 623 | 625 | ||
| 624 | case sns_irTransceive_STATE_START_RECEIVE: |
626 | case sns_irTransceive_STATE_START_RECEIVE: |
| 625 | IrTransceiver_ResetRx(channel); |
627 | IrTransceiver_ResetRx(channel); |
| 626 | cli(); |
628 | cli(); |
| 627 | irRxChannel[channel].newData = FALSE; |
629 | irRxChannel[channel].newData = FALSE; |
| 628 | sei(); |
630 | sei(); |
| 629 | irRxChannel[channel].state = sns_irTransceive_STATE_RECEIVING; |
631 | irRxChannel[channel].state = sns_irTransceive_STATE_RECEIVING; |
| - | 632 | //gpio_set_pin(EXP_J); |
|
| 630 | break; |
633 | break; |
| 631 | 634 | ||
| 632 | case sns_irTransceive_STATE_RECEIVING: |
635 | case sns_irTransceive_STATE_RECEIVING: |
| 633 | if (irRxChannel[channel].newData == TRUE) { |
636 | if (irRxChannel[channel].newData == TRUE) { |
| - | 637 | //printf("sRx\n"); |
|
| 634 | /* TODO: move this line to the RX callback */ |
638 | /* TODO: move this line to the RX callback */ |
| 635 | IrTransceiver_DisableRx(channel); |
639 | IrTransceiver_DisableRx(channel); |
| 636 | cli(); |
640 | cli(); |
| 637 | irRxChannel[channel].newData = FALSE; |
641 | irRxChannel[channel].newData = FALSE; |
| 638 | sei(); |
642 | sei(); |
| Line 651... | Line 655... | ||
| 651 | StdCan_Put(&irTxMsg); |
655 | StdCan_Put(&irTxMsg); |
| 652 | } |
656 | } |
| 653 | else if (irRxChannel[channel].proto.protocol == IR_PROTO_UNKNOWN) |
657 | else if (irRxChannel[channel].proto.protocol == IR_PROTO_UNKNOWN) |
| 654 | { |
658 | { |
| 655 | #if (sns_irTransceive_SEND_DEBUG==1) |
659 | #if (sns_irTransceive_SEND_DEBUG==1) |
| 656 | //gpio_toggle_pin(EXP_J); |
- | |
| 657 | send_debug(irRxChannel[channel].rxbuf, irRxChannel[channel].rxlen); |
660 | send_debug(irRxChannel[channel].rxbuf, irRxChannel[channel].rxlen); |
| 658 | irRxChannel[channel].proto.timeout=300; |
661 | irRxChannel[channel].proto.timeout=300; |
| 659 | #elif sns_irTransceive_PRONTO_SUPPORT==1 |
662 | #elif sns_irTransceive_PRONTO_SUPPORT==1 |
| 660 | pronto_sendData(irRxChannel[channel].rxbuf, irRxChannel[channel].rxlen, channel, irRxChannel[channel].proto.modfreq); |
663 | pronto_sendData(irRxChannel[channel].rxbuf, irRxChannel[channel].rxlen, channel, irRxChannel[channel].proto.modfreq); |
| 661 | irRxChannel[channel].proto.timeout=1; |
664 | irRxChannel[channel].proto.timeout=1; |
| Line 664... | Line 667... | ||
| 664 | 667 | ||
| 665 | /* Enable the receiver again */ |
668 | /* Enable the receiver again */ |
| 666 | IrTransceiver_EnableRx(channel); |
669 | IrTransceiver_EnableRx(channel); |
| 667 | 670 | ||
| 668 | irRxChannel[channel].state = sns_irTransceive_STATE_START_PAUSE; |
671 | irRxChannel[channel].state = sns_irTransceive_STATE_START_PAUSE; |
| - | 672 | //gpio_clr_pin(EXP_H); |
|
| - | 673 | //gpio_clr_pin(EXP_J); |
|
| 669 | } |
674 | } |
| 670 | break; |
675 | break; |
| 671 | 676 | ||
| 672 | case sns_irTransceive_STATE_START_PAUSE: |
677 | case sns_irTransceive_STATE_START_PAUSE: |
| - | 678 | //printf("sP\n"); |
|
| 673 | /* set a timer so we can send release button event when no new IR is arriving */ |
679 | /* set a timer so we can send release button event when no new IR is arriving */ |
| 674 | Timer_SetTimeout(irRxChannel[channel].timerNum, irRxChannel[channel].proto.timeout, TimerTypeOneShot, 0); |
680 | Timer_SetTimeout(irRxChannel[channel].timerNum, irRxChannel[channel].proto.timeout, TimerTypeOneShot, 0); |
| 675 | irRxChannel[channel].state = sns_irTransceive_STATE_PAUSING; |
681 | irRxChannel[channel].state = sns_irTransceive_STATE_PAUSING; |
| 676 | break; |
682 | break; |
| 677 | 683 | ||
| 678 | case sns_irTransceive_STATE_PAUSING: |
684 | case sns_irTransceive_STATE_PAUSING: |
| 679 | /* reset timer if new IR arrived */ |
685 | /* reset timer if new IR arrived */ |
| 680 | if (irRxChannel[channel].newData == TRUE || IrTransceiver_GetStoreEnableRx(channel) == TRUE) { |
686 | if (irRxChannel[channel].newData == TRUE || IrTransceiver_GetStoreEnableRx(channel) == TRUE) { |
| - | 687 | //printf("sT\n"); |
|
| 681 | cli(); |
688 | cli(); |
| 682 | irRxChannel[channel].newData = FALSE; |
689 | irRxChannel[channel].newData = FALSE; |
| 683 | sei(); |
690 | sei(); |
| 684 | Timer_SetTimeout(irRxChannel[channel].timerNum, irRxChannel[channel].proto.timeout, TimerTypeOneShot, 0); |
691 | Timer_SetTimeout(irRxChannel[channel].timerNum, irRxChannel[channel].proto.timeout, TimerTypeOneShot, 0); |
| 685 | } |
692 | } |
| 686 | 693 | ||
| 687 | if (Timer_Expired(irRxChannel[channel].timerNum)) { |
694 | if (Timer_Expired(irRxChannel[channel].timerNum)) { |
| - | 695 | //printf("sD\n"); |
|
| 688 | irRxChannel[channel].state = sns_irTransceive_STATE_IDLE; |
696 | irRxChannel[channel].state = sns_irTransceive_STATE_IDLE; |
| 689 | } |
697 | } |
| 690 | break; |
698 | break; |
| 691 | 699 | ||
| 692 | default: |
700 | default: |