Rev 1814 | Rev 1816 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1814 | Rev 1815 | ||
|---|---|---|---|
| Line 99... | Line 99... | ||
| 99 | 99 | ||
| 100 | #if sns_irTransceive_PRONTO_SUPPORT==1 |
100 | #if sns_irTransceive_PRONTO_SUPPORT==1 |
| 101 | #define sns_irTransceive_BaseFrq (4145146ULL) |
101 | #define sns_irTransceive_BaseFrq (4145146ULL) |
| 102 | void send_pronto(uint16_t *buffer, uint8_t len, uint8_t channel, uint8_t modfreq) { |
102 | void send_pronto(uint16_t *buffer, uint8_t len, uint8_t channel, uint8_t modfreq) { |
| 103 | StdCan_Msg_t msg; |
103 | StdCan_Msg_t msg; |
| - | 104 | ||
| - | 105 | /* TODO send timing command */ |
|
| 104 | 106 | ||
| 105 | StdCan_Set_class(msg.Header, CAN_MODULE_CLASS_SNS); |
107 | StdCan_Set_class(msg.Header, CAN_MODULE_CLASS_SNS); |
| 106 | StdCan_Set_direction(msg.Header, DIRECTIONFLAG_FROM_OWNER); |
108 | StdCan_Set_direction(msg.Header, DIRECTIONFLAG_FROM_OWNER); |
| 107 | msg.Length = 8; |
109 | msg.Length = 8; |
| 108 | msg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE; |
110 | msg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE; |
| 109 | msg.Header.ModuleId = sns_irTransceive_ID; |
111 | msg.Header.ModuleId = sns_irTransceive_ID; |
| 110 | msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOSTART; |
112 | msg.Header.Command = CAN_MODULE_CMD_IRTRANSCEIVE_IRPRONTOSTART; |
| 111 | 113 | ||
| 112 | msg.Data[0] = |
114 | msg.Data[0] = ((channel<<4)|0x0); /* Channel and Prontoformat 0x000 */ |
| 113 | msg.Data[1] = 0x00; |
115 | msg.Data[1] = 0x00; |
| 114 | msg.Data[2] = 0x00; /* Freq divider */ |
116 | msg.Data[2] = 0x00; /* Freq divider */ |
| 115 | msg.Data[3] = modfreq; |
117 | msg.Data[3] = modfreq; |
| 116 | msg.Data[4] = 0x00; /* Once seq length, first byte always 0 */ |
118 | msg.Data[4] = 0x00; /* Once seq length, first byte always 0 */ |
| 117 | msg.Data[5] = 0x00; //len/2; /* not correct if any byte overflows */ |
119 | msg.Data[5] = 0x00; //len/2; /* not correct if any byte overflows */ |
| Line 145... | Line 147... | ||
| 145 | { |
147 | { |
| 146 | /* If data does not fit into 8 bit, then split, memorize low byte */ |
148 | /* If data does not fit into 8 bit, then split, memorize low byte */ |
| 147 | mem = data&0xff; |
149 | mem = data&0xff; |
| 148 | /* Buffer high byte */ |
150 | /* Buffer high byte */ |
| 149 | msg.Data[j] = (data>>8)&0xff; |
151 | msg.Data[j] = (data>>8)&0xff; |
| 150 | j++; |
152 | j++; |
| 151 | if (j==8) |
153 | if (j==8) |
| 152 | { |
154 | { |
| 153 | /* If send buffer is full, send frame */ |
155 | /* If send buffer is full, send frame */ |
| 154 | /* can buffers will be filled when sending more than 2-3 messages, so retry until sent */ |
156 | /* can buffers will be filled when sending more than 2-3 messages, so retry until sent */ |
| 155 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
157 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
| 156 | _delay_ms(1); |
158 | _delay_ms(1); |
| 157 | j=0; |
159 | j=0; |
| 158 | msg.Header.Command++; |
160 | msg.Header.Command++; |
| 159 | } |
161 | } |
| 160 | /* Set complementary burst pair to 0 to indicate 16bit transmission */ |
162 | /* Set complementary burst pair to 0 to indicate 16bit transmission */ |
| 161 | msg.Data[j] = 0; |
163 | msg.Data[j] = 0; |
| 162 | } |
164 | } |
| 163 | else |
165 | else |
| 164 | { |
166 | { |
| 165 | msg.Data[j] = data&0xff; |
167 | msg.Data[j] = data&0xff; |
| 166 | } |
168 | } |
| 167 | 169 | ||
| 168 | i++; |
170 | i++; |
| - | 171 | } |
|
| - | 172 | ||
| - | 173 | j++; |
|
| - | 174 | if (j==8) |
|
| - | 175 | { |
|
| - | 176 | /* If send buffer is full, send frame */ |
|
| - | 177 | /* can buffers will be filled when sending more than 2-3 messages, so retry until sent */ |
|
| - | 178 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
|
| - | 179 | _delay_ms(1); |
|
| - | 180 | j=0; |
|
| - | 181 | msg.Header.Command++; |
|
| 169 | } |
182 | } |
| - | 183 | } |
|
| 170 | 184 | ||
| - | 185 | /* End with 25ms, TODO fix uglyness */ |
|
| - | 186 | msg.Data[j] = ((IR_MAX_PULSE_WIDTH/divider)>>8)&0xff; |
|
| - | 187 | j++; |
|
| - | 188 | if (j==8) |
|
| - | 189 | { |
|
| - | 190 | /* If send buffer is full, send frame */ |
|
| - | 191 | /* can buffers will be filled when sending more than 2-3 messages, so retry until sent */ |
|
| - | 192 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
|
| - | 193 | _delay_ms(1); |
|
| - | 194 | j=0; |
|
| - | 195 | msg.Header.Command++; |
|
| - | 196 | } |
|
| - | 197 | msg.Data[j] = 0; |
|
| - | 198 | j++; |
|
| - | 199 | msg.Data[j] = (IR_MAX_PULSE_WIDTH/divider)&0xff; |
|
| 171 | j++; |
200 | j++; |
| 172 | if (j==8) |
201 | if (j==8) |
| 173 | { |
202 | { |
| 174 | /* If send buffer is full, send frame */ |
203 | /* If send buffer is full, send frame */ |
| 175 | /* can buffers will be filled when sending more than 2-3 messages, so retry until sent */ |
204 | /* can buffers will be filled when sending more than 2-3 messages, so retry until sent */ |
| 176 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
205 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
| 177 | _delay_ms(1); |
206 | _delay_ms(1); |
| 178 | j=0; |
207 | j=0; |
| 179 | msg.Header.Command++; |
208 | msg.Header.Command++; |
| 180 | } |
209 | } |
| 181 | 210 | ||
| 182 | |
211 | if (j>0) |
| 183 | 212 | { |
|
| 184 | /* msg command kept from for loop, but increase 16 to send ProntoEnd */ |
213 | /* msg command kept from for loop, but increase 16 to send ProntoEnd */ |
| 185 | msg.Header.Command+=16; |
214 | msg.Header.Command+=16; |
| 186 | msg.Length = j; |
215 | msg.Length = j; |
| 187 | /* data kept from loop */ |
216 | /* data kept from loop */ |
| 188 | /* buffers will be filled when sending more than 2-3 messages, so retry until sent */ |
217 | /* buffers will be filled when sending more than 2-3 messages, so retry until sent */ |
| 189 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
218 | while (StdCan_Put(&msg) != StdCan_Ret_OK) {} |
| 190 | _delay_ms(1); |
219 | _delay_ms(1); |
| - | 220 | } |
|
| 191 | } |
221 | } |
| 192 | #endif |
222 | #endif |
| 193 | 223 | ||
| 194 | 224 | ||
| 195 | #if IR_RX_ENABLE==1 |
225 | #if IR_RX_ENABLE==1 |