USBD ROM Stack  1.0
ROM based USB device stack
USBD_CORE_API_T Struct Reference

USBD stack Core API functions structure. More...

#include <mw_usbd/mw_usbd_core.h>

Data Fields

ErrorCode_t(* RegisterClassHandler )(USBD_HANDLE_T hUsb, USB_EP_HANDLER_T pfn, void *data)
ErrorCode_t(* RegisterEpHandler )(USBD_HANDLE_T hUsb, uint32_t ep_index, USB_EP_HANDLER_T pfn, void *data)
void(* SetupStage )(USBD_HANDLE_T hUsb)
void(* DataInStage )(USBD_HANDLE_T hUsb)
void(* DataOutStage )(USBD_HANDLE_T hUsb)
void(* StatusInStage )(USBD_HANDLE_T hUsb)
void(* StatusOutStage )(USBD_HANDLE_T hUsb)
void(* StallEp0 )(USBD_HANDLE_T hUsb)

Detailed Description

USBD stack Core API functions structure.

This module exposes functions which interact directly with USB device stack's core layer. The application layer uses this component when it has to implement custom class function driver or standard class function driver which is not part of the current USB device stack. The functions exposed by this interface are to register class specific EP0 handlers and corresponding utility functions to manipulate EP0 state machine of the stack. This interface also exposes function to register custom endpoint interrupt handler.


Field Documentation

Function to register class specific EP0 event handler with USB device stack.

The application layer uses this function when it has to register the custom class's EP0 handler. The stack calls all the registered class handlers on any EP0 event before going through default handling of the event. This gives the class handlers to implement class specific request handlers and also to override the default stack handling for a particular event targeted to the interface. Check USB_EP_HANDLER_T for more details on how the callback function should be implemented. Also application layer could use this function to register EP0 handler which responds to vendor specific requests.

Parameters:
[in]hUsbHandle to the USB device stack.
[in]pfnClass specific EP0 handler function.
[in]dataPointer to the data which will be passed when callback function is called by the stack.
Returns:
Returns ErrorCode_t type to indicate success or error condition.
Return values:
LPC_OKOn success
ERR_USBD_TOO_MANY_CLASS_HDLR(0x0004000c)The number of class handlers registered is greater than the number of handlers allowed by the stack.

Function to register interrupt/event handler for the requested endpoint with USB device stack.

The application layer uses this function to register the endpoint event handler. The stack calls all the registered endpoint handlers when

  • USB_EVT_OUT or USB_EVT_OUT_NAK events happen for OUT endpoint.
  • USB_EVT_IN or USB_EVT_IN_NAK events happen for IN endpoint. Check USB_EP_HANDLER_T for more details on how the callback function should be implemented.
    Note:
    By default endpoint _NAK events are not enabled. Application should call USBD_HW_API_T::EnableEvent for the corresponding endpoint.
    Parameters:
    [in]hUsbHandle to the USB device stack.
    [in]ep_indexEndpoint index. Computed as
    • For OUT endpoints = 2 * endpoint number eg. for EP2_OUT it is 4.
    • For IN endopoints = (2 * endpoint number) + 1 eg. for EP2_IN it is 5.
    [in]pfnEndpoint event handler function.
    [in]dataPointer to the data which will be passed when callback function is called by the stack.
    Returns:
    Returns ErrorCode_t type to indicate success or error condition.
    Return values:
    LPC_OKOn success
    ERR_API_INVALID_PARAM2ep_index is outside the boundary ( < 2 * USBD_API_INIT_PARAM_T::max_num_ep).

Function to set EP0 state machine in setup state.

This function is called by USB stack and the application layer to set the EP0 state machine in setup state. This function will read the setup packet received from USB host into stack's buffer.

Note:
This interface is provided to users to invoke this function in other scenarios which are not handle by current stack. In most user applications this function is not called directly.Also this function can be used by users who are selectively modifying the USB device stack's standard handlers through callback interface exposed by the stack.
Parameters:
[in]hUsbHandle to the USB device stack.
Returns:
Nothing.

Function to set EP0 state machine in data_in state.

This function is called by USB stack and the application layer to set the EP0 state machine in data_in state. This function will write the data present in EP0Data buffer to EP0 FIFO for transmission to host.

Note:
This interface is provided to users to invoke this function in other scenarios which are not handle by current stack. In most user applications this function is not called directly.Also this function can be used by users who are selectively modifying the USB device stack's standard handlers through callback interface exposed by the stack.
Parameters:
[in]hUsbHandle to the USB device stack.
Returns:
Nothing.

Function to set EP0 state machine in data_out state.

This function is called by USB stack and the application layer to set the EP0 state machine in data_out state. This function will read the control data (EP0 out packets) received from USB host into EP0Data buffer.

Note:
This interface is provided to users to invoke this function in other scenarios which are not handle by current stack. In most user applications this function is not called directly.Also this function can be used by users who are selectively modifying the USB device stack's standard handlers through callback interface exposed by the stack.
Parameters:
[in]hUsbHandle to the USB device stack.
Returns:
Nothing.

Function to set EP0 state machine in status_in state.

This function is called by USB stack and the application layer to set the EP0 state machine in status_in state. This function will send zero length IN packet on EP0 to host, indicating positive status.

Note:
This interface is provided to users to invoke this function in other scenarios which are not handle by current stack. In most user applications this function is not called directly.Also this function can be used by users who are selectively modifying the USB device stack's standard handlers through callback interface exposed by the stack.
Parameters:
[in]hUsbHandle to the USB device stack.
Returns:
Nothing.

Function to set EP0 state machine in status_out state.

This function is called by USB stack and the application layer to set the EP0 state machine in status_out state. This function will read the zero length OUT packet received from USB host on EP0.

Note:
This interface is provided to users to invoke this function in other scenarios which are not handle by current stack. In most user applications this function is not called directly.Also this function can be used by users who are selectively modifying the USB device stack's standard handlers through callback interface exposed by the stack.
Parameters:
[in]hUsbHandle to the USB device stack.
Returns:
Nothing.

Function to set EP0 state machine in stall state.

This function is called by USB stack and the application layer to generate STALL signaling on EP0 endpoint. This function will also reset the EP0Data buffer.

Note:
This interface is provided to users to invoke this function in other scenarios which are not handle by current stack. In most user applications this function is not called directly.Also this function can be used by users who are selectively modifying the USB device stack's standard handlers through callback interface exposed by the stack.
Parameters:
[in]hUsbHandle to the USB device stack.
Returns:
Nothing.

The documentation for this struct was generated from the following file: