Rev 1818 | Rev 1822 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1818 | Rev 1821 | ||
|---|---|---|---|
| Line 90... | Line 90... | ||
| 90 | _delay_ms(1); |
90 | _delay_ms(1); |
| 91 | } |
91 | } |
| 92 | 92 | ||
| 93 | } |
93 | } |
| 94 | #endif |
94 | #endif |
| - | 95 | ||
| - | 96 | #define sns_irTransceive_BaseFrq (4145146ULL) |
|
| 95 | 97 | ||
| 96 | #ifndef sns_irTransceive_PRONTO_SUPPORT |
98 | #ifndef sns_irTransceive_PRONTO_SUPPORT |
| 97 | #define sns_irTransceive_PRONTO_SUPPORT 0 |
99 | #define sns_irTransceive_PRONTO_SUPPORT 0 |
| 98 | #endif |
100 | #endif |
| - | 101 | ||
| 99 | #if sns_irTransceive_PRONTO_SUPPORT==1 |
102 | #if sns_irTransceive_PRONTO_SUPPORT==1 |
| - | 103 | volatile uint32_t sns_irTransceive_LastPronto=0; |
|
| 100 | #define |
104 | #define sns_irTransceive_MAXTIMING (16*1000) |
| - | 105 | ||
| 101 | void send_pronto(uint16_t *buffer, uint8_t len, uint8_t channel, uint8_t modfreq) { |
106 | void send_pronto(uint16_t *buffer, uint8_t len, uint8_t channel, uint8_t modfreq) { |
| 102 | StdCan_Msg_t msg; |
107 | StdCan_Msg_t msg; |
| 103 | 108 | ||
| 104 | /* TODO send timing command */ |
- | |
| 105 | - | ||
| 106 | StdCan_Set_class(msg.Header, CAN_MODULE_CLASS_SNS); |
109 | StdCan_Set_class(msg.Header, CAN_MODULE_CLASS_SNS); |
| 107 | StdCan_Set_direction(msg.Header, DIRECTIONFLAG_FROM_OWNER); |
110 | StdCan_Set_direction(msg.Header, DIRECTIONFLAG_FROM_OWNER); |
| 108 | msg.Length = 8; |
- | |
| 109 | msg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE; |
111 | msg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE; |
| 110 | msg.Header.ModuleId = sns_irTransceive_ID; |
112 | msg.Header.ModuleId = sns_irTransceive_ID; |
| - | 113 | ||
| - | 114 | /* TODO send timing command */ |
|
| - | 115 | msg.Length = 5; |
|
| - | 116 | msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOTIMING; |
|
| - | 117 | uint32_t currentTime=Timer_GetTicks(); |
|
| - | 118 | if ((currentTime < sns_irTransceive_LastPronto+sns_irTransceive_MAXTIMING) && (sns_irTransceive_LastPronto != 0)) |
|
| - | 119 | { |
|
| - | 120 | msg.Data[0] = 0xff; |
|
| - | 121 | msg.Data[1] = 0x10; |
|
| - | 122 | msg.Data[2] = (((currentTime-sns_irTransceive_LastPronto)*1000)>>16)&0xff; |
|
| - | 123 | msg.Data[3] = (((currentTime-sns_irTransceive_LastPronto)*1000)>>8)&0xff; |
|
| - | 124 | msg.Data[4] = ((currentTime-sns_irTransceive_LastPronto)*1000)&0xff; |
|
| - | 125 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
|
| - | 126 | _delay_ms(1); |
|
| - | 127 | } |
|
| - | 128 | sns_irTransceive_LastPronto=currentTime; |
|
| - | 129 | ||
| - | 130 | msg.Length = 8; |
|
| 111 | msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOSTART; |
131 | msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOSTART; |
| 112 | 132 | ||
| 113 | msg.Data[0] = ((channel<<4)|0x0); /* Channel and Prontoformat 0x000 */ |
133 | msg.Data[0] = ((channel<<4)|0x0); /* Channel and Prontoformat 0x000 */ |
| 114 | msg.Data[1] = 0x00; |
134 | msg.Data[1] = 0x00; |
| 115 | msg.Data[2] = 0x00; /* Freq divider */ |
135 | msg.Data[2] = 0x00; /* Freq divider */ |