1 /**
2  * @file xmc_can.h
3  * @date 2019-07-02
4  *
5  * @cond
6  *********************************************************************************************************************
7  * XMClib v2.1.24 - XMC Peripheral Driver Library
8  *
9  * Copyright (c) 2015-2019, Infineon Technologies AG
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
13  * following conditions are met:
14  *
15  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
16  * disclaimer.
17  *
18  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided with the distribution.
20  *
21  * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
22  * products derived from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE  FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with
33  * Infineon Technologies AG dave@infineon.com).
34  *********************************************************************************************************************
35  *
36  * Change History
37  * --------------
38  *
39  * 2015-02-20:
40  *     - Initial <br>
41  *     - Documentation improved <br>
42  *
43  * 2015-05-20:
44  *     - New elements have added in XMC_CAN_MO_t data structure <br>
45  *     - XMC_CAN_MO_Config() signature has changed <br>
46  *     - XMC_CAN_STATUS_t enum structure has updated. <br>
47  *
48  * 2015-06-20:
49  *     - New APIs added: XMC_CAN_NODE_ClearStatus(),XMC_CAN_MO_ReceiveData(), XMC_CAN_GATEWAY_InitDesObject(). <br>
50  *     - Removed version macros and declaration of GetDriverVersion API
51  *
52  * 2015-07-09:
53  *     - New API added: XMC_CAN_NODE_Enable. <br>
54  *
55  * 2015-09-01:
56  *     - Removed fCANB clock support <br>
57  *
58  * 2015-09-15:
59  *     - Added "xmc_can_map.h" include <br>
60  *
61  * 2016-06-07:
62  *     - Added XMC_CAN_IsPanelControlReady()
63  *
64  * 2017-11-09:
65  *     - Added XMC_CAN_InitEx() and XMC_CAN_NODE_NominalBitTimeConfigureEx()
66  *     - Make XMC_CAN_GetBaudrateClockSource(), XMC_CAN_SetBaudrateClockSource() and XMC_CAN_GetBaudrateClockFrequency() available to all devices
67  *
68  * 2019-07-02:
69  *     - Added XMC_CAN_GetClockFrequency()
70  *     - Added XMC_CAN_IsListEmpty(), XMC_CAN_GetListBegin(), XMC_CAN_GetListSize(), XMC_CAN_MO_GetMessageObject(), XMC_CAN_MO_GetNextMessageObjectIdx()
71  *
72  * <b>Details of use for node configuration related APIs</b><br>
73  * Please use the XMC_CAN_NODE_SetInitBit() and XMC_CAN_NODE_EnableConfigurationChange() before calling node configuration
74  * related APIs.
75  * XMC_CAN_NODE_DisableConfigurationChange() and  XMC_CAN_NODE_ResetInitBit() can be called for disable the configuration
76  * change and enable the node for communication afterwards.
77  * Do not use this when configuring the nominal bit time with XMC_CAN_NODE_NominalBitTimeConfigure(). In this case the
78  * Enable/Disable node configuration change is taken in account.
79  *
80  * <b>Example Usage:</b>
81  * @code
82  * //disabling the Node
83  * XMC_CAN_NODE_SetInitBit(CAN_NODE0)
84  * //allowing the configuration change
85  * XMC_CAN_NODE_EnableConfigurationChange(CAN_NODE0)
86  * //Node configuration
87  * XMC_CAN_NODE_FrameCounterConfigure(CAN_NODE0,&can_node_frame_counter);
88  * XMC_CAN_NODE_EnableLoopBack(CAN_NODE0)
89  * //disable configuration
90  * XMC_CAN_NODE_DisableConfigurationChange(CAN_NODE0)
91  * //Enabling node for communication
92  * XMC_CAN_NODE_ResetInitBit(CAN_NODE0)
93  * @endcode
94  *
95  * 2016-06-20:
96  *     - Fixed bug in XMC_CAN_MO_Config() <br>
97  * @endcond
98  *
99  */
100 
101 #ifndef XMC_CAN_H
102 #define XMC_CAN_H
103 
104 /*********************************************************************************************************************
105  * HEADER FILES
106  ********************************************************************************************************************/
107 #include "xmc_common.h"
108 
109 #if defined(CAN)
110 
111 #include "xmc_scu.h"
112 #include "xmc_can_map.h"
113 #include <string.h>
114 
115 /**
116  * @addtogroup XMClib XMC Peripheral Library
117  * @{
118  */
119 
120 /**
121  * @addtogroup CAN
122  * @brief Controller Area Network Controller (CAN) driver for the XMC microcontroller family.
123  *
124  * CAN driver provides transfer of CAN frames in accordance with CAN specificetion V2.0 B (active). Each CAN node
125  * can receive and transmit standard frames with 11-bit identifiers as well as extended frames with 29-bit identifiers.
126  * All CAN nodes share a common set of message objects. Each message object can be individually allocated to one of the
127  * CAN nodes.
128  * Besides serving as a storage container for incoming and outgoing frames, message objects can be combined to build
129  * gateways between
130  * the CAN nodes or to setup a FIFO buffer. The CAN module provides Analyzer mode,Loop-back mode and bit timming for
131  * node analysis.
132  *
133  * The driver is divided into five sections:
134  * \par CAN Global features:
135  * -# Allows to configure module frequency using function XMC_CAN_Init().
136  * -# Allows to configure Module interrupt using configuration structure XMC_CAN_NODE_INTERRUPT_TRIGGER_t and function
137  *    XMC_CAN_EventTrigger().
138  *
139  * \par CAN_NODE features:
140  * -# Allows to set baud rate by configuration structure XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t and Baudrate Configuration
141  *    function XMC_CAN_NODE_NominalBitTimeConfigure().
142  * -# Allows to configure loop-back mode using fuction XMC_CAN_NODE_EnableLoopBack().
143  * -# Allows to configure CAN Node analyzer using function XMC_CAN_NODE_SetAnalyzerMode().
144  * -# Allows CAN node events enable/ disable by enum structure XMC_CAN_NODE_EVENT_t and functions XMC_CAN_NODE_EnableEvent()
145  *    and XMC_CAN_NODE_DisableEvent().
146  * -# Provides bit timming analysis, configuration structure XMC_CAN_NODE_FRAME_COUNTER_t and function
147  *    XMC_CAN_NODE_FrameCounterConfigure().
148  *
149  * \par CAN_MO features:
150  * -# Allows message object initialization by configuration structure XMC_CAN_MO_t and function XMC_CAN_MO_Config().
151  * -# Allows transfer of message objects using functions XMC_CAN_MO_Transmit() and XMC_CAN_MO_Receive().
152  * -# Allows to configure Single Data Transfer and Single Transmit Trial using functions
153  * XMC_CAN_MO_EnableSingleTransmitTrial() and XMC_CAN_MO_EnableSingleTransmitTrial().
154  * -# Allows to configure MO events using function XMC_CAN_MO_EnableEvent().
155  *
156  * \par CAN_FIFO features:
157  * -# Allows message object FIFO structure by configuration structure XMC_CAN_FIFO_CONFIG_t and functions
158  * XMC_CAN_TXFIFO_ConfigMOBaseObject() , XMC_CAN_RXFIFO_ConfigMOBaseObject() and XMC_CAN_TXFIFO_Transmit().
159  *
160  * \par CAN_GATEWAY features:
161  * -# Provides Gateway mode, configuration structure XMC_CAN_GATEWAY_CONFIG_t and function XMC_CAN_GATEWAY_InitSourceObject().
162  *
163  * @{
164  */
165 
166 /*********************************************************************************************************************
167  * MACROS
168  ********************************************************************************************************************/
169 #define XMC_CAN_MO_MOAR_STDID_Pos (18U)   /**< Standard Identifier bitposition */
170 
171 #define XMC_CAN_MO_MOAR_STDID_Msk ((0x000007FFUL) << XMC_CAN_MO_MOAR_STDID_Pos) /**< Standard Identifier bitMask */
172 
173 #define CAN_NODE_NIPR_Msk         (0x7UL) /**< Node event mask */
174 
175 #define CAN_MO_MOIPR_Msk          (0x7U)  /**< Message Object event mask */
176 
177 /*********************************************************************************************************************
178  * ENUMS
179  ********************************************************************************************************************/
180 /**
181  *  Defines the status of CAN, to verify the CAN related API calls. Use type \a XMC_CAN_STATUS_t for this enum.
182 */
183 typedef enum XMC_CAN_STATUS
184 {
185   XMC_CAN_STATUS_SUCCESS,           /**< Driver accepted application request*/
186   XMC_CAN_STATUS_ERROR,             /**< Returned when unknown error occurred */
187   XMC_CAN_STATUS_BUSY,              /**< Driver is busy and can not handle request*/
188   XMC_CAN_STATUS_MO_NOT_ACCEPTABLE, /**< Message object type not allowed*/
189   XMC_CAN_STATUS_MO_DISABLED       /**< Returned if Message object is disabled */
190 } XMC_CAN_STATUS_t;
191 
192 /**
193 * Defines CAN module Panel Commands . Use type \a XMC_CAN_PANCMD_t for this enum.
194 */
195 typedef enum XMC_CAN_PANCMD
196 {
197   XMC_CAN_PANCMD_INIT_LIST = 1U,              /**< Command to initialize a list */
198   XMC_CAN_PANCMD_STATIC_ALLOCATE = 2U,        /**< Command to activate static allocation */
199   XMC_CAN_PANCMD_DYNAMIC_ALLOCATE = 3U,       /**< Command to activate dynamic allocation */
200 
201   XMC_CAN_PANCMD_STATIC_INSERT_BEFORE = 4U,   /**< Remove a message object from the list and insert it before a given object.*/
202   XMC_CAN_PANCMD_DYNAMIC_INSERT_BEFORE = 5U,  /**< Command to activate dynamic allocation */
203   XMC_CAN_PANCMD_STATIC_INSERT_BEHIND = 6U,   /**< Command to activate dynamic allocation */
204   XMC_CAN_PANCMD_DYNAMIC_INSERT_BEHIND = 7U   /**< Command to activate dynamic allocation */
205 } XMC_CAN_PANCMD_t;
206 
207 /**
208 * Defines loop Back Mode, to enable/disable an in-system test of the MultiCAN module .
209 * Use type \a XMC_CAN_LOOKBACKMODE_t for this enum.
210 */
211 typedef enum XMC_CAN_LOOKBACKMODE
212 {
213   XMC_CAN_LOOKBACKMODE_ENABLED,   /**< Each CAN node can be connected to the internal CAN bus  */
214   XMC_CAN_LOOKBACKMODE_DISABLED   /**< Each CAN node can be connected to the external CAN bus */
215 } XMC_CAN_LOOKBACKMODE_t;
216 
217 /**
218  * Defines Message Object direction. Use type \a XMC_CAN_MO_TYPE_t for this enum.
219  */
220 typedef enum XMC_CAN_MO_TYPE
221 {
222   XMC_CAN_MO_TYPE_RECMSGOBJ,   /**< Receive Message Object selected */
223   XMC_CAN_MO_TYPE_TRANSMSGOBJ  /**< Transmit Message Object selected */
224 } XMC_CAN_MO_TYPE_t;
225 
226 /**
227  * Defines Data frame types. Use type \a XMC_CAN_FRAME_TYPE_t for this enum.
228  */
229 typedef enum XMC_CAN_FRAME_TYPE
230 {
231   XMC_CAN_FRAME_TYPE_STANDARD_11BITS, /**< Standard type identifier*/
232   XMC_CAN_FRAME_TYPE_EXTENDED_29BITS  /**< Extended type identifier*/
233 } XMC_CAN_FRAME_TYPE_t;
234 
235 
236 /**
237  * Defines arbitration mode for transmit acceptance filtering. Use type \a XMC_CAN_ARBITRATION_MODE_t for this enum.
238  */
239 typedef enum XMC_CAN_ARBITRATION_MODE
240 {
241   XMC_CAN_ARBITRATION_MODE_ORDER_BASED_PRIO_1 = 1U,   /**< Transmit acceptance based in the order(prio) */
242   XMC_CAN_ARBITRATION_MODE_IDE_DIR_BASED_PRIO_2 = 2U, /**< Transmit acceptance filtering is based on the CAN identifier */
243   XMC_CAN_ARBITRATION_MODE_ORDER_BASED_PRIO_3 = 3U    /**< Transmit acceptance based in the order */
244 } XMC_CAN_ARBITRATION_MODE_t;
245 
246 /**
247  * Defines the operation mode of the frame counter. Use type \a XMC_CAN_FRAME_COUNT_MODE_t for this enum.
248  */
249 typedef enum XMC_CAN_FRAME_COUNT_MODE
250 {
251   XMC_CAN_FRAME_COUNT_MODE = 0U,       /**< Frame Count Mode */
252   XMC_CAN_FRAME_COUNT_MODE_TIME_STAMP = 1U,  /**< The frame counter is incremented with the beginning of a new bit time*/
253   XMC_CAN_FRAME_COUNT_MODE_BIT_TIMING = 2U   /**< Used for baud rate detection and analysis of the bit timing */
254 } XMC_CAN_FRAME_COUNT_MODE_t;
255 
256 /**
257  * Defines the Divider Modes. Use type \a XMC_CAN_DM_t for this enum.
258  */
259 typedef enum XMC_CAN_DM
260 {
261   XMC_CAN_DM_NORMAL = 1U,      /**< Normal divider mode */
262   XMC_CAN_DM_FRACTIONAL = 2U,  /**< Fractional divider mode */
263   XMC_CAN_DM_OFF = 3U          /**< Divider Mode in off-state*/
264 } XMC_CAN_DM_t;
265 
266 /**
267  * Defines mask value for CAN Message Object set status. Use type \a XMC_CAN_MO_SET_STATUS_t for this enum.
268  */
269 typedef enum XMC_CAN_MO_SET_STATUS
270 {
271   XMC_CAN_MO_SET_STATUS_RX_PENDING = CAN_MO_MOCTR_SETRXPND_Msk,     /**< Set receive pending */
272   XMC_CAN_MO_SET_STATUS_TX_PENDING = CAN_MO_MOCTR_SETTXPND_Msk,     /**< Set transmit pending */
273   XMC_CAN_MO_SET_STATUS_RX_UPDATING = CAN_MO_MOCTR_SETRXUPD_Msk,    /**< Set receive updating */
274   XMC_CAN_MO_SET_STATUS_NEW_DATA = CAN_MO_MOCTR_SETNEWDAT_Msk,      /**< Set new data */
275   XMC_CAN_MO_SET_STATUS_MESSAGE_LOST = CAN_MO_MOCTR_SETMSGLST_Msk,  /**< Set message lost */
276   XMC_CAN_MO_SET_STATUS_MESSAGE_VALID = CAN_MO_MOCTR_SETMSGVAL_Msk, /**< Set message valid */
277   XMC_CAN_MO_SET_STATUS_RX_TX_SELECTED = CAN_MO_MOCTR_SETRTSEL_Msk, /**< Set transmit/receive selected */
278   XMC_CAN_MO_SET_STATUS_RX_ENABLE = CAN_MO_MOCTR_SETRXEN_Msk,       /**< Set receive enable */
279   XMC_CAN_MO_SET_STATUS_TX_REQUEST = CAN_MO_MOCTR_SETTXRQ_Msk,      /**< Set transmit request */
280   XMC_CAN_MO_SET_STATUS_TX_ENABLE0 = CAN_MO_MOCTR_SETTXEN0_Msk,     /**< Set transmit enable 0 */
281   XMC_CAN_MO_SET_STATUS_TX_ENABLE1 = CAN_MO_MOCTR_SETTXEN1_Msk,     /**< Set transmit enable 1 */
282   XMC_CAN_MO_SET_STATUS_MESSAGE_DIRECTION = CAN_MO_MOCTR_SETDIR_Msk /**< Set message direction */
283 } XMC_CAN_MO_SET_STATUS_t;
284 
285 /**
286  * Defines mask value for CAN Message Object reset status. Use type \a XMC_CAN_MO_RESET_STATUS_t for this enum.
287  */
288 typedef enum XMC_CAN_MO_RESET_STATUS
289 {
290   XMC_CAN_MO_RESET_STATUS_RX_PENDING = CAN_MO_MOCTR_RESRXPND_Msk,     /**< Reset receive pending */
291   XMC_CAN_MO_RESET_STATUS_TX_PENDING = CAN_MO_MOCTR_RESTXPND_Msk,     /**< Reset transmit pending */
292   XMC_CAN_MO_RESET_STATUS_RX_UPDATING = CAN_MO_MOCTR_RESRXUPD_Msk,    /**< Reset receive updating */
293   XMC_CAN_MO_RESET_STATUS_NEW_DATA = CAN_MO_MOCTR_RESNEWDAT_Msk,      /**< Reset new data */
294   XMC_CAN_MO_RESET_STATUS_MESSAGE_LOST = CAN_MO_MOCTR_RESMSGLST_Msk,  /**< Reset message lost */
295   XMC_CAN_MO_RESET_STATUS_MESSAGE_VALID = CAN_MO_MOCTR_RESMSGVAL_Msk, /**< Reset message valid */
296   XMC_CAN_MO_RESET_STATUS_RX_TX_SELECTED = CAN_MO_MOCTR_RESRTSEL_Msk, /**< Reset transmit/receive selected */
297   XMC_CAN_MO_RESET_STATUS_RX_ENABLE = CAN_MO_MOCTR_RESRXEN_Msk,       /**< Reset receive enable */
298   XMC_CAN_MO_RESET_STATUS_TX_REQUEST = CAN_MO_MOCTR_RESTXRQ_Msk,      /**< Reset transmit request */
299   XMC_CAN_MO_RESET_STATUS_TX_ENABLE0 = CAN_MO_MOCTR_RESTXEN0_Msk,     /**< Reset transmit enable 0 */
300   XMC_CAN_MO_RESET_STATUS_TX_ENABLE1 = CAN_MO_MOCTR_RESTXEN1_Msk,     /**< Reset transmit enable 1 */
301   XMC_CAN_MO_RESET_STATUS_MESSAGE_DIRECTION = CAN_MO_MOCTR_RESDIR_Msk /**< Reset message direction */
302 } XMC_CAN_MO_RESET_STATUS_t;
303 
304 /**
305  * Defines mask value for CAN Message Object status. Use type \a XMC_CAN_MO_STATUS_t for this enum.
306  */
307 typedef enum XMC_CAN_MO_STATUS
308 {
309   XMC_CAN_MO_STATUS_RX_PENDING = CAN_MO_MOSTAT_RXPND_Msk,                   /**< Defines message has been successfully received or not received */
310   XMC_CAN_MO_STATUS_TX_PENDING = CAN_MO_MOSTAT_TXPND_Msk,                   /**< Defines message has been successfully transmitted or not transmitted */
311   XMC_CAN_MO_STATUS_RX_UPDATING = CAN_MO_MOSTAT_RXUPD_Msk,                  /**< Defines Message identifier, DLC, and data of the message object are currently updated or not updated */
312   XMC_CAN_MO_STATUS_NEW_DATA = CAN_MO_MOSTAT_NEWDAT_Msk,                    /**< Defines no update of the message object since last flag reset or Message object has been updated */
313   XMC_CAN_MO_STATUS_MESSAGE_LOST = CAN_MO_MOSTAT_MSGLST_Msk,                /**< CAN message is lost because NEWDAT has become set again when it has already been set or No CAN message is lost */
314   XMC_CAN_MO_STATUS_MESSAGE_VALID = CAN_MO_MOSTAT_MSGVAL_Msk,               /**< Message valid */
315   XMC_CAN_MO_STATUS_RX_TX_SELECTED = CAN_MO_MOSTAT_RTSEL_Msk,               /**< Transmit/Receive selected */
316   XMC_CAN_MO_STATUS_RX_ENABLE = CAN_MO_MOSTAT_RXEN_Msk,                     /**< Receive enable */
317   XMC_CAN_MO_STATUS_TX_REQUEST = CAN_MO_MOSTAT_TXRQ_Msk,                    /**< Transmit request */
318   XMC_CAN_MO_STATUS_TX_ENABLE0 = CAN_MO_MOSTAT_TXEN0_Msk,                   /**< Transmit enable 0 */
319   XMC_CAN_MO_STATUS_TX_ENABLE1 = CAN_MO_MOSTAT_TXEN1_Msk,                   /**< Transmit enable 1 */
320   XMC_CAN_MO_STATUS_MESSAGE_DIRECTION = CAN_MO_MOSTAT_DIR_Msk,              /**< Message direction */
321   XMC_CAN_MO_STATUS_LIST = CAN_MO_MOSTAT_LIST_Msk,                          /**< List allocation */
322   XMC_CAN_MO_STATUS_POINTER_TO_PREVIOUS_MO = CAN_MO_MOSTAT_PPREV_Msk,     /**< Pointer to previous Message Object */
323   XMC_CAN_MO_STATUS_POINTER_TO_NEXT_MO = (int32_t)CAN_MO_MOSTAT_PNEXT_Msk   /**< Pointer to next Message Object */
324 } XMC_CAN_MO_STATUS_t;
325 
326 /**
327  * Defines mask value for CAN Node status. Use type \a XMC_CAN_NODE_STATUS_t for this enum.
328  */
329 typedef enum XMC_CAN_NODE_STATUS
330 {
331   XMC_CAN_NODE_STATUS_LAST_ERROR_CODE = CAN_NODE_NSR_LEC_Msk,       /**< Last Error Code */
332   XMC_CAN_NODE_STATUS_TX_OK = CAN_NODE_NSR_TXOK_Msk,                /**< Message transmitted successfully */
333   XMC_CAN_NODE_STATUS_RX_OK = CAN_NODE_NSR_RXOK_Msk,                /**< Message received successfully */
334   XMC_CAN_NODE_STATUS_ALERT_WARNING = CAN_NODE_NSR_ALERT_Msk,       /**< Alert warning */
335   XMC_CAN_NODE_STATUS_ERROR_WARNING_STATUS = CAN_NODE_NSR_EWRN_Msk, /**< Error warning status */
336   XMC_CAN_NODE_STATUS_BUS_OFF= CAN_NODE_NSR_BOFF_Msk,       /**< Bus-off status */
337   XMC_CAN_NODE_STATUS_LIST_LENGTH_ERROR = CAN_NODE_NSR_LLE_Msk,     /**< List length error */
338   XMC_CAN_NODE_STATUS_LIST_OBJECT_ERROR = CAN_NODE_NSR_LOE_Msk,     /**< List object error */
339 #if !defined(MULTICAN_PLUS)
340   XMC_CAN_NODE_STATUS_SUSPENDED_ACK = CAN_NODE_NSR_SUSACK_Msk       /**< Suspend Acknowledge */
341 #endif
342 } XMC_CAN_NODE_STATUS_t;
343 
344 /**
345  * Defines mask value for CAN Node control like initialization, node disable and analyzer mode .
346  * Use type \a XMC_CAN_NODE_CONTROL_t for this enum.
347  */
348 typedef enum XMC_CAN_NODE_CONTROL
349 {
350   XMC_CAN_NODE_CONTROL_NODE_INIT = CAN_NODE_NCR_INIT_Msk,            /**< Node initialization */
351   XMC_CAN_NODE_CONTROL_TX_INT_ENABLE = CAN_NODE_NCR_TRIE_Msk,        /**< Transfer event enable */
352   XMC_CAN_NODE_CONTROL_LEC_INT_ENABLE = CAN_NODE_NCR_LECIE_Msk,      /**< LEC Indicated Error Event Enable */
353   XMC_CAN_NODE_CONTROL_ALERT_INT_ENABLE = CAN_NODE_NCR_ALIE_Msk,     /**< Alert Event Enable */
354   XMC_CAN_NODE_CONTROL_CAN_DISABLE = CAN_NODE_NCR_CANDIS_Msk,        /**< CAN disable */
355   XMC_CAN_NODE_CONTROL_CONF_CHANGE_ENABLE= CAN_NODE_NCR_CCE_Msk,     /**< Configuration change enable */
356   XMC_CAN_NODE_CONTROL_CAN_ANALYZER_NODEDE = CAN_NODE_NCR_CALM_Msk,  /**< CAN Analyzer mode */
357 #if !defined(MULTICAN_PLUS)
358   XMC_CAN_NODE_CONTROL_SUSPENDED_ENABLE = CAN_NODE_NCR_SUSEN_Msk     /**< Suspend Enable */
359 #endif
360 } XMC_CAN_NODE_CONTROL_t;
361 
362 /**
363  * Defines mask value for CAN Node events. Use type \a XMC_CAN_NODE_EVENT_t for this enum.
364  */
365 typedef enum XMC_CAN_NODE_EVENT
366 {
367   XMC_CAN_NODE_EVENT_TX_INT = CAN_NODE_NCR_TRIE_Msk,   /**< Node Transfer OK Event */
368   XMC_CAN_NODE_EVENT_ALERT = CAN_NODE_NCR_ALIE_Msk,    /**< Node Alert Event */
369   XMC_CAN_NODE_EVENT_LEC = CAN_NODE_NCR_LECIE_Msk,     /**< Last Error code Event */
370   XMC_CAN_NODE_EVENT_CFCIE = CAN_NODE_NFCR_CFCIE_Msk   /**< CAN Frame Count Event  */
371 } XMC_CAN_NODE_EVENT_t;
372 
373 /**
374  * Defines mask value for CAN node pointer events position. Use type \a XMC_CAN_NODE_POINTER_EVENT_t for this enum.
375  */
376 typedef enum XMC_CAN_NODE_POINTER_EVENT
377 {
378   XMC_CAN_NODE_POINTER_EVENT_ALERT = CAN_NODE_NIPR_ALINP_Pos,           /**< Node Alert Event node pointer */
379   XMC_CAN_NODE_POINTER_EVENT_LEC = CAN_NODE_NIPR_LECINP_Pos,            /**< Last Error code Event node pointer */
380   XMC_CAN_NODE_POINTER_EVENT_TRANSFER_OK = CAN_NODE_NIPR_TRINP_Pos,     /**< Transmit Event node pointer */
381   XMC_CAN_NODE_POINTER_EVENT_FRAME_COUNTER = CAN_NODE_NIPR_CFCINP_Pos   /**< CAN Frame Count Event node pointer */
382 } XMC_CAN_NODE_POINTER_EVENT_t;
383 
384 /**
385  * Defines CAN Message Object event node pointer position. Use type \a XMC_CAN_MO_POINTER_EVENT_t for this enum.
386  */
387 typedef enum XMC_CAN_MO_POINTER_EVENT
388 {
389   XMC_CAN_MO_POINTER_EVENT_TRANSMIT = CAN_MO_MOIPR_TXINP_Pos,     /**< Transmit Event node pointer */
390   XMC_CAN_MO_POINTER_EVENT_RECEIVE = CAN_MO_MOIPR_RXINP_Pos       /**< Receive Event node pointer */
391 } XMC_CAN_MO_POINTER_EVENT_t;
392 
393 /**
394  * Defines mask value for CAN Message Object event type. Use type \a XMC_CAN_MO_EVENT_t for this enum.
395  */
396 typedef enum XMC_CAN_MO_EVENT
397 {
398   XMC_CAN_MO_EVENT_TRANSMIT = CAN_MO_MOFCR_TXIE_Msk,  /**< Message Object transmit event */
399   XMC_CAN_MO_EVENT_RECEIVE = CAN_MO_MOFCR_RXIE_Msk,   /**< Message Object receive event */
400   XMC_CAN_MO_EVENT_OVERFLOW = CAN_MO_MOFCR_OVIE_Msk,  /**< Message Object overflow event */
401 } XMC_CAN_MO_EVENT_t;
402 
403 /**
404  * Defines the possible receive inputs. Use type \a XMC_CAN_NODE_RECEIVE_INPUT_t for this enum.
405  */
406 typedef enum XMC_CAN_NODE_RECEIVE_INPUT
407 {
408   XMC_CAN_NODE_RECEIVE_INPUT_RXDCA,   /**< CAN Receive Input A */
409   XMC_CAN_NODE_RECEIVE_INPUT_RXDCB,   /**< CAN Receive Input B */
410   XMC_CAN_NODE_RECEIVE_INPUT_RXDCC,   /**< CAN Receive Input C */
411   XMC_CAN_NODE_RECEIVE_INPUT_RXDCD,   /**< CAN Receive Input D */
412   XMC_CAN_NODE_RECEIVE_INPUT_RXDCE,   /**< CAN Receive Input E */
413   XMC_CAN_NODE_RECEIVE_INPUT_RXDCF,   /**< CAN Receive Input F */
414   XMC_CAN_NODE_RECEIVE_INPUT_RXDCG,   /**< CAN Receive Input G */
415   XMC_CAN_NODE_RECEIVE_INPUT_RXDCH    /**< CAN Receive Input H */
416 } XMC_CAN_NODE_RECEIVE_INPUT_t;
417 
418 /**
419  * Defines last error transfer direction. Use type \a XMC_CAN_NODE_LAST_ERROR_DIR_t for this enum.
420  */
421 typedef enum XMC_CAN_NODE_LAST_ERROR_DIR
422 {
423   XMC_CAN_NODE_LAST_ERROR_DIR_WHILE_NODE_RECEPCION,    /**< The last error occurred while the CAN node x was receiver */
424   XMC_CAN_NODE_LAST_ERROR_DIR_WHILE_NODE_TRANSMISSION  /**< The last error occurred while the CAN node x was transmitter */
425 } XMC_CAN_NODE_LAST_ERROR_DIR_t;
426 
427 
428 /**
429  * Defines last error increment. Use type \a XMC_CAN_NODE_LAST_ERROR_INC_t for this enum.
430  */
431 typedef enum XMC_CAN_NODE_LAST_ERROR_INC
432 {
433   XMC_CAN_NODE_LAST_ERROR_INC_1, /**< The last error led to an error counter increment of 1. */
434   XMC_CAN_NODE_LAST_ERROR_INC_8  /**< The last error led to an error counter increment of 8. */
435 } XMC_CAN_NODE_LAST_ERROR_INC_t;
436 
437 /**
438  * Defines interrupt request on interrupt output line INT_O[n]. Use type \a XMC_CAN_NODE_INTERRUPT_TRIGGER_t for this enum.
439  */
440 typedef enum XMC_CAN_NODE_INTERRUPT_TRIGGER
441 {
442   XMC_CAN_NODE_INTR_TRIGGER_0 = 0x1U,
443   XMC_CAN_NODE_INTR_TRIGGER_1 = 0x2U,
444   XMC_CAN_NODE_INTR_TRIGGER_2 = 0x4U,
445   XMC_CAN_NODE_INTR_TRIGGER_3 = 0x8U,
446   XMC_CAN_NODE_INTR_TRIGGER_4 = 0x16U,
447   XMC_CAN_NODE_INTR_TRIGGER_5 = 0x32U,
448   XMC_CAN_NODE_INTR_TRIGGER_6 = 0x64U,
449   XMC_CAN_NODE_INTR_TRIGGER_7 = 0x128U,
450 } XMC_CAN_NODE_INTERRUPT_TRIGGER_t;
451 
452 /**
453  * Defines the Clock source used for the MCAN baudrate generator
454  */
455 typedef enum XMC_CAN_CANCLKSRC
456 {
457 #if defined(MULTICAN_PLUS) || defined(DOXYGEN)
458 #if (UC_FAMILY == XMC4)
459   XMC_CAN_CANCLKSRC_FPERI = 0x1U, /**< Use peripheral clock as MCAN baudrate generator input clock. */
460 #else
461   XMC_CAN_CANCLKSRC_MCLK = 0x1U, /**< Use peripheral clock as MCAN baudrate generator input clock. */
462 #endif
463   XMC_CAN_CANCLKSRC_FOHP = 0x2U, /**< Use high performance oscillator (fOHP) as MCAN baudrate generator input clock. @note Only available for XMC1400, XMC4800 and XMC4700 series*/
464 #else
465   XMC_CAN_CANCLKSRC_FPERI = 0x1U, /**< Use peripheral clock as MCAN baudrate generator input clock. */
466 #endif
467 } XMC_CAN_CANCLKSRC_t;
468 
469 /*********************************************************************************************************************
470  * DATA STRUCTURES
471  ********************************************************************************************************************/
472 /**
473  * Defines CAN node Nominal Bit Time. Use type \a XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t for this structure.
474 */
475 typedef struct XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG
476 {
477   uint32_t can_frequency;       /**< Frequency of the CAN module(fCAN). \a can_frequency shall be range of 5MHz to 144MHz */
478   uint32_t baudrate;          /**< Specifies the node baud rate. Unit: baud \a baudrate shall be range of 100Kbps to 1000Kbps*/
479   uint16_t sample_point;      /**< Sample point is used to compensate mismatch between transmitter and receiver clock phases detected in
480                    the synchronization segment. Sample point. Range = [0, 10000] with respect [0%, 100%] of the total bit time.*/
481   uint16_t sjw;               /**< (Re) Synchronization Jump Width. Range:0-3 */
482 } XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t;
483 
484 /**
485  * Defines base, top and bottom of CAN Message Object FIFO Structure. Use type \a XMC_CAN_FIFO_CONFIG_t for this structure.
486  * A FIFO consists of one base object and n slave objects.
487  */
488 typedef struct XMC_CAN_FIFO_CONFIG
489 {
490   uint8_t fifo_bottom;    /**< points to the first element(slave object) in a FIFO structure.Range :0-63*/
491   uint8_t fifo_top;     /**< points to the last element(slave object) in a FIFO structure. Range :0-63*/
492   uint8_t fifo_base;    /**< points to the actual target object(Base object) within a FIFO/Gateway structure. Range :0-63*/
493 } XMC_CAN_FIFO_CONFIG_t;
494 
495 /**
496  * Defines CAN Gateway FIFO structure and provides additional options for gateway destination object.
497  * Use type \a XMC_CAN_GATEWAY_CONFIG_t for this structure.
498  */
499 typedef struct XMC_CAN_GATEWAY_CONFIG
500 {
501   uint8_t gateway_bottom;       /**< points to the first element(gateway destination object) in a FIFO structure. Range :0-63*/
502   uint8_t gateway_top;        /**< points to the last element(gateway destination object) in a FIFO structure.  Range :0-63*/
503   uint8_t gateway_base;       /**< points to the actual target object within a FIFO/Gateway structure. Range :0-63*/
504   bool gateway_data_frame_send;   /**< TXRQ updated in the gateway destination object after the internal transfer from the gateway source
505                                          to the gateway destination object */
506   bool gateway_identifier_copy;   /**< The identifier of the gateway source object (after storing the received frame in the source) is copied
507                                          to the gateway destination object. */
508 
509   bool gateway_data_length_code_copy; /**< Data length code of the gateway source object (after storing the received frame in the source) is copied to the
510                                            gateway destination object */
511   bool gateway_data_copy;  /**< Data fields in registers MODATALn and MODATAHn of the gateway source object (after storing the received frame in the source)
512                                 are copied to the gateway destination.*/
513 
514 } XMC_CAN_GATEWAY_CONFIG_t;
515 
516 /**
517 * Defines CAN Global Initialization structure
518 */
519 typedef CAN_GLOBAL_TypeDef XMC_CAN_t;
520 
521 /*Anonymous structure/union guard start*/
522 #if defined(__CC_ARM)
523   #pragma push
524   #pragma anon_unions
525 #elif defined(__TASKING__)
526   #pragma warning 586
527 #endif
528 
529 /**
530  * Defines frame counter configuration. Use type \a XMC_CAN_NODE_FRAME_COUNTER_t for this structure.
531  * It provides configuration of frame counter that counts transmitted/received CAN frames or obtains information about the time
532  * when a frame has been started to transmit or be received by the CAN node.
533 */
534 typedef struct XMC_CAN_NODE_FRAME_COUNTER
535 {
536 
537   union{
538     struct{
539       uint32_t : 16;
540       uint32_t can_frame_count_selection:3;   /**<   Defines function of the frame counter  */
541       uint32_t can_frame_count_mode:2;      /**<   Determines the operation mode of the frame counter */
542       uint32_t : 11;
543     };
544     uint32_t nfcr;
545 
546   };
547 } XMC_CAN_NODE_FRAME_COUNTER_t;
548 
549 /**
550  *Defines Node Runtime structure.
551 */
552 typedef CAN_NODE_TypeDef  XMC_CAN_NODE_t;            /**<  pointer to the Node CAN register */
553 
554 /**
555  * Defines CAN Message Object runtime elements. Use type \a XMC_CAN_MO_t for this structure.
556  */
557 typedef struct XMC_CAN_MO
558 {
559   CAN_MO_TypeDef *can_mo_ptr;                     /**< Pointer to the Message Object CAN register */
560   union{
561     struct{
562       uint32_t can_identifier:29;            /**< standard (11 bit)/Extended (29 bit) message identifier */
563       uint32_t can_id_mode:1;                /**< Standard/Extended identifier support */
564       uint32_t can_priority:2;               /**< Arbitration Mode/Priority */
565     };
566     uint32_t mo_ar;
567   };
568   union{
569     struct{
570       uint32_t can_id_mask:29;              /**< CAN Identifier of Message Object */
571       uint32_t can_ide_mask:1;              /**< Identifier Extension Bit of Message Object */
572     };
573     uint32_t mo_amr;
574   };
575   uint8_t can_data_length;                        /**< Message data length, Range:0-8 */
576 
577   union{
578 
579       uint8_t can_data_byte[8];                 /**< Each position of the array represents a data byte*/
580       uint16_t can_data_word[4];                /**< Each position of the array represents a 16 bits data word*/
581       uint32_t can_data[2];                     /**< can_data[0] lower 4 bytes of the data. can_data[1], higher 4 bytes
582                               of the data */
583       uint64_t can_data_long;                   /** Data of the Message Object*/
584       };
585 
586   XMC_CAN_MO_TYPE_t can_mo_type;                  /**<  Message Type */
587 
588 } XMC_CAN_MO_t;
589 /*Anonymous structure/union guard end*/
590 #if defined(__CC_ARM)
591   #pragma pop
592 #elif defined(__TASKING__)
593   #pragma warning restore
594 #endif
595 /*********************************************************************************************************************
596  * API Prototypes
597  ********************************************************************************************************************/
598 #ifdef __cplusplus
599 extern "C" {
600 #endif
601 
602 /**
603  *
604  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
605  *        for details.
606  *
607  * @return None
608  *
609  * \par<b>Description:</b><br>
610  *  Disables CAN module. In disabled state, no registers of CAN module can be read or written except the CAN_CLC register.
611  *
612  * \par<b>Related APIs:</b><BR>
613  * XMC_CAN_Enable()\n\n\n
614  *
615  */
616 
617 void XMC_CAN_Disable(XMC_CAN_t *const obj);
618 
619 /**
620  *
621  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
622  *         for details.
623  *
624  * @return None
625  *
626  * \par<b>Description:</b><br>
627  *  Enables CAN module and initializes all CAN registers to reset values. It is required to re-configure desired CAN nodes,
628  *  before any data transfer. It configures CAN_CLC.DISR bit.
629  *
630  * \par<b>Related APIs:</b><BR>
631  *  XMC_CAN_Disable()\n\n\n
632  *
633  */
634 
635 void XMC_CAN_Enable(XMC_CAN_t *const obj);
636 
637 /**
638  *
639  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
640  *       for details.
641  *
642  * @param node_num  CAN node number,Range : 0-2
643  * @param mo_num  CAN Message Object number,Range : 0-63
644  *
645  * @return None
646  *
647  * \par<b>Description:</b><br>
648  *  Allocates Message Object from free list to node list. Each \a node_num is linked to one unique list of message objects.
649  *  A CAN node performs message transfer only with the \a mo_num message objects that are allocated to the list of the CAN node.
650  *  It configures PANCTR register.
651  *
652  * \par<b>Related APIs:</b><BR>
653  *  None
654  *
655  */
656 
657 void XMC_CAN_AllocateMOtoNodeList(XMC_CAN_t *const obj, const uint8_t node_num, const uint8_t mo_num);
658 
659 /**
660  *
661  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
662  *       for details.
663  *
664  * @return Ready status of list controller
665  *
666  * \par<b>Description:</b><br>
667  *  Returns ready status of the list controller
668  *
669  * \par<b>Related APIs:</b><BR>
670  *  XMC_CAN_PanelControl()
671  *
672  */
XMC_CAN_IsPanelControlReady(XMC_CAN_t * const obj)673 __STATIC_INLINE bool XMC_CAN_IsPanelControlReady(XMC_CAN_t *const obj)
674 {
675   return (bool)((obj->PANCTR & (CAN_PANCTR_BUSY_Msk | CAN_PANCTR_RBUSY_Msk)) == 0);
676 }
677 
678 /**
679  *
680  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
681  *        for details.
682  *
683  * @param pancmd panal command selection. Refer @ref XMC_CAN_PANCMD_t for valid values.
684  * @param arg1   Panel Argument 1,Range : 0-2
685  * @param arg2   Panel Argument 2, Range : 0-63
686  *
687  * @return None
688  *
689  * \par<b>Description:</b><br>
690  *  Configures the panel command and panel arguments. A panel operation consists of a command code (PANCMD) and up to two
691  *  panel arguments (PANAR1, PANAR2). Commands that have a return value deliver it to the PANAR1 bit field. Commands that
692  *  return an error flag deliver it to bit 31 of the Panel Control Register, this means bit 7 of PANAR2. \a arg1 represents
693  *  panel argument PANAR1,\a arg2 represents panel argument PANAR2 and \a pancmd represents command code. It configures PANCTR
694  *  register.
695  *
696  * \par<b>Related APIs:</b><BR>
697  *  None
698  *
699  */
700 
XMC_CAN_PanelControl(XMC_CAN_t * const obj,const XMC_CAN_PANCMD_t pancmd,const uint8_t arg1,const uint8_t arg2)701 __STATIC_INLINE void XMC_CAN_PanelControl(XMC_CAN_t *const obj,
702                                           const XMC_CAN_PANCMD_t pancmd,
703                                       const uint8_t arg1,
704                                       const uint8_t arg2)
705 {
706   obj->PANCTR = (((uint32_t)pancmd << CAN_PANCTR_PANCMD_Pos) & (uint32_t)CAN_PANCTR_PANCMD_Msk) |
707             (((uint32_t)arg1 << CAN_PANCTR_PANAR1_Pos) & (uint32_t)CAN_PANCTR_PANAR1_Msk) |
708             (((uint32_t)arg2 << CAN_PANCTR_PANAR2_Pos) & (uint32_t)CAN_PANCTR_PANAR2_Msk);
709 }
710 
711 
712 /**
713  *
714  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
715  *        for details.
716  *
717  * @param service_requestr  Interrupt trigger number selection. Refer @ref XMC_CAN_NODE_INTERRUPT_TRIGGER_t for valid values.
718  *               Multiple interrupt trigger events can be ORed.
719  *
720  * @return None
721  *
722  * \par<b>Description:</b><br>
723  *  Configures multiple interrupt requests with a single write operation. \a service_requestr represents single interrupt
724  *  request or multiple.It configures MITR register.
725  *
726  * \par<b>Related APIs:</b><BR>
727  *  None
728  *
729  */
730 
XMC_CAN_EventTrigger(XMC_CAN_t * const obj,const XMC_CAN_NODE_INTERRUPT_TRIGGER_t service_requestr)731 __STATIC_INLINE void XMC_CAN_EventTrigger(XMC_CAN_t *const obj,const XMC_CAN_NODE_INTERRUPT_TRIGGER_t service_requestr)
732 {
733   obj->MITR = ((uint32_t)service_requestr << CAN_MITR_IT_Pos) & (uint32_t)CAN_MITR_IT_Msk;
734 }
735 
736 
737 /**
738  *
739  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
740  *        for details.
741  *
742  * @param clksrc CAN module frequency clock source
743  * @param can_frequency CAN module frequency(fCAN).
744  *        The can_frequency shall be an integer divisor of the CAN clock source frequency (fPERI/fMCLK or fOHP) and
745  *        it should be selected such that if fulfills the minimum operating frequency specified in the clock control section of the reference manual.
746  *        In addition the can_frequency shall be an integer multiple of the baudrate.
747  *        Max. value: Max. clock source frequency, i.e. if using fOHP and using a XTAL of 20MHz then fCAN max. value is 20MHz.
748  *
749  * @return Actual frequency
750  *
751  * \par<b>Description:</b><br>
752  * Similar to XMC_CAN_Init() configures clock rate of the module timer clock fCAN.
753  * The difference being that only the normal divider is used to avoid jitter.
754  * In addition the actual achievable frequency is returned.
755  * @note Use XMC_CAN_InitEx() for new projects. XMC_CAN_Init() is kept for backward compatibility reasons.
756  *
757  * Altering CAN module \a can_frequency shall affects baud rate, call XMC_CAN_NODE_NominalBitTimeConfigureEx() to configure baud rate for current CAN frequency.
758  * It configures FDR register.
759  *
760  * \par<b>Related APIs:</b><BR>
761  * XMC_CAN_NODE_NominalBitTimeConfigure(), XMC_CAN_NODE_NominalBitTimeConfigureEx()\n\n\n
762  *
763  */
764 uint32_t XMC_CAN_InitEx(XMC_CAN_t *const obj, XMC_CAN_CANCLKSRC_t clksrc, uint32_t can_frequency);
765 
766 /**
767  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
768  *        for details.
769  *
770  * @return Baudrate generator clock source
771  *
772  * \par<b>Description:</b><br>
773  * Returns CAN baudrate generator clock source
774  */
775 XMC_CAN_CANCLKSRC_t XMC_CAN_GetBaudrateClockSource(XMC_CAN_t *const obj);
776 
777 /**
778  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
779  *        for details.
780  *
781  * @return None
782  *
783  * \par<b>Description:</b><br>
784  * Sets CAN baudrate generator clock source
785  */
786 void XMC_CAN_SetBaudrateClockSource(XMC_CAN_t *const obj,const XMC_CAN_CANCLKSRC_t source);
787 
788 /**
789  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
790  *        for details.
791  *
792  * @return baudrate generator input clock frequency
793  *
794  * \par<b>Description:</b><br>
795  * Gets CAN baudrate generator input clock frequency
796  */
797 uint32_t XMC_CAN_GetBaudrateClockFrequency(XMC_CAN_t *const obj);
798 
799 /**
800  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
801  *        for details.
802  *
803  * @return fCAN clock frequency
804  *
805  * \par<b>Description:</b><br>
806  * Gets CAN base clock frequency
807  *
808  */
809 uint32_t XMC_CAN_GetClockFrequency(XMC_CAN_t *const obj);
810 
811 #if defined(MULTICAN_PLUS) || defined(DOXYGEN)
812 /**
813  *
814  * @param obj Pointer pointing to XMC_CAN Global Initialization structure. Defines CAN global registers,refer CAN_NODE_TypeDef
815  *        for details.
816  *
817  * @param clksrc CAN module frequency clock source.
818  * @param can_frequency CAN module frequency(fCAN). Max. value: Max. clock source frequency, i.e. if using fOHP and using a XTAL of 20MHz then fCAN max. value is 20MHz.
819  * @note Use clksrc parameter only for XMC1400 series and XMC47/4800 series projects, otherwise omit this parameter.
820  *
821  * @return None
822  *
823  * \par<b>Description:</b><br>
824  * Configures clock rate of the module timer clock fCAN. Altering CAN module \a can_frequency shall affects baud rate,
825  * call XMC_CAN_NODE_NominalBitTimeConfigure() or XMC_CAN_NODE_NominalBitTimeConfigureEx() to configure baud rate for current CAN frequency.
826  * It configures FDR register.
827  *
828  * @note Use XMC_CAN_InitEx() for new projects. XMC_CAN_Init() is kept for backward compatibility reasons.
829  *
830  * \par<b>Related APIs:</b><BR>
831  * XMC_CAN_NODE_NominalBitTimeConfigure(), XMC_CAN_NODE_NominalBitTimeConfigureEx(), XMC_CAN_InitEx()\n\n\n
832  *
833  */
834 void XMC_CAN_Init(XMC_CAN_t *const obj, XMC_CAN_CANCLKSRC_t clksrc, uint32_t can_frequency);
835 #else
836 void XMC_CAN_Init(XMC_CAN_t *const obj, uint32_t can_frequency);
837 #endif
838 
839 /**
840  *
841  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
842  *
843  * @return None
844  *
845  * \par<b>Description:</b><br>
846  * Initializes CAN message object. Initialization includes configuring Message Object identifier type, Message Object
847  * identifier value, Message Object type, and transfer requests. It configures FDR register.
848  *
849  * \par<b>Related APIs:</b><BR>
850  * None
851  *
852  */
853 void XMC_CAN_MO_Config(const XMC_CAN_MO_t *const can_mo);
854 
855 /* NODE APIs */
856 
857 /**
858  *
859  * @param can_node      Pointer pointing to CAN_NODE Structure. Defines CAN_NODE registers.
860  * @param ptr_event     CAN_NODE interrupt pointer position. Refer @ref XMC_CAN_NODE_POINTER_EVENT_t structure for valid values.
861  * @param service_request Interrupt service request number. Range : 0-7
862  *
863  * @return None
864  *
865  * \par<b>Description:</b><br>
866  *  Configures node interrupt pointer \a service_request for CAN Node events \a ptr_event. It configures NIPR register.
867  *
868  * \par<b>Related APIs:</b><BR>
869  * None
870  *
871  */
872 
XMC_CAN_NODE_SetEventNodePointer(XMC_CAN_NODE_t * const can_node,const XMC_CAN_NODE_POINTER_EVENT_t ptr_event,const uint32_t service_request)873 __STATIC_INLINE void XMC_CAN_NODE_SetEventNodePointer(XMC_CAN_NODE_t *const can_node,
874                                           const XMC_CAN_NODE_POINTER_EVENT_t ptr_event,
875                                           const uint32_t service_request)
876 {
877   can_node->NIPR = (uint32_t)((can_node->NIPR) & ~(uint32_t)(CAN_NODE_NIPR_Msk << (uint32_t)ptr_event)) | (service_request << (uint32_t)ptr_event);
878 }
879 
880 
881 /**
882  *
883  * @param can_node    Pointer pointing to CAN_NODE Structure. Defines CAN_NODE registers. Range :CAN_NODE0-CAN_NODE2
884  * @param can_bit_time  Nominal bit time configuration data structure. Refer @ref XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t for details.
885  *
886  * @return None
887  *
888  * \par<b>Description:</b><br>
889  * Configures CAN node Baudrate. \a can_bit_time specifies required baudrate for a specified \a can_node.
890  * It configures NBTR register.
891  *
892  * \par<b>Related APIs:</b><BR>
893  * None
894  *
895  */
896 void XMC_CAN_NODE_NominalBitTimeConfigure(XMC_CAN_NODE_t *const can_node,
897                                           const XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t *const can_bit_time);
898 
899 /**
900  *
901  * @param can_node    Pointer pointing to CAN_NODE Structure. Defines CAN_NODE registers. Range :CAN_NODE0-CAN_NODE2
902  * @param can_bit_time  Nominal bit time configuration data structure. Refer @ref XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t for details.
903  *
904  * @return Status on the sucess setting the desired bitrate XMC_CAN_STATUS_t
905  *
906  * \par<b>Description:</b><br>
907  * Similar to XMC_CAN_NODE_NominalBitTimeConfigure() configures the CAN node baudrate.
908  * The difference being that allows bitrates below 100kpbs.
909  * @note Consider using the new API for new projects. XMC_CAN_NODE_NominalBitTimeConfigure() is kept for backward compatibility reasons.
910  *
911  * Configures CAN node Baudrate. \a can_bit_time specifies required baudrate for a specified \a can_node.
912  * It configures NBTR register.
913  *
914  * \par<b>Related APIs:</b><BR>
915  * XMC_CAN_InitEx()
916  *
917  */
918 int32_t XMC_CAN_NODE_NominalBitTimeConfigureEx(XMC_CAN_NODE_t *const can_node,
919                                                const XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t *const can_bit_time);
920 
921 /**
922  * @param can_node Pointer pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
923  * @param input    CAN receive input selection. Refer @ref XMC_CAN_NODE_RECEIVE_INPUT_t for details.
924  *
925  * @return None
926  *
927  * \par<b>Description:</b><br>
928  * \a input specifies CAN input receive pin. This API Configures NPCRx register,it is required to call
929  * XMC_CAN_NODE_EnableConfigurationChange(), before configuring NPCRx register, call XMC_CAN_NODE_DisableConfigurationChange()
930  * API after configuring NPCRx register. CAN input receive pins which falls under analog port pins should call
931  * XMC_GPIO_EnableDigitalInput(),to enable digital pad.
932  *
933  *\par<b>Related APIs:</b><BR>
934  * None
935  *
936  * \par<b>Note:</b><br>
937  * NPCRx can be written only if bit NCRx.CCE is set.
938  *
939  */
940 
XMC_CAN_NODE_SetReceiveInput(XMC_CAN_NODE_t * const can_node,const XMC_CAN_NODE_RECEIVE_INPUT_t input)941 __STATIC_INLINE void XMC_CAN_NODE_SetReceiveInput(XMC_CAN_NODE_t *const can_node,
942                                               const XMC_CAN_NODE_RECEIVE_INPUT_t input)
943 {
944   can_node->NPCR = ((can_node->NPCR) & ~(uint32_t)(CAN_NODE_NPCR_RXSEL_Msk)) |
945                    (((uint32_t)input << CAN_NODE_NPCR_RXSEL_Pos) & (uint32_t)CAN_NODE_NPCR_RXSEL_Msk);
946 }
947 
948 
949 /**
950  * @param can_node  Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
951  *
952  * @return None
953  *
954  * \par<b>Description:</b><br>
955  * Enable Node \a can_node in Loop-Back Mode. A Node is connected to an internal (virtual) loop-back CAN bus. All CAN
956  * nodes which are in Loop- Back Mode are connected to this virtual CAN bus so that they can communicate with each
957  * other internally. The external transmit line is forced recessive in Loop-Back Mode. This API Configures NPCRx register.
958  * call XMC_CAN_NODE_EnableConfigurationChange() API before NPCRx configuration, same way XMC_CAN_NODE_DisableConfigurationChange()
959  * API after NPCRx configuration configuration.
960  *
961  * \par<b>Related APIs:</b><BR>]
962  *  XMC_CAN_NODE_DisableLoopBack().
963  *
964  *  \par<b>Note:</b><br>
965  *  NPCRx can be written only if bit NCRx.CCE is set.
966  *
967  */
968 
XMC_CAN_NODE_EnableLoopBack(XMC_CAN_NODE_t * const can_node)969 __STATIC_INLINE void XMC_CAN_NODE_EnableLoopBack(XMC_CAN_NODE_t *const can_node)
970 {
971   can_node->NPCR |= (uint32_t)CAN_NODE_NPCR_LBM_Msk;
972 }
973 
974 
975 /**
976  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
977  *
978  * @return None
979  *
980  * \par<b>Description:</b><br>
981  * Disable Node Loop-Back Mode, disables internal (virtual) loop-back CAN bus. This API Configures NPCRx register.
982  * Call XMC_CAN_NODE_EnableConfigurationChange() API before NPCRx configuration, same way XMC_CAN_NODE_DisableConfigurationChange()
983  * API after NPCRx configuration.
984  *
985  * \par<b>Related APIs:</b><BR>]
986  * XMC_CAN_NODE_EnableLoopBack()
987  *
988  *
989  * \par<b>Note:</b><br>
990  * NPCRx can be written only if bit NCRx.CCE is set.
991  *
992  */
993 
XMC_CAN_NODE_DisableLoopBack(XMC_CAN_NODE_t * const can_node)994 __STATIC_INLINE void XMC_CAN_NODE_DisableLoopBack(XMC_CAN_NODE_t *const can_node)
995 {
996   can_node->NPCR &= ~(uint32_t)CAN_NODE_NPCR_LBM_Msk;
997 }
998 
999 
1000 /**
1001  *
1002  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1003  * @param event    CAN node event mask value. Refer @ref XMC_CAN_NODE_EVENT_t structure for valid values.
1004  *           multiple events can be ORed.
1005  *
1006  * @return None
1007  *
1008  * \par<b>Description:</b><br>
1009  *  Enable CAN Node events. It configures NFCR register.
1010  *
1011  * \par<b>Related APIs:</b><BR>
1012  * XMC_CAN_NODE_DisableEvent()
1013  *
1014  */
1015 
1016 void XMC_CAN_NODE_EnableEvent(XMC_CAN_NODE_t *const can_node, const XMC_CAN_NODE_EVENT_t event);
1017 
1018 
1019 /**
1020  *
1021  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1022  * @param event    CAN node event mask value. Refer @ref XMC_CAN_NODE_EVENT_t structure for valid values.
1023  *           multiple events can be ORed.
1024  *
1025  * @return None
1026  *
1027  * \par<b>Description:</b><br>
1028  *  Disable CAN Node events. It configures NFCR register.
1029  *
1030  * \par<b>Related APIs:</b><BR>
1031  * XMC_CAN_NODE_EnableEvent()
1032  *
1033  */
1034 
1035 void XMC_CAN_NODE_DisableEvent(XMC_CAN_NODE_t *const can_node, const XMC_CAN_NODE_EVENT_t event);
1036 
1037 
1038 /**
1039  *
1040  * @param node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1041  *
1042  * @return XMC_CAN_NODE_LAST_ERROR_DIR_t Last error transfer direction. Refer @ref XMC_CAN_NODE_LAST_ERROR_DIR_t.
1043  *
1044  * \par<b>Description:</b><br>
1045  * Returns NODE Last Error occurred during Transmit/receive direction. It returns value of NFCR register.
1046  *
1047  * \par<b>Related APIs:</b><BR>
1048  * XMC_CAN_NODE_GetLastErrTransferInc()\n\n\n
1049  *
1050  */
1051 
XMC_CAN_NODE_GetLastErrTransferDir(XMC_CAN_NODE_t * const node)1052 __STATIC_INLINE XMC_CAN_NODE_LAST_ERROR_DIR_t XMC_CAN_NODE_GetLastErrTransferDir(XMC_CAN_NODE_t *const node)
1053 {
1054   return (XMC_CAN_NODE_LAST_ERROR_DIR_t)(((node->NECNT) & CAN_NODE_NECNT_LETD_Msk) >> CAN_NODE_NECNT_LETD_Pos);
1055 }
1056 
1057 
1058 /**
1059  *
1060  * @param node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1061  *
1062  * @return XMC_CAN_NODE_LAST_ERROR_INC_t Last error transfer increment. Refer @ref XMC_CAN_NODE_LAST_ERROR_INC_t.
1063  *
1064  * \par<b>Description:</b><br>
1065  *  Returns NODE Last Error Transfer Increment. It returns value of NFCR register.
1066  *
1067  * \par<b>Related APIs:</b><BR>
1068  * XMC_CAN_NODE_GetLastErrTransferDir()\n\n\n
1069  *
1070  */
1071 
XMC_CAN_NODE_GetLastErrTransferInc(XMC_CAN_NODE_t * const node)1072 __STATIC_INLINE XMC_CAN_NODE_LAST_ERROR_INC_t XMC_CAN_NODE_GetLastErrTransferInc(XMC_CAN_NODE_t *const node)
1073 {
1074   return (XMC_CAN_NODE_LAST_ERROR_INC_t)(((node->NECNT) & CAN_NODE_NECNT_LEINC_Msk)>> CAN_NODE_NECNT_LEINC_Pos);
1075 }
1076 
1077 
1078 /**
1079  *
1080  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1081  * @param  error_warning_level  Error Warning level value. Range :0-255.
1082  *
1083  * @return None
1084  *
1085  * \par<b>Description:</b><br>
1086  * Configures error warning level in order to set the corresponding error warning bit EWRN. It configures \a error_warning_level
1087  * into NECNT register. Before this configuration call XMC_CAN_NODE_EnableConfigurationChange() API.
1088  *
1089  * \par<b>Related APIs:</b><BR>
1090  * XMC_CAN_NODE_GetErrorWarningLevel()\n\n\n
1091  *
1092  * \par<b>Note:</b><br>
1093  *  NECNTx can be written only if bit NCRx.CCE is set.
1094  *
1095  */
1096 
XMC_CAN_NODE_SetErrorWarningLevel(XMC_CAN_NODE_t * const can_node,uint8_t error_warning_level)1097 __STATIC_INLINE void XMC_CAN_NODE_SetErrorWarningLevel(XMC_CAN_NODE_t *const can_node, uint8_t error_warning_level)
1098 {
1099   can_node->NECNT = ((can_node->NECNT) & ~(uint32_t)(CAN_NODE_NECNT_EWRNLVL_Msk)) |
1100                     (((uint32_t)error_warning_level << CAN_NODE_NECNT_EWRNLVL_Pos) & (uint32_t)CAN_NODE_NECNT_EWRNLVL_Msk);
1101 }
1102 
1103 
1104 /**
1105  *
1106  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1107  * @param can_tec  transmit error counter value. Range :0-255
1108  *
1109  * @return None
1110  *
1111  * \par<b>Description:</b><br>
1112  *  Configures Transmit error counter. It configures \a can_tec into NECNT register. Before this configuration call
1113  *  XMC_CAN_NODE_EnableConfigurationChange() API.
1114  *
1115  * \par<b>Related APIs:</b><BR>
1116  * XMC_CAN_NODE_GetTransmitErrorCounter()\n\n\n
1117  *
1118  *  \par<b>Note:</b><br>
1119  *  NECNTx can be written only if bit NCRx.CCE is set.
1120  *
1121  */
1122 
1123 
XMC_CAN_NODE_SetTransmitErrorCounter(XMC_CAN_NODE_t * const can_node,uint8_t can_tec)1124 __STATIC_INLINE void XMC_CAN_NODE_SetTransmitErrorCounter(XMC_CAN_NODE_t *const can_node, uint8_t can_tec)
1125 {
1126   can_node->NECNT = ((can_node->NECNT) & ~(uint32_t)(CAN_NODE_NECNT_TEC_Msk)) |
1127                     (((uint32_t)can_tec << CAN_NODE_NECNT_TEC_Pos) & (uint32_t)CAN_NODE_NECNT_TEC_Msk);
1128 }
1129 
1130 
1131 /**
1132  *
1133  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1134  * @param can_rec  receive error counter value. Range :0-255
1135  *
1136  * @return None
1137  *
1138  * \par<b>Description:</b><br>
1139  * Configures Receive Error Counter. It configures \a can_rec into NECNT register. Before this configuration call
1140  * XMC_CAN_NODE_EnableConfigurationChange() API.
1141  *
1142  * \par<b>Related APIs:</b><BR>
1143  * XMC_CAN_NODE_GetReceiveErrorCounter()\n\n\n
1144  *
1145  * \par<b>Note:</b><br>
1146  *  NECNTx can be written only if bit NCRx.CCE is set.
1147  *
1148  */
1149 
XMC_CAN_NODE_SetReceiveErrorCounter(XMC_CAN_NODE_t * const can_node,uint8_t can_rec)1150 __STATIC_INLINE void XMC_CAN_NODE_SetReceiveErrorCounter(XMC_CAN_NODE_t *const can_node, uint8_t can_rec)
1151 {
1152  can_node->NECNT = ((can_node->NECNT) & ~(uint32_t)(CAN_NODE_NECNT_REC_Msk)) |
1153                    (((uint32_t)can_rec << CAN_NODE_NECNT_REC_Pos) & (uint32_t)CAN_NODE_NECNT_REC_Msk);
1154 }
1155 
1156 
1157 /**
1158  *
1159  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1160  *
1161  * @return uint8_t Error Warning Level. Range :0 - 255
1162  *
1163  * \par<b>Description:</b><br>
1164  *  Returns error warning level. This determines the threshold value (warning level, default 96) to be reached in order
1165  *  to set the corresponding error warning bit EWRN. It reads NECNT register.
1166  *
1167  * \par<b>Related APIs:</b><BR>
1168  * XMC_CAN_NODE_SetErrorWarningLevel()\n\n\n
1169  *
1170  */
1171 
1172 
XMC_CAN_NODE_GetErrorWarningLevel(XMC_CAN_NODE_t * const can_node)1173 __STATIC_INLINE uint8_t XMC_CAN_NODE_GetErrorWarningLevel(XMC_CAN_NODE_t *const can_node)
1174 {
1175  return (uint8_t)((uint32_t)((can_node->NECNT)  & CAN_NODE_NECNT_EWRNLVL_Msk) >> CAN_NODE_NECNT_EWRNLVL_Pos);
1176 }
1177 
1178 
1179 /**
1180  *
1181  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1182  *
1183  * @return uint8_t transmit error counter value. Range :0 - 255
1184  *
1185  * \par<b>Description:</b><br>
1186  *  Returns Transmit Error Counter value. If the Bitstream Processor detects an error while a transmit operation is
1187  *  running, the Transmit Error Counter is incremented by 8. An increment of 1 is used when the error condition was
1188  *  reported by an external CAN node via an Error Frame generation. It reads NECNT register.
1189  *
1190  * \par<b>Related APIs:</b><BR>
1191  * XMC_CAN_NODE_SetTransmitErrorCounter()
1192  *
1193  * \par<b>Note:</b><br>
1194  *  NECNTx can be written only if bit NCRx.CCE is set.
1195  *
1196  */
1197 
XMC_CAN_NODE_GetTransmitErrorCounter(XMC_CAN_NODE_t * const can_node)1198 __STATIC_INLINE uint8_t XMC_CAN_NODE_GetTransmitErrorCounter(XMC_CAN_NODE_t *const can_node)
1199 {
1200   return (uint8_t)((uint32_t)((can_node->NECNT)  & CAN_NODE_NECNT_TEC_Msk) >> CAN_NODE_NECNT_TEC_Pos);
1201 }
1202 
1203 
1204 /**
1205  *
1206  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1207  *
1208  * @return uint8_t  receive error counter value.
1209  *
1210  * \par<b>Description:</b><br>
1211  *  Returns Receive Error Counter value. It reads NECNT register.
1212  *
1213  * \par<b>Related APIs:</b><BR>
1214  * XMC_CAN_NODE_SetReceiveErrorCounter()
1215  *
1216  */
1217 
XMC_CAN_NODE_GetReceiveErrorCounter(XMC_CAN_NODE_t * const can_node)1218 __STATIC_INLINE uint8_t XMC_CAN_NODE_GetReceiveErrorCounter(XMC_CAN_NODE_t *const can_node)
1219 {
1220   return (uint8_t)((uint32_t)((can_node->NECNT)  & CAN_NODE_NECNT_REC_Msk) >> CAN_NODE_NECNT_REC_Pos);
1221 }
1222 
1223 
1224 /**
1225  *
1226  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1227  *
1228  * @return uint32_t Current status of the node.
1229  *
1230  * \par<b>Description:</b><br>
1231  * Returns errors status as well as successfully transferred CAN frames status.
1232  *
1233  * \par<b>Related APIs:</b><BR>
1234  *  XMC_CAN_NODE_ClearStatus()
1235  *
1236  */
1237 
XMC_CAN_NODE_GetStatus(XMC_CAN_NODE_t * const can_node)1238 __STATIC_INLINE uint32_t XMC_CAN_NODE_GetStatus(XMC_CAN_NODE_t *const can_node)
1239 {
1240   return ((can_node->NSR));
1241 }
1242 
1243 /**
1244  *
1245  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1246  * @param can_node_status Status to clear.Refer @ref XMC_CAN_NODE_STATUS_t for valid values.
1247  *
1248  * @return None
1249  *
1250  * \par<b>Description:</b><br>
1251  * Clear errors status as well as successfully transferred CAN frames status.
1252  *
1253  * \par<b>Related APIs:</b><BR>
1254  * XMC_CAN_NODE_GetStatus()
1255  *
1256  */
1257 
XMC_CAN_NODE_ClearStatus(XMC_CAN_NODE_t * const can_node,XMC_CAN_NODE_STATUS_t can_node_status)1258 __STATIC_INLINE void XMC_CAN_NODE_ClearStatus(XMC_CAN_NODE_t *const can_node,XMC_CAN_NODE_STATUS_t can_node_status)
1259 {
1260    can_node->NSR &= ~(uint32_t)can_node_status;
1261 }
1262 
1263 
1264 /**
1265  *
1266  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1267  *
1268  * @return None
1269  *
1270  * \par<b>Description:</b><br>
1271  * Allow to change the configuration of the CAN node, like bit timing, CAN bus transmit/receive ports and error
1272  * counters read. It configures NCRx.CCE bit.
1273  *
1274  * \par<b>Related APIs:</b><BR>
1275  * XMC_CAN_NODE_DisableConfigurationChange()
1276  *
1277  */
1278 
XMC_CAN_NODE_EnableConfigurationChange(XMC_CAN_NODE_t * const can_node)1279 __STATIC_INLINE void XMC_CAN_NODE_EnableConfigurationChange(XMC_CAN_NODE_t *const can_node)
1280 {
1281   can_node->NCR |= (uint32_t)CAN_NODE_NCR_CCE_Msk;
1282 }
1283 
1284 
1285 /**
1286  *
1287  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1288  *
1289  * @return None
1290  *
1291  * \par<b>Description:</b><br>
1292  *  Forbid to change the configuration of the CAN node. It configures NCRx.CCE bit.
1293  *
1294  * \par<b>Related API's:</b><br>
1295  * XMC_CAN_NODE_EnableConfigurationChange()
1296  *
1297  */
1298 
XMC_CAN_NODE_DisableConfigurationChange(XMC_CAN_NODE_t * const can_node)1299 __STATIC_INLINE void XMC_CAN_NODE_DisableConfigurationChange(XMC_CAN_NODE_t *const can_node)
1300 {
1301   can_node->NCR &= ~(uint32_t)CAN_NODE_NCR_CCE_Msk;
1302 }
1303 
1304 
1305 
1306 /**
1307  *
1308  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1309  *
1310  * @return None
1311  *
1312  * \par<b>Description:</b><br>
1313  * Disable CAN node participation in CAN traffic. Bit INIT is automatically set when the CAN node enters the bus-off
1314  * state. It configures NCR.INIT bit.
1315  *
1316  * \par<b>Related API's:</b><br>
1317  * XMC_CAN_NODE_ResetInitBit()
1318  *
1319  */
1320 
XMC_CAN_NODE_SetInitBit(XMC_CAN_NODE_t * const can_node)1321 __STATIC_INLINE void XMC_CAN_NODE_SetInitBit(XMC_CAN_NODE_t *const can_node)
1322 {
1323   can_node->NCR |= (uint32_t)CAN_NODE_NCR_INIT_Msk;
1324 }
1325 
1326 /**
1327  *
1328  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1329  *
1330  * @return None
1331  *
1332  * \par<b>Description:</b><br>
1333  * Enable CAN node participation in CAN traffic. Bit INIT is automatically set when the CAN node enters the bus-off
1334  * state. It configures NCR.INIT bit.
1335  *
1336  * \par<b>Related API's:</b><br>
1337  * XMC_CAN_NODE_SetInitBit()
1338  *
1339  */
XMC_CAN_NODE_ResetInitBit(XMC_CAN_NODE_t * const can_node)1340 __STATIC_INLINE void XMC_CAN_NODE_ResetInitBit(XMC_CAN_NODE_t *const can_node)
1341 {
1342   can_node->NCR &= ~(uint32_t)CAN_NODE_NCR_INIT_Msk;
1343 }
1344 
1345 /**
1346  *
1347  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1348  *
1349  * @return None
1350  *
1351  * \par<b>Description:</b><br>
1352  * Enable the CAN node, starts the participation in CAN traffic. It configures NCR.CANDIS and the NCR.INIT bits.
1353  *
1354  * \par<b>Related API's:</b><br>
1355  * None
1356  *
1357  */
XMC_CAN_NODE_Enable(XMC_CAN_NODE_t * const can_node)1358 __STATIC_INLINE void XMC_CAN_NODE_Enable(XMC_CAN_NODE_t *const can_node)
1359 {
1360   can_node->NCR &= ~(uint32_t)CAN_NODE_NCR_CANDIS_Msk;
1361   XMC_CAN_NODE_ResetInitBit(can_node);
1362 }
1363 
1364 /**
1365  *
1366  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1367  *
1368  * @return None
1369  *
1370  * \par<b>Description:</b><br>
1371  * Disable the CAN node, terminates participation in CAN traffic. It configures NCR.CANDIS bit.
1372  *
1373  * \par<b>Related API's:</b><br>
1374  * None
1375  *
1376  */
XMC_CAN_NODE_Disable(XMC_CAN_NODE_t * const can_node)1377 __STATIC_INLINE void XMC_CAN_NODE_Disable(XMC_CAN_NODE_t *const can_node)
1378 {
1379   can_node->NCR |= (uint32_t)CAN_NODE_NCR_CANDIS_Msk;
1380 }
1381 
1382 /**
1383  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1384  *
1385  * @return None
1386  *
1387  * \par<b>Description:</b><br>
1388  * Configure CAN node in Analyzer Mode. This means that messages may be received, but not transmitted. No acknowledge
1389  * is sent on the CAN bus upon frame reception. Active-error flags are sent recessive instead of dominant.
1390  * The transmit line is continuously held at recessive (1) level. XMC_CAN_NODE_SetInitBit() should be called before
1391  * set / reset AnalyzerMode. It configures NCR.CALM bit.
1392  *
1393  * \par<b>Related API's:</b><br>
1394  * XMC_CAN_NODE_ReSetAnalyzerMode()
1395  *
1396  */
1397 
1398 
XMC_CAN_NODE_SetAnalyzerMode(XMC_CAN_NODE_t * const can_node)1399 __STATIC_INLINE void XMC_CAN_NODE_SetAnalyzerMode(XMC_CAN_NODE_t *const can_node)
1400 {
1401   can_node->NCR |= (uint32_t)CAN_NODE_NCR_CALM_Msk;
1402 }
1403 
1404 
1405 /**
1406  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1407  *
1408  * @return None
1409  *
1410  * \par<b>Description:</b><br>
1411  * Reset the Analyzer mode. CAN node is no more in Analyzer Mode. Please refer XMC_CAN_NODE_SetAnalyzerMode().
1412  * It configures NCR.CALM bit. XMC_CAN_NODE_SetInitBit() should be called before set / reset AnalyzerMode.
1413  *
1414  * \par<b>Related API's:</b><br>
1415  * XMC_CAN_NODE_SetAnalyzerMode()
1416  *
1417  */
1418 
XMC_CAN_NODE_ReSetAnalyzerMode(XMC_CAN_NODE_t * const can_node)1419 __STATIC_INLINE void XMC_CAN_NODE_ReSetAnalyzerMode(XMC_CAN_NODE_t *const can_node)
1420 {
1421   can_node->NCR &= ~(uint32_t)CAN_NODE_NCR_CALM_Msk;
1422 }
1423 
1424 #if !defined(MULTICAN_PLUS)
1425 /**
1426  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1427  *
1428  * @return None
1429  *
1430  * \par<b>Description:</b><br>
1431  * Trigger the suspension of the CAN node. An OCDS(on chip debug support) suspend trigger disables the CAN node: As
1432  * soon as the CAN node becomes bus-idle or bus-off, bit INIT is internally forced to 1 to disable the CAN node.
1433  * The actual value of bit INIT remains unchanged. It configures NCR.SUSEN bit
1434  *
1435  * \par<b>Related API's:</b><br>
1436  * None
1437  *
1438  *\par<b>Note:</b><br>
1439  * Bit SUSEN is reset via OCDS(on chip debug support) Reset.
1440  *
1441  */
1442 
XMC_CAN_NODE_EnableSuspend(XMC_CAN_NODE_t * const can_node)1443 __STATIC_INLINE void XMC_CAN_NODE_EnableSuspend(XMC_CAN_NODE_t *const can_node)
1444 {
1445   can_node->NCR |= (uint32_t)CAN_NODE_NCR_SUSEN_Msk;
1446 }
1447 #else
1448 /**
1449  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1450  *
1451  * @return None
1452  *
1453  * \par<b>Description:</b><br>
1454  * Disables the transmission on CAN node x as soon as bus-idle is reached.
1455  *
1456  * \par<b>Related API's:</b><br>
1457  * None
1458  *
1459  * @note Only available for XMC1400,XMC4800 and XMC4700 series
1460  */
1461 
XMC_CAN_NODE_DisableTransmit(XMC_CAN_NODE_t * const can_node)1462 __STATIC_INLINE void XMC_CAN_NODE_DisableTransmit(XMC_CAN_NODE_t *const can_node)
1463 {
1464   can_node->NCR |= (uint32_t)CAN_NODE_NCR_TXDIS_Msk;
1465 }
1466 #endif
1467 
1468 
1469 /**
1470  *
1471  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1472  * @param can_node_init frame counter mode selection. Refer @ref XMC_CAN_NODE_FRAME_COUNTER_t for valid values.
1473  *
1474  * @return None
1475  *
1476  * \par<b>Description:</b><br>
1477  * Configures frame counter functions. Each CAN \a can_node is equipped with a frame counter that counts transmitted/received
1478  * CAN frames or obtains information about the time when a frame has been started to transmit or be received by the CAN
1479  * node. It configures NFCR register.
1480  *
1481  * \par<b>Related API's:</b><br>
1482  * None
1483  *
1484  */
1485 
XMC_CAN_NODE_FrameCounterConfigure(XMC_CAN_NODE_t * const can_node,const XMC_CAN_NODE_FRAME_COUNTER_t * const can_node_init)1486 __STATIC_INLINE void XMC_CAN_NODE_FrameCounterConfigure(XMC_CAN_NODE_t *const can_node,
1487                                         const XMC_CAN_NODE_FRAME_COUNTER_t *const can_node_init)
1488 {
1489   can_node->NFCR = (can_node->NFCR & ~(uint32_t)(CAN_NODE_NFCR_CFMOD_Msk |
1490                                        CAN_NODE_NFCR_CFSEL_Msk)) |
1491                     can_node_init->nfcr;
1492 }
1493 
1494 
1495 /**
1496  *
1497  * @param can_node Pointer Pointing to CAN_NODE Structure. Defines CAN_NODE registers, Range :CAN_NODE0-CAN_NODE2.
1498  *
1499  * @return uint16_t current value of the CAN frame counter. Range :0-65535
1500  *
1501  * \par<b>Description:</b><br>
1502  *  Returns the frame counter value \a can_node of the CAN node. In Frame Count Mode (CFMOD = 00B), this API returns the frame
1503  *  count value. In Time Stamp Mode (CFMOD = 01B), this API returns the captured bit time count value, captured with
1504  *  the start of a new frame. In all Bit Timing Analysis Modes (CFMOD = 10B), this API always returns the number of
1505  *  fCLC clock cycles (measurement result) minus 1.
1506  *
1507  * \par<b>Related API's:</b><br>
1508  * None
1509  *
1510  */
1511 
XMC_CAN_NODE_GetCANFrameCounter(XMC_CAN_NODE_t * const can_node)1512 __STATIC_INLINE uint16_t XMC_CAN_NODE_GetCANFrameCounter(XMC_CAN_NODE_t *const can_node)
1513 {
1514   return (uint16_t)(((uint32_t)(can_node->NFCR & CAN_NODE_NFCR_CFC_Msk) >> CAN_NODE_NFCR_CFC_Pos));
1515 }
1516 
1517                                      /*MO APIs*/
1518 
1519 /**
1520  *
1521  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1522  *
1523  * @return XMC_CAN_STATUS_t CAN Node status. Refer @ref XMC_CAN_STATUS_t structure for details.
1524  *
1525  * @return None
1526  *
1527  * \par<b>Description:</b><br>
1528  * Configures Data to be transmitted and data length code.
1529  *
1530  * \par<b>Related API's:</b><br>
1531  * XMC_CAN_MO_Config()\n\n\n
1532  *
1533  */
1534 
1535 
1536 XMC_CAN_STATUS_t XMC_CAN_MO_UpdateData(const XMC_CAN_MO_t *const can_mo);
1537 
1538 /**
1539  *
1540  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1541  *
1542  * @return XMC_CAN_STATUS_t CAN Node status. Refer @ref XMC_CAN_STATUS_t structure for details.
1543  *
1544  * \par<b>Description:</b><br>
1545  *  Configures transmit request for sending data frame. It configures MOCTR register. Data shall be updated
1546  *  using XMC_CAN_MO_UpdateData() before calling this API.
1547  *
1548  * \par<b>Related API's:</b><br>
1549  * XMC_CAN_MO_UpdateData()\n\n\n
1550  *
1551  */
1552 
1553 XMC_CAN_STATUS_t XMC_CAN_MO_Transmit(const XMC_CAN_MO_t *const can_mo);
1554 
1555 
1556 /**
1557  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1558  *
1559  * @return XMC_CAN_STATUS_t CAN Node status. Refer @ref XMC_CAN_STATUS_t structure for details.
1560  *
1561  * \par<b>Description:</b><br>
1562  *  Reads the Message Object data bytes, into message pointer passed as input parameter \a can_mo.
1563  *  can_data[0] of can_mo holds lower 4 bytes, can_data[1] of can_mo holds higher 4 bytes.
1564  *
1565  * \par<b>Related API's:</b><br>
1566  * None
1567  *
1568  */
1569 
1570 XMC_CAN_STATUS_t XMC_CAN_MO_Receive(XMC_CAN_MO_t *can_mo);
1571 
1572 
1573 /**
1574  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1575  *
1576  * @return XMC_CAN_STATUS_t CAN Node status. Refer @ref XMC_CAN_STATUS_t structure for details.
1577  *
1578  * \par<b>Description:</b><br>
1579  *  Reads the Message Object data bytes, into message pointer passed as input parameter \a can_mo.
1580  *  can_data[0] of can_mo holds lower 4 bytes, can_data[1] of can_mo holds higher 4 bytes.
1581  *
1582  * \par<b>Related API's:</b><br>
1583  * None
1584  *
1585  */
1586 XMC_CAN_STATUS_t XMC_CAN_MO_ReceiveData (XMC_CAN_MO_t *can_mo);
1587 /**
1588  * @param can_mo       Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1589  * @param can_mo_ptr_int   Message Object event node pointer selection. Refer @ref XMC_CAN_MO_POINTER_EVENT_t structure
1590  *                for valid values.
1591  * @param service_request interrupt output line of multiCAN module.
1592  *
1593  * @return None
1594  *
1595  * \par<b>Description:</b><br>
1596  * Configures Message Object event node pointer with \a service_request number. It configures MOIPR register.
1597  *
1598  * \par<b>Related API's:</b><br>
1599  * None
1600  *
1601  */
1602 
XMC_CAN_MO_SetEventNodePointer(const XMC_CAN_MO_t * const can_mo,const XMC_CAN_MO_POINTER_EVENT_t can_mo_ptr_int,const uint32_t service_request)1603 __STATIC_INLINE void XMC_CAN_MO_SetEventNodePointer(const XMC_CAN_MO_t *const can_mo,
1604                                                 const XMC_CAN_MO_POINTER_EVENT_t can_mo_ptr_int,
1605                                                 const uint32_t service_request)
1606 {
1607   can_mo->can_mo_ptr->MOIPR = ((can_mo->can_mo_ptr->MOIPR ) & ~(uint32_t)((uint32_t)CAN_MO_MOIPR_Msk << (uint32_t)can_mo_ptr_int)) |
1608                           (service_request << (uint32_t)can_mo_ptr_int);
1609 }
1610 
1611 /**
1612  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1613  *
1614  * @return uint32_t Current Message Object status.
1615  *
1616  * \par<b>Description:</b><br>
1617  *  Returns Message Object status, that indicates message object transfer status and message object list status
1618  *  information such as the number of the current message object predecessor and successor message object, as well as
1619  *  the list number to which the message object is assigned.
1620  *
1621  * \par<b>Related API's:</b><br>
1622  * None
1623  *
1624  */
1625 
XMC_CAN_MO_GetStatus(const XMC_CAN_MO_t * const can_mo)1626 __STATIC_INLINE uint32_t XMC_CAN_MO_GetStatus(const XMC_CAN_MO_t *const can_mo)
1627 {
1628   return ((can_mo->can_mo_ptr->MOSTAT));
1629 }
1630 
1631 /**
1632  *
1633  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1634  * @param mask   Message Object set status selection. Refer @ref XMC_CAN_MO_SET_STATUS_t for details.
1635  *         Multiple enums can be ORed.
1636  * @return None
1637  *
1638  * \par<b>Description:</b><br>
1639  *  Configures Message Object set Status. It configures MOCTR register.
1640  *
1641  * \par<b>Related API's:</b><br>
1642  * XMC_CAN_MO_ResetStatus()\n\n\n
1643  *
1644  */
1645 
XMC_CAN_MO_SetStatus(const XMC_CAN_MO_t * const can_mo,const uint32_t mask)1646 __STATIC_INLINE void XMC_CAN_MO_SetStatus(const XMC_CAN_MO_t *const can_mo, const uint32_t mask)
1647 {
1648   can_mo->can_mo_ptr->MOCTR = mask;
1649 }
1650 
1651 /**
1652  *
1653  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1654  * @param mask   Message Object set status selection. Refer @ref XMC_CAN_MO_RESET_STATUS_t for details.
1655  *             Multiple enums can be ORed.
1656  * @return None
1657  *
1658  * \par<b>Description:</b><br>
1659  *  Clears Message Object interrupt events. It configures MOCTR register.
1660  *
1661  * \par<b>Related API's:</b><br>
1662  * None
1663  *
1664  */
1665 
XMC_CAN_MO_ResetStatus(const XMC_CAN_MO_t * const can_mo,const uint32_t mask)1666 __STATIC_INLINE void XMC_CAN_MO_ResetStatus(const XMC_CAN_MO_t *const can_mo,const uint32_t mask)
1667 {
1668   can_mo->can_mo_ptr->MOCTR = mask;
1669 }
1670 
1671 
1672 
1673 /**
1674  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1675  * @param event  CAN node Message Object event selection. Refer @ref XMC_CAN_MO_EVENT_t for details.
1676  *
1677  * @return None
1678  *
1679  * \par<b>Description:</b><br>
1680  * Enable CAN Message Object events. \a event can be ORed multiple Message Object events. It configures MOFCR register.
1681  *
1682  * \par<b>Related API's:</b><br>
1683  *  XMC_CAN_MO_DisableEvent()
1684  *
1685  */
1686 
XMC_CAN_MO_EnableEvent(const XMC_CAN_MO_t * const can_mo,const uint32_t event)1687 __STATIC_INLINE void XMC_CAN_MO_EnableEvent(const XMC_CAN_MO_t *const can_mo,
1688                                         const uint32_t event)
1689 {
1690   can_mo->can_mo_ptr->MOFCR |= event;
1691 }
1692 
1693 
1694 /**
1695  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1696  * @param event  CAN node Message Object event selection. Refer @ref XMC_CAN_MO_EVENT_t for details.
1697  *
1698  * @return None
1699  *
1700  * \par<b>Description:</b><br>
1701  *  Disable CAN Message Object events. \a event can be ORed multiple Message Object events. It configures MOFCR register.
1702  *
1703  * \par<b>Related API's:</b><br>
1704  * XMC_CAN_MO_EnableEvent()
1705  *
1706  *
1707  */
1708 
XMC_CAN_MO_DisableEvent(const XMC_CAN_MO_t * const can_mo,const uint32_t event)1709 __STATIC_INLINE void XMC_CAN_MO_DisableEvent(const XMC_CAN_MO_t *const can_mo,
1710                                          const uint32_t event)
1711 {
1712   can_mo->can_mo_ptr->MOFCR &= ~event;
1713 }
1714 
1715 /**
1716  *
1717  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1718  *
1719  * @return None
1720  *
1721  * \par<b>Description:</b><br>
1722  *  Enable the single transmit trial(STT). In STT,TXRQ is cleared on transmission start of message object n. Thus,
1723  *  no transmission retry is performed in case of transmission failure. It configures MOFCR.STT bit.
1724  *
1725  * \par<b>Related API's:</b><br>
1726  * XMC_CAN_MO_DisableSingleTransmitTrial()
1727  *
1728  */
1729 
XMC_CAN_MO_EnableSingleTransmitTrial(const XMC_CAN_MO_t * const can_mo)1730 __STATIC_INLINE void XMC_CAN_MO_EnableSingleTransmitTrial(const XMC_CAN_MO_t *const can_mo)
1731 {
1732   can_mo->can_mo_ptr->MOFCR |= (uint32_t) CAN_MO_MOFCR_STT_Msk;
1733 }
1734 
1735 
1736 /**
1737  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1738  *
1739  * @return None
1740  *
1741  * \par<b>Description:</b><br>
1742  *  Disable the single transmit trial(STT). In STT,TXRQ is cleared on transmission start of message object n. Thus,
1743  *  no transmission retry is performed in case of transmission failure. It configures MOFCR.STT bit.
1744  *
1745  * \par<b>Related API's:</b><br>
1746  *  XMC_CAN_MO_EnableSingleTransmitTrial()
1747  *
1748  */
1749 
XMC_CAN_MO_DisableSingleTransmitTrial(const XMC_CAN_MO_t * const can_mo)1750 __STATIC_INLINE void XMC_CAN_MO_DisableSingleTransmitTrial(const XMC_CAN_MO_t *const can_mo)
1751 {
1752   can_mo->can_mo_ptr->MOFCR &= ~(uint32_t)CAN_MO_MOFCR_STT_Msk;
1753 }
1754 
1755 /**
1756  *
1757  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1758  * @param data_length_code  transfer data length. Range:0-8
1759  *
1760  * @return None
1761  *
1762  * \par<b>Description:</b><br>
1763  *  Configures CAN Message Object Data Length Code. It configures MOFCR register.
1764  *
1765  * \par<b>Related API's:</b><br>
1766  * None
1767  *
1768  */
1769 
XMC_CAN_MO_DataLengthCode(const XMC_CAN_MO_t * const can_mo,const uint8_t data_length_code)1770 __STATIC_INLINE void XMC_CAN_MO_DataLengthCode(const XMC_CAN_MO_t *const can_mo,const uint8_t data_length_code)
1771 {
1772   can_mo->can_mo_ptr->MOFCR = ((can_mo->can_mo_ptr->MOFCR ) & ~(uint32_t)(CAN_MO_MOFCR_DLC_Msk)) |
1773                               (((uint32_t)data_length_code << CAN_MO_MOFCR_DLC_Pos) & (uint32_t)CAN_MO_MOFCR_DLC_Msk);
1774 }
1775 
1776 /**
1777  *
1778  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1779  * @param data_length_code  transfer data length. Range:0-8
1780  *
1781  * @return None
1782  *
1783  * \par<b>Description:</b><br>
1784  *  Configures CAN Message Object Data Length Code. It configures MOFCR register.
1785  *
1786  * \par<b>Related API's:</b><br>
1787  * XMC_CAN_MO_GetDataLengthCode()
1788  *
1789  */
1790 
XMC_CAN_MO_SetDataLengthCode(XMC_CAN_MO_t * const can_mo,const uint8_t data_length_code)1791 __STATIC_INLINE void XMC_CAN_MO_SetDataLengthCode(XMC_CAN_MO_t *const can_mo,const uint8_t data_length_code)
1792 {
1793   can_mo->can_data_length = data_length_code;
1794   can_mo->can_mo_ptr->MOFCR = ((can_mo->can_mo_ptr->MOFCR ) & ~(uint32_t)(CAN_MO_MOFCR_DLC_Msk)) |
1795                               (((uint32_t)data_length_code << CAN_MO_MOFCR_DLC_Pos) & (uint32_t)CAN_MO_MOFCR_DLC_Msk);
1796 }
1797 
1798 /**
1799  *
1800  * @param can_mo           Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1801  *
1802  * @return Data length code
1803  *
1804  * \par<b>Description:</b><br>
1805  *   Gets the Data Length Code.
1806  *
1807  * \par<b>Related API's:</b><br>
1808  * XMC_CAN_MO_SetDataLengthCode()
1809  *
1810  */
1811 
XMC_CAN_MO_GetDataLengthCode(const XMC_CAN_MO_t * const can_mo)1812 __STATIC_INLINE uint8_t XMC_CAN_MO_GetDataLengthCode(const XMC_CAN_MO_t *const can_mo)
1813 {
1814   return (((can_mo->can_mo_ptr->MOFCR) & (uint32_t)(CAN_MO_MOFCR_DLC_Msk)) >> CAN_MO_MOFCR_DLC_Pos);
1815 }
1816 
1817 /**
1818  *
1819  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1820  * @param can_identifier  Identifier.
1821  *
1822  * @return None
1823  *
1824  * \par<b>Description:</b><br>
1825  *  Configures CAN Message Object Identifier. It configures MOAR register.
1826  *
1827  * \par<b>Related API's:</b><br>
1828  * XMC_CAN_MO_GetIdentifier()
1829  *
1830  */
1831 
1832 void XMC_CAN_MO_SetIdentifier(XMC_CAN_MO_t *const can_mo, const uint32_t can_identifier);
1833 
1834 /**
1835  *
1836  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1837  *
1838  * @return CAN MO identifier
1839  *
1840  * \par<b>Description:</b><br>
1841  *  Gets the Identifier of the MO
1842  *
1843  * \par<b>Related API's:</b><br>
1844  * XMC_CAN_MO_SetIdentifier()
1845  *
1846  */
1847 
1848 uint32_t XMC_CAN_MO_GetIdentifier(const XMC_CAN_MO_t *const can_mo);
1849 
1850 /**
1851  *
1852  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1853  *
1854  * @return Acceptance mask
1855  *
1856  * \par<b>Description:</b><br>
1857  *  Gets the acceptance mask for the CAN MO.
1858  *
1859  * \par<b>Related API's:</b><br>
1860  * XMC_CAN_MO_SetAcceptanceMask()
1861  *
1862  */
1863 
1864 uint32_t XMC_CAN_MO_GetAcceptanceMask(const XMC_CAN_MO_t *const can_mo);
1865 
1866 /**
1867  *
1868  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1869  * @param can_id_mask     CAN MO acceptance mask.
1870  *
1871  * @return None
1872  *
1873  * \par<b>Description:</b><br>
1874  * Sets the acceptance mask of the MO
1875  *
1876  * \par<b>Related API's:</b><br>
1877  * XMC_CAN_MO_GetAcceptanceMask()
1878  *
1879  */
1880 
1881 void XMC_CAN_MO_SetAcceptanceMask(XMC_CAN_MO_t *const can_mo,const uint32_t can_id_mask);
1882 
1883 /**
1884  *
1885  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1886  *
1887  * @return None
1888  *
1889  * \par<b>Description:</b><br>
1890  *  Message object receives frames only with matching IDE bit.
1891  *
1892  * \par<b>Related API's:</b><br>
1893  * XMC_CAN_MO_AcceptStandardAndExtendedID()
1894  *
1895  */
1896 
XMC_CAN_MO_AcceptOnlyMatchingIDE(XMC_CAN_MO_t * const can_mo)1897 __STATIC_INLINE void XMC_CAN_MO_AcceptOnlyMatchingIDE(XMC_CAN_MO_t *const can_mo)
1898 {
1899   can_mo->can_ide_mask = 1U;
1900   can_mo->can_mo_ptr->MOAMR |=(uint32_t)(CAN_MO_MOAMR_MIDE_Msk);
1901 }
1902 
1903 /**
1904  *
1905  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1906  *
1907  * @return None
1908  *
1909  * \par<b>Description:</b><br>
1910  *  Message object accepts the reception of both, standard and extended frames.
1911  *
1912  * \par<b>Related API's:</b><br>
1913  * XMC_CAN_MO_AcceptOnlyMatchingIDE()
1914  *
1915  */
1916 
XMC_CAN_MO_AcceptStandardAndExtendedID(XMC_CAN_MO_t * const can_mo)1917 __STATIC_INLINE void XMC_CAN_MO_AcceptStandardAndExtendedID(XMC_CAN_MO_t *const can_mo)
1918 {
1919   can_mo->can_ide_mask = 0U;
1920   can_mo->can_mo_ptr->MOAMR &= ~(uint32_t)(CAN_MO_MOAMR_MIDE_Msk);
1921 }
1922 
1923 /**
1924  *
1925  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1926  *
1927  * @return None
1928  *
1929  * \par<b>Description:</b><br>
1930  *  Message object handles standard frames with 11-bit identifier.
1931  *
1932  * \par<b>Related API's:</b><br>
1933  * XMC_CAN_MO_SetExtendedID()
1934  *
1935  * \par<b>Note:</b><br>
1936  * After setting the identifier type user has to set the identifier value by using @ref XMC_CAN_MO_SetIdentifier() API.
1937  */
1938 
XMC_CAN_MO_SetStandardID(XMC_CAN_MO_t * const can_mo)1939 __STATIC_INLINE void XMC_CAN_MO_SetStandardID(XMC_CAN_MO_t *const can_mo)
1940 {
1941   can_mo->can_id_mode = (uint32_t)XMC_CAN_FRAME_TYPE_STANDARD_11BITS;
1942   can_mo->can_mo_ptr->MOAR &= ~(uint32_t)(CAN_MO_MOAR_IDE_Msk);
1943 }
1944 
1945 /**
1946  *
1947  * @param can_mo            Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1948  *
1949  * @return None
1950  *
1951  * \par<b>Description:</b><br>
1952  *  Message object handles extended frames with 29-bit identifier.
1953  *
1954  * \par<b>Related API's:</b><br>
1955  * XMC_CAN_MO_SetStandardID()
1956  *
1957  * \par<b>Note:</b><br>
1958  * After setting the identifier type user has to set the identifier value by using @ref XMC_CAN_MO_SetIdentifier() API.
1959  *
1960  */
1961 
XMC_CAN_MO_SetExtendedID(XMC_CAN_MO_t * const can_mo)1962 __STATIC_INLINE void XMC_CAN_MO_SetExtendedID(XMC_CAN_MO_t *const can_mo)
1963 {
1964   can_mo->can_id_mode = (uint32_t)XMC_CAN_FRAME_TYPE_EXTENDED_29BITS;
1965   can_mo->can_mo_ptr->MOAR |= (uint32_t)CAN_MO_MOAR_IDE_Msk;
1966 }
1967 
1968 /**
1969  *
1970  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1971  *
1972  * @return None
1973  *
1974  * \par<b>Description:</b><br>
1975  *  Configuration allows to enable the FIFO Foreign Remote Request. This Specifies TXRQ of the message object referenced
1976  *  by the pointer CUR is set on reception of a matching Remote Frame. It configures MOFCR.FRREN register.
1977  *
1978  * \par<b>Related API's:</b><br>
1979  * XMC_CAN_FIFO_DisableForeingRemoteRequest()\n\n\n
1980  *
1981  */
1982 
XMC_CAN_FIFO_EnableForeignRemoteRequest(const XMC_CAN_MO_t * const can_mo)1983 __STATIC_INLINE void XMC_CAN_FIFO_EnableForeignRemoteRequest(const XMC_CAN_MO_t *const can_mo)
1984 {
1985   can_mo->can_mo_ptr->MOFCR |= (uint32_t)CAN_MO_MOFCR_FRREN_Msk;
1986 }
1987 
1988 /**
1989  *
1990  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
1991  *
1992  * @return None
1993  *
1994  * \par<b>Description:</b><br>
1995  * Configuration allows to disable the FIFO Foreign Remote Request. TXRQ of message object n is set on reception
1996  * of a matching Remote Frame. It configures MOFCR.FRREN register.
1997  *
1998  * \par<b>Related API's:</b><br>
1999  * XMC_CAN_FIFO_EnableForeignRemoteRequest()\n\n\n
2000  *
2001  */
2002 
XMC_CAN_FIFO_DisableForeingRemoteRequest(const XMC_CAN_MO_t * const can_mo)2003 __STATIC_INLINE void XMC_CAN_FIFO_DisableForeingRemoteRequest(const XMC_CAN_MO_t *const can_mo)
2004 {
2005   can_mo->can_mo_ptr->MOFCR &= ~(uint32_t)CAN_MO_MOFCR_FRREN_Msk;
2006 }
2007 
2008 
2009 /**
2010  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2011  *
2012  * @return None
2013  *
2014  * \par<b>Description:</b><br>
2015  * Configuration allows to enable the FIFO Remote Monitoring. This Specifies identifier, IDE(Identifier Extension) bit,
2016  * and DLC of a matching Remote Frame are copied to transmit object n in order to monitor incoming Remote Frames.
2017  * It configures MOFCR.RMM bit.
2018  *
2019  * \par<b>Related API's:</b><br>
2020  * XMC_CAN_FIFO_DisableRemoteMonitoring()\n\n\n
2021  *
2022  * \par<b>Note:</b><br>
2023  *  Remote monitoring(RMM) applies only to transmit objects and has no effect on receive objects.
2024  *
2025  */
XMC_CAN_FIFO_EnableRemoteMonitoring(const XMC_CAN_MO_t * const can_mo)2026 __STATIC_INLINE void XMC_CAN_FIFO_EnableRemoteMonitoring(const XMC_CAN_MO_t *const can_mo)
2027 {
2028   can_mo->can_mo_ptr->MOFCR |= (uint32_t)CAN_MO_MOFCR_RMM_Msk;
2029 }
2030 
2031 
2032 /**
2033  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2034  *
2035  * @return None
2036  *
2037  * \par<b>Description:</b><br>
2038  * Configuration allows to disable the FIFO Remote Monitoring. This Specifies Identifier, Identifier Extension bit,
2039  * and DLC of message object n remain unchanged upon the reception of a matching Remote Frame.
2040  * It configures MOFCR.RMM bit.
2041  *
2042  * \par<b>Related API's:</b><br>
2043  * XMC_CAN_FIFO_EnableRemoteMonitoring()\n\n\n
2044  *
2045  * \par<b>Note:</b><br>
2046  *  Remote monitoring(RMM) applies only to transmit objects and has no effect on receive objects.
2047  *
2048  */
2049 
XMC_CAN_FIFO_DisableRemoteMonitoring(const XMC_CAN_MO_t * const can_mo)2050 __STATIC_INLINE void XMC_CAN_FIFO_DisableRemoteMonitoring(const XMC_CAN_MO_t *const can_mo)
2051 {
2052   can_mo->can_mo_ptr->MOFCR &= ~(uint32_t)CAN_MO_MOFCR_RMM_Msk;
2053 }
2054 
2055 
2056 /**
2057  * @param can_mo     Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2058  * @param select_pointer Selected Message Object number. Range:0-63
2059  *
2060  * @return None
2061  *
2062  * \par<b>Description:</b><br>
2063  * Set Object Select Pointer. If the current pointer CUR of FIFO base object becomes equal \a select_pointer,
2064  * a FIFO overflow interrupt request is generated. Used for FIFO monitoring purpose.
2065  *
2066  * \par<b>Related API's:</b><br>
2067  * None
2068  *
2069  */
2070 
XMC_CAN_FIFO_SetSELMO(const XMC_CAN_MO_t * const can_mo,const uint8_t select_pointer)2071 __STATIC_INLINE void XMC_CAN_FIFO_SetSELMO(const XMC_CAN_MO_t *const can_mo,const uint8_t select_pointer)
2072 {
2073   can_mo->can_mo_ptr->MOFGPR = ((can_mo->can_mo_ptr->MOFGPR ) & ~(uint32_t)(CAN_MO_MOFGPR_SEL_Msk)) |
2074                                (((uint32_t)select_pointer << CAN_MO_MOFGPR_SEL_Pos) & (uint32_t)CAN_MO_MOFGPR_SEL_Msk);
2075 }
2076 
2077 
2078 /**
2079  *
2080  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2081  *
2082  * @return uint8_t  Current Message Object Number. Range:0-63
2083  *
2084  * \par<b>Description:</b><br>
2085  * Returns the current FIFO Message Object,points to the actual target object within a FIFO/Gateway structure.
2086  *
2087  * \par<b>Related API's:</b><br>
2088  * None
2089  *
2090  */
2091 
XMC_CAN_FIFO_GetCurrentMO(const XMC_CAN_MO_t * const can_mo)2092 __STATIC_INLINE uint8_t XMC_CAN_FIFO_GetCurrentMO(const XMC_CAN_MO_t *const can_mo)
2093 {
2094   return (uint8_t)((uint32_t)(can_mo->can_mo_ptr->MOFGPR & CAN_MO_MOFGPR_CUR_Msk) >> CAN_MO_MOFGPR_CUR_Pos);
2095 }
2096 
2097 
2098 /**
2099  *
2100  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2101  *
2102  * @return None
2103  *
2104  * \par<b>Description:</b><br>
2105  * Configuration allows to enable the Single Data Transfer of the FIFO Message Object. If SDT = 1 and message object n
2106  * is not a FIFO base object, then MSGVAL is reset when this object has taken part in a successful data transfer
2107  * (receive or transmit). If SDT = 1 and message object n is a FIFO base object, then MSGVAL is reset when the pointer
2108  * to the current object CUR reaches the value of SEL in the FIFO/Gateway Pointer Register. It configures MOFCR.SDT bit.
2109  *
2110  * \par<b>Related API's:</b><br>
2111  * XMC_CAN_FIFO_DisableSingleDataTransfer()
2112  *
2113  */
2114 
XMC_CAN_FIFO_EnableSingleDataTransfer(const XMC_CAN_MO_t * const can_mo)2115 __STATIC_INLINE void XMC_CAN_FIFO_EnableSingleDataTransfer(const XMC_CAN_MO_t *const can_mo)
2116 {
2117   can_mo->can_mo_ptr->MOFCR |= (uint32_t)CAN_MO_MOFCR_SDT_Msk;
2118 }
2119 
2120 
2121 /**
2122  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2123  *
2124  * @return None
2125  *
2126  * \par<b>Description:</b><br>
2127  *  Configuration allows to disable the Single Data Transfer of the FIFO Message Object, with this configuration bit
2128  *  MSGVAL is not affected. It configures MOFCR.SDT bit.
2129  *
2130  * \par<b>Related API's:</b><br>
2131  * XMC_CAN_FIFO_EnableSingleDataTransfer()
2132  *
2133  */
2134 
XMC_CAN_FIFO_DisableSingleDataTransfer(const XMC_CAN_MO_t * const can_mo)2135 __STATIC_INLINE void XMC_CAN_FIFO_DisableSingleDataTransfer(const XMC_CAN_MO_t *const can_mo)
2136 {
2137   can_mo->can_mo_ptr->MOFCR &= ~(uint32_t)CAN_MO_MOFCR_SDT_Msk;
2138 }
2139 
2140 
2141 /**
2142  *
2143  * @param can_mo   Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2144  * @param can_fifo CAN FIFO configuration data structure. Refer @ref XMC_CAN_FIFO_CONFIG_t data structure for details.
2145  *
2146  * @return None
2147  *
2148  * \par<b>Description:</b><br>
2149  *  Configures the transmit FIFO. A FIFO consists of one base object and n slave objects. Please refer
2150  *  reference manual \b Transmit FIFO for more info.
2151  *
2152  * \par<b>Related API's:</b><br>
2153  * None.
2154  *
2155  */
2156 
2157 void XMC_CAN_TXFIFO_ConfigMOBaseObject(const XMC_CAN_MO_t *const can_mo,const XMC_CAN_FIFO_CONFIG_t can_fifo);
2158 
2159 
2160 /**
2161  *
2162  * @param can_mo   Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2163  * @param can_fifo CAN FIFO configuration data structure. Refer @ref XMC_CAN_FIFO_CONFIG_t data structure for details.
2164  *
2165  * @return None
2166  *
2167  * \par<b>Description:</b><br>
2168  *  Configures the base object of receive FIFO.
2169  *
2170  * \par<b>Related API's:</b><br>
2171  *  None
2172  */
2173 
2174 void XMC_CAN_RXFIFO_ConfigMOBaseObject(const XMC_CAN_MO_t *const can_mo,const XMC_CAN_FIFO_CONFIG_t can_fifo);
2175 
2176 
2177 /**
2178  *
2179  * @param can_mo  Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2180  * @param can_fifo  CAN FIFO configuration data structure. Refer @ref XMC_CAN_FIFO_CONFIG_t data structure for details.
2181  *
2182  * @return None
2183  *
2184  * \par<b>Description:</b><br>
2185  * Configures the slave object of transmit FIFO.
2186  *
2187  * \par<b>Related API's:</b><br>
2188  * None
2189  *
2190  */
2191 void XMC_CAN_TXFIFO_ConfigMOSlaveObject(const XMC_CAN_MO_t *const can_mo,const XMC_CAN_FIFO_CONFIG_t can_fifo);
2192 
2193 
2194 /**
2195  *
2196  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2197  *
2198  * @return None
2199  *
2200  * \par<b>Description:</b><br>
2201  *  Configures the slave Object of receive FIFO. It configures MOCTR.RESRXEN bit.
2202  *
2203  * \par<b>Related API's:</b><br>
2204  * None
2205  *
2206  */
2207 
XMC_CAN_RXFIFO_ConfigMOSlaveObject(const XMC_CAN_MO_t * const can_mo)2208 __STATIC_INLINE void XMC_CAN_RXFIFO_ConfigMOSlaveObject(const XMC_CAN_MO_t *const can_mo)
2209 {
2210   can_mo->can_mo_ptr->MOCTR = (uint32_t)CAN_MO_MOCTR_RESRXEN_Msk;
2211 }
2212 
2213 
2214 /**
2215  *
2216  * @param can_mo    Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2217  * @param can_gateway CAN  gateway configuration data structure. Refer XMC_CAN_GATEWAY_CONFIG_t data structure for details.
2218  *
2219  * @return None
2220  *
2221  * \par<b>Description:</b><br>
2222  *  Configures the Gateway source object. The Gateway Mode \a can_gateway makes it possible to establish an automatic
2223  *  information transfer between two independent CAN buses without CPU interaction. Please refer reference manual
2224  *  \b GatewayMode for more info.
2225  *
2226  * \par<b>Related API's:</b><br>
2227  * None
2228  *
2229  */
2230 
2231 void XMC_CAN_GATEWAY_InitSourceObject(const XMC_CAN_MO_t *const can_mo,const XMC_CAN_GATEWAY_CONFIG_t can_gateway);
2232 
2233 
2234 /**
2235  *
2236  * @param can_mo    Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2237  *
2238  * @return None
2239  *
2240  * \par<b>Description:</b><br>
2241  *  Configures the Gateway destination object. The Gateway Mode \a can_gateway makes it possible to establish an automatic
2242  *  information transfer between two independent CAN buses without CPU interaction. Please refer reference manual
2243  *  \b GatewayMode for more info.
2244  *
2245  * \par<b>Related API's:</b><br>
2246  * None
2247  *
2248  */
2249 
XMC_CAN_GATEWAY_InitDesObject(const XMC_CAN_MO_t * const can_mo)2250 __STATIC_INLINE void XMC_CAN_GATEWAY_InitDesObject(const XMC_CAN_MO_t *const can_mo)
2251 {
2252   can_mo->can_mo_ptr->MOCTR  = CAN_MO_MOCTR_RESRXEN_Msk |
2253                            CAN_MO_MOCTR_RESNEWDAT_Msk;
2254 }
2255 
2256 /**
2257  *
2258  * @param can_mo Pointer to Message Object structure. Refer @ref XMC_CAN_MO_t data structure for details.
2259  *
2260  * @return XMC_CAN_STATUS_t CAN Node status. Refer @ref XMC_CAN_STATUS_t structure for details.
2261  *
2262  * \par<b>Description:</b><br>
2263  *  To transmit Message Object from the FIFO. Prior to this CAN node Message Object FIFO structure shall be made using
2264  *  XMC_CAN_TXFIFO_ConfigMOBaseObject(), XMC_CAN_TXFIFO_ConfigMOSlaveObject(),XMC_CAN_RXFIFO_ConfigMOBaseObject() API's.
2265  *  Please refer reference manual \b MessageObject \b FIFOStructure for more info.
2266  *
2267  *
2268  */
2269 XMC_CAN_STATUS_t XMC_CAN_TXFIFO_Transmit(const XMC_CAN_MO_t *const can_mo);
2270 
2271 /**
2272  * @param obj Pointer pointing to XMC_CAN Global Initialization structure
2273  * @param list_idx List index
2274  *
2275  * @return List empty status.
2276  *
2277  * \par<b>Description:</b><br>
2278  * This function returns false in case at least one message object is allocated to list list_idx.
2279  */
XMC_CAN_IsListEmpty(XMC_CAN_t * const obj,uint8_t list_idx)2280 __STATIC_INLINE bool XMC_CAN_IsListEmpty(XMC_CAN_t *const obj, uint8_t list_idx)
2281 {
2282   return (bool)(obj->LIST[list_idx + 1] & CAN_LIST_EMPTY_Msk);
2283 }
2284 
2285 /**
2286  * @param obj Pointer pointing to XMC_CAN Global Initialization structure
2287  * @param list_idx List index
2288  *
2289  * @return Object index of the first message object in the list list_idx.
2290  *
2291  * \par<b>Description:</b><br>
2292  * This function returns object index of the first message object in the list list_idx.
2293  */
XMC_CAN_GetListBegin(XMC_CAN_t * const obj,uint8_t list_idx)2294 __STATIC_INLINE uint32_t XMC_CAN_GetListBegin(XMC_CAN_t *const obj, uint8_t list_idx)
2295 {
2296   return ((obj->LIST[list_idx + 1] & CAN_LIST_BEGIN_Msk) >> CAN_LIST_BEGIN_Pos);
2297 }
2298 
2299 /**
2300  * @param obj Pointer pointing to XMC_CAN Global Initialization structure
2301  * @param list_idx List index
2302  *
2303  * @return Number of message objects allocated to list list_idx
2304  *
2305  * \par<b>Description:</b><br>
2306  * This function returns number of message objects allocated to list list_idx
2307  */
XMC_CAN_GetListSize(XMC_CAN_t * const obj,uint8_t list_idx)2308 __STATIC_INLINE uint32_t XMC_CAN_GetListSize(XMC_CAN_t *const obj, uint8_t list_idx)
2309 {
2310   return ((obj->LIST[list_idx + 1] & CAN_LIST_SIZE_Msk) >> CAN_LIST_SIZE_Pos) + 1;
2311 }
2312 
2313 /**
2314  * @param can_mo Pointer to Message Object structure.
2315  * @param mo_idx Message object index.
2316  *
2317  * @return None.
2318  *
2319  * \par<b>Description:</b><br>
2320  * This function updates the hardware message object pointer to message object with index mo_idx
2321  */
XMC_CAN_MO_GetMessageObject(XMC_CAN_MO_t * const can_mo,uint8_t mo_idx)2322 __STATIC_INLINE void XMC_CAN_MO_GetMessageObject(XMC_CAN_MO_t *const can_mo, uint8_t mo_idx)
2323 {
2324 #if defined(CAN_MO0)
2325   CAN_MO_TypeDef *can_mo_ptr = &CAN_MO0[mo_idx];
2326 #elif defined(CAN_MO)
2327   CAN_MO_TypeDef *can_mo_ptr = &CAN_MO->MO[mo_idx];
2328 #endif
2329   can_mo->can_mo_ptr = can_mo_ptr;
2330 }
2331 
2332 /**
2333  * @param can_mo Pointer to Message Object structure.
2334  *
2335  * @return object index of next linked message object.
2336  *
2337  * \par<b>Description:</b><br>
2338  * This function returns the object index of next linked message object.
2339  */
XMC_CAN_MO_GetNextMessageObjectIdx(XMC_CAN_MO_t * can_mo)2340 __STATIC_INLINE uint32_t XMC_CAN_MO_GetNextMessageObjectIdx(XMC_CAN_MO_t *can_mo)
2341 {
2342   return ((can_mo->can_mo_ptr->MOSTAT & CAN_MO_MOSTAT_PNEXT_Msk) >> CAN_MO_MOSTAT_PNEXT_Pos);
2343 }
2344 
2345 #ifdef __cplusplus
2346 }
2347 #endif
2348 
2349 /**
2350   * @}
2351   */
2352 
2353 /**
2354   * @}
2355   */
2356 
2357 #endif /* defined(CAN) */
2358 
2359 #endif /* XMC_CAN_H */
2360 
2361 
2362 
2363