Rev 1849 | Rev 1854 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1849 | Rev 1850 | ||
|---|---|---|---|
| Line 99... | Line 99... | ||
| 99 | #endif |
99 | #endif |
| 100 | 100 | ||
| 101 | #define sns_irTransceive_BaseFrq (4145146UL) |
101 | #define sns_irTransceive_BaseFrq (4145146UL) |
| 102 | 102 | ||
| 103 | #ifndef sns_irTransceive_PRONTO_SUPPORT |
103 | #ifndef sns_irTransceive_PRONTO_SUPPORT |
| 104 | #define sns_irTransceive_PRONTO_SUPPORT |
104 | #define sns_irTransceive_PRONTO_SUPPORT 0 |
| 105 | #endif |
105 | #endif |
| 106 | 106 | ||
| 107 | /* |
107 | /* |
| 108 | * PRONTO HEX Routines |
108 | * PRONTO HEX Routines |
| 109 | */ |
109 | */ |
| 110 | #if sns_irTransceive_PRONTO_SUPPORT==1 |
110 | #if sns_irTransceive_PRONTO_SUPPORT==1 |
| 111 | volatile uint32_t sns_irTransceive_LastPronto=0; |
111 | volatile uint32_t sns_irTransceive_LastPronto=0; |
| 112 | static uint8_t activeChannel = 0; |
112 | static uint8_t activeChannel = 0; |
| 113 | #define sns_irTransceive_MAXTIMING (16*1000) |
113 | #define sns_irTransceive_MAXTIMING (16*1000) |
| 114 | 114 | ||
| 115 | static void send_pronto(uint16_t *buffer, uint8_t len, uint8_t channel, uint16_t modfreq) |
115 | static void send_pronto(uint16_t *buffer, uint8_t len, uint8_t channel, uint16_t modfreq) |
| - | 116 | { |
|
| - | 117 | uint32_t currentTime = Timer_GetTicks(); |
|
| - | 118 | ||
| 116 | StdCan_Msg_t msg; |
119 | StdCan_Msg_t msg; |
| 117 | 120 | ||
| 118 | StdCan_Set_class(msg.Header, CAN_MODULE_CLASS_SNS); |
121 | StdCan_Set_class(msg.Header, CAN_MODULE_CLASS_SNS); |
| 119 | StdCan_Set_direction(msg.Header, DIRECTIONFLAG_FROM_OWNER); |
122 | StdCan_Set_direction(msg.Header, DIRECTIONFLAG_FROM_OWNER); |
| 120 | msg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE; |
123 | msg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE; |
| 121 | msg.Header.ModuleId = sns_irTransceive_ID; |
124 | msg.Header.ModuleId = sns_irTransceive_ID; |
| 122 | - | ||
| 123 | //printf("LEN:%04d", len); |
- | |
| 124 | 125 | ||
| 125 | /* Send timing command */ |
126 | /* Send timing command */ |
| 126 | msg.Length = 5; |
127 | msg.Length = 5; |
| 127 | msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOTIMING; |
128 | msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOTIMING; |
| 128 | uint32_t currentTime=Timer_GetTicks(); |
- | |
| - | 129 | ||
| 129 | if ((currentTime < sns_irTransceive_LastPronto+sns_irTransceive_MAXTIMING) && (sns_irTransceive_LastPronto != 0)) |
130 | if ((currentTime < sns_irTransceive_LastPronto+sns_irTransceive_MAXTIMING) && (sns_irTransceive_LastPronto != 0)) |
| 130 | { |
131 | { |
| - | 132 | /* Calculate elapsed time since last pronto packet */ |
|
| - | 133 | uint32_t elapsedTime = ((currentTime - sns_irTransceive_LastPronto) * 1000) & 0x00FFFFFFUL; //24bit value |
|
| - | 134 | ||
| - | 135 | /* Remove length of the last received sequence */ |
|
| - | 136 | uint32_t sequenceLength = IR_MAX_PULSE_WIDTH; // timeout value not included in buffer |
|
| - | 137 | for (uint8_t i = 0; i < len; i++) { |
|
| - | 138 | sequenceLength += (uint32_t)buffer[i]; |
|
| - | 139 | } |
|
| - | 140 | if (sequenceLength <= elapsedTime) { |
|
| - | 141 | elapsedTime -= sequenceLength; |
|
| - | 142 | } |
|
| - | 143 | ||
| 131 | msg.Data[0] = ((channel<<4)|0xf); |
144 | msg.Data[0] = ((channel<<4)|0xf); |
| 132 | msg.Data[1] = 0x10; |
145 | msg.Data[1] = 0x10; |
| 133 | msg.Data[2] = ( |
146 | msg.Data[2] = (uint8_t)(elapsedTime >> 16); |
| 134 | msg.Data[3] = ( |
147 | msg.Data[3] = (uint8_t)(elapsedTime >> 8); |
| 135 | msg.Data[4] = ( |
148 | msg.Data[4] = (uint8_t)(elapsedTime >> 0); |
| 136 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
149 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
| 137 | _delay_ms(1); |
150 | _delay_ms(1); |
| 138 | } |
151 | } |
| 139 | sns_irTransceive_LastPronto=currentTime; |
152 | sns_irTransceive_LastPronto = currentTime; |
| 140 | 153 | ||