2 * The Clear BSD License
3 * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted (subject to the limitations in the disclaimer below) provided
9 * that the following conditions are met:
11 * o Redistributions of source code must retain the above copyright notice, this list
12 * of conditions and the following disclaimer.
14 * o Redistributions in binary form must reproduce the above copyright notice, this
15 * list of conditions and the following disclaimer in the documentation and/or
16 * other materials provided with the distribution.
18 * o Neither the name of the copyright holder nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
22 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef __USB_DEVICE_H__
36 #define __USB_DEVICE_H__
39 * @addtogroup usb_device_driver
43 /*******************************************************************************
45 ******************************************************************************/
47 /*! @brief Defines Get/Set status Types */
48 typedef enum _usb_device_status
50 kUSB_DeviceStatusTestMode = 1U, /*!< Test mode */
51 kUSB_DeviceStatusSpeed, /*!< Current speed */
52 kUSB_DeviceStatusOtg, /*!< OTG status */
53 kUSB_DeviceStatusDevice, /*!< Device status */
54 kUSB_DeviceStatusEndpoint, /*!< Endpoint state usb_device_endpoint_status_t */
55 kUSB_DeviceStatusDeviceState, /*!< Device state */
56 kUSB_DeviceStatusAddress, /*!< Device address */
57 kUSB_DeviceStatusSynchFrame, /*!< Current frame */
58 kUSB_DeviceStatusBus, /*!< Bus status */
59 kUSB_DeviceStatusBusSuspend, /*!< Bus suspend */
60 kUSB_DeviceStatusBusSleep, /*!< Bus suspend */
61 kUSB_DeviceStatusBusResume, /*!< Bus resume */
62 kUSB_DeviceStatusRemoteWakeup, /*!< Remote wakeup state */
63 kUSB_DeviceStatusBusSleepResume, /*!< Bus resume */
64 } usb_device_status_t;
66 /*! @brief Defines USB 2.0 device state */
67 typedef enum _usb_device_state
69 kUSB_DeviceStateConfigured = 0U, /*!< Device state, Configured*/
70 kUSB_DeviceStateAddress, /*!< Device state, Address*/
71 kUSB_DeviceStateDefault, /*!< Device state, Default*/
72 kUSB_DeviceStateAddressing, /*!< Device state, Address setting*/
73 kUSB_DeviceStateTestMode, /*!< Device state, Test mode*/
76 #if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U))
77 typedef enum _usb_dcd_detection_sequence_status
79 kUSB_DcdDetectionNotEnabled = 0x0U,
80 kUSB_DcdDataPinDetectionCompleted = 0x01U,
81 kUSB_DcdChargingPortDetectionCompleted = 0x02U,
82 kUSB_DcdChargerTypeDetectionCompleted = 0x03U,
83 } usb_dcd_detection_sequence_status_t;
85 typedef enum _usb_dcd_detection_sequence_results
87 kUSB_DcdDetectionNoResults = 0x0U,
88 kUSB_DcdDetectionStandardHost = 0x01U,
89 kUSB_DcdDetectionChargingPort = 0x02U,
90 kUSB_DcdDetectionDedicatedCharger = 0x03U,
91 } usb_dcd_detection_sequence_results_t;
94 /*! @brief Defines endpoint state */
95 typedef enum _usb_endpoint_status
97 kUSB_DeviceEndpointStateIdle = 0U, /*!< Endpoint state, idle*/
98 kUSB_DeviceEndpointStateStalled, /*!< Endpoint state, stalled*/
99 } usb_device_endpoint_status_t;
101 /*! @brief Control endpoint index */
102 #define USB_CONTROL_ENDPOINT (0U)
103 /*! @brief Control endpoint maxPacketSize */
104 #define USB_CONTROL_MAX_PACKET_SIZE (64U)
106 #if (USB_DEVICE_CONFIG_EHCI && (USB_CONTROL_MAX_PACKET_SIZE != (64U)))
107 #error For high speed, USB_CONTROL_MAX_PACKET_SIZE must be 64!!!
110 /*! @brief The setup packet size of USB control transfer. */
111 #define USB_SETUP_PACKET_SIZE (8U)
112 /*! @brief USB endpoint mask */
113 #define USB_ENDPOINT_NUMBER_MASK (0x0FU)
115 /*! @brief Default invalid value or the endpoint callback length of cancelled transfer */
116 #define USB_UNINITIALIZED_VAL_32 (0xFFFFFFFFU)
118 /*! @brief Available common EVENT types in device callback */
119 typedef enum _usb_device_event
121 kUSB_DeviceEventBusReset = 1U, /*!< USB bus reset signal detected */
122 kUSB_DeviceEventSuspend, /*!< USB bus suspend signal detected */
123 kUSB_DeviceEventResume, /*!< USB bus resume signal detected. The resume signal is driven by itself or a host */
124 kUSB_DeviceEventSleeped, /*!< USB bus LPM suspend signal detected */
125 kUSB_DeviceEventLPMResume, /*!< USB bus LPM resume signal detected. The resume signal is driven by itself or a host
127 kUSB_DeviceEventError, /*!< An error is happened in the bus. */
128 kUSB_DeviceEventDetach, /*!< USB device is disconnected from a host. */
129 kUSB_DeviceEventAttach, /*!< USB device is connected to a host. */
130 kUSB_DeviceEventSetConfiguration, /*!< Set configuration. */
131 kUSB_DeviceEventSetInterface, /*!< Set interface. */
133 kUSB_DeviceEventGetDeviceDescriptor, /*!< Get device descriptor. */
134 kUSB_DeviceEventGetConfigurationDescriptor, /*!< Get configuration descriptor. */
135 kUSB_DeviceEventGetStringDescriptor, /*!< Get string descriptor. */
136 kUSB_DeviceEventGetHidDescriptor, /*!< Get HID descriptor. */
137 kUSB_DeviceEventGetHidReportDescriptor, /*!< Get HID report descriptor. */
138 kUSB_DeviceEventGetHidPhysicalDescriptor, /*!< Get HID physical descriptor. */
139 kUSB_DeviceEventGetBOSDescriptor, /*!< Get configuration descriptor. */
140 kUSB_DeviceEventGetDeviceQualifierDescriptor, /*!< Get device qualifier descriptor. */
141 kUSB_DeviceEventVendorRequest, /*!< Vendor request. */
142 kUSB_DeviceEventSetRemoteWakeup, /*!< Enable or disable remote wakeup function. */
143 kUSB_DeviceEventGetConfiguration, /*!< Get current configuration index */
144 kUSB_DeviceEventGetInterface, /*!< Get current interface alternate setting value */
145 kUSB_DeviceEventSetBHNPEnable,
146 #if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U))
147 kUSB_DeviceEventDcdTimeOut, /*!< Dcd detect result is timeout */
148 kUSB_DeviceEventDcdUnknownType, /*!< Dcd detect result is unknown type */
149 kUSB_DeviceEventSDPDetected, /*!< The SDP facility is detected */
150 kUSB_DeviceEventChargingPortDetected, /*!< The charging port is detected */
151 kUSB_DeviceEventChargingHostDetected, /*!< The CDP facility is detected */
152 kUSB_DeviceEventDedicatedChargerDetected, /*!< The DCP facility is detected */
154 } usb_device_event_t;
156 /*! @brief Endpoint callback message structure */
157 typedef struct _usb_device_endpoint_callback_message_struct
159 uint8_t *buffer; /*!< Transferred buffer */
160 uint32_t length; /*!< Transferred data length */
161 uint8_t isSetup; /*!< Is in a setup phase */
162 } usb_device_endpoint_callback_message_struct_t;
165 * @brief Endpoint callback function typedef.
167 * This callback function is used to notify the upper layer what the transfer result is.
168 * This callback pointer is passed when a specified endpoint is initialized by calling API #USB_DeviceInitEndpoint.
170 * @param handle The device handle. It equals to the value returned from #USB_DeviceInit.
171 * @param message The result of a transfer, which includes transfer buffer, transfer length, and whether is in a
173 * phase for control pipe.
174 * @param callbackParam The parameter for this callback. It is same with
175 * usb_device_endpoint_callback_struct_t::callbackParam.
177 * @return A USB error code or kStatus_USB_Success.
179 typedef usb_status_t (*usb_device_endpoint_callback_t)(usb_device_handle handle,
180 usb_device_endpoint_callback_message_struct_t *message,
181 void *callbackParam);
184 * @brief Device callback function typedef.
186 * This callback function is used to notify the upper layer that the device status has changed.
187 * This callback pointer is passed by calling API #USB_DeviceInit.
189 * @param handle The device handle. It equals the value returned from #USB_DeviceInit.
190 * @param callbackEvent The callback event type. See enumeration #usb_device_event_t.
191 * @param eventParam The event parameter for this callback. The parameter type is determined by the callback event.
193 * @return A USB error code or kStatus_USB_Success.
195 typedef usb_status_t (*usb_device_callback_t)(usb_device_handle handle, uint32_t callbackEvent, void *eventParam);
197 /*! @brief Endpoint callback structure */
198 typedef struct _usb_device_endpoint_callback_struct
200 usb_device_endpoint_callback_t callbackFn; /*!< Endpoint callback function*/
201 void *callbackParam; /*!< Parameter for callback function*/
203 } usb_device_endpoint_callback_struct_t;
205 /*! @brief Endpoint initialization structure */
206 typedef struct _usb_device_endpoint_init_struct
208 uint16_t maxPacketSize; /*!< Endpoint maximum packet size */
209 uint8_t endpointAddress; /*!< Endpoint address*/
210 uint8_t transferType; /*!< Endpoint transfer type*/
211 uint8_t zlt; /*!< ZLT flag*/
212 } usb_device_endpoint_init_struct_t;
214 /*! @brief Endpoint status structure */
215 typedef struct _usb_device_endpoint_status_struct
217 uint8_t endpointAddress; /*!< Endpoint address */
218 uint16_t endpointStatus; /*!< Endpoint status : idle or stalled */
219 } usb_device_endpoint_status_struct_t;
221 #if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U))
222 /*! @brief USB DCD charge timing specification structure */
223 typedef struct _usb_device_dcd_charging_time
225 uint16_t dcdSeqInitTime; /*!< The dcd sequence init time */
226 uint16_t dcdDbncTime; /*!< The debounce time period on DP signal */
227 uint16_t dcdDpSrcOnTime; /*!< The time period comparator enabled */
228 uint16_t dcdTimeWaitAfterPrD; /*!< The time period between primary and secondary detection */
229 uint8_t dcdTimeDMSrcOn; /*!< The amount of time that the modules enable the Vdm_src */
230 } usb_device_dcd_charging_time_t;
233 #if defined(__cplusplus)
235 #endif /* __cplusplus*/
238 * @name USB device APIs
242 /*******************************************************************************
244 ******************************************************************************/
247 * @brief Initializes the USB device stack.
249 * This function initializes the USB device module specified by the controllerId.
251 * @param[in] controllerId The controller ID of the USB IP. See the enumeration #usb_controller_index_t.
252 * @param[in] deviceCallback Function pointer of the device callback.
253 * @param[out] handle It is an out parameter used to return the pointer of the device handle to the caller.
255 * @retval kStatus_USB_Success The device is initialized successfully.
256 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer.
257 * @retval kStatus_USB_Busy Cannot allocate a device handle.
258 * @retval kStatus_USB_ControllerNotFound Cannot find the controller according to the controller id.
259 * @retval kStatus_USB_InvalidControllerInterface The controller driver interfaces is invalid. There is an empty
261 * @retval kStatus_USB_Error The macro USB_DEVICE_CONFIG_ENDPOINTS is more than the IP's endpoint number.
262 * Or, the device has been initialized.
263 * Or, the mutex or message queue is created failed.
265 extern usb_status_t USB_DeviceInit(uint8_t controllerId,
266 usb_device_callback_t deviceCallback,
267 usb_device_handle *handle);
270 * @brief Enables the device functionality.
272 * The function enables the device functionality, so that the device can be recognized by the host when the device
273 * detects that it has been connected to a host.
275 * @param[in] handle The device handle got from #USB_DeviceInit.
277 * @retval kStatus_USB_Success The device is run successfully.
278 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
279 * @retval kStatus_USB_InvalidHandle The device handle is a NULL pointer. Or the controller handle is invalid.
282 extern usb_status_t USB_DeviceRun(usb_device_handle handle);
285 * @brief Disables the device functionality.
287 * The function disables the device functionality. After this function called, even if the device is detached to the
291 * @param[in] handle The device handle received from #USB_DeviceInit.
293 * @retval kStatus_USB_Success The device is stopped successfully.
294 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
295 * @retval kStatus_USB_InvalidHandle The device handle is a NULL pointer or the controller handle is invalid.
297 extern usb_status_t USB_DeviceStop(usb_device_handle handle);
300 * @brief De-initializes the device controller.
302 * The function de-initializes the device controller specified by the handle.
304 * @param[in] handle The device handle got from #USB_DeviceInit.
306 * @retval kStatus_USB_Success The device is stopped successfully.
307 * @retval kStatus_USB_InvalidHandle The device handle is a NULL pointer or the controller handle is invalid.
309 extern usb_status_t USB_DeviceDeinit(usb_device_handle handle);
312 * @brief Sends data through a specified endpoint.
314 * The function is used to send data through a specified endpoint.
316 * @param[in] handle The device handle got from #USB_DeviceInit.
317 * @param[in] endpointAddress Endpoint index.
318 * @param[in] buffer The memory address to hold the data need to be sent. The function is not reentrant.
319 * @param[in] length The data length need to be sent.
321 * @retval kStatus_USB_Success The send request is sent successfully.
322 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer. Or the controller handle is invalid.
323 * @retval kStatus_USB_Busy Cannot allocate DTDS for current transfer in EHCI driver.
324 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
325 * @retval kStatus_USB_Error The device is doing reset.
327 * @note The return value indicates whether the sending request is successful or not. The transfer done is notified by
329 * corresponding callback function.
330 * Currently, only one transfer request can be supported for one specific endpoint.
331 * If there is a specific requirement to support multiple transfer requests for one specific endpoint, the application
332 * should implement a queue on the application level.
333 * The subsequent transfer can begin only when the previous transfer is done (get notification through the endpoint
336 extern usb_status_t USB_DeviceSendRequest(usb_device_handle handle,
337 uint8_t endpointAddress,
342 * @brief Receives data through a specified endpoint.
344 * The function is used to receive data through a specified endpoint. The function is not reentrant.
346 * @param[in] handle The device handle got from #USB_DeviceInit.
347 * @param[in] endpointAddress Endpoint index.
348 * @param[in] buffer The memory address to save the received data.
349 * @param[in] length The data length want to be received.
351 * @retval kStatus_USB_Success The receive request is sent successfully.
352 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer. Or the controller handle is invalid.
353 * @retval kStatus_USB_Busy Cannot allocate DTDS for current transfer in EHCI driver.
354 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
355 * @retval kStatus_USB_Error The device is doing reset.
357 * @note The return value indicates whether the receiving request is successful or not. The transfer done is notified by
359 * corresponding callback function.
360 * Currently, only one transfer request can be supported for one specific endpoint.
361 * If there is a specific requirement to support multiple transfer requests for one specific endpoint, the application
362 * should implement a queue on the application level.
363 * The subsequent transfer can begin only when the previous transfer is done (get notification through the endpoint
366 extern usb_status_t USB_DeviceRecvRequest(usb_device_handle handle,
367 uint8_t endpointAddress,
372 * @brief Cancels the pending transfer in a specified endpoint.
374 * The function is used to cancel the pending transfer in a specified endpoint.
376 * @param[in] handle The device handle got from #USB_DeviceInit.
377 * @param[in] endpointAddress Endpoint address, bit7 is the direction of endpoint, 1U - IN, and 0U - OUT.
379 * @retval kStatus_USB_Success The transfer is cancelled.
380 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer or the controller handle is invalid.
381 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
383 extern usb_status_t USB_DeviceCancel(usb_device_handle handle, uint8_t endpointAddress);
386 * @brief Initializes a specified endpoint.
388 * The function is used to initialize a specified endpoint. The corresponding endpoint callback is also initialized.
390 * @param[in] handle The device handle received from #USB_DeviceInit.
391 * @param[in] epInit Endpoint initialization structure. See the structure usb_device_endpoint_init_struct_t.
392 * @param[in] epCallback Endpoint callback structure. See the structure
393 * usb_device_endpoint_callback_struct_t.
395 * @retval kStatus_USB_Success The endpoint is initialized successfully.
396 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer. Or the controller handle is invalid.
397 * @retval kStatus_USB_InvalidParameter The epInit or epCallback is NULL pointer. Or the endpoint number is
398 * more than USB_DEVICE_CONFIG_ENDPOINTS.
399 * @retval kStatus_USB_Busy The endpoint is busy in EHCI driver.
400 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
402 extern usb_status_t USB_DeviceInitEndpoint(usb_device_handle handle,
403 usb_device_endpoint_init_struct_t *epInit,
404 usb_device_endpoint_callback_struct_t *epCallback);
407 * @brief Deinitializes a specified endpoint.
409 * The function is used to deinitializes a specified endpoint.
411 * @param[in] handle The device handle got from #USB_DeviceInit.
412 * @param[in] endpointAddress Endpoint address, bit7 is the direction of endpoint, 1U - IN, and 0U - OUT.
414 * @retval kStatus_USB_Success The endpoint is de-initialized successfully.
415 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer. Or the controller handle is invalid.
416 * @retval kStatus_USB_InvalidParameter The endpoint number is more than USB_DEVICE_CONFIG_ENDPOINTS.
417 * @retval kStatus_USB_Busy The endpoint is busy in EHCI driver.
418 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
420 extern usb_status_t USB_DeviceDeinitEndpoint(usb_device_handle handle, uint8_t endpointAddress);
423 * @brief Stalls a specified endpoint.
425 * The function is used to stall a specified endpoint.
427 * @param[in] handle The device handle received from #USB_DeviceInit.
428 * @param[in] endpointAddress Endpoint address, bit7 is the direction of endpoint, 1U - IN, and 0U - OUT.
430 * @retval kStatus_USB_Success The endpoint is stalled successfully.
431 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer. Or the controller handle is invalid.
432 * @retval kStatus_USB_InvalidParameter The endpoint number is more than USB_DEVICE_CONFIG_ENDPOINTS.
433 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
435 extern usb_status_t USB_DeviceStallEndpoint(usb_device_handle handle, uint8_t endpointAddress);
438 * @brief Unstalls a specified endpoint.
440 * The function is used to unstall a specified endpoint.
442 * @param[in] handle The device handle received from #USB_DeviceInit.
443 * @param[in] endpointAddress Endpoint address, bit7 is the direction of endpoint, 1U - IN, and 0U - OUT.
445 * @retval kStatus_USB_Success The endpoint is unstalled successfully.
446 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer. Or the controller handle is invalid.
447 * @retval kStatus_USB_InvalidParameter The endpoint number is more than USB_DEVICE_CONFIG_ENDPOINTS.
448 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
450 extern usb_status_t USB_DeviceUnstallEndpoint(usb_device_handle handle, uint8_t endpointAddress);
453 * @brief Gets the status of the selected item.
455 * The function is used to get the status of the selected item.
457 * @param[in] handle The device handle got from #USB_DeviceInit.
458 * @param[in] type The selected item. See the structure #usb_device_status_t.
459 * @param[out] param The parameter type is determined by the selected item.
461 * @retval kStatus_USB_Success Get status successfully.
462 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer. Or the controller handle is invalid.
463 * @retval kStatus_USB_InvalidParameter The parameter is NULL pointer.
464 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
465 * @retval kStatus_USB_Error Unsupported type.
467 extern usb_status_t USB_DeviceGetStatus(usb_device_handle handle, usb_device_status_t type, void *param);
470 * @brief Sets the status of the selected item.
472 * The function is used to set the status of the selected item.
474 * @param[in] handle The device handle got from #USB_DeviceInit.
475 * @param[in] type The selected item. See the structure #usb_device_status_t.
476 * @param[in] param The parameter type is determined by the selected item.
478 * @retval kStatus_USB_Success Set status successfully.
479 * @retval kStatus_USB_InvalidHandle The handle is a NULL pointer. Or the controller handle is invalid.
480 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
481 * @retval kStatus_USB_Error Unsupported type or the parameter is NULL pointer.
483 extern usb_status_t USB_DeviceSetStatus(usb_device_handle handle, usb_device_status_t type, void *param);
485 #if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U))
487 * @brief Initializes the device dcd module.
489 * The function initializes the device dcd module.
491 * @param[in] handle The device handle got from #USB_DeviceInit.
492 * @param[in] time_param The time parameter used to config the dcd timing registers.
494 * @retval kStatus_USB_Success The device is run successfully.
495 * @retval kStatus_USB_ControllerNotFound Cannot find the controller.
496 * @retval kStatus_USB_InvalidHandle The device handle is a NULL pointer. Or the controller handle is invalid.
499 extern usb_status_t USB_DeviceDcdInitModule(usb_device_handle handle, void *time_param);
502 * @brief De-initializes the device dcd module.
504 * The function de-initializes the device dcd module specified by the handle.
506 * @param[in] handle The device handle got from #USB_DeviceInit.
508 * @retval kStatus_USB_Success The device is stopped successfully.
509 * @retval kStatus_USB_InvalidHandle The device handle is a NULL pointer or the controller handle is invalid.
511 extern usb_status_t USB_DeviceDcdDeinitModule(usb_device_handle handle);
514 * @brief Device task function.
516 * The function is used to handle the controller message.
517 * This function should not be called in the application directly.
519 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
521 extern void USB_DeviceTaskFunction(void *deviceHandle);
523 #if ((defined(USB_DEVICE_CONFIG_KHCI)) && (USB_DEVICE_CONFIG_KHCI > 0U))
525 * @brief Device KHCI task function.
527 * The function is used to handle the KHCI controller message.
528 * In the bare metal environment, this function should be called periodically in the main function.
529 * In the RTOS environment, this function should be used as a function entry to create a task.
531 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
533 #define USB_DeviceKhciTaskFunction(deviceHandle) USB_DeviceTaskFunction(deviceHandle)
536 #if ((defined(USB_DEVICE_CONFIG_EHCI)) && (USB_DEVICE_CONFIG_EHCI > 0U))
538 * @brief Device EHCI task function.
540 * The function is used to handle the EHCI controller message.
541 * In the bare metal environment, this function should be called periodically in the main function.
542 * In the RTOS environment, this function should be used as a function entry to create a task.
544 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
546 #define USB_DeviceEhciTaskFunction(deviceHandle) USB_DeviceTaskFunction(deviceHandle)
547 #if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U))
549 * @brief Device EHCI DCD ISR function.
551 * The function is the EHCI DCD interrupt service routine.
553 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
555 extern void USB_DeviceDcdHSIsrFunction(void *deviceHandle);
559 #if (((defined(USB_DEVICE_CONFIG_LPCIP3511FS)) && (USB_DEVICE_CONFIG_LPCIP3511FS > 0U)) || \
560 ((defined(USB_DEVICE_CONFIG_LPCIP3511HS)) && (USB_DEVICE_CONFIG_LPCIP3511HS > 0U)))
562 * @brief Device LPC ip3511 controller task function.
564 * The function is used to handle the LPC ip3511 controller message.
565 * In the bare metal environment, this function should be called periodically in the main function.
566 * In the RTOS environment, this function should be used as a function entry to create a task.
568 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
570 #define USB_DeviceLpcIp3511TaskFunction(deviceHandle) USB_DeviceTaskFunction(deviceHandle)
573 #if ((defined(USB_DEVICE_CONFIG_KHCI)) && (USB_DEVICE_CONFIG_KHCI > 0U))
575 * @brief Device KHCI ISR function.
577 * The function is the KHCI interrupt service routine.
579 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
581 extern void USB_DeviceKhciIsrFunction(void *deviceHandle);
582 #if (defined(USB_DEVICE_CHARGER_DETECT_ENABLE) && (USB_DEVICE_CHARGER_DETECT_ENABLE > 0U))
584 * @brief Device KHCI DCD ISR function.
586 * The function is the KHCI DCD interrupt service routine.
588 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
590 extern void USB_DeviceDcdIsrFunction(void *deviceHandle);
594 #if ((defined(USB_DEVICE_CONFIG_EHCI)) && (USB_DEVICE_CONFIG_EHCI > 0U))
596 * @brief Device EHCI ISR function.
598 * The function is the EHCI interrupt service routine.
600 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
602 extern void USB_DeviceEhciIsrFunction(void *deviceHandle);
605 #if (((defined(USB_DEVICE_CONFIG_LPCIP3511FS)) && (USB_DEVICE_CONFIG_LPCIP3511FS > 0U)) || \
606 ((defined(USB_DEVICE_CONFIG_LPCIP3511HS)) && (USB_DEVICE_CONFIG_LPCIP3511HS > 0U)))
608 * @brief Device LPC USB ISR function.
610 * The function is the LPC USB interrupt service routine.
612 * @param[in] deviceHandle The device handle got from #USB_DeviceInit.
614 extern void USB_DeviceLpcIp3511IsrFunction(void *deviceHandle);
618 * @brief Gets the device stack version function.
620 * The function is used to get the device stack version.
622 * @param[out] version The version structure pointer to keep the device stack version.
625 extern void USB_DeviceGetVersion(uint32_t *version);
627 #if ((defined(USB_DEVICE_CONFIG_REMOTE_WAKEUP)) && (USB_DEVICE_CONFIG_REMOTE_WAKEUP > 0U))
629 * @brief Update the hardware tick.
631 * The function is used to update the hardware tick.
633 * @param[in] handle The device handle got from #USB_DeviceInit.
634 * @param[in] tick Current hardware tick(uint is ms).
637 extern usb_status_t USB_DeviceUpdateHwTick(usb_device_handle handle, uint64_t tick);
642 #if defined(__cplusplus)
644 #endif /* __cplusplus*/
648 #endif /* __USB_DEVICE_H__ */