1 /**
2  * @file xmc_usbd.h
3  * @date 2015-06-20
4  *
5  *********************************************************************************************************************
6  * XMClib v2.1.24 - XMC Peripheral Driver Library
7  *
8  * Copyright (c) 2015-2019, Infineon Technologies AG
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
12  * following conditions are met:
13  *
14  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
15  * disclaimer.
16  *
17  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided with the distribution.
19  *
20  * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
21  * products derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE  FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with
32  * Infineon Technologies AG dave@infineon.com).
33  *********************************************************************************************************************
34  *
35  * Change History
36  * --------------
37  *
38  * 2015-02-16:
39  *     - Initial Version.<br>
40  * 2015-03-18:
41  *     - Updated the doxygen comments for documentation. <br>
42  *     - Updated the XMC_USBD_PATCH_VERSION to 4. <br>
43  *
44  * 2015-06-20:
45  *     - Removed version macros and declaration of GetDriverVersion API.<br>
46  *     - Updated the doxygen comments for API XMC_USBD_IsEnumDone().<br>
47  *     - Updated the copy right in the file header.<br>
48  *
49  * @endcond
50  *
51  */
52 
53 #ifndef XMC_USBD_H
54 #define XMC_USBD_H
55 
56 /**********************************************************************************************************************
57  * HEADER FILES
58  *********************************************************************************************************************/
59 #include "xmc_common.h"
60 
61 #if defined(USB0)
62 
63 #include <stdlib.h>
64 #include <string.h>
65 #include "xmc_usbd_regs.h"
66 #include "xmc_scu.h"
67 
68 /**
69  * @addtogroup XMClib XMC Peripheral Library
70  * @{
71  */
72 
73 /**
74  * @addtogroup USBD
75  * @brief Universal Serial Bus Device (USBD) driver for the XMC4000 microcontroller family.
76  *
77  * The USBD is the device driver for the USB0 hardware module on XMC4000 family of microcontrollers.
78  * The USB0 module can be used to establish a USB interface between outside world and XMC4000 family of controllers.
79  * The USB module includes the following features in device mode:
80  * -# Complies with the USB 2.0 Specification.
81  * -# Support for the Full-Speed (12-Mbps) mode.
82  * -# Supports up to 7 bidirectional endpoints, including control endpoint 0.
83  * -# Supports SOFs in Full-Speed modes.
84  * -# Supports clock gating for power saving.
85  * -# Supports USB suspend/resume.
86  * -# Supports USB soft disconnect.
87  * -# Supports DMA mode.
88  * -# Supports FIFO mode.
89  *
90  * The below figure shows the overview of USB0 module in XMC4 microntroller.
91  * @image html USB_module_overview.png
92  * @image latex ../images/USB_module_overview.png
93  *
94  * The below figure shows the USB device connection of USB0 module.
95  * @image html USB_device_connection.png
96  * @image latex ../images/USB_device_connection.png
97  *
98  * The USBD device driver supports the following features:\n
99  * -# Initialize/Uninitialize the USB0 module on XMC4000 device.
100  * -# Connect the USB device to host.
101  * -# Get USB device state.
102  * -# Set the USB device address.
103  * -# Configure/Unconfigure the USB endpoints.
104  * -# Stall/Abort the USB endpoints.
105  * -# USB IN transfers on EP0 and non EP0 endpoints.
106  * -# USB OUT transfers on EP0 and non EP0 endpoints.
107  *
108  * The USBD device driver provides the configuration structure ::XMC_USBD_t which user need to configure before initializing the USB.\n
109  * The following elements of configuration structure need to be initialized before calling the ::XMC_USBD_Init API:
110  * -# cb_xmc_device_event of type ::XMC_USBD_SignalDeviceEvent_t.
111  * -# cb_endpoint_event of type ::XMC_USBD_SignalEndpointEvent_t.
112  * -# usbd_max_num_eps of type ::XMC_USBD_MAX_NUM_EPS_t.
113  * -# usbd_transfer_mode of type ::XMC_USBD_TRANSFER_MODE_t.
114  *
115  * @{
116  */
117 
118 /**********************************************************************************************************************
119  * MACROS
120  *********************************************************************************************************************/
121 
122 #define XMC_USBD_NUM_TX_FIFOS                          (7U) 	/**< Number of hardware transmission endpoint fifos */
123 
124 #define XMC_USBD_MAX_FIFO_SIZE                         (2048U)  /**< Maximum USBD endpoint fifo size */
125 
126 #define XMC_USBD_NUM_EPS                               (7U)		/**< Number of hardware endpoints */
127 
128 #define	XMC_USBD_MAX_PACKET_SIZE                       (64U)	/**< Maximum packet size for all endpoints
129 	                                                                (including ep0) */
130 
131 /**< Maximum transfer size for endpoints.
132  *
133  * It's based on the maximum payload, due to the fact,
134  * that we only can transfer 2^10 - 1 packets and this is less than the
135  * transfer size field can hold.
136  */
137 #define XMC_USBD_MAX_TRANSFER_SIZE                     (((uint32_t)((uint32_t)1U << (uint32_t)10U) - 1U) * (uint32_t)XMC_USBD_MAX_PACKET_SIZE)
138 
139 #define XMC_USBD_MAX_TRANSFER_SIZE_EP0                 (64U)	/**< Maximum transfer size for endpoint 0*/
140 
141 #define XMC_USBD_SETUP_COUNT                           (3U)		/**< The number of USB setup packets */
142 
143 #define XMC_USBD_SETUP_SIZE                            (8U)		/**< The size of USB setup data */
144 
145 #define XMC_USBD_EP_NUM_MASK                           (0x0FU)	/**< USB Endpoint number mask. */
146 
147 #define XMC_USBD_EP_DIR_MASK                           (0x80U)	/**< USB Endpoint direction mask */
148 
149 #define XMC_USBD_DCFG_DEVSPD_FS	                       (0x3U)	/*USB Full Speed device flag in DCFG register */
150 
151 #define XMC_USBD_TX_FIFO_REG_OFFSET                    (0x1000U)/* First endpoint fifo register offset from base address */
152 
153 #define XMC_USBD_TX_FIFO_OFFSET		                   (0x1000U)/* Offset for each fifo register */
154 
155 #define XMC_USBD_ENDPOINT_NUMBER_MASK                  (0x0FU)	/**< USB Endpoint number mask to get the EP number from address. */
156 
157 #define XMC_USBD_ENDPOINT_DIRECTION_MASK               (0x80U)	/**< USB Endpoint direction mask to get the EP direction from address. */
158 
159 #define XMC_USBD_ENDPOINT_MAX_PACKET_SIZE_MASK         (0x07FFU)/**< USB Endpoint Maximum Packet Size mask */
160 
161 #define XMC_USBD_ENDPOINT_MFRAME_TR_MASK 			         (0x1800U)/* USB Endpoint micro frame TR mask */
162 #define XMC_USBD_ENDPOINT_MFRAME_TR_1                  (0x0000U)/* Selects USB Endpoint micro frame TR1 */
163 #define XMC_USBD_ENDPOINT_MFRAME_TR_2                  (0x0800U)/* Selects USB Endpoint micro frame TR2 */
164 #define XMC_USBD_ENDPOINT_MFRAME_TR_3                  (0x1000U)/* Selects USB Endpoint micro frame TR3 */
165 
166 
167 #define XMC_USBD_SPEED_FULL                            (1U)		/**< Speed Mode. Full Speed */
168 
169 #define XMC_USBD_EP0_BUFFER_SIZE                       (64U)	/* Endpoint 0 buffer size */
170 
171 #define XMC_USBD_EP1_BUFFER_SIZE                       (64U)	/* Endpoint 1 buffer size */
172 
173 #define XMC_USBD_EP2_BUFFER_SIZE                       (64U)	/* Endpoint 2 buffer size */
174 
175 #define XMC_USBD_EP3_BUFFER_SIZE                       (64U)	/* Endpoint 3 buffer size */
176 
177 #define XMC_USBD_EP4_BUFFER_SIZE                       (64U)	/* Endpoint 4 buffer size */
178 
179 #define XMC_USBD_EP5_BUFFER_SIZE                       (64U)	/* Endpoint 5 buffer size */
180 
181 #define XMC_USBD_EP6_BUFFER_SIZE                       (64U)	/* Endpoint 6 buffer size */
182 
183 
184 /**********************************************************************************************************************
185  * ENUMS
186  *********************************************************************************************************************/
187 
188 /**
189  * Defines the options for the global receive fifo packet status.
190  * Use type ::XMC_USBD_GRXSTS_PKTSTS_t for this enum.
191  * */
192 typedef enum XMC_USBD_GRXSTS_PKTSTS {
193   XMC_USBD_GRXSTS_PKTSTS_GOUTNAK   = 0x1U,      				/**< Global out nack send ( triggers an interrupt ) */
194   XMC_USBD_GRXSTS_PKTSTS_OUTDATA   = 0x2U,      				/**< OUT data packet received */
195   XMC_USBD_GRXSTS_PKTSTS_OUTCMPL   = 0x3U,      				/**< OUT transfer completed (triggers an interrupt) */
196   XMC_USBD_GRXSTS_PKTSTS_SETUPCMPL = 0x4U,      				/**< SETUP transaction completed (triggers an interrupt) */
197   XMC_USBD_GRXSTS_PKTSTS_SETUP     = 0x6U       				/**< SETUP data packet received */
198 } XMC_USBD_GRXSTS_PKTSTS_t;
199 
200 /**
201 *  Defines the options for the USB endpoint type. The values are from the USB 2.0 specification.
202 *  Use type ::XMC_USBD_ENDPOINT_TYPE_t for this enum.
203 */
204 typedef enum XMC_USBD_ENDPOINT_TYPE {
205   XMC_USBD_ENDPOINT_TYPE_CONTROL        = 0x0U,      			/**< Control endpoint */
206   XMC_USBD_ENDPOINT_TYPE_ISOCHRONOUS    = 0x01U,     			/**< Isochronous endpoint */
207   XMC_USBD_ENDPOINT_TYPE_BULK           = 0x02U,     			/**< Bulk endpoint */
208   XMC_USBD_ENDPOINT_TYPE_INTERRUPT      = 0x03U      			/**< Interrupt endpoint */
209 } XMC_USBD_ENDPOINT_TYPE_t;
210 
211 
212 /**
213 *  Defines the options for USB device state while setting the address.
214 *  Use type ::XMC_USBD_SET_ADDRESS_STAGE_t for this enum.
215 */
216 typedef enum XMC_USBD_SET_ADDRESS_STAGE {
217   XMC_USBD_SET_ADDRESS_STAGE_SETUP,             				/**< Setup address */
218   XMC_USBD_SET_ADDRESS_STAGE_STATUS             				/**< Status address */
219 } XMC_USBD_SET_ADDRESS_STAGE_t;
220 
221 
222 /**
223 * Defines the USB Device Status of executed operation.
224 * Use type ::XMC_USBD_STATUS_t for this enum.
225 */
226 typedef enum XMC_USBD_STATUS {
227   XMC_USBD_STATUS_OK       = 0U,         						/**< USBD Status: Operation succeeded*/
228   XMC_USBD_STATUS_BUSY     = 2U,         						/**< Driver is busy and cannot handle request */
229   XMC_USBD_STATUS_ERROR    = 1U          						/**< USBD Status: Unspecified error*/
230 } XMC_USBD_STATUS_t;
231 
232 
233 /**
234 * Defines the USB Device events.
235 * Use type ::XMC_USBD_EVENT_t for this enum.
236 */
237 typedef enum XMC_USBD_EVENT {
238   XMC_USBD_EVENT_POWER_ON,              						/**< USB Device Power On */
239   XMC_USBD_EVENT_POWER_OFF,             						/**< USB Device Power Off */
240   XMC_USBD_EVENT_CONNECT,               						/**< USB Device connected */
241   XMC_USBD_EVENT_DISCONNECT,            						/**< USB Device disconnected */
242   XMC_USBD_EVENT_RESET,                 						/**< USB Reset occurred */
243   XMC_USBD_EVENT_HIGH_SPEED,            						/**< USB switch to High Speed occurred */
244   XMC_USBD_EVENT_SUSPEND,               						/**< USB Suspend occurred */
245   XMC_USBD_EVENT_RESUME,                						/**< USB Resume occurred */
246   XMC_USBD_EVENT_REMOTE_WAKEUP,       							/**< USB Remote wakeup */
247   XMC_USBD_EVENT_SOF, 											/**< USB Start of frame event */
248   XMC_USBD_EVENT_EARLYSUSPEND,          						/**< USB Early suspend */
249   XMC_USBD_EVENT_ENUMDONE,              						/**< USB enumeration done */
250   XMC_USBD_EVENT_ENUMNOTDONE,           						/**< USB enumeration not done */
251   XMC_USBD_EVENT_OUTEP,                 						/**< USB OUT endpoint */
252   XMC_USBD_EVENT_INEP                   						/**< USB IN endpoint */
253 } XMC_USBD_EVENT_t;
254 
255 /**
256 * Defines the USB IN endpoint events.
257 * Use type ::XMC_USBD_EVENT_IN_EP_t for this enum.
258 */
259 typedef enum XMC_USBD_EVENT_IN_EP {
260   XMC_USBD_EVENT_IN_EP_TX_COMPLET = 1U,      					/**< USB IN ep transmission complete */
261   XMC_USBD_EVENT_IN_EP_DISABLED = 2U,        					/**< USB IN ep disabled */
262   XMC_USBD_EVENT_IN_EP_AHB_ERROR = 4U,       					/**< USB IN ep AHB error */
263   XMC_USBD_EVENT_IN_EP_TIMEOUT = 8U,         					/**< USB IN ep timeout */
264 } XMC_USBD_EVENT_IN_EP_t;
265 
266 /**
267 * Defines the USB OUT endpoint events.
268 * Use type ::XMC_USBD_EVENT_OUT_EP_t for this enum.
269 */
270 typedef enum XMC_USBD_EVENT_OUT_EP {
271   XMC_USBD_EVENT_OUT_EP_TX_COMPLET = 1U,      					/**< USB OUT ep transmission complete */
272   XMC_USBD_EVENT_OUT_EP_DISABLED = 2U,        					/**< USB OUT ep disabled */
273   XMC_USBD_EVENT_OUT_EP_AHB_ERROR = 4U,       					/**< USB OUT ep AHB error */
274   XMC_USBD_EVENT_OUT_EP_SETUP = 8U,           					/**< USB OUT ep setup */
275 } XMC_USBD_EVENT_OUT_EP_t;
276 
277 
278 /**
279 * Defines the generic USB endpoint events.
280 * Use type ::XMC_USBD_EP_EVENT_t for this enum.
281 */
282 typedef enum XMC_USBD_EP_EVENT {
283   XMC_USBD_EP_EVENT_SETUP,              						/**< SETUP packet*/
284   XMC_USBD_EP_EVENT_OUT,                						/**< OUT packet*/
285   XMC_USBD_EP_EVENT_IN                  						/**< IN packet*/
286 } XMC_USBD_EP_EVENT_t;
287 
288 /**
289 * Defines the options for the USB data transfer modes.
290 * Use type ::XMC_USBD_TRANSFER_MODE_t for this enum.
291 */
292 typedef enum XMC_USBD_TRANSFER_MODE {
293   XMC_USBD_USE_DMA,  											/**< Transfer by DMA*/
294   XMC_USBD_USE_FIFO  											/**< Transfer by FIFO*/
295 } XMC_USBD_TRANSFER_MODE_t;
296 
297 /**
298 * Defines the options for the maximum number of endpoints used.
299 * Use type ::XMC_USBD_MAX_NUM_EPS_t for this enum.
300 */
301 typedef enum XMC_USBD_MAX_NUM_EPS {
302   XMC_USBD_MAX_NUM_EPS_1      = 1U,								/**< Maximum 1 endpoint used*/
303   XMC_USBD_MAX_NUM_EPS_2      = 2U,								/**< Maximum 2 endpoints used*/
304   XMC_USBD_MAX_NUM_EPS_3      = 3U,								/**< Maximum 3 endpoints used*/
305   XMC_USBD_MAX_NUM_EPS_4      = 4U,								/**< Maximum 4 endpoints used*/
306   XMC_USBD_MAX_NUM_EPS_5      = 5U,								/**< Maximum 5 endpoints used*/
307   XMC_USBD_MAX_NUM_EPS_6      = 6U,								/**< Maximum 6 endpoints used*/
308   XMC_USBD_MAX_NUM_EPS_7      = 7U								/**< Maximum 2 endpoints used*/
309 } XMC_USBD_MAX_NUM_EPS_t;
310 
311 /**
312 * USB device/endpoint event function pointers
313 */
314 typedef void (*XMC_USBD_SignalDeviceEvent_t)   (XMC_USBD_EVENT_t event);/**< Pointer to USB device event call back.
315  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 Uses type ::XMC_USBD_EVENT_t as the argument of callback.*/
316 typedef void (*XMC_USBD_SignalEndpointEvent_t) (uint8_t ep_addr, XMC_USBD_EP_EVENT_t ep_event);/**< Pointer to USB endpoint event call back.
317 																								Uses type ::XMC_USBD_EP_EVENT_t and EP address as the argument of callback.*/
318 
319 /**********************************************************************************************************************
320  * DATA STRUCTURES
321  *********************************************************************************************************************/
322 
323 /**
324  * Describes the USB Device Driver Capabilities.
325  */
326 typedef struct XMC_USBD_CAPABILITIES {
327   uint32_t event_power_on      :  1;    						/**< Signal Power On event*/
328   uint32_t event_power_off     :  1;    						/**< Signal Power Off event*/
329   uint32_t event_connect       :  1;    						/**< Signal Connect event*/
330   uint32_t event_disconnect    :  1;    						/**< Signal Disconnect event*/
331   uint32_t event_reset         :  1;    						/**< Signal Reset event*/
332   uint32_t event_high_speed    :  1;    						/**< Signal switch to High-speed event*/
333   uint32_t event_suspend       :  1;    						/**< Signal Suspend event*/
334   uint32_t event_resume        :  1;    						/**< Signal Resume event*/
335   uint32_t event_remote_wakeup :  1;    						/**< Signal Remote Wake up event*/
336   uint32_t reserved            : 23;    						/**< Reserved for future use*/
337 } XMC_USBD_CAPABILITIES_t;
338 
339 /**
340  * Describes the current USB Device State.
341  */
342 typedef struct XMC_USBD_STATE {
343   uint32_t powered     : 1;        								/**< USB Device powered flag*/
344   uint32_t connected   : 1;        								/**< USB Device connected flag*/
345   uint32_t active      : 1;        								/**< USB Device active lag*/
346   uint32_t speed       : 2;        								/**< USB Device speed */
347 } XMC_USBD_STATE_t;
348 
349 /**
350  * Describes a USB endpoint<BR>
351  *
352  * All information to control an endpoint is stored in this structure.
353  * It contains information about the endpoints and the status of the device.
354  */
355 typedef struct {
356   union {
357     uint32_t address            : 8;     						/**< The endpoint address including the direction */
358       struct {
359         uint32_t number         : 4;     						/**< The endpoint number.It can be from 0 to 6 */
360         uint32_t pading         : 3;     						/**< Padding between number and direction */
361         uint32_t direction      : 1;     						/**< The endpoint direction */
362 	  } address_st;
363     } address_u;
364   uint32_t type                 : 2;     						/**< The endpoint type */
365   uint32_t isConfigured         : 1;     						/**< The flag showing, if the endpoint is configured */
366   volatile uint32_t inInUse     : 1;     						/**< Sets if the selected USB IN endpoint is currently in use */
367   volatile uint32_t outInUse    : 1;     						/**< Sets if the selected USB OUT endpoint is currently in use */
368   uint32_t isStalled            : 1;     						/**< Sets if the selected USB endpoint is stalled. */
369   uint32_t txFifoNum            : 4;     						/**< Endpoint transmit Fifo Number */
370   uint32_t sendZeroLengthPacket : 1;							/**< If set, a zero length packet will be send at the end of the transfer */
371   uint32_t maxPacketSize        : 7;							/**< The maximum size of packet for USB endpoint ( due to FS Speed device only 64 Byte )*/
372   uint32_t maxTransferSize      : 19;							/**< The maximum amount of data the core can send at once.*/
373   uint8_t *outBuffer;                    						/**< The buffer for operation as OUT endpoint */
374   uint32_t outBytesAvailable;            						/**< The number of bytes available in the EP OUT buffer */
375   uint32_t outBufferSize;                						/**< The size of the EP OUT buffer */
376   uint32_t outOffset;                    						/**< The read offset of the EP OUT buffer */
377   uint8_t *inBuffer;                     						/**< The buffer for operation as IN endpoint */
378   uint32_t inBufferSize;                 						/**< The size of the EP IN buffer */
379   uint8_t *xferBuffer;                   						/**< The buffer of the current transfer */
380   uint32_t xferLength;                   						/**< The length of the current transfer */
381   uint32_t xferCount;                    						/**< Bytes transfered of the current USB data transfer */
382   uint32_t xferTotal;                    						/**< The length of total data in buffer */
383 } XMC_USBD_EP_t;
384 
385 /**
386  * Describes the XMC USB device<BR>
387  *
388  * All information to control an XMC USB device is stored in
389  * this structure. It contains register, callbacks, information
390  * about the endpoints and the status of the device.
391  */
392 typedef struct XMC_USBD_DEVICE {
393   XMC_USBD_EP_t ep[8];                                                     	/**< Endpoints of the USB device. It is of type ::XMC_USBD_EP_t */
394   dwc_otg_core_global_regs_t *global_register;                             	/**< Global register interface */
395   dwc_otg_device_global_regs_t *device_register;                           	/**< Device register interface */
396   dwc_otg_dev_in_ep_regs_t *endpoint_in_register[(uint8_t)XMC_USBD_NUM_EPS];/**< IN Endpoint register interface */
397   dwc_otg_dev_out_ep_regs_t *endpoint_out_register[(uint8_t)XMC_USBD_NUM_EPS];/**< OUT Endpoint register interface */
398   volatile uint32_t *fifo[(uint8_t)XMC_USBD_NUM_TX_FIFOS];                  /**< Transmit fifo interface */
399   uint16_t txfifomsk;                                                      	/**< Mask of used TX fifos */
400   uint32_t IsConnected       : 1;                                           /**< Sets if device is connected */
401   uint32_t IsActive          : 1;                                           /**< Sets if device is currently active */
402   uint32_t IsPowered		 : 1;                                           /**< Sets if device is powered by Vbus */
403   XMC_USBD_SignalDeviceEvent_t DeviceEvent_cb;                              /**< The USB device event callback. */
404   XMC_USBD_SignalEndpointEvent_t EndpointEvent_cb;                          /**< The USB endpoint event callback. */
405 } XMC_USBD_DEVICE_t;
406 
407 
408 /**
409  * USB device initialization structure
410  */
411 typedef struct XMC_USBD_OBJ
412 {
413   USB0_GLOBAL_TypeDef *const usbd;                   						/**< USB Module Pointer. The USB0 module base address. */
414   XMC_USBD_SignalDeviceEvent_t  cb_xmc_device_event; 						/**< USB device event callback. Use ::XMC_USBD_SignalDeviceEvent_t type of function pointer. */
415   XMC_USBD_SignalEndpointEvent_t cb_endpoint_event;  						/**< USB endpoint event callback. Use ::XMC_USBD_SignalEndpointEvent_t type of function pointer.*/
416   XMC_USBD_MAX_NUM_EPS_t usbd_max_num_eps;           						/**< Maximum number of end points used. The maximum range can be 7.*/
417   XMC_USBD_TRANSFER_MODE_t usbd_transfer_mode;       						/**< USB data transfer mode.Use ::XMC_USBD_TRANSFER_MODE_t type to specify the transfer mode. */
418 } XMC_USBD_t;
419 
420 /**
421  * Defines the access structure of the USB Device Driver.
422  */
423 typedef struct XMC_USBD_DRIVER {
424 
425 
426   XMC_USBD_CAPABILITIES_t (*GetCapabilities)    (void);									 /**< Pointer to @ref XMC_USBD_GetCapabilities : Get driver capabilities.*/
427 
428 
429   XMC_USBD_STATUS_t       (*Initialize)         (XMC_USBD_t *obj);						/**< Pointer to  @ref XMC_USBD_Init : Initialize USB Device Interface.*/
430 
431 
432   XMC_USBD_STATUS_t       (*Uninitialize)       (void);									/**< Pointer to @ref XMC_USBD_Uninitialize : De-initialize USB Device Interface.*/
433 
434 
435   XMC_USBD_STATUS_t       (*DeviceConnect)      (void);									/**< Pointer to @ref XMC_USBD_DeviceConnect : Connect USB Device.*/
436 
437 
438   XMC_USBD_STATUS_t       (*DeviceDisconnect)   (void);									/**< Pointer to @ref XMC_USBD_DeviceDisconnect : Disconnect USB Device.*/
439 
440 
441   XMC_USBD_STATE_t        (*DeviceGetState)     (const XMC_USBD_t *const obj);			/**< Pointer to @ref XMC_USBD_DeviceGetState : Get current USB Device State.*/
442 
443 
444   XMC_USBD_STATUS_t       (*DeviceSetAddress)   (uint8_t dev_addr, XMC_USBD_SET_ADDRESS_STAGE_t stage);/**< Pointer to @ref XMC_USBD_DeviceSetAddress : Set USB Device Address.*/
445 
446 
447   XMC_USBD_STATUS_t       (*EndpointConfigure)  (uint8_t ep_addr,XMC_USBD_ENDPOINT_TYPE_t ep_type, uint16_t ep_max_packet_size);/**< Pointer to @ref XMC_USBD_EndpointConfigure : Configure USB Endpoint.*/
448 
449 
450   XMC_USBD_STATUS_t       (*EndpointUnconfigure)(uint8_t ep_addr);						/**< Pointer to @ref XMC_USBD_EndpointUnconfigure : Unconfigure USB Endpoint.*/
451 
452 
453   XMC_USBD_STATUS_t       (*EndpointStall)      (uint8_t ep_addr, bool stall);			/**< Pointer to @ref XMC_USBD_EndpointStall : Set/Clear Stall for USB Endpoint.*/
454 
455 
456   XMC_USBD_STATUS_t       (*EndpointReadStart)  (uint8_t ep_addr, uint32_t len);		/**< Pointer to @ref XMC_USBD_EndpointReadStart : Start USB Endpoint Read operation.*/
457 
458 
459   int32_t                 (*EndpointRead)       (uint8_t ep_addr, uint8_t *buf, uint32_t len);/**< Pointer to @ref XMC_USBD_EndpointRead : Read data from USB Endpoint.*/
460 
461 
462   int32_t                 (*EndpointWrite)      (uint8_t ep_addr, const uint8_t *buf, uint32_t len); /**< Pointer to @ref XMC_USBD_EndpointWrite : Write data to USB Endpoint.*/
463 
464 
465   XMC_USBD_STATUS_t       (*EndpointAbort)      (uint8_t ep_addr);						/**< Pointer to @ref XMC_USBD_EndpointAbort : Abort current USB Endpoint transfer.*/
466 
467 
468   uint16_t                (*GetFrameNumber)     (void);									/**< Pointer to @ref XMC_USBD_GetFrameNumber : Get current USB Frame Number.*/
469 
470 
471   uint32_t    	          (*IsEnumDone)         (void);									/**< Pointer to @ref XMC_USBD_IsEnumDone : Is enumeration done in Host?.*/
472 } const XMC_USBD_DRIVER_t;
473 
474 /**
475  * Defines the driver interface function table.
476  * To access the XMC device controller driver interface use this table of functions.
477  **/
478 extern const XMC_USBD_DRIVER_t Driver_USBD0;
479 
480 
481 /**
482  * Defines the XMC USB device data
483  * The instance of ::XMC_USBD_DEVICE_t structure describing the XMC device.
484  **/
485 extern XMC_USBD_DEVICE_t xmc_device;
486 
487 /**********************************************************************************************************************
488  * API PROTOTYPES
489  *********************************************************************************************************************/
490 
491 #ifdef __cplusplus
492 extern "C" {
493 #endif
494 
495 /**
496  * @param	None.
497  *
498  * @return 	None.
499  *
500  * \par<b>Description:</b><BR>
501  * Enables the USB module in the XMC controller.<BR>
502  * It de-asserts the peripheral reset on USB0 module and enables the USB power.
503  *
504  * \par<b>Note:</b><BR>
505  * This API is called inside the XMC_USBD_Init().\n
506  *
507  * \par<b>Related APIs:</b><BR>
508  * XMC_USBD_Disable()\n
509  **/
510 void XMC_USBD_Enable(void);
511 
512 /**
513  * @param	None.
514  *
515  * @return 	None.
516  *
517  * \par<b>Description:</b><BR>
518  * Disables the USB module in the XMC controller.<BR>
519  * It asserts the peripheral reset on USB0 module and disables the USB power.
520  *
521  * \par<b>Related APIs:</b><BR>
522  * XMC_USBD_Enable()\n
523  **/
524 void XMC_USBD_Disable(void);
525 
526 /**
527  * @param	event The single event that needs to be cleared. Use ::XMC_USBD_EVENT_t as argument.\n
528  *
529  * @return 	None.
530  *
531  * \par<b>Description:</b><BR>
532  * Clears the selected USBD \a event.<BR>
533  * It clears the event by writing to the GINTSTS register.
534  *
535  * \par<b>Note:</b><BR>
536  * This API is called inside the USB interrupt handler to clear the event XMC_USBD_EVENT_t
537  * and maintain the device state machine.\n
538  *
539  * \par<b>Related APIs:</b><BR>
540  * ::XMC_USBD_ClearEventOUTEP(),::XMC_USBD_ClearEventINEP()\n
541  **/
542 void XMC_USBD_ClearEvent(XMC_USBD_EVENT_t event);
543 
544 
545 /**
546  * @param	event The single event or multiple events that need to be cleared.
547  *
548  * @param	ep_num The IN endpoint number on which the events to be cleared.
549  *
550  * @return 	None.
551  *
552  * \par<b>Description:</b><BR>
553  * Clears the single event or multiple events of the selected IN endpoint.<BR>
554  * The multiple events can be selected by the bitwise OR operation of ::XMC_USBD_EVENT_IN_EP_t elements.\n
555  * It clears the event by programming DIEPINT register.\n
556  *
557  * \par<b>Note:</b><BR>
558  * This API is called inside the USB IN EP interrupt handler to clear the ::XMC_USBD_EVENT_IN_EP_t event
559  * and maintain the device state machine.\n
560  *
561  * \par<b>Related APIs:</b><BR>
562  * ::XMC_USBD_ClearEventOUTEP()\n
563  **/
564 void XMC_USBD_ClearEventINEP(uint32_t event,uint8_t ep_num);
565 
566 
567 /**
568  * @param	event The single event or multiple events that need to be cleared.
569  *
570  * @param	ep_num The OUT endpoint number on which the events to be cleared.
571  *
572  * @return 	None.
573  *
574  * \par<b>Description:</b><BR>
575  * Clears the single \a event or multiple events of the selected OUT endpoint.<BR>
576  * The multiple events can be selected by the bitwise OR operation of ::XMC_USBD_EVENT_OUT_EP_t elements.
577  * It clears the event by writing to DOEPINT register.
578  *
579  * \par<b>Note:</b><BR>
580  * This API is called inside the USB OUT EP interrupt handler to clear the ::XMC_USBD_EVENT_OUT_EP_t event
581  * and maintain the device state machine.\n
582  *
583  * \par<b>Related APIs:</b><BR>
584  * ::XMC_USBD_ClearEventINEP()\n
585  **/
586 void XMC_USBD_ClearEventOUTEP(uint32_t event,uint8_t ep_num);
587 
588 /**
589  * @param	event The single event or multiple events that need to be enabled.
590  *
591  * @return 	None.
592  *
593  * \par<b>Description:</b><BR>
594  * Enables the event or multiple events of the OUT endpoints.<BR>
595  * The multiple events can be selected by the bitwise OR operation of ::XMC_USBD_EVENT_OUT_EP_t elements.
596  * It enables the event by programming DOEPMSK register.
597  *
598  * \par<b>Note:</b><BR>
599  * This API is called inside the ::XMC_USBD_Init() to enable the OUT EP interrupts.\n
600  *
601  * \par<b>Related APIs:</b><BR>
602  * ::XMC_USBD_EnableEventINEP()\n
603  **/
604 void XMC_USBD_EnableEventOUTEP(uint32_t event);
605 
606 /**
607  * @param	event The single event or multiple events that need to be enabled.
608  *
609  * @return 	None.
610  *
611  * \par<b>Description:</b><BR>
612  * Enables the \a event or multiple events of the USB IN endpoints.<BR>
613  * The multiple events can be selected by the bitwise OR operation of ::XMC_USBD_EVENT_IN_EP_t elements.
614  * It enables the event by programming DIEPMSK register.
615  *
616  * \par<b>Note:</b><BR>
617  * This API is called inside the ::XMC_USBD_Init() to enable the IN EP interrupts.\n
618  *
619  * \par<b>Related APIs:</b><BR>
620  * ::XMC_USBD_EnableEventOUTEP()\n
621  **/
622 void XMC_USBD_EnableEventINEP(uint32_t event);
623 
624 /**
625  * @param	None.
626  *
627  * @return 	::XMC_USBD_CAPABILITIES_t.
628  *
629  * \par<b>Description:</b><BR>
630  * Retrieves the USB device capabilities of type \a XMC_USBD_CAPABILITIES_t<BR>
631  * The USB device capabilities supported by the USBD driver, like power on/off, connect/disconnect,
632  * reset,suspend/resume,USB speed etc are retrieved.
633  *
634  * It can be called after initializing the USB device to get the information on the USBD capabilities.
635  *
636  **/
637 XMC_USBD_CAPABILITIES_t XMC_USBD_GetCapabilities(void);
638 
639 
640 /**
641  * @param	obj The pointer to the USB device handle ::XMC_USBD_t.
642  *
643  * @return 	XMC_USBD_STATUS_t The USB device status of type ::XMC_USBD_STATUS_t.
644  *
645  * \par<b>Description:</b><BR>
646  * Initializes the USB device to get ready for connect to USB host.<BR>
647  * Enables the USB module,sets the EP buffer sizes,registers the device and EP event call backs.
648  * Initializes the global,device and FIFO register base addresses.
649  * Configures the global AHB,enables the global interrupt and DMA by programming GAHBCFG register.
650  * Configures the USB in to device mode and enables the session request protocol by programming GUSBCFG register.
651  * Configures the USB device speed to full speed by programming DCFG register.
652  * Disconnects the USB device by programming DCTL register.
653  * Enables the USB common and device interrupts by programming GINTMSK register.
654  *
655  * \par<b>Note:</b><BR>
656  * This API makes the USB device ready to connect to host.The user has to explicitly call
657  * the ::XMC_USBD_DeviceConnect() after the USB initialization to connect to USB host.\n
658  *
659  * \par<b>Related APIs:</b><BR>
660  * ::XMC_USBD_DeviceConnect()\n
661  **/
662 XMC_USBD_STATUS_t XMC_USBD_Init(XMC_USBD_t *obj);
663 
664 /**
665  * @param	None.
666  *
667  * @return 	::XMC_USBD_STATUS_t.
668  *
669  * \par<b>Description:</b><BR>
670  * Uninitialises the USB device.<BR>
671  * Disconnects the USB device by programming DCTL register and resets the XMC USB device data.
672  *
673  * \par<b>Note:</b><BR>
674  * Once this API is called, USB device will not be accessible from host.\n
675  *
676  * \par<b>Related APIs:</b><BR>
677  * ::XMC_USBD_Init()\n
678  **/
679 XMC_USBD_STATUS_t XMC_USBD_Uninitialize(void);
680 
681 /**
682  * @param	None.
683  *
684  * @return 	::XMC_USBD_STATUS_t.
685  *
686  * \par<b>Description:</b><BR>
687  * Connects the USB device to host and triggers the USB enumeration.<BR>
688  * Connects the USB device to host by programming DCTL register.\n
689  * It resets the soft disconnect bit, which activates the speed pull up at d+ line of USB.
690  * ::XMC_USBD_Init() should be called before calling this API.
691  *
692  * \par<b>Note:</b><BR>
693  * Once this API is called, USB host starts the enumeration process and the device should
694  * handle the descriptor requests.\n
695  *
696  * \par<b>Related APIs:</b><BR>
697  * ::XMC_USBD_Init()\n
698  **/
699 XMC_USBD_STATUS_t XMC_USBD_DeviceConnect(void);
700 
701 /**
702  * @param	None.
703  *
704  * @return 	::XMC_USBD_STATUS_t.
705  *
706  * \par<b>Description:</b><BR>
707  * Disconnects the USB device from host.<BR>
708  * By programming DCTL register, it sets the soft disconnect bit, which deactivates\n
709  * the speed pull up at d+ line of USB.
710  *
711  * \par<b>Note:</b><BR>
712  * Once this API is called, USB device will not be accessible from host.\n
713  *
714  * \par<b>Related APIs:</b><BR>
715  * ::XMC_USBD_DeviceConnect()\n
716  **/
717 XMC_USBD_STATUS_t XMC_USBD_DeviceDisconnect(void);
718 
719 /**
720  * @param	obj The pointer to the USB device handle structure \a XMC_USBD_t.
721  *
722  * @return 	::XMC_USBD_STATE_t.
723  *
724  * \par<b>Description:</b><BR>
725  * Retrieves the current USB device state.<BR>
726  * Power,active,speed and connection status data are retrieved.\n
727  *
728  * \par<b>Note:</b><BR>
729  * Before calling this API, USB should be initialized with ::XMC_USBD_Init.\n
730  *
731  * \par<b>Related APIs:</b><BR>
732  * ::XMC_USBD_Init()\n
733  **/
734 XMC_USBD_STATE_t XMC_USBD_DeviceGetState(const XMC_USBD_t *const obj);
735 
736 
737 /**
738  * @param	address The address to be set for the USB device .
739  * @param	stage 	The device request stage-setup or status ::XMC_USBD_SET_ADDRESS_STAGE_t.
740  *
741  * @return 	::XMC_USBD_STATUS_t.
742  *
743  * \par<b>Description:</b><BR>
744  * Sets the USB device address.<BR>
745  * The device address is programmed in the DCFG register.<BR>
746  *
747  * The address should be more than 0; as 0 is the default USB device address at the starting of enumeration.
748  * As part of enumeration, host sends the control request to the device to set the USB address; and in turn,\n
749  * in the USB device event call back handler, user has to set the address using this API for the set address request.<BR>
750  *
751  * The stage parameter should be XMC_USBD_SET_ADDRESS_STAGE_SETUP from the enum ::XMC_USBD_SET_ADDRESS_STAGE_t.
752  *
753  * \par<b>Note:</b><BR>
754  * Before calling this API, USB should be initialized with ::XMC_USBD_Init () and connected to
755  * USB host using ::XMC_USBD_DeviceConnect() \n
756  *
757  * \par<b>Related APIs:</b><BR>
758  * ::XMC_USBD_Init(), ::XMC_USBD_DeviceConnect()\n
759  **/
760 XMC_USBD_STATUS_t XMC_USBD_DeviceSetAddress(uint8_t address,XMC_USBD_SET_ADDRESS_STAGE_t stage);
761 
762 /**
763  * @param	ep_addr The address of the USB endpoint, which needs to be configured.
764  * @param	ep_type The ::XMC_USBD_ENDPOINT_TYPE_t.
765  * @param	ep_max_packet_size The maximum packet size of endpoint in USB full speed.
766  *
767  * @return 	::XMC_USBD_STATUS_t.
768  *
769  * \par<b>Description:</b><BR>
770  * Configures the USB endpoint.<BR>
771  * The endpoint is configured by programming the DAINT,DIEPCTL and DOEPCTL registers.<BR>
772  *
773  * Configures the EP type, FIFO number,maximum packet size, enables endpoint and sets the DATA0 PID.
774  * This function also initializes the internal buffer handling for the specified endpoint,
775  * but does not start any transfers.<BR>
776  *
777  * As part of enumeration, host sends the control request to the device to set the configuration; and in turn,\n
778  * in the USB device event call back handler, user has to set the configuration and configure the endpoints \n
779  * required for the device.\n
780  *
781  * \par<b>Note:</b><BR>
782  * This API should only be used as part of enumeration.\n
783  *
784  * \par<b>Related APIs:</b><BR>
785  * ::XMC_USBD_Init(),::XMC_USBD_DeviceConnect(),::XMC_USBD_EndpointUnconfigure()\n
786  **/
787 XMC_USBD_STATUS_t XMC_USBD_EndpointConfigure(uint8_t ep_addr,
788                                              XMC_USBD_ENDPOINT_TYPE_t ep_type,
789 		                                     uint16_t ep_max_packet_size);
790 
791 /**
792  * @param	ep_addr The address of the USB endpoint, which needs to be unconfigured.
793  *
794  * @return 	::XMC_USBD_STATUS_t.
795  *
796  * \par<b>Description:</b><BR>
797  * Unconfigures the USB endpoint.<BR>
798  * The endpoint is unconfigured by programming the DAINT,DIEPCTL and DOEPCTL registers.\n
799  * Disables the endpoint, unassign the fifo, deactivate it and only send nacks.\n
800  * Waits until the endpoint has finished operation and disables it. All (eventuallly) allocated buffers gets freed.
801  * Forces the endpoint to stop immediately, any pending transfers are killed(Can cause device reset).
802  *
803  * \par<b>Related APIs:</b><BR>
804  * ::XMC_USBD_EndpointConfigure()\n
805  **/
806 XMC_USBD_STATUS_t XMC_USBD_EndpointUnconfigure(uint8_t ep_addr);
807 
808 /**
809  * @param	ep_addr The address of the USB endpoint, on which stall needs to be set or cleared.
810  * @param	stall 	The boolean variable to decide on set or clear of stall on EP.
811  *
812  * @return 	::XMC_USBD_STATUS_t.
813  *
814  * \par<b>Description:</b><BR>
815  * Set or Clear stall on the USB endpoint \a ep_addr, based on \a stall parameter.<BR>
816  *
817  * By programming stall bit in the doepctl and diepctl, it sets or clears the stall on the endpoint.
818  * The endpoint can be stalled when a non supported request comes from the USB host.
819  * The XMC_USBD_EndpointStall() should be called with \a stall set to 0, in the clear feature standard request
820  * in the USB device event call back handler. *
821  *
822  * \par<b>Note:</b><BR>
823  * The host should clear the stall set on the endpoint by sending the clear feature standard
824  * request on the non EP0 endpoints. On EP0, the stall will automatically gets cleared on the next control request.\n
825  *
826  * \par<b>Related APIs:</b><BR>
827  * ::XMC_USBD_EndpointAbort()\n
828  **/
829 XMC_USBD_STATUS_t XMC_USBD_EndpointStall(uint8_t ep_addr, bool stall);
830 
831 
832 /**
833  * @param	ep_addr The address of the USB endpoint, from which data need to be read.
834  * @param	size 	The number of bytes to be read.
835  *
836  * @return 	::XMC_USBD_STATUS_t.
837  *
838  * \par<b>Description:</b><BR>
839  * Prepares an endpoint to receive OUT tokens from the USB host.<BR>
840  * The selected endpoint gets configured, so that it receives the specified amount of data from the host.
841  * As part of streaming of OUT data, after reading the current OUT buffer using ::XMC_USBD_EndpointRead(),\n
842  * user can prepare endpoint for the next OUT packet by using ::XMC_USBD_EndpointReadStart().
843  *
844  * The registers DOEPDMA,DOEPTSIZ and DOEPCTL are programmed to start a new read request.
845  *
846  * \par<b>Note:</b><BR>
847  * For the data received on OUT EP buffer, use ::XMC_USBD_EndpointRead().\n
848  *
849  * \par<b>Related APIs:</b><BR>
850  * XMC_USBD_EndpointRead()\n
851  **/
852 XMC_USBD_STATUS_t XMC_USBD_EndpointReadStart(const uint8_t ep_addr, uint32_t size);
853 
854 
855 /**
856  * @param	ep_addr The address of the USB OUT endpoint, from which data need to be read.
857  * @param	buffer 	The pointer to the user buffer,in which data need to be received.
858  * @param	length 	The number of bytes to be read from OUT EP.
859  *
860  * @return 	<BR>
861  * 			The actual number of bytes received.
862  *
863  * \par<b>Description:</b><BR>
864  * Read \a length number of bytes from an OUT endpoint \a ep_addr.<BR>
865  * If data has been received for this endpoint, it gets copied into the user buffer until its full
866  * or no data is left in the driver buffer.
867  *
868  * \par<b>Note:</b><BR>
869  * For preparing the next OUT token, use ::XMC_USBD_EndpointReadStart() after ::XMC_USBD_EndpointRead().\n
870  *
871  *
872  * \par<b>Related APIs:</b><BR>
873  * ::XMC_USBD_EndpointReadStart()\n
874  **/
875 int32_t XMC_USBD_EndpointRead(const uint8_t ep_addr,uint8_t * buffer, uint32_t length);
876 
877 
878 /**
879  * @param	ep_addr The address of the USB IN endpoint, on which data should be sent.
880  * @param	buffer 	The pointer to the data buffer, to write to the endpoint.
881  * @param	length 	The number of bytes to be written to IN EP.
882  *
883  * @return 	<BR>
884  * 			The actual amount of data written to the endpoint buffer.
885  *
886  * \par<b>Description:</b><BR>
887  * Write the \a length bytes of data to an IN endpoint \a ep_addr.<BR>
888  * The User data gets copied into the driver buffer or will be send directly based on the buffer concept
889  * selected in the ::XMC_USBD_TRANSFER_MODE_t configuration.
890  *
891  * Then the endpoint is set up to transfer the data to the host.\n
892  * DIEPDMA,DIEPTSIZ and DIEPCTL registers are programmed to start the IN transfer.
893  *
894  *
895  * \par<b>Related APIs:</b><BR>
896  * ::XMC_USBD_EndpointRead()\n
897  **/
898 int32_t XMC_USBD_EndpointWrite(const uint8_t ep_addr,const uint8_t * buffer,uint32_t length);
899 
900 
901 /**
902  * @param	ep_addr The address of the USB endpoint, on which the data need to be aborted.
903  *
904  * @return 	::XMC_USBD_STATUS_t
905  *
906  * \par<b>Description:</b><BR>
907  * Abort the transfer on endpoint \a ep_addr.<BR>
908  * On any failure with the USB transmission user can reset the endpoint into default state and clear all
909  * assigned buffers, to start from a clean point. The endpoint will not be unconfigured or disabled.
910  *
911  * \par<b>Related APIs:</b><BR>
912  * ::XMC_USBD_EndpointUnconfigure()\n
913  **/
914 XMC_USBD_STATUS_t XMC_USBD_EndpointAbort(uint8_t ep_addr);
915 
916 /**
917  * @param	None.
918  *
919  * @return 	The 16 bit current USB frame number.
920  *
921  * \par<b>Description:</b><BR>
922  * Read the current USB frame number.<BR> *
923  * Reads the device status register (DSTS) and returns the SOFFN field.
924  *
925  **/
926 uint16_t XMC_USBD_GetFrameNumber(void);
927 
928 /**
929  * @param	None.
930  *
931  * @return 	Returns 1, if the speed enumeration is done and 0 otherwise.
932  *
933  * \par<b>Description:</b><BR>
934  * Gets the speed enumeration completion status of the USB device.<BR>
935  *
936  * \par<b>Note:</b><BR>
937  * This should not be used for the actual USB enumeration completion status. For the actual USB enumeration status,
938  * the application layer should check for the completion of USB standard request 'Set configuration'.\n
939  *
940  **/
941 uint32_t XMC_USBD_IsEnumDone(void);
942 
943 
944 /**
945  * @param	obj	The pointer to the USB device handle structure.
946  *
947  * @return 	None.
948  *
949  * \par<b>Description:</b><BR>
950  * USB device default IRQ handler.<BR>
951  * USBD Peripheral LLD provides default implementation of ISR.
952  * The user needs to explicitly either use our default implementation or use its own one using the LLD APIs.
953  *
954  * For example:
955  *  XMC_USBD_t *obj;
956  *  void USB0_0_IRQHandler(void)
957  *   {
958  *    XMC_USBD_IRQHandler(obj);
959  *   }
960  *
961  * \par<b>Note:</b><BR>
962  * The user should initialize the XMC USB device configuration structure before calling
963  * ::XMC_USBD_IRQHandler() in the actual USB0 IRQ handler.
964  *
965  **/
966 void XMC_USBD_IRQHandler(const XMC_USBD_t *const obj);
967 
968 #ifdef __cplusplus
969 }
970 #endif
971 
972 /**
973  * MISRA C 2004 Deviations
974  *
975  * 1. Function like macro- defined- MISRA Advisory Rule 19.7
976  * 2. usage of unions - MISRA Required Rule 18.4
977  */
978 
979 /**
980  * @}
981  */
982 
983 /**
984  * @}
985  */
986 
987 #endif /* defined(USB0) */
988 
989 #endif /* XMC_USBD_H */
990