USBD ROM Stack
2.0
ROM based USB device stack
|
Hardware API functions structure.This module exposes functions which interact directly with USB device controller hardware. More...
Data Fields | |
uint32_t(* | GetMemSize )(USBD_API_INIT_PARAM_T *param) |
ErrorCode_t(* | Init )(USBD_HANDLE_T *phUsb, USB_CORE_DESCS_T *pDesc, USBD_API_INIT_PARAM_T *param) |
void(* | Connect )(USBD_HANDLE_T hUsb, uint32_t con) |
void(* | ISR )(USBD_HANDLE_T hUsb) |
void(* | Reset )(USBD_HANDLE_T hUsb) |
void(* | ForceFullSpeed )(USBD_HANDLE_T hUsb, uint32_t cfg) |
void(* | WakeUpCfg )(USBD_HANDLE_T hUsb, uint32_t cfg) |
void(* | SetAddress )(USBD_HANDLE_T hUsb, uint32_t adr) |
void(* | Configure )(USBD_HANDLE_T hUsb, uint32_t cfg) |
void(* | ConfigEP )(USBD_HANDLE_T hUsb, USB_ENDPOINT_DESCRIPTOR *pEPD) |
void(* | DirCtrlEP )(USBD_HANDLE_T hUsb, uint32_t dir) |
void(* | EnableEP )(USBD_HANDLE_T hUsb, uint32_t EPNum) |
void(* | DisableEP )(USBD_HANDLE_T hUsb, uint32_t EPNum) |
void(* | ResetEP )(USBD_HANDLE_T hUsb, uint32_t EPNum) |
void(* | SetStallEP )(USBD_HANDLE_T hUsb, uint32_t EPNum) |
void(* | ClrStallEP )(USBD_HANDLE_T hUsb, uint32_t EPNum) |
ErrorCode_t(* | SetTestMode )(USBD_HANDLE_T hUsb, uint8_t mode) |
uint32_t(* | ReadEP )(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData) |
uint32_t(* | ReadReqEP )(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData, uint32_t len) |
uint32_t(* | ReadSetupPkt )(USBD_HANDLE_T hUsb, uint32_t EPNum, uint32_t *pData) |
uint32_t(* | WriteEP )(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData, uint32_t cnt) |
void(* | WakeUp )(USBD_HANDLE_T hUsb) |
ErrorCode_t(* | EnableEvent )(USBD_HANDLE_T hUsb, uint32_t EPNum, uint32_t event_type, uint32_t enable) |
Hardware API functions structure.
This module exposes functions which interact directly with USB device controller hardware.
uint32_t USBD_HW_API_T::GetMemSize |
Function to determine the memory required by the USB device stack's DCD and core layers.
This function 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. |
ErrorCode_t USBD_HW_API_T::Init |
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] | pDesc | Structure containing pointers to various descriptor arrays needed by the stack. These descriptors are reported to USB host as part of enumerations process. |
[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. |
void USBD_HW_API_T::Connect |
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). |
void USBD_HW_API_T::ISR |
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. |
void USBD_HW_API_T::Reset |
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. |
void USBD_HW_API_T::ForceFullSpeed |
Function to force high speed USB device to operate in full speed mode.
This function is useful for testing the behavior 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. |
void USBD_HW_API_T::WakeUpCfg |
Function to configure USB device controller to wake-up 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. |
void USBD_HW_API_T::SetAddress |
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. |
void USBD_HW_API_T::Configure |
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. |
void USBD_HW_API_T::ConfigEP |
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. |
void USBD_HW_API_T::DirCtrlEP |
Function to set direction for USB control endpoint EP0.
This function is called automatically by the stack on need basis. 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 |
void USBD_HW_API_T::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. |
void USBD_HW_API_T::DisableEP |
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. |
void USBD_HW_API_T::ResetEP |
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. |
void USBD_HW_API_T::SetStallEP |
Function to STALL selected USB endpoint.
Generates STALL signaling 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. |
void USBD_HW_API_T::ClrStallEP |
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. |
ErrorCode_t USBD_HW_API_T::SetTestMode |
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. |
uint32_t USBD_HW_API_T::ReadEP |
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. |
uint32_t USBD_HW_API_T::ReadReqEP |
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. |
uint32_t USBD_HW_API_T::ReadSetupPkt |
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. |
uint32_t USBD_HW_API_T::WriteEP |
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. |
void USBD_HW_API_T::WakeUp |
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. |
void USBD_HW_API_T::EnableEvent |
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 event. ie. An EP1_IN is represented by 0x81 number. For device events set this param to 0x0. |
[in] | event_type | 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. |