?? can.lst
字號:
212 1 /// - 8 valid data bytes
213 1 /// - this message object works with CAN node A
214 1 /// - remote monitoring is disabled
215 1 /// - receive interrupt node pointer: TwinCAN SRN 0
216 1
217 1 CAN_MSGCFGL0 = 0x0080; // load message configuration register low
218 1 CAN_MSGCFGH0 = 0x0000; // load message configuration register high
219 1
220 1 /// - acceptance mask 11-bit: 0x708
221 1 /// - identifier 11-bit: 0x200
222 1
223 1 CAN_MSGAMRL0 = 0x0000; // load acceptance mask register low
224 1 CAN_MSGAMRH0 = 0xFC20; // load acceptance mask register high
225 1 CAN_MSGARL0 = 0x0000; // load arbitration register low
226 1 CAN_MSGARH0 = 0x0800; // load arbitration register high
227 1 CAN_MSGDRL00 = 0x0000; // load data register 0 low
228 1 CAN_MSGDRH00 = 0x0000; // load data register 0 high
229 1 CAN_MSGDRL04 = 0x0000; // load data register 4 low
230 1 CAN_MSGDRH04 = 0x0000; // load data register 4 high
231 1
232 1 /// - functionality of standard message object
233 1
234 1 CAN_MSGFGCRL0 = 0x0000; // load FIFO/gateway control register low
235 1 CAN_MSGFGCRH0 = 0x0000; // load FIFO/gateway control register high
236 1
237 1 CAN_MSGCTRH0 = 0x0000; // load message control register high
238 1 CAN_MSGCTRL0 = 0x5599; // load message control register low
239 1
240 1 /// -----------------------------------------------------------------------
241 1 /// Configuration of Message Object 1:
C166 COMPILER V6.04, CAN 04/06/2009 22:15:28 PAGE 5
242 1 /// -----------------------------------------------------------------------
243 1 /// - message object 1 is valid
244 1
245 1 /// - message object is used as transmit object
246 1 /// - standard 11-bit identifier
247 1 /// - 8 valid data bytes
248 1 /// - this message object works with CAN node A
249 1 /// - remote monitoring is disabled
250 1
251 1 CAN_MSGCFGL1 = 0x0088; // load message configuration register low
252 1 CAN_MSGCFGH1 = 0x0000; // load message configuration register high
253 1
254 1 /// - acceptance mask 11-bit: 0x7FF
255 1 /// - identifier 11-bit: 0x110
256 1
257 1 CAN_MSGAMRL1 = 0xFFFF; // load acceptance mask register low
258 1 CAN_MSGAMRH1 = 0xFFFF; // load acceptance mask register high
259 1 CAN_MSGARL1 = 0x0000; // load arbitration register low
260 1 CAN_MSGARH1 = 0x0440; // load arbitration register high
261 1 CAN_MSGDRL10 = 0xFD00; // load data register 0 low
262 1 CAN_MSGDRH10 = 0x0000; // load data register 0 high
263 1 CAN_MSGDRL14 = 0x0000; // load data register 4 low
264 1 CAN_MSGDRH14 = 0xAA00; // load data register 4 high
265 1
266 1 /// - functionality of standard message object
267 1
268 1 CAN_MSGFGCRL1 = 0x0000; // load FIFO/gateway control register low
269 1 CAN_MSGFGCRH1 = 0x0001; // load FIFO/gateway control register high
270 1
271 1 CAN_MSGCTRH1 = 0x0000; // load message control register high
272 1 CAN_MSGCTRL1 = 0x5595; // load message control register low
273 1
274 1
275 1 /// -----------------------------------------------------------------------
276 1 /// Configuration of Service Request Nodes 0 - 7:
277 1 /// -----------------------------------------------------------------------
278 1 /// SRN0 service request node configuration:
279 1 /// - SRN0 interrupt priority level (ILVL) = 10
280 1 /// - SRN0 interrupt group level (GLVL) = 1
281 1 /// - SRN0 group priority extension (GPX) = 0
282 1
283 1 CAN_0IC = 0x0069;
284 1
285 1
286 1
287 1 // USER CODE BEGIN (Init,3)
288 1
289 1 // USER CODE END
290 1
291 1
292 1 CAN_PISEL = 0x0000; // load port input select register
293 1
294 1 // -----------------------------------------------------------------------
295 1 // Start the CAN Nodes:
296 1 // -----------------------------------------------------------------------
297 1
298 1 CAN_ACR &= ~(uword)0x0041; // reset INIT and CCE
299 1
300 1
301 1 // USER CODE BEGIN (Init,4)
302 1
303 1 // USER CODE END
C166 COMPILER V6.04, CAN 04/06/2009 22:15:28 PAGE 6
304 1
305 1 } // End of function CAN_vInit
306
307
308 //****************************************************************************
309 // @Function void CAN_vGetMsgObj(ubyte ubObjNr, TCAN_SWObj *pstObj)
310 //
311 //----------------------------------------------------------------------------
312 // @Description This function fills the forwarded SW message object with
313 // the content of the chosen HW message object.
314 //
315 // The structure of the SW message object is defined in the
316 // header file CAN.H (see TCAN_SWObj).
317 //
318 //----------------------------------------------------------------------------
319 // @Returnvalue None
320 //
321 //----------------------------------------------------------------------------
322 // @Parameters ubObjNr:
323 // Number of the message object to be read (0-31)
324 // @Parameters *pstObj:
325 // Pointer on a message object to be filled by this function
326 //
327 //----------------------------------------------------------------------------
328 // @Date 2009-4-4
329 //
330 //****************************************************************************
331
332 // USER CODE BEGIN (GetMsgObj,1)
333
334 // USER CODE END
335
336 void CAN_vGetMsgObj(ubyte ubObjNr, TCAN_SWObj *pstObj)
337 {
338 1 ubyte i;
339 1
340 1 for(i = 0; i < (CAN_HWOBJ[ubObjNr].uwMSGCFG & 0x00f0) >> 4; i++)
341 1 {
342 2 pstObj->ubData[i] = CAN_HWOBJ[ubObjNr].ubData[i];
343 2 }
344 1
345 1 if(CAN_HWOBJ[ubObjNr].uwMSGCFG & 0x04) // extended identifier
346 1 {
347 2 pstObj->ulID = CAN_HWOBJ[ubObjNr].ulCANAR;
348 2 pstObj->ulMask = CAN_HWOBJ[ubObjNr].ulCANAMR;
349 2 }
350 1 else // standard identifier
351 1 {
352 2 pstObj->ulID = CAN_HWOBJ[ubObjNr].ulCANAR >> 18;
353 2 pstObj->ulMask = CAN_HWOBJ[ubObjNr].ulCANAMR >> 18;
354 2 }
355 1
356 1 pstObj->uwCounter = CAN_HWOBJ[ubObjNr].uwCounter;
357 1 pstObj->uwMsgCfg = CAN_HWOBJ[ubObjNr].uwMSGCFG;
358 1
359 1 } // End of function CAN_vGetMsgObj
360
361
362 //****************************************************************************
363 // @Function void CAN_vTransmit(ubyte ubObjNr)
364 //
365 //----------------------------------------------------------------------------
C166 COMPILER V6.04, CAN 04/06/2009 22:15:28 PAGE 7
366 // @Description This function triggers the CAN controller to send the
367 // selected message.
368 // If the selected message object is a TRANSMIT OBJECT then
369 // this function triggers the sending of a data frame. If
370 // however the selected message object is a RECEIVE OBJECT
371 // this function triggers the sending of a remote frame.
372 //
373 //----------------------------------------------------------------------------
374 // @Returnvalue None
375 //
376 //----------------------------------------------------------------------------
377 // @Parameters ubObjNr:
378 // Number of the message object (0-31)
379 //
380 //----------------------------------------------------------------------------
381 // @Date 2009-4-4
382 //
383 //****************************************************************************
384
385 // USER CODE BEGIN (Transmit,1)
386
387 // USER CODE END
388
389 void CAN_vTransmit(ubyte ubObjNr)
390 {
391 1 CAN_HWOBJ[ubObjNr].uwMSGCTR = 0xe7ff; // set TXRQ, reset CPUUPD
392 1
393 1 } // End of function CAN_vTransmit
394
395
396 //****************************************************************************
397 // @Function void CAN_viSRN0(void)
398 //
399 //----------------------------------------------------------------------------
400 // @Description This is the interrupt service routine for the Service
401 // Request Node 0 of the TwinCAN module.
402 //
403 //----------------------------------------------------------------------------
404 // @Returnvalue None
405 //
406 //----------------------------------------------------------------------------
407 // @Parameters None
408 //
409 //----------------------------------------------------------------------------
410 // @Date 2009-4-4
411 //
412 //****************************************************************************
413
414 // USER CODE BEGIN (SRN0,1)
415
416 // USER CODE END
417
418 void CAN_viSRN0(void) interrupt CAN_SRN0INT
419 {
420 1 uword uwStatusA;
421 1
422 1 // USER CODE BEGIN (SRN0,2)
423 1 unsigned char i=0;
424 1 // USER CODE END
425 1
426 1 while((( ((ulong)CAN_RXIPNDH << 16) + CAN_RXIPNDL) & 0x00000001) || (CAN_ASR & 0x0018))
427 1 {
C166 COMPILER V6.04, CAN 04/06/2009 22:15:28 PAGE 8
428 2
429 2 // status change interrupt of node A
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -