Subversion Repositories HomeAutomation

Rev

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

Rev 549 Rev 603
Line 4... Line 4...
4
#include <string.h>
4
#include <string.h>
5
#include <config.h> // All configuration parameters
5
#include <config.h> // All configuration parameters
6
#include <bios.h>   // BIOS interface declarations, including CAN structure and ID defines.
6
#include <bios.h>   // BIOS interface declarations, including CAN structure and ID defines.
7
//#include <drivers/uart/serial.h>
7
//#include <drivers/uart/serial.h>
8
#include <drivers/timer/timebase.h>
8
#include <drivers/timer/timebase.h>
-
 
9
#include <drivers/ir/transceiver/irtransceiver.h>
9
#include <drivers/ir/receiver/irreceiver.h>
10
//#include <drivers/ir/receiver/irreceiver.h>
10
 
11
 
11
#define APP_TYPE    CAN_APPTYPES_IRRECEIVER
12
#define APP_TYPE    CAN_APPTYPES_IRRECEIVER
12
#define APP_VERSION 0x0003
13
#define APP_VERSION 0x0003
13
 
14
 
14
#define STATE_IDLE      0
15
#define STATE_IDLE      0
Line 57... Line 58...
57
    //txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_IR << CAN_SHIFT_SNS_TYPE) | (IR_ID_DATA<<CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
58
    //txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_IR << CAN_SHIFT_SNS_TYPE) | (IR_ID_DATA<<CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
58
   
59
   
59
    unsigned long time = Timebase_CurrentTime();
60
    unsigned long time = Timebase_CurrentTime();
60
    unsigned long irTimeoutTime = 100;
61
    unsigned long irTimeoutTime = 100;
61
   
62
   
-
 
63
    uint8_t ir_protocol;
62
    uint8_t ir_protocol, ir_address, ir_command;
64
    //uint8_t ir_address, ir_command;
-
 
65
    uint32_t ir_data;
63
    uint16_t ir_timeout;
66
    uint16_t ir_timeout;
64
    uint8_t state = STATE_IDLE;
67
    uint8_t state = STATE_IDLE;
65
 
68
 
66
    while (1) {
69
    while (1) {
67
        time = Timebase_CurrentTime();
70
        time = Timebase_CurrentTime();
68
       
71
       
69
        if (state == STATE_IDLE) {
72
        if (state == STATE_IDLE) {
70
            /* test for irdata */
73
            /* test for irdata */
71
            uint8_t returnval = IrReceive_CheckIR(&ir_protocol, &ir_address, &ir_command, &ir_timeout);
74
            //uint8_t returnval = IrReceive_CheckIR(&ir_protocol, &ir_address, &ir_command, &ir_timeout);
-
 
75
            uint8_t returnval = IrReceive_CheckIR(&ir_protocol, &ir_data, &ir_timeout);
72
            if (returnval == IR_OK) {
76
            if (returnval == IR_OK) {
73
                /* a protocol was found for irdata, send on can */
77
                /* a protocol was found for irdata, send on can */
74
                txMsg.Data.bytes[0] = IR_BUTTON_DOWN;
78
                txMsg.Data.bytes[0] = IR_BUTTON_DOWN;
75
                txMsg.Data.bytes[1] = ir_protocol;
79
                txMsg.Data.bytes[1] = ir_protocol;
76
                txMsg.Data.bytes[2] = ir_address;
80
                txMsg.Data.bytes[2] = (ir_data>>24)&0xff;
-
 
81
                txMsg.Data.bytes[3] = (ir_data>>16)&0xff;
-
 
82
                txMsg.Data.bytes[4] = (ir_data>>8)&0xff;
77
                txMsg.Data.bytes[3] = ir_command;
83
                txMsg.Data.bytes[5] = ir_data&0xff;
78
                txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_IR << CAN_SHIFT_SNS_TYPE) | (IR_ID_DATA<<CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
84
                txMsg.Id = ((CAN_SNS << CAN_SHIFT_CLASS) | (SNS_TYPE_IR << CAN_SHIFT_SNS_TYPE) | (IR_ID_DATA<<CAN_SHIFT_SNS_ID) | (NODE_ID << CAN_SHIFT_SNS_SID));
79
                txMsg.DataLength = 4;
85
                txMsg.DataLength = 6;
80
                BIOS_CanSend(&txMsg);
86
                BIOS_CanSend(&txMsg);
81
               
87
               
82
                /* set up timeout */
88
                /* set up timeout */
83
                irTimeoutTime = Timebase_CurrentTime();
89
                irTimeoutTime = Timebase_CurrentTime();
84
                state = STATE_IR_REPEAT;
90
                state = STATE_IR_REPEAT;