USBD ROM Stack  2.0
ROM based USB device stack
Data Fields
USBD_CORE_API_T Struct Reference

USBD stack Core API functions structure. More...

#include <C:/Data/nxp/GIT/lpcopen_v3/lpcopen_version3/LPC43xx_18xx/lpc43xx_18xx/LPC_USBD_Lib/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)
 
ErrorCode_t(* GetEpHandler )(USBD_HANDLE_T hUsb, uint32_t ep_index, USB_EP_HANDLER_T *ep_handler, void **data)
 

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

◆ RegisterClassHandler

ErrorCode_t USBD_CORE_API_T::RegisterClassHandler

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.

◆ RegisterEpHandler

ErrorCode_t USBD_CORE_API_T::RegisterEpHandler

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).

◆ SetupStage

void USBD_CORE_API_T::SetupStage

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.

◆ DataInStage

void USBD_CORE_API_T::DataInStage

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.

◆ DataOutStage

void USBD_CORE_API_T::DataOutStage

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.

◆ StatusInStage

void USBD_CORE_API_T::StatusInStage

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.

◆ StatusOutStage

void USBD_CORE_API_T::StatusOutStage

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.

◆ StallEp0

void USBD_CORE_API_T::StallEp0

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.

◆ GetEpHandler

ErrorCode_t USBD_CORE_API_T::GetEpHandler

Function to get default EP handler and its parameter for a particular endpoint.

This function is called by the application layer to retrieve the default Endpoint Handler and its data parameter for a particular endpoint.

Note
This interface is provided so that the application could get the default handler, then register their own endpoint handler to do some special handling and then call the default handler.
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,out]ep_handlerDouble Pointer to Endpoint event handler function which is updated in the function.
[in,out]dataDouble Pointer to the data parameter that needs to be passed when calling the event handler.
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).

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