Subversion Repositories HomeAutomation

Rev

Rev 1487 | Rev 1490 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1487 Rev 1488
Line 23... Line 23...
23
    uint8_t             stopSend;
23
    uint8_t             stopSend;
24
    Ir_Protocol_Data_t  proto;
24
    Ir_Protocol_Data_t  proto;
25
} irTxChannel[sns_irTransceive_SUPPORTED_NUM_CHANNELS];
25
} irTxChannel[sns_irTransceive_SUPPORTED_NUM_CHANNELS];
26
#endif
26
#endif
27
 
27
 
28
uint16_t    buf0[MAX_NR_TIMES];
-
 
29
uint16_t    buf1[MAX_NR_TIMES];
28
uint16_t    buf[2][MAX_NR_TIMES];
30
//uint16_t  buf2[MAX_NR_TIMES];
-
 
31
 
29
 
32
StdCan_Msg_t        irTxMsg;
30
StdCan_Msg_t        irTxMsg;
33
 
31
 
34
#if (sns_irTransceive_SEND_DEBUG==1)
32
#if (sns_irTransceive_SEND_DEBUG==1)
35
void send_debug(uint16_t *buffer, uint8_t len) {
33
void send_debug(uint16_t *buffer, uint8_t len) {
Line 87... Line 85...
87
 
85
 
88
void sns_irTransceive_TX_done_callback(uint8_t channel)
86
void sns_irTransceive_TX_done_callback(uint8_t channel)
89
{
87
{
90
    if (channel < sns_irTransceive_SUPPORTED_NUM_CHANNELS)
88
    if (channel < sns_irTransceive_SUPPORTED_NUM_CHANNELS)
91
    {
89
    {
92
        irTxChannel[channel].sendComplete == TRUE;
90
        irTxChannel[channel].sendComplete = TRUE;
93
    }
91
    }
94
}
92
}
95
 
93
 
96
void sns_irTransceive_Init(void)
94
void sns_irTransceive_Init(void)
97
{
95
{
Line 141... Line 139...
141
#endif
139
#endif
142
   
140
   
143
    IrTransceiver_Init();
141
    IrTransceiver_Init();
144
 
142
 
145
#if IR_RX_ENABLE==1
143
#if IR_RX_ENABLE==1
146
    irRxChannel[0].rxbuf = buf0;
144
    irRxChannel[0].rxbuf = buf[0];
147
    IrTransceiver_InitRxChannel(0, irRxChannel[0].rxbuf, sns_irTransceive_RX_done_callback, sns_irTransceive_RX0_PCINT, sns_irTransceive_RX0_PIN);
145
    IrTransceiver_InitRxChannel(0, irRxChannel[0].rxbuf, sns_irTransceive_RX_done_callback, sns_irTransceive_RX0_PCINT, sns_irTransceive_RX0_PIN);
148
#endif
146
#endif
149
 
147
 
150
#if IR_TX_ENABLE==1
148
#if IR_TX_ENABLE==1
151
    irTxChannel[0].txbuf = buf1;
149
    irTxChannel[0].txbuf = buf[1];
152
    IrTransceiver_InitTxChannel(0, sns_irTransceive_TX_done_callback, sns_irTransceive_TX0_PIN);
150
    IrTransceiver_InitTxChannel(0, sns_irTransceive_TX_done_callback, sns_irTransceive_TX0_PIN);
153
#endif
151
#endif
154
 
152
 
155
}
153
}
156
 
154
 
Line 255... Line 253...
255
        case sns_irTransceive_STATE_IDLE:
253
        case sns_irTransceive_STATE_IDLE:
256
            /* transmission is started when a command is received on can */
254
            /* transmission is started when a command is received on can */
257
            break;
255
            break;
258
 
256
 
259
        case sns_irTransceive_STATE_START_TRANSMIT:
257
        case sns_irTransceive_STATE_START_TRANSMIT:
-
 
258
//      printf("1\n");
260
            if (expandProtocol(irTxChannel[channel].txbuf, &irTxChannel[channel].txlen, &irTxChannel[channel].proto) == IR_OK)
259
            if (expandProtocol(irTxChannel[channel].txbuf, &irTxChannel[channel].txlen, &irTxChannel[channel].proto) == IR_OK)
261
            {
260
            {
262
                IrTransceiver_Transmit(channel, irTxChannel[channel].txbuf, irTxChannel[channel].txlen);
261
                IrTransceiver_Transmit(channel, irTxChannel[channel].txbuf, irTxChannel[channel].txlen);
263
                irTxChannel[channel].state = sns_irTransceive_STATE_TRANSMITTING;
262
                irTxChannel[channel].state = sns_irTransceive_STATE_TRANSMITTING;
-
 
263
//      printf("2\n");
264
            }
264
            }
265
            else
265
            else
266
            {
266
            {
267
                irTxChannel[channel].state = sns_irTransceive_STATE_IDLE;
267
                irTxChannel[channel].state = sns_irTransceive_STATE_IDLE;
268
            }
268
            }
Line 273... Line 273...
273
            {
273
            {
274
                cli();
274
                cli();
275
                irTxChannel[channel].sendComplete = FALSE;
275
                irTxChannel[channel].sendComplete = FALSE;
276
                sei();
276
                sei();
277
                irTxChannel[channel].state = sns_irTransceive_STATE_START_PAUSE;
277
                irTxChannel[channel].state = sns_irTransceive_STATE_START_PAUSE;
-
 
278
//      printf("3\n");
278
            }
279
            }
279
            break;
280
            break;
280
 
281
 
281
        case sns_irTransceive_STATE_START_PAUSE:
282
        case sns_irTransceive_STATE_START_PAUSE:
282
            if (irTxChannel[channel].repeatCount < irTxChannel[channel].proto.repeats)
283
            if (irTxChannel[channel].repeatCount < irTxChannel[channel].proto.repeats)
Line 296... Line 297...
296
 
297
 
297
        case sns_irTransceive_STATE_PAUSING:
298
        case sns_irTransceive_STATE_PAUSING:
298
            if (Timer_Expired(irTxChannel[channel].timerNum))
299
            if (Timer_Expired(irTxChannel[channel].timerNum))
299
            {
300
            {
300
                irTxChannel[channel].state = sns_irTransceive_STATE_START_TRANSMIT;
301
                irTxChannel[channel].state = sns_irTransceive_STATE_START_TRANSMIT;
-
 
302
//      printf("4\n");
301
            }
303
            }
302
           
304
           
303
            /* transmission is stopped when such command is recevied on can */
305
            /* transmission is stopped when such command is recevied on can */
304
            if (irTxChannel[channel].stopSend == TRUE && irTxChannel[channel].repeatCount >= irTxChannel[channel].proto.repeats)
306
            if (irTxChannel[channel].stopSend == TRUE && irTxChannel[channel].repeatCount >= irTxChannel[channel].proto.repeats)
305
            {
307
            {
306
                //TODO maybe send message on can for status? to confirm stopped sending, ready for new command
308
                //TODO maybe send message on can for status? to confirm stopped sending, ready for new command
307
                irTxChannel[channel].state = sns_irTransceive_STATE_START_IDLE;
309
                irTxChannel[channel].state = sns_irTransceive_STATE_START_IDLE;
-
 
310
//      printf("5\n");
308
            }
311
            }
309
            break;
312
            break;
310
 
313
 
311
        case sns_irTransceive_STATE_START_IDLE:
314
        case sns_irTransceive_STATE_START_IDLE:
312
            irTxChannel[channel].stopSend = FALSE;
315
            irTxChannel[channel].stopSend = FALSE;
313
            irTxChannel[channel].repeatCount = 0;
316
            irTxChannel[channel].repeatCount = 0;
314
            irTxChannel[channel].proto.framecnt = 0;
317
            irTxChannel[channel].proto.framecnt = 0;
315
           
318
           
316
            irTxChannel[channel].state = sns_irTransceive_STATE_IDLE;
319
            irTxChannel[channel].state = sns_irTransceive_STATE_IDLE;
-
 
320
//      printf("6\n");
317
            break;
321
            break;
318
        }
322
        }
319
#endif
323
#endif
320
 
324
 
321
    }
325
    }