Subversion Repositories HomeAutomation

Rev

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

Rev 800 Rev 801
Line 80... Line 80...
80
         * message in the queue.
80
         * message in the queue.
81
         */
81
         */
82
    }
82
    }
83
}
83
}
84
 
84
 
85
StdCan_Ret_t StdCan_Init(Node_Desc_t* node_desc)
85
StdCan_Ret_t StdCan_Init()
86
{
86
{
87
    StdCan_Ret_t retval;
87
    StdCan_Ret_t retval;
88
   
88
   
89
    /* Reset all queue variables. */
89
    /* Reset all queue variables. */
90
    RxQ_Rd_idx = 0;
90
    RxQ_Rd_idx = 0;
Line 118... Line 118...
118
   
118
   
119
    /* Set up Startup message format. */
119
    /* Set up Startup message format. */
120
    Startup.ExtendedFlag = 1;
120
    Startup.ExtendedFlag = 1;
121
    Startup.RemoteFlag = 0;
121
    Startup.RemoteFlag = 0;
122
    Startup.DataLength = 4;
122
    Startup.DataLength = 4;
123
    Startup.Id = (CAN_NMT_APP_START << CAN_SHIFT_NMT_TYPE) | (NODE_ID << CAN_SHIFT_NMT_SID);
123
    Startup.Id = (CAN_NMT << CAN_SHIFT_CLASS) | (CAN_NMT_APP_START << CAN_SHIFT_NMT_TYPE);
124
    Startup.Data.bytes[1] = APP_TYPE&0xff;
124
    Startup.Data.bytes[0] = NODE_HW_ID&0xff;
125
    Startup.Data.bytes[0] = (APP_TYPE>>8)&0xff;
125
    Startup.Data.bytes[1] = (NODE_HW_ID>>8)&0xff;
126
    Startup.Data.bytes[3] = APP_VERSION&0xff;
126
    Startup.Data.bytes[2] = (NODE_HW_ID>>16)&0xff;
127
    Startup.Data.bytes[2] = (APP_VERSION>>8)&0xff;
127
    Startup.Data.bytes[3] = (NODE_HW_ID>>24)&0xff;
128
   
128
   
129
    /* Try to send it. */
129
    /* Try to send it. */
130
    Can_Send(&Startup);
130
    Can_Send(&Startup);
131
#endif
131
#endif
132
   
132
   
Line 183... Line 183...
183
    Can_Msg.DataLength = msg->Length;
183
    Can_Msg.DataLength = msg->Length;
184
    for (n = 0; n < msg->Length; n++) {
184
    for (n = 0; n < msg->Length; n++) {
185
        Can_Msg.Data.bytes[n] = msg->Data[n];
185
        Can_Msg.Data.bytes[n] = msg->Data[n];
186
    }
186
    }
187
   
187
 
188
    if (Can_Send(&Can_Msg) == CAN_OK)
188
    if (Can_Send(&Can_Msg) == CAN_OK) {
-
 
189
        Can_Process(&Can_Msg);
189
        return StdCan_Ret_OK;
190
        return StdCan_Ret_OK;
-
 
191
    }
190
    else
192
    else
191
        return StdCan_Ret_Full;
193
        return StdCan_Ret_Full;
192
}
194
}
193
 
195
 
194
void StdCan_SendHeartbeat(uint8_t n)
196
void StdCan_SendHeartbeat(uint8_t n)
Line 199... Line 201...
199
    Can_Message_t Heartbeat;
201
    Can_Message_t Heartbeat;
200
   
202
   
201
    /* Set up Heartbeat message format. */
203
    /* Set up Heartbeat message format. */
202
    Heartbeat.ExtendedFlag = 1;
204
    Heartbeat.ExtendedFlag = 1;
203
    Heartbeat.RemoteFlag = 0;
205
    Heartbeat.RemoteFlag = 0;
204
    Heartbeat.DataLength = 0;
206
    Heartbeat.DataLength = 4;
205
    Heartbeat.Id = (CAN_NMT << CAN_SHIFT_CLASS)
207
    Heartbeat.Id = (CAN_NMT << CAN_SHIFT_CLASS) | (CAN_NMT_HEARTBEAT << CAN_SHIFT_NMT_TYPE);
206
                 | (CAN_NMT_HEARTBEAT << CAN_SHIFT_NMT_TYPE)
208
    Heartbeat.Data.bytes[0] = NODE_HW_ID&0xff;
-
 
209
    Heartbeat.Data.bytes[1] = (NODE_HW_ID>>8)&0xff;
-
 
210
    Heartbeat.Data.bytes[2] = (NODE_HW_ID>>16)&0xff;
207
                 | (NODE_ID << CAN_SHIFT_NMT_SID);
211
    Heartbeat.Data.bytes[3] = (NODE_HW_ID>>24)&0xff;
208
   
212
   
209
    /* Try to send it. */
213
    /* Try to send it. */
210
    Can_Send(&Heartbeat);
214
    Can_Send(&Heartbeat);
211
}
215
}
212
 
216