Subversion Repositories HomeAutomation

Rev

Rev 254 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 254 Rev 258
Line 89... Line 89...
89
}
89
}
90
 
90
 
91
void Can_Process(Can_Message_t* msg) {
91
void Can_Process(Can_Message_t* msg) {
92
    if (!(msg->ExtendedFlag)) return;
92
    if (!(msg->ExtendedFlag)) return;
93
   
93
   
94
    if ((msg->Id & (CAN_MASK_CLASS | CAN_MASK_NMT_RID)) ==
94
    //applikationen ska bara ta hand om paket som inte är nmt så else:et nedan kommer om det inte är nmt enbart
95
                ((uint32_t)CAN_NMT << CAN_SHIFT_CLASS |
95
    if ((msg->Id & CAN_MASK_CLASS) == ((uint32_t)CAN_NMT << CAN_SHIFT_CLASS)) {
96
                 (uint32_t)NODE_ID << CAN_SHIFT_NMT_RID)) {
96
        if ((msg->Id & CAN_MASK_NMT_RID) == ((uint32_t)NODE_ID << CAN_SHIFT_NMT_RID)) {
97
        //printf("BIOS received msg!\n");
97
            //printf("BIOS received msg!\n");
98
        if ((msg->Id & CAN_MASK_NMT_TYPE)>>CAN_SHIFT_NMT_TYPE == CAN_NMT_RESET) {
98
            if ((msg->Id & CAN_MASK_NMT_TYPE)>>CAN_SHIFT_NMT_TYPE == CAN_NMT_RESET) {
99
            reset();
99
                reset();
100
        }
100
            }
101
        // Copy message to bios buffer if bios is done with the previous message.
101
            // Copy message to bios buffer if bios is done with the previous message.
Line 107... Line 107...
107
            bios_msg_full = 1;
107
                bios_msg_full = 1;
108
        }      
108
            }      
109
    } else if (bios->can_callback) {
109
        } else if (bios->can_callback) {
110
        //printf("Calling app callback.\n");
110
            //printf("Calling app callback.\n");
111
        bios->can_callback(msg);
111
            bios->can_callback(msg);
-
 
112
        }
112
    }
113
    }
113
}
114
}
114
 
115
 
115
#define BIOS_APP    1
116
#define BIOS_APP    1
116
#define BIOS_NOAPP  2
117
#define BIOS_NOAPP  2
Line 164... Line 165...
164
        bios_state = BIOS_NOAPP;
165
        bios_state = BIOS_NOAPP;
165
    } else {
166
    } else {
166
        // Application exists
167
        // Application exists
167
        //send CAN_NMT_BIOS_START(BIOS_VERSION, 1)
168
        //send CAN_NMT_BIOS_START(BIOS_VERSION, 1)
168
        tx_msg.Data.bytes[2] = 1;
169
        tx_msg.Data.bytes[2] = 1;
-
 
170
        //for now, set state to BIOS_NOAPP to be able to reprogram application
169
        bios_state = BIOS_APP;
171
        bios_state = BIOS_NOAPP;
170
    }
172
    }
171
   
173
   
172
    while (Can_Send(&tx_msg) != CAN_OK);
174
    while (Can_Send(&tx_msg) != CAN_OK);
173
 
175
 
174
    tx_msg.DataLength = 2;
176
    tx_msg.DataLength = 2;