Rev 1491 | Rev 1730 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1491 | Rev 1498 | ||
|---|---|---|---|
| Line 7... | Line 7... | ||
| 7 | uint8_t newData; |
7 | uint8_t newData; |
| 8 | uint16_t *rxbuf; |
8 | uint16_t *rxbuf; |
| 9 | uint8_t rxlen; |
9 | uint8_t rxlen; |
| 10 | uint8_t timerNum; |
10 | uint8_t timerNum; |
| 11 | Ir_Protocol_Data_t proto; |
11 | Ir_Protocol_Data_t proto; |
| 12 | } irRxChannel[ |
12 | } irRxChannel[IR_SUPPORTED_NUM_CHANNELS]; |
| 13 | #endif |
13 | #endif |
| 14 | 14 | ||
| 15 | #if IR_TX_ENABLE==1 |
15 | #if IR_TX_ENABLE==1 |
| 16 | struct { |
16 | struct { |
| 17 | uint8_t state; |
17 | uint8_t state; |
| Line 20... | Line 20... | ||
| 20 | uint8_t txlen; |
20 | uint8_t txlen; |
| 21 | uint8_t timerNum; |
21 | uint8_t timerNum; |
| 22 | uint8_t repeatCount; |
22 | uint8_t repeatCount; |
| 23 | uint8_t stopSend; |
23 | uint8_t stopSend; |
| 24 | Ir_Protocol_Data_t proto; |
24 | Ir_Protocol_Data_t proto; |
| 25 | } irTxChannel[ |
25 | } irTxChannel[IR_SUPPORTED_NUM_CHANNELS]; |
| 26 | #endif |
26 | #endif |
| 27 | 27 | ||
| 28 | uint16_t buf[ |
28 | uint16_t buf[3][MAX_NR_TIMES]; |
| 29 | 29 | ||
| 30 | StdCan_Msg_t irTxMsg; |
30 | StdCan_Msg_t irTxMsg; |
| 31 | 31 | ||
| 32 | #if (sns_irTransceive_SEND_DEBUG==1) |
32 | #if (sns_irTransceive_SEND_DEBUG==1) |
| 33 | void send_debug(uint16_t *buffer, uint8_t len) { |
33 | void send_debug(uint16_t *buffer, uint8_t len) { |
| Line 73... | Line 73... | ||
| 73 | #endif |
73 | #endif |
| 74 | 74 | ||
| 75 | #if IR_RX_ENABLE==1 |
75 | #if IR_RX_ENABLE==1 |
| 76 | void sns_irTransceive_RX_done_callback(uint8_t channel, uint16_t *buffer, uint8_t len) |
76 | void sns_irTransceive_RX_done_callback(uint8_t channel, uint16_t *buffer, uint8_t len) |
| 77 | { |
77 | { |
| 78 | if (channel < |
78 | if (channel < IR_SUPPORTED_NUM_CHANNELS) |
| 79 | { |
79 | { |
| 80 | irRxChannel[channel].newData = TRUE; |
80 | irRxChannel[channel].newData = TRUE; |
| 81 | irRxChannel[channel].rxlen = len; |
81 | irRxChannel[channel].rxlen = len; |
| 82 | } |
82 | } |
| 83 | } |
83 | } |
| 84 | #endif |
84 | #endif |
| 85 | 85 | ||
| 86 | void sns_irTransceive_TX_done_callback(uint8_t channel) |
86 | void sns_irTransceive_TX_done_callback(uint8_t channel) |
| 87 | { |
87 | { |
| 88 | if (channel < |
88 | if (channel < IR_SUPPORTED_NUM_CHANNELS) |
| 89 | { |
89 | { |
| 90 | irTxChannel[channel].sendComplete = TRUE; |
90 | irTxChannel[channel].sendComplete = TRUE; |
| 91 | } |
91 | } |
| 92 | } |
92 | } |
| 93 | 93 | ||
| Line 100... | Line 100... | ||
| 100 | irTxMsg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE; |
100 | irTxMsg.Header.ModuleType = CAN_MODULE_TYPE_SNS_IRTRANSCEIVE; |
| 101 | irTxMsg.Header.ModuleId = sns_irTransceive_ID; |
101 | irTxMsg.Header.ModuleId = sns_irTransceive_ID; |
| 102 | irTxMsg.Header.Command = CAN_MODULE_CMD_PHYSICAL_IR; |
102 | irTxMsg.Header.Command = CAN_MODULE_CMD_PHYSICAL_IR; |
| 103 | irTxMsg.Length = 6; |
103 | irTxMsg.Length = 6; |
| 104 | 104 | ||
| 105 | for (uint8_t i = 0; i < |
105 | for (uint8_t i = 0; i < IR_SUPPORTED_NUM_CHANNELS; i++) |
| 106 | { |
106 | { |
| 107 | #if IR_RX_ENABLE==1 |
107 | #if IR_RX_ENABLE==1 |
| 108 | irRxChannel[i].state = sns_irTransceive_STATE_RECEIVING; |
108 | irRxChannel[i].state = sns_irTransceive_STATE_RECEIVING; |
| 109 | irRxChannel[i].newData = FALSE; |
109 | irRxChannel[i].newData = FALSE; |
| 110 | irRxChannel[i].rxlen = 0; |
110 | irRxChannel[i].rxlen = 0; |
| Line 160... | Line 160... | ||
| 160 | gpio_set_pin(sns_irTransceive_TX0_PIN); |
160 | gpio_set_pin(sns_irTransceive_TX0_PIN); |
| 161 | gpio_set_pin(sns_irTransceive_TX1_PIN); |
161 | gpio_set_pin(sns_irTransceive_TX1_PIN); |
| 162 | gpio_set_pin(sns_irTransceive_TX2_PIN); |
162 | gpio_set_pin(sns_irTransceive_TX2_PIN); |
| 163 | #endif |
163 | #endif |
| 164 | 164 | ||
| 165 | irTxChannel[0].txbuf = buf[ |
165 | irTxChannel[0].txbuf = buf[0]; |
| 166 | IrTransceiver_InitTxChannel(0, sns_irTransceive_TX_done_callback, sns_irTransceive_TX0_PIN); |
166 | IrTransceiver_InitTxChannel(0, sns_irTransceive_TX_done_callback, sns_irTransceive_TX0_PIN); |
| - | 167 | ||
| - | 168 | irTxChannel[1].txbuf = buf[1]; |
|
| - | 169 | IrTransceiver_InitTxChannel(1, sns_irTransceive_TX_done_callback, sns_irTransceive_TX1_PIN); |
|
| - | 170 | ||
| - | 171 | irTxChannel[2].txbuf = buf[2]; |
|
| - | 172 | IrTransceiver_InitTxChannel(2, sns_irTransceive_TX_done_callback, sns_irTransceive_TX2_PIN); |
|
| 167 | #endif |
173 | #endif |
| 168 | 174 | ||
| 169 | } |
175 | } |
| 170 | 176 | ||
| 171 | void sns_irTransceive_Process(void) |
177 | void sns_irTransceive_Process(void) |
| 172 | { |
178 | { |
| 173 | for (uint8_t channel=0; channel < |
179 | for (uint8_t channel=0; channel < IR_SUPPORTED_NUM_CHANNELS; channel++) |
| 174 | { |
180 | { |
| 175 | //gpio_toggle_pin(EXP_A); |
181 | //gpio_toggle_pin(EXP_A); |
| 176 | 182 | ||
| 177 | #if IR_RX_ENABLE==1 |
183 | #if IR_RX_ENABLE==1 |
| 178 | switch (irRxChannel[channel].state) |
184 | switch (irRxChannel[channel].state) |
| Line 351... | Line 357... | ||
| 351 | uint8_t channel; |
357 | uint8_t channel; |
| 352 | switch (rxMsg->Header.Command) |
358 | switch (rxMsg->Header.Command) |
| 353 | { |
359 | { |
| 354 | case CAN_MODULE_CMD_PHYSICAL_IR: |
360 | case CAN_MODULE_CMD_PHYSICAL_IR: |
| 355 | channel = rxMsg->Data[0]>>4; |
361 | channel = rxMsg->Data[0]>>4; |
| 356 | if ((0xf&rxMsg->Data[0]) == CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_PRESSED && channel < |
362 | if ((0xf&rxMsg->Data[0]) == CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_PRESSED && channel < IR_SUPPORTED_NUM_CHANNELS) |
| 357 | { |
363 | { |
| 358 | if (irTxChannel[channel].state == sns_irTransceive_STATE_IDLE) |
364 | if (irTxChannel[channel].state == sns_irTransceive_STATE_IDLE) |
| 359 | { |
365 | { |
| 360 | irTxChannel[channel].proto.protocol = rxMsg->Data[1]; |
366 | irTxChannel[channel].proto.protocol = rxMsg->Data[1]; |
| 361 | 367 | ||
| Line 368... | Line 374... | ||
| 368 | irTxChannel[channel].proto.data |= rxMsg->Data[5]; |
374 | irTxChannel[channel].proto.data |= rxMsg->Data[5]; |
| 369 | 375 | ||
| 370 | irTxChannel[channel].state = sns_irTransceive_STATE_START_TRANSMIT; |
376 | irTxChannel[channel].state = sns_irTransceive_STATE_START_TRANSMIT; |
| 371 | } |
377 | } |
| 372 | } |
378 | } |
| 373 | else if ((0xf&rxMsg->Data[0]) == CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_RELEASED && channel < |
379 | else if ((0xf&rxMsg->Data[0]) == CAN_MODULE_ENUM_PHYSICAL_IR_STATUS_RELEASED && channel < IR_SUPPORTED_NUM_CHANNELS) |
| 374 | { |
380 | { |
| 375 | if (irTxChannel[channel].state != sns_irTransceive_STATE_IDLE) |
381 | if (irTxChannel[channel].state != sns_irTransceive_STATE_IDLE) |
| 376 | { |
382 | { |
| 377 | irTxChannel[channel].stopSend = TRUE; |
383 | irTxChannel[channel].stopSend = TRUE; |
| 378 | } |
384 | } |