| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- Data Structures
- Data Structure Index
- Data Fields

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Fields
USBD_CORE_API_T Struct Reference
USB Core Layer

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

Definition at line 294 of file usbd_core.h.

`#include "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)

## Field Documentation

void(* DataInStage)(USBD_HANDLE_T hUsb)

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 tranmission 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] | hUsb | Handle 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 tranmission 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

  hUsb | Handle to the USB device stack.

Returns
  Nothing.

Definition at line 372 of file usbd_core.h.

void(* DataOutStage)(USBD_HANDLE_T hUsb)

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] | hUsb | Handle 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

  hUsb | Handle to the USB device stack.

Returns
  Nothing.

Definition at line 390 of file usbd_core.h.

ErrorCode_t(* RegisterClassHandler)(USBD_HANDLE_T hUsb, USB_EP_HANDLER_T pfn, void *data)

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] | hUsb | Handle to the USB device stack.
  [in] | pfn | Class specific EP0 handler function.
  [in] | data | Pointer 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_OK | On 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 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

  hUsb | Handle to the USB device stack.
  pfn | Class specific EP0 handler function.
  data | Pointer 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_OK | On 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.

Definition at line 316 of file usbd_core.h.

ErrorCode_t(* RegisterEpHandler)(USBD_HANDLE_T hUsb, uint32_t ep_index, USB_EP_HANDLER_T pfn, void *data)

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

The application layer uses this function 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.

Parameters

  [in] | hUsb | Handle to the USB device stack.
  [in] | ep_index | Class specific EP0 handler function.
  [in] | pfn | Class specific EP0 handler function.
  [in] | data | Pointer 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_OK | On success
  ERR_USBD_TOO_MANY_CLASS_HDLR(0x0004000c) | Too many endpoint handlers.

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

The application layer uses this function 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.

Parameters

  hUsb | Handle to the USB device stack.
  ep_index | Class specific EP0 handler function.
  pfn | Class specific EP0 handler function.
  data | Pointer 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_OK | On success
  ERR_USBD_TOO_MANY_CLASS_HDLR(0x0004000c) | Too many endpoint handlers.

Definition at line 336 of file usbd_core.h.

void(* SetupStage)(USBD_HANDLE_T hUsb)

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] | hUsb | Handle to the USB device stack.

Returns
  Nothing.

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

  hUsb | Handle to the USB device stack.

Returns
  Nothing.

Definition at line 354 of file usbd_core.h.

void(* StallEp0)(USBD_HANDLE_T hUsb)

Function to set EP0 state machine in stall state.

This function is called by USB stack and the application layer to generate STALL signalling 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] | hUsb | Handle 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 signalling 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

  hUsb | Handle to the USB device stack.

Returns
  Nothing.

Definition at line 443 of file usbd_core.h.

void(* StatusInStage)(USBD_HANDLE_T hUsb)

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] | hUsb | Handle 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

  hUsb | Handle to the USB device stack.

Returns
  Nothing.

Definition at line 408 of file usbd_core.h.

void(* StatusOutStage)(USBD_HANDLE_T hUsb)

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] | hUsb | Handle 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

  hUsb | Handle to the USB device stack.

Returns
  Nothing.

Definition at line 425 of file usbd_core.h.

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

- C:/nxp/v1.03/lpcopen_v1.03/lpcopen/software/lpc_core/lpc_ip/usbd_rom/usbd_core.h
- C:/nxp/v1.03/lpcopen_v1.03/lpcopen/software/LPCUSBLib/Drivers/USB/Core/DCD/USBRom/usbd_core.h