iLLD_TC27xC  1.0
IfxMultican_Can.h
Go to the documentation of this file.
1 /**
2  * \file IfxMultican_Can.h
3  * \brief MULTICAN CAN details
4  * \ingroup IfxLld_Multican
5  *
6  * \version iLLD_0_1_0_10
7  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8  *
9  *
10  * IMPORTANT NOTICE
11  *
12  *
13  * Infineon Technologies AG (Infineon) is supplying this file for use
14  * exclusively with Infineon's microcontroller products. This file can be freely
15  * distributed within development tools that are supporting such microcontroller
16  * products.
17  *
18  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23  *
24  * \defgroup IfxLld_Multican_Can_Usage How to use the CAN Interface driver?
25  * \ingroup IfxLld_Multican
26  *
27  * The CAN interface driver provides a default configuration for various modes.
28  *
29  * In the following sections it will be described, how to integrate the driver into the application framework.
30  *
31  * \section IfxLld_Multican_Can_Preparation Preparation
32  * \subsection IfxLld_Multican_Can_Include Include Files
33  *
34  * Include following header file into your C code:
35  * \code
36  * #include <Multican/Can/IfxMultican_Can.h>
37  * \endcode
38  *
39  * \subsection IfxLld_Multican_Can_Variables Variables
40  *
41  * Declare the CAN handles as global variables in your C code:
42  * \code
43  * // CAN handle
44  * IfxMultican_Can can;
45  *
46  * // Two Nodes (for external loopback demo)
47  * IfxMultican_Can_Node canSrcNode;
48  * IfxMultican_Can_Node canDstNode;
49  *
50  * // Two Message objects (for external loopback demo)
51  * IfxMultican_Can_MsgObj canSrcMsgObj;
52  * IfxMultican_Can_MsgObj canDstMsgObj;
53  * \endcode
54  *
55  * \subsection IfxLld_Multican_Can_Init Module Initialisation
56  *
57  * The module initialisation can be done as followed:
58  * \code
59  * // create configuration
60  * IfxMultican_Can_Config canConfig;
61  * IfxMultican_Can_initModuleConfig(&canConfig, &MODULE_CAN);
62  *
63  * // initialize module
64  * // IfxMultican_Can can; // defined globally
65  * IfxMultican_Can_initModule(&can, &canConfig);
66  * \endcode
67  *
68  * \subsection IfxLld_Multican_Can_InitNode Node Initialisation
69  *
70  * The Can nodes initialisation can be done as followed:
71  *
72  * \code
73  * // create CAN node config
74  * IfxMultican_Can_NodeConfig canNodeConfig;
75  * IfxMultican_Can_Node_initConfig(&canNodeConfig, &can);
76  *
77  * canNodeConfig.baudrate = 1000000; // 1 MBaud
78  *
79  * // Source Node
80  * // IfxMultican_Can_Node canSrcNode; // defined globally
81  * {
82  * canNodeConfig.nodeId = IfxMultican_NodeId_0;
83  * canNodeConfig.rxPin = IfxMultican_RXD0A_P02_1_IN;
84  * canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
85  * canNodeConfig.txPin = IfxMultican_TXD0_P02_0_OUT;
86  * canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
87  *
88  * // initialise the node
89  * IfxMultican_Can_Node_init(&canSrcNode, &canNodeConfig);
90  * }
91  *
92  * // Destination Node
93  * // IfxMultican_Can_Node canDstNode; // defined globally
94  * {
95  * canNodeConfig.nodeId = IfxMultican_NodeId_1;
96  * canNodeConfig.rxPin = IfxMultican_RXD1B_P14_1_IN;
97  * canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
98  * canNodeConfig.txPin = IfxMultican_TXD1_P14_0_OUT;
99  * canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
100  *
101  * // initialise the node
102  * IfxMultican_Can_Node_init(&canDstNode, &canNodeConfig);
103  * }
104  * \endcode
105  *
106  * \subsection IfxLld_Multican_Can_InitMessageObject Message Object Initialisation
107  *
108  * The Can message objects initialisation can be done as followed:
109  *
110  * \code
111  * const unsigned id = 0x100 ;
112  *
113  * // IfxMultican_Can_MsgObj canSrcMsgObj; // defined globally
114  * {
115  * // create message object config
116  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
117  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
118  *
119  * // assigned message object:
120  * canMsgObjConfig.msgObjId = 0;
121  *
122  * canMsgObjConfig.messageId = id;
123  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
124  * canMsgObjConfig.frame = IfxMultican_Frame_transmit;
125  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
126  * canMsgObjConfig.control.extendedFrame = FALSE;
127  * canMsgObjConfig.control.matchingId = TRUE;
128  *
129  * // initialize message object
130  * IfxMultican_Can_MsgObj_init(&canSrcMsgObj, &canMsgObjConfig);
131  * }
132  *
133  * // IfxMultican_Can_MsgObj canDstMsgObj; // defined globally
134  * {
135  * // create message object config
136  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
137  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
138  *
139  * // assigned message object:
140  * canMsgObjConfig.msgObjId = 1;
141  *
142  * canMsgObjConfig.messageId = id;
143  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
144  * canMsgObjConfig.frame = IfxMultican_Frame_receive;
145  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
146  * canMsgObjConfig.control.extendedFrame = FALSE;
147  * canMsgObjConfig.control.matchingId = TRUE;
148  *
149  * // initialize message object
150  * IfxMultican_Can_MsgObj_init(&canDstMsgObj, &canMsgObjConfig);
151  * }
152  * \endcode
153  *
154  * The MULTICAN is ready for use now!
155  *
156  *
157  * \section IfxLld_Multican_Can_StandardDataTransfers Single Data Transfers
158  *
159  * The CAN driver provides simple to use transfer functions
160  *
161  * Data can be sent by the following way:
162  * \code
163  * const unsigned dataLow = 0x12345678;
164  * const unsigned dataLow = 0x9abcdef0;
165  *
166  * // Initialise the message strcture
167  * IfxMultican_Message msg;
168  * IfxMultican_Message_init(&msg, id, dataLow, dataHigh, IfxMultican_DataLengthCode_8);
169  *
170  * // Transmit Data
171  * while( IfxMultican_Can_MsgObj_sendMessage(&canSrcMsgObj, &msg) == IfxMultican_Status_notSentBusy );
172  * \endcode
173  *
174  * Data can be received by the following way:
175  * \code
176  * // Receiving Data
177  *
178  * // Initialise the message structure with dummy values, will be replaced by the received values
179  * IfxMultican_Message msg;
180  * IfxMultican_Message_init(&msg, 0xdead, 0xdeadbeef, 0xdeadbeef, IfxMultican_DataLengthCode_8); // start with invalid values
181  *
182  * // wait until Multican received a new message
183  * while( !IfxMultican_Can_MsgObj_isRxPending(&canDstMsgObj) );
184  *
185  * // read message
186  * IfxMultican_Status readStatus = IfxMultican_Can_MsgObj_readMessage(&canDstMsgObj, &msg);
187  *
188  * if( readStatus != IfxMultican_Status_noError ) {
189  * clib_ver_printf("ERROR: IfxMultican_Can_MsgObj_readMessage returned 0x%04x\n", readStatus);
190  * result |= 1;
191  * }
192  *
193  * // data now available at msg.data[0] and msg.data[1]
194  * \endcode
195  *
196  *
197  * \section IfxLld_Multican_Can_FIFOBasedTransfers FIFO based Transfers
198  *
199  * A transmit and receive FIFO can be enabled during the node configuration by specifing the number of allocated message objects with the canMsgObjConfig.msgObjCount item.
200  * and specifying the message object number of first slave object with the canMsgObjConfig.firstSlaveObjId item.
201  *
202  * Message objects will be allocated to the FIFO in ascending order.
203  *
204  * Here a configuration example:
205  * \code
206  * #define RX_FIFO_SIZE 16
207  * #define TX_FIFO_SIZE 8
208  *
209  * const unsigned id = 0x100 ;
210  *
211  * // IfxMultican_Can_MsgObj canSrcMsgObj; // defined globally
212  * {
213  * // create message object config
214  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
215  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
216  *
217  * // FIFO MsgObj allocation:
218  * canMsgObjConfig.msgObjId = 0; // will allocate MsgObj 0
219  * canMsgObjConfig.msgObjCount = TX_FIFO_SIZE;
220  * canMsgObjConfig.firstSlaveObjId = 1; // will allocate MsgObj 1..8 for the FIFO
221  *
222  * canMsgObjConfig.messageId = id;
223  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
224  * canMsgObjConfig.frame = IfxMultican_Frame_transmit;
225  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
226  * canMsgObjConfig.control.extendedFrame = FALSE;
227  * canMsgObjConfig.control.matchingId = TRUE;
228  *
229  * // initialize message object
230  * IfxMultican_Can_MsgObj_init(&canSrcMsgObj, &canMsgObjConfig);
231  * }
232  *
233  * // IfxMultican_Can_MsgObj canDstMsgObj; // defined globally
234  * {
235  * // create message object config
236  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
237  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
238  *
239  * // FIFO MsgObj allocation:
240  * canMsgObjConfig.msgObjId = 9; // because the Tx FIFO allocated MsgObj 0..8
241  * canMsgObjConfig.msgObjCount = RX_FIFO_SIZE;
242  *
243  * canMsgObjConfig.firstSlaveObjId = 10; // will allocate MsgObj 10..25
244  *
245  * canMsgObjConfig.messageId = id;
246  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
247  * canMsgObjConfig.frame = IfxMultican_Frame_receive;
248  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
249  * canMsgObjConfig.control.extendedFrame = FALSE;
250  * canMsgObjConfig.control.matchingId = TRUE;
251  *
252  * // initialize message object
253  * IfxMultican_Can_MsgObj_init(&canDstMsgObj, &canMsgObjConfig);
254  * }
255  * \endcode
256  *
257  * Data can now be sent and received with the IfxMultican_Can_MsgObj_sendMessage and IfxMultican_Can_MsgObj_readMessage functions as usual (see above).
258  *
259  *
260  * \section IfxLld_Multican_Can_FDDataTransfers CAN FD Data Transfers
261  *
262  * The CAN driver provides simple to use FD transfer functions
263  *
264  * Node configuration:
265  * \code
266  * // create CAN node config
267  * IfxMultican_Can_NodeConfig canNodeConfig;
268  * IfxMultican_Can_Node_initConfig(&canNodeConfig, &can);
269  *
270  * canNodeConfig.baudrate = 1000000; // 1 MBaud
271  *
272  * // Source Node
273  * // IfxMultican_Can_Node canSrcNode; // defined globally
274  * {
275  * canNodeConfig.nodeId = IfxMultican_NodeId_0;
276  * canNodeConfig.rxPin = IfxMultican_RXD0A_P02_1_IN;
277  * canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
278  * canNodeConfig.txPin = IfxMultican_TXD0_P02_0_OUT;
279  * canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
280  *
281  * // choose CAN FD transfer enable or disable //
282  * canNodeConfig.flexibleDataRate = TRUE;
283  *
284  * // if CAN FD enabled choose the FD configuration //
285  * canNodeConfig.fdConfig.nominalBaudrate = 500000;
286  * canNodeConfig.fdConfig.nominalSynchJumpWidth = 8000;
287  * canNodeConfig.fdConfig.nominalSamplePoint = 2000;
288  * canNodeConfig.fdConfig.fastBaudrate = 1000000;
289  * canNodeConfig.fdConfig.fastSynchJumpWidth = 8000;
290  * canNodeConfig.fdConfig.fastSamplePoint = 2000;
291  * canNodeConfig.fdConfig.loopDelayOffset = 0;
292  *
293  * // initialise the node
294  * IfxMultican_Can_Node_init(&canSrcNode, &canNodeConfig);
295  * }
296  *
297  * // Destination Node
298  * // IfxMultican_Can_Node canDstNode; // defined globally
299  * {
300  * canNodeConfig.nodeId = IfxMultican_NodeId_1;
301  * canNodeConfig.rxPin = IfxMultican_RXD1B_P14_1_IN;
302  * canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
303  * canNodeConfig.txPin = IfxMultican_TXD1_P14_0_OUT;
304  * canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
305  *
306  * // choose CAN FD transfer enable or disable //
307  * config->flexibleDataRate = TRUE;
308  *
309  * // if CAN FD enabled choose the FD configuration //
310  * canNodeConfig.fdConfig.nominalBaudrate = 500000;
311  * canNodeConfig.fdConfig.nominalSynchJumpWidth = 8000;
312  * canNodeConfig.fdConfig.nominalSamplePoint = 2000;
313  * canNodeConfig.fdConfig.fastBaudrate = 1000000;
314  * canNodeConfig.fdConfig.fastSynchJumpWidth = 8000;
315  * canNodeConfig.fdConfig.fastSamplePoint = 2000;
316  * canNodeConfig.fdConfig.loopDelayOffset = 0;
317  *
318  * // initialise the node
319  * IfxMultican_Can_Node_init(&canDstNode, &canNodeConfig);
320  * }
321  * \endcode
322  *
323  * The CAN FD message objects initialisation can be done as followed:
324  *
325  * \code
326  * const unsigned id = 0x100 ;
327  *
328  * // IfxMultican_Can_MsgObj canSrcMsgObj; // defined globally
329  * {
330  * // create message object config
331  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
332  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
333  *
334  * // assigned message object:
335  * canMsgObjConfig.msgObjId = 0;
336  *
337  * canMsgObjConfig.messageId = id;
338  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
339  * canMsgObjConfig.frame = IfxMultican_Frame_transmit;
340  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
341  * canMsgObjConfig.control.extendedFrame = FALSE;
342  * canMsgObjConfig.control.matchingId = TRUE;
343  *
344  * canMsgObjConfig.control.topMsgObjId = 252;
345  * canMsgObjConfig.control.bottomMsgObjId = 253;
346  * canMsgObjConfig.control.fastBitRate = TRUE; // fast bit rate enable/disable
347  *
348  * // initialize message object
349  * IfxMultican_Can_MsgObj_init(&canSrcMsgObj, &canMsgObjConfig);
350  * }
351  *
352  * // IfxMultican_Can_MsgObj canDstMsgObj; // defined globally
353  * {
354  * // create message object config
355  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
356  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
357  *
358  * // assigned message object:
359  * canMsgObjConfig.msgObjId = 1;
360  *
361  * canMsgObjConfig.messageId = id;
362  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
363  * canMsgObjConfig.frame = IfxMultican_Frame_receive;
364  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
365  * canMsgObjConfig.control.extendedFrame = FALSE;
366  * canMsgObjConfig.control.matchingId = TRUE;
367  *
368  * canMsgObjConfig.control.topMsgObjId = 250;
369  * canMsgObjConfig.control.bottomMsgObjId = 251;
370  * canMsgObjConfig.control.fastBitRate = TRUE; // fast bit rate enable/disable
371  *
372  * // initialize message object
373  * IfxMultican_Can_MsgObj_init(&canDstMsgObj, &canMsgObjConfig);
374  * }
375  * \endcode
376  *
377  *
378  * In case of standard messages data can be sent and received with the IfxMultican_Can_MsgObj_sendMessage and IfxMultican_Can_MsgObj_readMessage functions as usual (see above).
379  *
380  * In case of long frames of length more than 8 bytes
381  * the data can be sent by the following way
382  *
383  * \code
384  * // load txData buffer with the data that needs to be send
385  * // txData is assumed to be declared globally
386  * int i;
387  * for (i = 0; i < 16; ++i)
388  * {
389  * txData[i] = (0x11110000 + i);
390  * }
391  *
392  * // Initialise the message strcture
393  * IfxMultican_Message msg;
394  * IfxMultican_Message_longFrameInit(&msg, id, IfxMultican_DataLengthCode_64, FALSE);
395  *
396  * // Transmit Data
397  * while( IfxMultican_Can_MsgObj_sendlongFrame(&canSrcMsgObj, &msg, &txData) == IfxMultican_Status_notSentBusy );
398  * \endcode
399  *
400  * You can recieve the data by the following way
401  *
402  * \code
403  * // Receiving Data
404  *
405  * // Initialise the message strcture with dummy values, will be replaced by the received values
406  * IfxMultican_Message msg;
407  * IfxMultican_Message_longFrameInit(&msg, 0xdead, IfxMultican_DataLengthCode_64, FALSE); // start with invalid values
408  *
409  * // wait until Multican received a new message
410  * while( !IfxMultican_Can_MsgObj_isRxPending(&canDstMsgObj) );
411  *
412  *
413  * // read the message
414  * //rxData is assumed to be declared globally
415  * IfxMultican_Status readStatus = IfxMultican_Can_MsgObj_readLongFrame(&canDstMsgObj, &msg, &rxData);
416  *
417  * if( readStatus != IfxMultican_Status_noError ) {
418  * clib_ver_printf("ERROR: IfxMultican_Can_MsgObj_readMessage returned 0x%04x\n", readStatus);
419  * result |= 1;
420  * }
421  *
422  * // clear pending flag
423  * IfxMultican_Can_MsgObj_clearRxPending(&canDstMsgObj);
424  * \endcode
425  *
426  *
427  * \section IfxLld_Multican_Can_GatewayTransfers Gateway Transfers
428  *
429  * A Gateway source object can be enabled during the message object configuration by specifing with the canMsgObjConfig.gatewayTransfersEnable item.
430  *
431  * Here a configuration example:
432  * \code
433  * // source message object
434  * // IfxMultican_Can_MsgObj canSrcMsgObj; // defined globally
435  * {
436  * // create message object config
437  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
438  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
439  *
440  * canMsgObjConfig.msgObjId = 0;
441  * canMsgObjConfig.messageId = id;
442  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
443  * canMsgObjConfig.frame = IfxMultican_Frame_transmit;
444  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
445  * canMsgObjConfig.control.extendedFrame = FALSE;
446  * canMsgObjConfig.control.matchingId = TRUE;
447  * canMsgObjConfig.gatewayTransfers = FALSE;
448  *
449  * // initialize message object
450  * IfxMultican_Can_MsgObj_init(&canSrcMsgObj, &canMsgObjConfig);
451  * }
452  *
453  * // gateway source message object //
454  * // data will be received into this object from SrcObj, and then copied into gateway destination object //
455  * IfxMultican_Can_MsgObj canGatewaySrcMsgObj;
456  * {
457  * // create message object config
458  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
459  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
460  *
461  * canMsgObjConfig.msgObjId = 1;
462  * canMsgObjConfig.messageId = id;
463  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
464  * canMsgObjConfig.frame = IfxMultican_Frame_receive;
465  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
466  * canMsgObjConfig.control.extendedFrame = FALSE;
467  * canMsgObjConfig.control.matchingId = TRUE;
468  * canMsgObjConfig.gatewayTransfers = TRUE;
469  * canMsgObjConfig.gatewayConfig.copyDataLengthCode = TRUE;
470  * canMsgObjConfig.gatewayConfig.copyData = TRUE;
471  * canMsgObjConfig.gatewayConfig.copyId = FALSE;
472  * canMsgObjConfig.gatewayConfig.enableTransmit = TRUE; // if this is not choosen, then no need to initialise canDstMsgObj to read the final data
473  * canMsgObjConfig.gatewayConfig.gatewayDstObjId = 3; // specify the destination object number
474  *
475  * // initialize message object
476  * IfxMultican_Can_MsgObj_init(&canGatewaySrcMsgObj, &canMsgObjConfig);
477  * }
478  *
479  * // gateway destination object //
480  * // data, id , datlength code will be copied from GatewaySrcObj into this object through gateway transfers //
481  * // and then sent onto the bus for sending the message to destination message object //
482  * IfxMultican_Can_MsgObj canGatewayDstMsgObj;
483  * {
484  * // create message object config
485  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
486  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
487  *
488  * canMsgObjConfig.msgObjId = 3;
489  * canMsgObjConfig.messageId = 0x200;
490  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
491  * canMsgObjConfig.frame = IfxMultican_Frame_transmit;
492  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_4;
493  * canMsgObjConfig.control.extendedFrame = FALSE;
494  * canMsgObjConfig.control.matchingId = TRUE;
495  * canMsgObjConfig.gatewayTransfers = FALSE;
496  *
497  * // initialize message object
498  * IfxMultican_Can_MsgObj_init(&canGatewayDstMsgObj, &canMsgObjConfig);
499  * }
500  *
501  * // destination message object, not needed if enableTransmit is not chosen in gateway source object, or you don't want to read the data//
502  * // data will be received from GatewayDstObj into this obj //
503  * // IfxMultican_Can_MsgObj canDstMsgObj; // defined globally
504  * {
505  * // create message object config
506  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
507  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
508  *
509  * canMsgObjConfig.msgObjId = 10;
510  * canMsgObjConfig.messageId = 0x200;
511  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
512  * canMsgObjConfig.frame = IfxMultican_Frame_receive;
513  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
514  * canMsgObjConfig.control.extendedFrame = FALSE;
515  * canMsgObjConfig.control.matchingId = FALSE;
516  * canMsgObjConfig.gatewayTransfers = FALSE;
517  *
518  * // initialize message object
519  * IfxMultican_Can_MsgObj_init(&canDstMsgObj, &canMsgObjConfig);
520  * }
521  * \endcode
522  *
523  * Data can now be sent and received with the IfxMultican_Can_MsgObj_sendMessage and IfxMultican_Can_MsgObj_readMessage functions as usual (see above).
524  *
525  * The data flow is as followed,
526  *
527  * Data will be sent from the source object (canSrcMsgObj), it will be received by the gateway source object (canGatewaySrcMsgObj).
528  * and then gets copied into the gateway destination object (canGatewayDstMsgObj) without CPU intervention,
529  *
530  * If GDFS is selected in gateway source object (canGatewaySrcMsgObj)then,
531  * the data will be transmitted from gateway destination object(canGatewayDstMsgObj) to the destination object (canDstMsgObj)
532  *
533  * \section IfxLld_Multican_Can_Gateway_Fifo_Transfers Gateway FIFO based Transfers
534  *
535  * A gateway source FIFO can be enabled during the node configuration by specifing the number of allocated message objects with the canMsgObjConfig.msgObjCount item.
536  * and anbling the gateway transfers with the canMsgObjConfig.gatewayTransfersEnable item. and also by selecting the start object of the FIFO with the
537  * canMsgObjConfig.firstSlaveObjId item.
538  *
539  * Message objects will be allocated to the gateway FIFO in ascending order.
540  * Here a configuration example:
541  * \code
542  * // source message object, you can even make it as a Tx FIFO
543  * // IfxMultican_Can_MsgObj canSrcMsgObj; // defined globally
544  * {
545  * // create message object config
546  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
547  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
548  *
549  * canMsgObjConfig.msgObjId = 0;
550  * canMsgObjConfig.messageId = id;
551  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
552  * canMsgObjConfig.frame = IfxMultican_Frame_transmit;
553  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
554  * canMsgObjConfig.control.extendedFrame = FALSE;
555  * canMsgObjConfig.control.matchingId = TRUE;
556  * canMsgObjConfig.gatewayTransfers = FALSE;
557  *
558  * // initialize message object
559  * IfxMultican_Can_MsgObj_init(&canSrcMsgObj, &canMsgObjConfig);
560  * }
561  *
562  * // gateway source Fifo //
563  * // data will be received into this object from SrcObj, and then copied into gateway Fifo objects //
564  * IfxMultican_Can_MsgObj canGatewaySrcMsgObj;
565  * {
566  * // create message object config
567  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
568  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
569  *
570  * canMsgObjConfig.msgObjId = 1;
571  * canMsgObjConfig.messageId = id;
572  * canMsgObjConfig.msgObjCount = 4; // FIFO
573  * canMsgObjConfig.firstSlaveObjId = 2; // will allocate MsgObj 2..5 for the gateway FIFO
574  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
575  * canMsgObjConfig.frame = IfxMultican_Frame_receive;
576  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
577  * canMsgObjConfig.control.extendedFrame = FALSE;
578  * canMsgObjConfig.control.matchingId = TRUE;
579  * canMsgObjConfig.gatewayTransfers = TRUE; // gateway FIFO
580  * canMsgObjConfig.gatewayConfig.copyDataLengthCode = TRUE;
581  * canMsgObjConfig.gatewayConfig.copyData = TRUE;
582  * canMsgObjConfig.gatewayConfig.copyId = FALSE;
583  * canMsgObjConfig.gatewayConfig.enableTransmit = TRUE; // if this is not choosen, then no need to initialise canDstMsgObj to read the final data
584  *
585  *
586  *
587  * // initialize message object
588  * IfxMultican_Can_MsgObj_init(&canGatewaySrcMsgObj, &canMsgObjConfig);
589  * }
590  *
591  * int i = 0;
592  * for (i = 0; i < 4 ; ++i)
593  * {
594  * // gateway destination objects //
595  * // data, id , datlength code will be copied from GatewaySrcObj into this object through gateway transfers //
596  * // and then sent onto the bus for sending the message to destination receive Fifo message objects //
597  * IfxMultican_Can_MsgObj canGatewayDstMsgObj;
598  * {
599  * // create message object config
600  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
601  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
602  *
603  * canMsgObjConfig.msgObjId = 2 + i;
604  * canMsgObjConfig.messageId = 0x200;
605  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
606  * canMsgObjConfig.frame = IfxMultican_Frame_transmit;
607  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_4;
608  * canMsgObjConfig.control.extendedFrame = FALSE;
609  * canMsgObjConfig.control.matchingId = TRUE;
610  * canMsgObjConfig.gatewayTransfers = FALSE;
611  *
612  * // initialize message object
613  * IfxMultican_Can_MsgObj_init(&canGatewayDstMsgObj, &canMsgObjConfig);
614  * }
615  * }
616  * // destination receive Fifo, not needed if enableTransmit is not chosen in gateway source object, or you don't want to read the data //
617  * // data will be received from GatewayDstObj into this Fifo //
618  * // IfxMultican_Can_MsgObj canDstMsgObj; // defined globally
619  * {
620  * // create message object config
621  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
622  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
623  *
624  * canMsgObjConfig.msgObjId = 10;
625  * canMsgObjConfig.messageId = 0x200;
626  * canMsgObjConfig.msgObjCount = 4; // receive FIFO
627  * canMsgObjConfig.firstSlaveObjId = 11; // will allocate MsgObj 11..14 for the receive FIFO
628  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
629  * canMsgObjConfig.frame = IfxMultican_Frame_receive;
630  * canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
631  * canMsgObjConfig.control.extendedFrame = FALSE;
632  * canMsgObjConfig.control.matchingId = FALSE;
633  * canMsgObjConfig.gatewayTransfers = FALSE;
634  * canMsgObjConfig.firstSlaveObjId = 11;
635  *
636  *
637  * // initialize message object
638  * IfxMultican_Can_MsgObj_init(&canDstMsgObj, &canMsgObjConfig);
639  * }
640  * \endcode
641  *
642  * Data can now be sent and received with the IfxMultican_Can_MsgObj_sendMessage and IfxMultican_Can_MsgObj_readMessage functions as usual (see above).
643  * here is an example
644  * \code
645  * for (i = 0; i < 4; ++i)
646  * {
647  * // Transmit Data from the source message object //
648  * IfxMultican_Message msg;
649  * IfxMultican_Message_init(&msg, id, dataLow + i, dataHigh + i, IfxMultican_DataLengthCode_8);
650  *
651  * while( IfxMultican_Can_MsgObj_sendMessage(&canSrcMsgObj, &msg) == IfxMultican_Status_notSentBusy );
652  * }
653  * \endcode
654  *
655  * The data flow is as followed,
656  *
657  * data will be sent from the source object (canSrcMsgObj) or source TX FIFO, it will be received by the gateway source FIFO (canGatewaySrcMsgObj).
658  * and then gets copied into the gateway destination objects (canGatewayDstMsgObj) without CPU intervention,
659  *
660  * If GDFS is selected in gateway source object (FIFO) (canGatewaySrcMsgObj)then,
661  * the data will be transmitted from gateway destination objects (canGatewayDstMsgObj) to the destination objects or receive FIFO (canDstMsgObj)
662  *
663  * if you want to read the data you read by the following way
664  * \code
665  * for (i = 0; i < 4; ++i)
666  * {
667  * // Receiving Data, read the data from the destination receive Fifo //
668  * // wait until MCAN received the frame
669  * // wait until Multican received a new message
670  * while( !IfxMultican_Can_MsgObj_isRxPending(&canDstMsgObj) );
671  *
672  * IfxMultican_Message msg1;
673  * IfxMultican_Message_init(&msg1, 0xdead, 0xdeadbeef, 0xdeadbeef, IfxMultican_DataLengthCode_8); // start with invalid values
674  *
675  * IfxMultican_Status readStatus = IfxMultican_Can_MsgObj_readMessage(&canDstMsgObj, &msg1);
676  * if( readStatus != IfxMultican_Status_noError ) {
677  * clib_ver_printf("ERROR: IfxMultican_Can_MsgObj_readMessage returned 0x%04x\n", readStatus);
678  * result |= 1;
679  * }
680  *
681  * // check the received data
682  * result |= clib_trace(msg1.data[0], dataLow);
683  * result |= clib_trace(msg1.data[1], dataHigh);
684  * }
685  * \endcode
686  *
687  *
688  * \defgroup IfxLld_Multican_Can Can
689  * \ingroup IfxLld_Multican
690  * \defgroup IfxLld_Multican_Can_Data_Structures Data structures
691  * \ingroup IfxLld_Multican_Can
692  * \defgroup IfxLld_Multican_Can_General General functions
693  * \ingroup IfxLld_Multican_Can
694  * \defgroup IfxLld_Multican_Can_Node CAN Nodes
695  * \ingroup IfxLld_Multican_Can
696  * \defgroup IfxLld_Multican_Can_Message_Objects Message Objects
697  * \ingroup IfxLld_Multican_Can
698  * \defgroup IfxLld_Multican_Can_Interrupts Interrupts
699  * \ingroup IfxLld_Multican_Can
700  */
701 
702 #ifndef IFXMULTICAN_CAN_H
703 #define IFXMULTICAN_CAN_H 1
704 
705 /******************************************************************************/
706 /*----------------------------------Includes----------------------------------*/
707 /******************************************************************************/
708 
710 
711 /******************************************************************************/
712 /*-----------------------------Data Structures--------------------------------*/
713 /******************************************************************************/
714 
715 /** \addtogroup IfxLld_Multican_Can_Data_Structures
716  * \{ */
717 /** \brief Structure for CAN FD configuration
718  */
719 typedef struct
720 {
721  uint32 nominalBaudrate; /**< \brief Specifies the FD nominal baudrate (Nominal Bit Rate) */
722  uint16 nominalSynchJumpWidth; /**< \brief Specifies the FD nominal resynchronisation jump width. Range = [0, 10000] resp. [0%, 100%] of the total nominal bit time */
723  uint16 nominalSamplePoint; /**< \brief Specifies the FD nominal sample point. Range = [0, 10000] resp. [0%, 100%] of the total bit time */
724  uint32 fastBaudrate; /**< \brief Specifies the FD fast baudrate (Data Bit rate) */
725  uint16 fastSynchJumpWidth; /**< \brief Specifies the FD fast resynchronisation jump width. Range = [0, 10000] resp. [0%, 100%] of the total fast bit time */
726  uint16 fastSamplePoint; /**< \brief Specifies the FD fast sample point. Range = [0, 10000] resp. [0%, 100%] of the total bit time */
727  uint16 loopDelayOffset; /**< \brief Specifies the transceiver delay ompensation offset that is added to the measured transceiver delay. Range = [0, 15] */
729 
730 /** \brief Structure for gateway configuration
731  */
732 typedef struct
733 {
734  uint32 copyDataLengthCode : 1; /**< \brief Specifies the choice for copying data length code */
735  uint32 copyData : 1; /**< \brief Specifies the choice for copying data (data low and data high) */
736  uint32 copyId : 1; /**< \brief Specifies the choice for copying id of the message */
737  uint32 enableTransmit : 1; /**< \brief Specifies the enable choice of TXRQ in the destination gateway object (GDFS of source gateway object) */
738  IfxMultican_MsgObjId gatewayDstObjId; /**< \brief Message object number of first slave object (bottom pointer) */
740 
741 /** \brief Structure for interrupt configuration
742  */
743 typedef struct
744 {
745  uint16 priority; /**< \brief interrupt priority */
746  IfxSrc_Tos typeOfService; /**< \brief type of interrupt service */
748 
749 /** \brief Structure for interrupt source
750  */
751 typedef struct
752 {
753  boolean enabled; /**< \brief If true, enables the interrupt generation */
754  IfxMultican_SrcId srcId; /**< \brief interrupt node pointer used */
756 
757 /** \brief Message object control
758  */
759 typedef struct
760 {
761  uint32 singleDataTransfer : 1; /**< \brief Specifies the single data transfer option. If 1, single data transfer is selected */
762  uint32 singleTransmitTrial : 1; /**< \brief Specifies the single transmit trial option. If 1, single transmit trial is selected */
763  IfxMultican_DataLengthCode messageLen; /**< \brief Specifies the length of the transmited data (number of bytes). This value is ignored for receive object */
764  uint32 extendedFrame : 1; /**< \brief Specifies the standard / extended frame mode. 0: standard frame 11 bit ID; 1: extended frame 29 bit ID */
765  uint32 matchingId : 1; /**< \brief Specifies the acceptance mask. 0: standard & extended frame (11 & 29 bit); 1: only frames with maching IDE */
766  IfxMultican_MsgObjId topMsgObjId; /**< \brief Specifies the ID of the message object with data byte 8 to 35. (CAN FD) */
767  IfxMultican_MsgObjId bottomMsgObjId; /**< \brief Specifies the ID of the message object with data byte 36 to 63. (CAN FD) */
768  uint32 fastBitRate : 1; /**< \brief Specifies the bit rate switch. 0: nominal bit rate ; 1: fast bit rate */
770 
771 /** \brief CAN node handle data structure
772  */
773 typedef struct
774 {
775  Ifx_CAN *mcan; /**< \brief Specifies the pointer to the MULTICAN module registers */
776  Ifx_CAN_N *node; /**< \brief Specifies the pointer to the MULTICAN node registers */
777  IfxMultican_NodeId nodeId; /**< \brief Specifies the node Id */
778  boolean fastNode; /**< \brief CAN FD fast node enable/disable */
780 
781 /** \} */
782 
783 /** \addtogroup IfxLld_Multican_Can_Data_Structures
784  * \{ */
785 /** \brief CAN handle data structure
786  */
787 typedef struct
788 {
789  Ifx_CAN *mcan; /**< \brief Specifies the pointer to the MULTICAN module registers */
791 
792 /** \brief CAN module configuration
793  */
794 typedef struct
795 {
796  Ifx_CAN *module; /**< \brief pointer to MULTICAN module */
797  IfxMultican_ClockSelect clockSelect; /**< \brief Selected module input clock */
798  float32 moduleFreq; /**< \brief Required module frequency in Hertz */
799  IfxMultican_Can_InterruptConfig nodePointer[IFXMULTICAN_SRC_COUNT]; /**< \brief Node pointer configuration */
801 
802 /** \brief CAN message object handle data structure
803  */
804 typedef struct
805 {
806  IfxMultican_Can_Node *node; /**< \brief Specifies the pointer to the node handle */
807  IfxMultican_MsgObjId msgObjId; /**< \brief Specifies the message object ID */
808  uint16 msgObjCount; /**< \brief Number of message object sto be initialised (1 for standard Msg Obj and no. of objects including base object for FIFO transfers) */
809  IfxMultican_MsgObjId fifoPointer; /**< \brief Pointer for FIFO based transfers */
811 
812 /** \brief CAN message object configuration
813  */
814 typedef struct
815 {
816  IfxMultican_Can_Node *node; /**< \brief Specifies the pointer to the node handle */
817  IfxMultican_MsgObjId msgObjId; /**< \brief Specifies the message object ID */
818  uint16 msgObjCount; /**< \brief Number of message object sto be initialised (1 for standard Msg Obj and no. of objects including base object for FIFO transfers) */
819  IfxMultican_Can_MsgObjControl control; /**< \brief Message object control */
820  IfxMultican_Frame frame; /**< \brief Specifies the frame type */
821  uint32 acceptanceMask; /**< \brief Specifies the acceptance mask */
822  uint32 messageId; /**< \brief Specifies the message ID */
823  IfxMultican_Priority priority; /**< \brief Specifies the message object priority */
824  IfxMultican_Can_InterruptSource rxInterrupt; /**< \brief Rx Interrupt configuration */
825  IfxMultican_Can_InterruptSource txInterrupt; /**< \brief Tx Interrupt configuration */
826  uint32 gatewayTransfers : 1; /**< \brief Specifies the gateway source object (gateway transfres enable / disable choice) */
827  IfxMultican_Can_GatewayConfig gatewayConfig; /**< \brief Structure for gateway configuration */
828  IfxMultican_MsgObjId firstSlaveObjId; /**< \brief Message object number of first slave object (bottom pointer) */
830 
831 /** \brief CAN Node configuration
832  */
833 typedef struct
834 {
835  Ifx_CAN *module; /**< \brief pointer to MULTICAN module */
836  IfxMultican_NodeId nodeId; /**< \brief Specifies the node Id */
837  boolean analyzerMode; /**< \brief Specifies the analizer mode. If TRUE then the CAN Node works in analizer mode */
838  boolean loopBackMode; /**< \brief Specifies the loop back mode. If TRUE then the CAN Node works in loop back mode */
839  uint32 baudrate; /**< \brief Specifies the baudrate */
840  uint16 samplePoint; /**< \brief Specifies the sample point. Range = [0, 10000] resp. [0%, 100%] of the total bit time */
841  uint16 synchJumpWidth; /**< \brief Specifies the resynchronisation jump width. Range = [0, 10000] resp. [0%, 100%] of the total bit time */
842  boolean flexibleDataRate; /**< \brief CANFD enable/disable */
843  IfxMultican_Can_FdConfig fdConfig; /**< \brief Specifies CAN FD configuration */
844  IfxMultican_Rxd_In *rxPin; /**< \brief Specifies the receive pin */
845  IfxPort_InputMode rxPinMode; /**< \brief Specifies the receive pin as input mode */
846  IfxMultican_Txd_Out *txPin; /**< \brief Specifies the transmit pin */
847  IfxPort_OutputMode txPinMode; /**< \brief Specifies the transmit pin output mode */
848  uint8 errorWarningLevel; /**< \brief Specifies the error warinig level */
849  IfxMultican_Can_InterruptSource transferInterrupt; /**< \brief Transfer interrupt */
850  IfxMultican_Can_InterruptSource lastErrorCodeInterrupt; /**< \brief Last error code interrupt */
851  IfxMultican_Can_InterruptSource alertInterrupt; /**< \brief Alert interrupt */
852  IfxMultican_Can_InterruptSource frameCounterInterrupt; /**< \brief Frame counter interrupt */
853  IfxMultican_Can_InterruptSource timerInterrupt; /**< \brief Timer Interrupt */
855 
856 /** \} */
857 
858 /** \addtogroup IfxLld_Multican_Can_General
859  * \{ */
860 
861 /******************************************************************************/
862 /*-------------------------Inline Function Prototypes-------------------------*/
863 /******************************************************************************/
864 
865 /** \brief Reset the CAN module.\n
866  * Reset and disable the CAN module, inclusive message object and node registers.
867  * \param mcan pointer to the CAN handle
868  * \return None
869  */
871 
872 /******************************************************************************/
873 /*-------------------------Global Function Prototypes-------------------------*/
874 /******************************************************************************/
875 
876 /** \brief Return the actual CAN module configuration
877  * \param mcan pointer to the CAN handle
878  * \param config Pointer to the configuration structure, will be filled by this function
879  * \return None
880  */
882 
883 /** \brief Get the module frequency
884  * \param mcan pointer to the CAN handle
885  * \return Frequency Value
886  */
888 
889 /** \brief Initialize the CAN module\n
890  * The following configuration is used:\n
891  * - The CAN module is stopped during sleep mode\n
892  * - The normal divider mode is selected\n
893  * - The CAN module clock is the system clock
894  * \param mcan pointer to the CAN handle
895  * \param config Specifies pointer to the CAN module configuration
896  * \return TRUE: Returns TRUE if the operation was successful\n
897  * FALSE: Returns FALSE if the operation was errorneous
898  *
899  * \code
900  * // create module config
901  * IfxMultican_Can_Config canConfig;
902  * IfxMultican_Can_initModuleConfig(&canConfig, &MODULE_CAN);
903  *
904  * // initialize module
905  * IfxMultican_Can can;
906  * IfxMultican_Can_initModule(&can, &canConfig);
907  * \endcode
908  *
909  */
911 
912 /** \brief Return the default MULTICAN configuration
913  * \param config Default configuration filled by this function
914  * \param mcan base address of the MULTICAN register space
915  * \return None
916  *
917  * A coding example can be found in \ref IfxMultican_Can_initModule
918  *
919  */
921 
922 /** \} */
923 
924 /** \addtogroup IfxLld_Multican_Can_Node
925  * \{ */
926 
927 /******************************************************************************/
928 /*-------------------------Inline Function Prototypes-------------------------*/
929 /******************************************************************************/
930 
931 /** \brief Activate the CAN Node. Participate in the CAN bus activities
932  * \param node Specifies the CAN node handle to be configured
933  * \return None
934  */
936 
937 /** \brief Deactivate the CAN Node. Take out from participation in the CAN bus activities
938  * \param node Specifies the CAN node handle to be configured
939  * \return None
940  */
942 
943 /** \brief Reset the CAN node
944  * \param node Specifies the CAN node handle to be configured
945  * \return None
946  */
948 
949 /** \brief Recovers the CAN node from bus off
950  * \param node Specifies the CAN node handle to be configured
951  * \return Status
952  *
953  * IfxMultican_Status status = IfxMultican_Status_busOff;
954  *
955  * while (status != IfxMultican_Status_noError)
956  * {
957  * status = IfxMultican_Can_Node_recoverBusOff(&canNode);
958  * }
959  *
960  */
962 
963 /******************************************************************************/
964 /*-------------------------Global Function Prototypes-------------------------*/
965 /******************************************************************************/
966 
967 /** \brief Get the actual message object configuration
968  * \param node Specifies the CAN node handle to be configured
969  * \param config Specifies the CAN node configuration
970  * \return None
971  */
973 
974 /** \brief Initialize the CAN node
975  * \param node Specifies the CAN node handle to be configured
976  * \param config Specifies the CAN node configuration
977  * \return TRUE: Returns TRUE if the operation was successful\n
978  * FALSE: Returns FALSE if the operation was errorneous
979  *
980  * \code
981  * // create CAN node config
982  * IfxMultican_Can_NodeConfig canNodeConfig;
983  * IfxMultican_Can_Node_initConfig(&canNodeConfig, &can);
984  *
985  * // choose the desired the baudrate
986  * canNodeConfig.baudrate = 1000000; // 1 MBaud
987  *
988  * for(int node=0; node<TESTED_NODES; ++node) {
989  *
990  * // initialize CAN node
991  * //IfxMultican_Can_Node canNode[TESTED_NODES]; // declared globally
992  *
993  * canNodeConfig.nodeId = (IfxMultican_NodeId)((int)IfxMultican_NodeId_0 + node);
994  * canNodeConfig.rxPin = IfxMultican_PinMap[node].rxPin;
995  * canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
996  * canNodeConfig.txPin = IfxMultican_PinMap[node].txPin;
997  * canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
998  *
999  * IfxMultican_Can_Node_init(&canNode, &canNodeConfig);
1000  * }
1001  * \endcode
1002  *
1003  */
1005 
1006 /** \brief Get default CAN node configuration
1007  * \param config Specifies the CAN node configuration
1008  * \param mcan pointer to the CAN handle
1009  * \return None
1010  *
1011  * A coding example can be found in \ref IfxMultican_Can_Node_init
1012  *
1013  */
1015 
1016 /** \brief Recovers the CAN node from bus off
1017  * \param node Specifies the CAN node handle to be configured
1018  * \return None
1019  *
1020  * IfxMultican_Status status = IfxMultican_Status_busOff;
1021  *
1022  * while (status != IfxMultican_Status_noError)
1023  * {
1024  * status = IfxMultican_Can_Node_recoverBusOff(&canNode);
1025  * }
1026  *
1027  */
1029 
1030 /** \} */
1031 
1032 /** \addtogroup IfxLld_Multican_Can_Message_Objects
1033  * \{ */
1034 
1035 /******************************************************************************/
1036 /*-------------------------Inline Function Prototypes-------------------------*/
1037 /******************************************************************************/
1038 
1039 /** \brief Cancel pending TX request by invalidating the request\n
1040  * Only when frame transmission has not been started
1041  * \param msgObj pointer to the CAN message object handle
1042  * \return TRUE if cancellation was successfully executed
1043  */
1045 
1046 /** \brief Clear the RX pending flag of a message object
1047  * \param msgObj pointer to the CAN message object handle
1048  * \return None
1049  *
1050  * \code
1051  * // clear pending flag
1052  * IfxMultican_Can_MsgObj_clearRxPending(&canMsgObj[node]);
1053  * \endcode
1054  *
1055  */
1057 
1058 /** \brief Clear the TX pending flag of a message object
1059  * \param msgObj pointer to the CAN message object handle
1060  * \return None
1061  *
1062  * \code
1063  * // clear pending flag
1064  * IfxMultican_Can_MsgObj_clearTxPending(&canMsgObj[node]);
1065  * \endcode
1066  *
1067  */
1069 
1070 /** \brief Reset the message object\n
1071  * Append the message object to the end of idle list and reset message object registers
1072  * \param msgObj pointer to the CAN message object handle
1073  * \return None
1074  */
1076 
1077 /** \brief Get message object ID which has TX/RX pending flag from a message object group
1078  * \param msgObj pointer to the CAN message object handle
1079  * \param msgObjGroup Message object group
1080  * \return Message Object Id
1081  */
1083 
1084 /** \brief Get the message object status
1085  * \param msgObj pointer to the CAN message object handle
1086  * \return \ref IfxMultican_MsgObjStat bitfield
1087  *
1088  * \code
1089  * IfxMultican_MsgObjStat msgStatus;
1090  *
1091  * msgStatus = IfxMultican_Can_MsgObj_getStatus(&canMsgObj[node]);
1092  * \endcode
1093  *
1094  */
1096 
1097 /** \brief Read a received CAN message
1098  * \param msgObj pointer to the CAN message object handle
1099  * \param msg This parameter is filled in by the function with the received message. Also when reading is not successful
1100  * \param data Pointer to data (in words)
1101  * \return IfxMultican_Status_noError: if the operation was successful\n
1102  * IfxMultican_Status_messageLost: if the message lost and new data is not yet ready\n
1103  * IfxMultican_Status_newDataButMessageLost: if the one message lost and last new data is retrieved successfully
1104  *
1105  * \code
1106  * // create message that is to be filled in by the function with the received message
1107  * IfxMultican_Message msg;
1108  * IfxMultican_Message_longFrameInit(&msg, 0xdead, 0xf, FALSE); // start with invalid values
1109  *
1110  * // wait until a new message is available
1111  * while( !IfxMultican_Can_MsgObj_isRxPending(&canDstMsgObj) );
1112  *
1113  * // read the message
1114  * // rxData is assumed to be declared gloabally
1115  * IfxMultican_Status readStatus = IfxMultican_Can_MsgObj_readLongFrame(&canDstMsgObj, &msg, &rxData);
1116  * \endcode
1117  *
1118  */
1120 
1121 /** \brief Read a received CAN message
1122  * \param msgObj pointer to the CAN message object handle
1123  * \param msg This parameter is filled in by the function with the received message. Also when reading is not successful
1124  * \param data Pointer to data (in words)
1125  * \return IfxMultican_Status_noError: if the operation was successful\n
1126  * IfxMultican_Status_messageLost: if the message lost and new data is not yet ready\n
1127  * IfxMultican_Status_newDataButMessageLost: if the one message lost and last new data is retrieved successfully
1128  *
1129  * \code
1130  * // create message that is to be send
1131  * IfxMultican_Message msg;
1132  * IfxMultican_Message_longFrameInit(&msg, id, IfxMultican_DataLengthCode_8, TRUE);
1133  *
1134  * //send the message
1135  * // txData assumed to be declared globally
1136  * while( IfxMultican_Can_MsgObj_sendLongFrame(&canSrcMsgObj, &msg, &txData) == IfxMultican_Status_notSentBusy );
1137  * \endcode
1138  *
1139  */
1141 
1142 /******************************************************************************/
1143 /*-------------------------Global Function Prototypes-------------------------*/
1144 /******************************************************************************/
1145 
1146 /** \brief Get the actual message object configuration
1147  * \param msgObj pointer to the CAN message object handle
1148  * \param config Pointer to the RAM buffer. Filled by this function
1149  * \return None
1150  */
1152 
1153 /** \brief Initialize the message object
1154  * \param msgObj pointer to the CAN message object handle
1155  * \param config pointer to the CAN message object configuration
1156  * \return Status
1157  *
1158  * \code
1159  * // create message object config
1160  * IfxMultican_Can_MsgObjConfig canMsgObjConfig;
1161  * IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canNode[node]);
1162  *
1163  * canMsgObjConfig.msgObjId = node;
1164  * canMsgObjConfig.messageId = id;
1165  * canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
1166  * canMsgObjConfig.frame = IfxMultican_Frame_receive;
1167  * canMsgObjConfig.control.messageLen = 8;
1168  * canMsgObjConfig.control.extendedFrame = FALSE;
1169  * canMsgObjConfig.control.matchingId = TRUE;
1170  *
1171  * // initialize message object
1172  * //IfxMultican_Can_MsgObj canMsgObj[TESTED_NODES]; // declared globally
1173  * IfxMultican_Can_MsgObj_init(&canMsgObj[node], &canMsgObjConfig);
1174  * \endcode
1175  *
1176  */
1178 
1179 /** \brief Initialise message config with default values and the given parameters
1180  * \param config pointer to the CAN message object configuration
1181  * \param node pointer to the CAN node handle to which the message object should be assigned
1182  * \return None
1183  *
1184  * A coding example can be found in \ref IfxMultican_Can_MsgObj_init
1185  *
1186  */
1188 
1189 /** \brief Returns the RX pending flag of a message object.
1190  * \param msgObj pointer to the CAN message object handle
1191  * \return TRUE of the RX pending flag of a message object is set
1192  */
1194 
1195 /** \brief Returns the TX pending flag of a message object.
1196  * \param msgObj pointer to the CAN message object handle
1197  * \return TRUE of the TX pending flag of a message object is set
1198  */
1200 
1201 /** \brief Read a received CAN message
1202  * \param msgObj pointer to the CAN message object handle
1203  * \param msg This parameter is filled in by the function with the received message. Also when reading is not successful
1204  * \return IfxMultican_Status_noError: if the operation was successful\n
1205  * IfxMultican_Status_messageLost: if the message lost and new data is not yet ready\n
1206  * IfxMultican_Status_newDataButMessageLost: if the one message lost and last new data is retrieved successfully
1207  *
1208  * \code
1209  * // create message that is to be filled in by the function with the received message
1210  * IfxMultican_Message msg;
1211  * IfxMultican_Message_init(&msg, 0xdead, 0xdeadbeef, 0xdeadbeef, 0xf); // start with invalid values
1212  *
1213  * // wait until a new message is available
1214  * while( !IfxMultican_Can_MsgObj_isRxPending(&canDstMsgObj) );
1215  *
1216  * // read the message
1217  * IfxMultican_Status readStatus = IfxMultican_Can_MsgObj_readMessage(&canDstMsgObj, &msg);
1218  * \endcode
1219  *
1220  */
1222 
1223 /** \brief Send a CAN message
1224  * \param msgObj pointer to the CAN message object handle
1225  * \param msg Specifies the msg to be send
1226  * \return IfxMultican_Status_noError: if the operation was successful\n
1227  * IfxMultican_Status_notSentBusy: if the operation was unsuccessful due to hardware is busy
1228  *
1229  * \code
1230  * // create message that is to be send
1231  * IfxMultican_Message msg;
1232  * IfxMultican_Message_init(&msg, id, dataLow, dataHigh, IfxMultican_DataLengthCode_8);
1233  *
1234  * //send the message
1235  * while( IfxMultican_Can_MsgObj_sendMessage(&canSrcMsgObj, &msg) == IfxMultican_Status_notSentBusy );
1236  * \endcode
1237  *
1238  */
1240 
1241 /** \} */
1242 
1243 /******************************************************************************/
1244 /*---------------------Inline Function Implementations------------------------*/
1245 /******************************************************************************/
1246 
1248 {
1249  IfxMultican_deinit(mcan->mcan);
1250 }
1251 
1252 
1254 {
1255  Ifx_CAN_N *hwNode = IfxMultican_Node_getPointer(node->mcan, node->nodeId);
1256 
1257  IfxMultican_Node_activate(hwNode);
1258 }
1259 
1260 
1262 {
1263  Ifx_CAN_N *hwNode = IfxMultican_Node_getPointer(node->mcan, node->nodeId);
1265 }
1266 
1267 
1269 {
1270  Ifx_CAN_N *hwNode = IfxMultican_Node_getPointer(node->mcan, node->nodeId);
1271 
1272  IfxMultican_Node_deinit(hwNode);
1273 }
1274 
1275 
1277 {
1278  Ifx_CAN_N *hwNode = IfxMultican_Node_getPointer(node->mcan, node->nodeId);
1279 
1280  return IfxMultican_Node_recoverBusOff(hwNode);
1281 }
1282 
1283 
1285 {
1286  Ifx_CAN_MO *hwObj = IfxMultican_MsgObj_getPointer(msgObj->node->mcan, msgObj->msgObjId);
1287 
1288  return IfxMultican_MsgObj_cancelSend(hwObj);
1289 }
1290 
1291 
1293 {
1294  Ifx_CAN_MO *hwObj = IfxMultican_MsgObj_getPointer(msgObj->node->mcan, msgObj->msgObjId);
1295 
1297 }
1298 
1299 
1301 {
1302  Ifx_CAN_MO *hwObj = IfxMultican_MsgObj_getPointer(msgObj->node->mcan, msgObj->msgObjId);
1303 
1305 }
1306 
1307 
1309 {
1310  IfxMultican_MsgObj_deinit(msgObj->node->mcan, msgObj->msgObjId);
1311 }
1312 
1313 
1315 {
1316  return IfxMultican_MsgObj_getPendingId(msgObj->node->mcan, msgObjGroup);
1317 }
1318 
1319 
1321 {
1322  Ifx_CAN_MO *hwObj = IfxMultican_MsgObj_getPointer(msgObj->node->mcan, msgObj->msgObjId);
1323 
1324  return IfxMultican_MsgObj_getStatus(hwObj);
1325 }
1326 
1327 
1329 {
1330  return IfxMultican_MsgObj_readLongFrame(msgObj->node->mcan, msgObj->msgObjId, msg, data);
1331 }
1332 
1333 
1335 {
1336  return IfxMultican_MsgObj_sendLongFrame(msgObj->node->mcan, msgObj->msgObjId, msg, data);
1337 }
1338 
1339 
1340 #endif /* IFXMULTICAN_CAN_H */