![]() |
LPCOpen Platform
v1.03
LPCOpen Platform for NXP LPC Microcontrollers
|
Hardware API functions structure.
This module exposes functions which interact directly with USB device controller hardware.
#include "usbd_hw.h"
| void(* ClrStallEP)(USBD_HANDLE_T hUsb, uint32_t EPNum) |
Function to clear STALL state for the requested endpoint.
This function clears STALL state for the requested endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
Function to clear STALL state for the requested endpoint.
This function clears STALL state for the requested endpoint.
| hUsb | Handle to the USB device stack. |
| EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
| void(* ConfigEP)(USBD_HANDLE_T hUsb, USB_ENDPOINT_DESCRIPTOR *pEPD) |
Function to configure USB Endpoint according to descriptor.
This function is called automatically when USB_REQUEST_SET_CONFIGURATION request is received by the stack from USB host. All the endpoints associated with the selected configuration are configured. 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.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | pEPD | Endpoint descriptor structure defined in USB 2.0 specification. |
Function to configure USB Endpoint according to descriptor.
This function is called automatically when USB_REQUEST_SET_CONFIGURATION request is received by the stack from USB host. All the endpoints associated with the selected configuration are configured. 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.
| hUsb | Handle to the USB device stack. |
| pEPD | Endpoint descriptor structure defined in USB 2.0 specification. |
| void(* Configure)(USBD_HANDLE_T hUsb, uint32_t cfg) |
Function to configure device controller hardware with selected configuration.
This function is called automatically when USB_REQUEST_SET_CONFIGURATION request is received by the stack from USB host. 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.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | cfg | Configuration index. |
Function to configure device controller hardware with selected configuration.
This function is called automatically when USB_REQUEST_SET_CONFIGURATION request is received by the stack from USB host. 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.
| hUsb | Handle to the USB device stack. |
| cfg | Configuration index. |
| void(* Connect)(USBD_HANDLE_T hUsb, uint32_t con) |
Function to make USB device visible/invisible on the USB bus.
This function is called after the USB initialization. This function uses the soft connect feature to make the device visible on the USB bus. This function is called only after the application is ready to handle the USB data. The enumeration process is started by the host after the device detection. The driver handles the enumeration process according to the USB descriptors passed in the USB initialization function.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | con | States whether to connect (1) or to disconnect (0). |
Function to make USB device visible/invisible on the USB bus.
This function is called after the USB initialization. This function uses the soft connect feature to make the device visible on the USB bus. This function is called only after the application is ready to handle the USB data. The enumeration process is started by the host after the device detection. The driver handles the enumeration process according to the USB descriptors passed in the USB initialization function.
| hUsb | Handle to the USB device stack. |
| con | States whether to connect (1) or to disconnect (0). |
| void(* DirCtrlEP)(USBD_HANDLE_T hUsb, uint32_t dir) |
Function to set firection for USB control endpoint EP0.
This function is called automatically by the stack on need bassis. 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.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | cfg | When 1 - Set EP0 in IN transfer mode 0 - Set EP0 in OUT transfer mode |
Function to set firection for USB control endpoint EP0.
This function is called automatically by the stack on need bassis. 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.
| hUsb | Handle to the USB device stack. |
| cfg | When 1 - Set EP0 in IN transfer mode 0 - Set EP0 in OUT transfer mode |
| void(* DisableEP)(USBD_HANDLE_T hUsb, uint32_t EPNum) |
Function to disable selected USB endpoint.
This function disables interrupts on selected endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
Function to disable selected USB endpoint.
This function disables interrupts on selected endpoint.
| hUsb | Handle to the USB device stack. |
| EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
| void EnableEP |
Function to enable selected USB endpoint.
This function enables interrupts on selected endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
Function to enable/disable selected USB event.
This function enables interrupts on selected endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number corresponding to the eventas per USB specification. ie. An EP1_IN is represented by 0x81 number. For device events set this param to 0x0. |
| [in] | event | Type of endpoint event. See USBD_EVENT_T for more details. |
| [in] | enable | 1 - enable event, 0 - disable event. |
| LPC_OK(0) | - On success |
| ERR_USBD_INVALID_REQ(0x00040001) | - Invalid event type. |
Function to enable selected USB endpoint.
This function enables interrupts on selected endpoint.
| hUsb | Handle to the USB device stack. |
| EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
Function to enable/disable selected USB event.
This function enables interrupts on selected endpoint.
| hUsb | Handle to the USB device stack. |
| EPNum | Endpoint number corresponding to the eventas per USB specification. ie. An EP1_IN is represented by 0x81 number. For device events set this param to 0x0. |
| event | Type of endpoint event. See USBD_EVENT_T for more details. |
| enable | 1 - enable event, 0 - disable event. |
| LPC_OK(0) | - On success |
| ERR_USBD_INVALID_REQ(0x00040001) | - Invalid event type. |
| ErrorCode_t(* EnableEvent)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint32_t event_type, uint32_t enable) |
| void(* ForceFullSpeed)(USBD_HANDLE_T hUsb, uint32_t cfg) |
Function to force high speed USB device to operate in full speed mode.
This function is useful for testing the behaviour of current device when connected to a full speed only hosts.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | cfg | When 1 - set force full-speed or 0 - clear force full-speed. |
Function to force high speed USB device to operate in full speed mode.
This function is useful for testing the behaviour of current device when connected to a full speed only hosts.
| hUsb | Handle to the USB device stack. |
| cfg | When 1 - set force full-speed or 0 - clear force full-speed. |
| uint32_t(* GetMemSize)(USBD_API_INIT_PARAM_T *param) |
Function to determine the memory required by the USB device stack's DCD and core layers.
This fuction is called by application layer before calling pUsbApi->hw->Init(), to allocate memory used by DCD and core layers. The application should allocate the memory which is accessible by USB controller/DMA controller.
| [in] | param | Structure containing USB device stack initialization parameters. |
Function to determine the memory required by the USB device stack's DCD and core layers.
This fuction is called by application layer before calling pUsbApi->hw->Init(), to allocate memory used by DCD and core layers. The application should allocate the memory which is accessible by USB controller/DMA controller.
| param | Structure containing USB device stack initialization parameters. |
| ErrorCode_t(* Init)(USBD_HANDLE_T *phUsb, USB_CORE_DESCS_T *pDesc, USBD_API_INIT_PARAM_T *param) |
Function to initialize USB device stack's DCD and core layers.
This function is called by application layer to initialize USB hardware and core layers. On successful initialization the function returns a handle to USB device stack which should be passed to the rest of the functions.
| [in,out] | phUsb | Pointer to the USB device stack handle of type USBD_HANDLE_T. |
| [in] | param | Structure containing USB device stack initialization parameters. |
| LPC_OK(0) | On success |
| ERR_USBD_BAD_MEM_BUF(0x0004000b) | When insufficient memory buffer is passed or memory is not aligned on 2048 boundary. |
Function to initialize USB device stack's DCD and core layers.
This function is called by application layer to initialize USB hardware and core layers. On successful initialization the function returns a handle to USB device stack which should be passed to the rest of the functions.
| [in,out] | phUsb | Pointer to the USB device stack handle of type USBD_HANDLE_T. |
| param | Structure containing USB device stack initialization parameters. |
| LPC_OK(0) | On success |
| ERR_USBD_BAD_MEM_BUF(0x0004000b) | When insufficient memory buffer is passed or memory is not aligned on 2048 boundary. |
| void(* ISR)(USBD_HANDLE_T hUsb) |
Function to USB device controller interrupt events.
When the user application is active the interrupt handlers are mapped in the user flash space. The user application must provide an interrupt handler for the USB interrupt and call this function in the interrupt handler routine. The driver interrupt handler takes appropriate action according to the data received on the USB bus.
| [in] | hUsb | Handle to the USB device stack. |
Function to USB device controller interrupt events.
When the user application is active the interrupt handlers are mapped in the user flash space. The user application must provide an interrupt handler for the USB interrupt and call this function in the interrupt handler routine. The driver interrupt handler takes appropriate action according to the data received on the USB bus.
| hUsb | Handle to the USB device stack. |
| uint32_t(* ReadEP)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData) |
Function to read data received on the requested endpoint.
This function is called by USB stack and the application layer to read the data received on the requested endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
| [in,out] | pData | Pointer to the data buffer where data is to be copied. |
Function to read data received on the requested endpoint.
This function is called by USB stack and the application layer to read the data received on the requested endpoint.
| hUsb | Handle to the USB device stack. | |
| EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. | |
| [in,out] | pData | Pointer to the data buffer where data is to be copied. |
| uint32_t(* ReadReqEP)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData, uint32_t len) |
Function to queue read request on the specified endpoint.
This function is called by USB stack and the application layer to queue a read request on the specified endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
| [in,out] | pData | Pointer to the data buffer where data is to be copied. This buffer address should be accessible by USB DMA master. |
| [in] | len | Length of the buffer passed. |
Function to queue read request on the specified endpoint.
This function is called by USB stack and the application layer to queue a read request on the specified endpoint.
| hUsb | Handle to the USB device stack. | |
| EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. | |
| [in,out] | pData | Pointer to the data buffer where data is to be copied. This buffer address should be accessible by USB DMA master. |
| len | Length of the buffer passed. |
| uint32_t(* ReadSetupPkt)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint32_t *pData) |
Function to read setup packet data received on the requested endpoint.
This function is called by USB stack and the application layer to read setup packet data received on the requested endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP0_IN is represented by 0x80 number. |
| [in,out] | pData | Pointer to the data buffer where data is to be copied. |
Function to read setup packet data received on the requested endpoint.
This function is called by USB stack and the application layer to read setup packet data received on the requested endpoint.
| hUsb | Handle to the USB device stack. | |
| EPNum | Endpoint number as per USB specification. ie. An EP0_IN is represented by 0x80 number. | |
| [in,out] | pData | Pointer to the data buffer where data is to be copied. |
| void(* Reset)(USBD_HANDLE_T hUsb) |
Function to Reset USB device stack and hardware controller.
Reset USB device stack and hardware controller. Disables all endpoints except EP0. Clears all pending interrupts and resets endpoint transfer queues. This function is called internally by pUsbApi->hw->init() and from reset event.
| [in] | hUsb | Handle to the USB device stack. |
Function to Reset USB device stack and hardware controller.
Reset USB device stack and hardware controller. Disables all endpoints except EP0. Clears all pending interrupts and resets endpoint transfer queues. This function is called internally by pUsbApi->hw->init() and from reset event.
| hUsb | Handle to the USB device stack. |
| void(* ResetEP)(USBD_HANDLE_T hUsb, uint32_t EPNum) |
Function to reset selected USB endpoint.
This function flushes the endpoint buffers and resets data toggle logic.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
Function to reset selected USB endpoint.
This function flushes the endpoint buffers and resets data toggle logic.
| hUsb | Handle to the USB device stack. |
| EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
| void(* SetAddress)(USBD_HANDLE_T hUsb, uint32_t adr) |
Function to set USB address assigned by host in device controller hardware.
This function is called automatically when USB_REQUEST_SET_ADDRESS request is received by the stack from USB host. 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.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | adr | USB bus Address to which the device controller should respond. Usually assigned by the USB host. |
Function to set USB address assigned by host in device controller hardware.
This function is called automatically when USB_REQUEST_SET_ADDRESS request is received by the stack from USB host. 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.
| hUsb | Handle to the USB device stack. |
| adr | USB bus Address to which the device controller should respond. Usually assigned by the USB host. |
| void(* SetStallEP)(USBD_HANDLE_T hUsb, uint32_t EPNum) |
Function to STALL selected USB endpoint.
Generates STALL signalling for requested endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
Function to STALL selected USB endpoint.
Generates STALL signalling for requested endpoint.
| hUsb | Handle to the USB device stack. |
| EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
| ErrorCode_t(* SetTestMode)(USBD_HANDLE_T hUsb, uint8_t mode) |
Function to set high speed USB device controller in requested test mode.
USB-IF requires the high speed device to be put in various test modes for electrical testing. This USB device stack calls this function whenever it receives USB_REQUEST_CLEAR_FEATURE request for USB_FEATURE_TEST_MODE. Users can put the device in test mode by directly calling this function. Returns ERR_USBD_INVALID_REQ when device controller is full-speed only.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | mode | Test mode defined in USB 2.0 electrical testing specification. |
| LPC_OK(0) | - On success |
| ERR_USBD_INVALID_REQ(0x00040001) | - Invalid test mode or Device controller is full-speed only. |
Function to set high speed USB device controller in requested test mode.
USB-IF requires the high speed device to be put in various test modes for electrical testing. This USB device stack calls this function whenever it receives USB_REQUEST_CLEAR_FEATURE request for USB_FEATURE_TEST_MODE. Users can put the device in test mode by directly calling this function. Returns ERR_USBD_INVALID_REQ when device controller is full-speed only.
| hUsb | Handle to the USB device stack. |
| mode | Test mode defined in USB 2.0 electrical testing specification. |
| LPC_OK(0) | - On success |
| ERR_USBD_INVALID_REQ(0x00040001) | - Invalid test mode or Device controller is full-speed only. |
| void(* WakeUp)(USBD_HANDLE_T hUsb) |
Function to generate resume signaling on bus for remote host wakeup.
This function is called by application layer to remotely wakeup host controller when system is in suspend state. Application should indicate this remote wakeup capability by setting USB_CONFIG_REMOTE_WAKEUP in bmAttributes of Configuration Descriptor. Also this routine will generate resume signalling only if host enables USB_FEATURE_REMOTE_WAKEUP by sending SET_FEATURE request before suspending the bus.
| [in] | hUsb | Handle to the USB device stack. |
Function to generate resume signaling on bus for remote host wakeup.
This function is called by application layer to remotely wakeup host controller when system is in suspend state. Application should indicate this remote wakeup capability by setting USB_CONFIG_REMOTE_WAKEUP in bmAttributes of Configuration Descriptor. Also this routine will generate resume signalling only if host enables USB_FEATURE_REMOTE_WAKEUP by sending SET_FEATURE request before suspending the bus.
| hUsb | Handle to the USB device stack. |
| void(* WakeUpCfg)(USBD_HANDLE_T hUsb, uint32_t cfg) |
Function to configure USB device controller to wakeup host on remote events.
This function is called by application layer to configure the USB device controller to wakeup on remote events. It is recommended to call this function from users's USB_WakeUpCfg() callback routine registered with stack.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | cfg | When 1 - Configure controller to wake on remote events or 0 - Configure controller not to wake on remote events. |
Function to configure USB device controller to wakeup host on remote events.
This function is called by application layer to configure the USB device controller to wakeup on remote events. It is recommended to call this function from users's USB_WakeUpCfg() callback routine registered with stack.
| hUsb | Handle to the USB device stack. |
| cfg | When 1 - Configure controller to wake on remote events or 0 - Configure controller not to wake on remote events. |
| uint32_t(* WriteEP)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData, uint32_t cnt) |
Function to write data to be sent on the requested endpoint.
This function is called by USB stack and the application layer to send data on the requested endpoint.
| [in] | hUsb | Handle to the USB device stack. |
| [in] | EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
| [in] | pData | Pointer to the data buffer from where data is to be copied. |
| [in] | cnt | Number of bytes to write. |
Function to write data to be sent on the requested endpoint.
This function is called by USB stack and the application layer to send data on the requested endpoint.
| hUsb | Handle to the USB device stack. |
| EPNum | Endpoint number as per USB specification. ie. An EP1_IN is represented by 0x81 number. |
| pData | Pointer to the data buffer from where data is to be copied. |
| cnt | Number of bytes to write. |