|
EFM32 Wonder Gecko Software Documentation
efm32wg-doc-5.1.2
|
Gecko USB DEVICE protocol stack, see USB device stack library page for detailed documentation.
Data Structures | |
| struct | USBD_Callbacks_TypeDef |
| USB Device stack callback structure. More... | |
| struct | USBD_Init_TypeDef |
| USB Device stack initialization structure. More... | |
Macros | |
| #define | USB_PWRSAVE_MODE_ENTEREM2 4 |
| #define | USB_PWRSAVE_MODE_OFF 0 |
| #define | USB_PWRSAVE_MODE_ONSUSPEND 1 |
| #define | USB_PWRSAVE_MODE_ONVBUSOFF 2 |
| #define | USB_USBC_32kHz_CLK_LFRCO 1 |
| #define | USB_USBC_32kHz_CLK_LFXO 0 |
Typedefs | |
| typedef struct USBD_Callbacks_TypeDef | USBD_Callbacks_TypeDef |
| USB Device stack callback structure. More... | |
| typedef void(* | USBD_DeviceStateChangeCb_TypeDef) (USBD_State_TypeDef oldState, USBD_State_TypeDef newState) |
| USB State change callback function. More... | |
| typedef bool(* | USBD_IsSelfPoweredCb_TypeDef) (void) |
| USB power mode callback function. More... | |
| typedef int(* | USBD_SetupCmdCb_TypeDef) (const USB_Setup_TypeDef *setup) |
| USB setup request callback function. More... | |
| typedef void(* | USBD_SofIntCb_TypeDef) (uint16_t sofNr) |
| USB Start Of Frame (SOF) interrupt callback function. More... | |
| typedef void(* | USBD_UsbResetCb_TypeDef) (void) |
| USB Reset callback function. More... | |
Enumerations | |
| enum | USBD_State_TypeDef { USBD_STATE_NONE = 0, USBD_STATE_ATTACHED = 1, USBD_STATE_POWERED = 2, USBD_STATE_DEFAULT = 3, USBD_STATE_ADDRESSED = 4, USBD_STATE_CONFIGURED = 5, USBD_STATE_SUSPENDED = 6, USBD_STATE_LASTMARKER = 7 } |
| USB device state enumerator. More... | |
Functions | |
| void | USBD_AbortAllTransfers (void) |
| Abort all pending transfers. More... | |
| int | USBD_AbortTransfer (int epAddr) |
| Abort a pending transfer on a specific endpoint. More... | |
| void | USBD_Connect (void) |
| Start USB device operation. More... | |
| void | USBD_Disconnect (void) |
| Stop USB device operation. More... | |
| bool | USBD_EpIsBusy (int epAddr) |
| Check if an endpoint is busy doing a transfer. More... | |
| USBD_State_TypeDef | USBD_GetUsbState (void) |
| Get current USB device state. More... | |
| const char * | USBD_GetUsbStateName (USBD_State_TypeDef state) |
| Get a string naming a device USB state. More... | |
| int | USBD_Init (const USBD_Init_TypeDef *p) |
| Initializes USB device hardware and internal protocol stack data structures, then connects the data-line (D+ or D-) pullup resistor to signal host that enumeration can begin. More... | |
| int | USBD_Read (int epAddr, void *data, int byteCount, USB_XferCompleteCb_TypeDef callback) |
| Start a read (OUT) transfer on an endpoint. More... | |
| int | USBD_RemoteWakeup (void) |
| Perform a remote wakeup signalling sequence. More... | |
| bool | USBD_SafeToEnterEM2 (void) |
| Check if it is ok to enter energy mode EM2. More... | |
| int | USBD_StallEp (int epAddr) |
| Set an endpoint in the stalled (halted) state. More... | |
| void | USBD_Stop (void) |
| Stop USB device stack operation. More... | |
| int | USBD_UnStallEp (int epAddr) |
| Reset stall state on a stalled (halted) endpoint. More... | |
| int | USBD_Write (int epAddr, void *data, int byteCount, USB_XferCompleteCb_TypeDef callback) |
| Start a write (IN) transfer on an endpoint. More... | |
| #define USB_PWRSAVE_MODE_ENTEREM2 4 |
| #define USB_PWRSAVE_MODE_OFF 0 |
| #define USB_PWRSAVE_MODE_ONSUSPEND 1 |
| #define USB_PWRSAVE_MODE_ONVBUSOFF 2 |
| #define USB_USBC_32kHz_CLK_LFRCO 1 |
| #define USB_USBC_32kHz_CLK_LFXO 0 |
| typedef struct USBD_Callbacks_TypeDef USBD_Callbacks_TypeDef |
USB Device stack callback structure.
Callback functions used by the device stack to signal events or query status to/from the application. See USBD_Init_TypeDef. Assign members to NULL if your application don't need a specific callback.
| typedef void(* USBD_DeviceStateChangeCb_TypeDef) (USBD_State_TypeDef oldState, USBD_State_TypeDef newState) |
USB State change callback function.
Called whenever the device change state.
| [in] | oldState | The device USB state just leaved. See USBD_State_TypeDef. |
| [in] | newState | New (the current) USB device state. See USBD_State_TypeDef. |
| typedef bool(* USBD_IsSelfPoweredCb_TypeDef) (void) |
USB power mode callback function.
Called whenever the device stack needs to query if the device is currently self- or bus-powered. Typically when host has issued an GET_STATUS setup command.
| typedef int(* USBD_SetupCmdCb_TypeDef) (const USB_Setup_TypeDef *setup) |
USB setup request callback function.
Called on each setup request received from host. This gives the application a possibility to extend or override standard requests, and to implement class or vendor specific requests. Return USB_STATUS_OK if the request is handled, return USB_STATUS_REQ_ERR if it is an illegal request or return USB_STATUS_REQ_UNHANDLED to pass the request on to the default request handler.
| [in] | setup | Pointer to an USB setup packet. See USB_Setup_TypeDef. |
| typedef void(* USBD_SofIntCb_TypeDef) (uint16_t sofNr) |
| typedef void(* USBD_UsbResetCb_TypeDef) (void) |
| enum USBD_State_TypeDef |
USB device state enumerator.
| void USBD_AbortAllTransfers | ( | void | ) |
Abort all pending transfers.
Aborts transfers for all endpoints currently in use. Pending transfers on the default endpoint (EP0) are not aborted.
Definition at line 55 of file em_usbd.c.
References CORE_ATOMIC_SECTION, and USB_STATUS_EP_ABORTED.
| int USBD_AbortTransfer | ( | int | epAddr | ) |
Abort a pending transfer on a specific endpoint.
| [in] | epAddr | The address of the endpoint to abort. |
Definition at line 73 of file em_usbd.c.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, USB_STATUS_EP_ABORTED, USB_STATUS_ILLEGAL, USB_STATUS_OK, USBD_STATE_ADDRESSED, and USBD_STATE_CONFIGURED.
Referenced by USBX_SetupCmdCb().
| void USBD_Connect | ( | void | ) |
Start USB device operation.
Device operation is started by connecting a pullup resistor on the appropriate USB data line.
Definition at line 130 of file em_usbd.c.
References CORE_ATOMIC_SECTION.
| void USBD_Disconnect | ( | void | ) |
Stop USB device operation.
Device operation is stopped by disconnecting the pullup resistor from the appropriate USB data line. Often referred to as a "soft" disconnect.
Definition at line 145 of file em_usbd.c.
References CORE_ATOMIC_SECTION.
Referenced by USBD_Stop().
| bool USBD_EpIsBusy | ( | int | epAddr | ) |
Check if an endpoint is busy doing a transfer.
| [in] | epAddr | The address of the endpoint to check. |
Definition at line 162 of file em_usbd.c.
References USB_STATUS_ILLEGAL.
| USBD_State_TypeDef USBD_GetUsbState | ( | void | ) |
Get current USB device state.
Definition at line 186 of file em_usbd.c.
Referenced by USBD_Read(), and USBD_Write().
| const char* USBD_GetUsbStateName | ( | USBD_State_TypeDef | state | ) |
Get a string naming a device USB state.
| [in] | state | Device USB state. See USBD_State_TypeDef. |
Definition at line 201 of file em_usbd.c.
References USBD_STATE_LASTMARKER.
| int USBD_Init | ( | const USBD_Init_TypeDef * | p | ) |
Initializes USB device hardware and internal protocol stack data structures, then connects the data-line (D+ or D-) pullup resistor to signal host that enumeration can begin.
| [in] | p | Pointer to device initialization struct. See USBD_Init_TypeDef. |
Definition at line 226 of file em_usbd.c.
References _USB_DOEP0CTL_MPS_32B, _USB_DOEP0CTL_MPS_64B, USB_InterfaceDescriptor_TypeDef::bAlternateSetting, USB_EndpointDescriptor_TypeDef::bEndpointAddress, USB_InterfaceDescriptor_TypeDef::bInterfaceNumber, USB_EndpointDescriptor_TypeDef::bmAttributes, USB_DeviceDescriptor_TypeDef::bMaxPacketSize0, USBD_Init_TypeDef::bufferingMultiplier, USBD_Init_TypeDef::callbacks, CMU, CMU_ClockEnable(), CMU_ClockSelectGet(), CMU_ClockSelectSet(), CMU_HFCORECLKEN0_USB, CMU_HFCORECLKEN0_USBC, CMU_OscillatorEnable(), cmuClock_HF, cmuClock_USBC, cmuOsc_LFRCO, cmuOsc_LFXO, cmuSelect_HFCLK, cmuSelect_HFXO, cmuSelect_LFRCO, cmuSelect_LFXO, CONFIG_DESC_BM_TRANSFERTYPE, USBD_Init_TypeDef::configDescriptor, CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, USBD_Init_TypeDef::deviceDescriptor, SYSTEM_ChipRevision_TypeDef::family, SYSTEM_ChipRevision_TypeDef::major, SYSTEM_ChipRevision_TypeDef::minor, USBD_Init_TypeDef::numberOfStrings, USBD_Init_TypeDef::stringDescriptors, SYSTEM_ChipRevisionGet(), USB, USB_ENDPOINT_DESCRIPTOR, USB_EPNUM_MASK, USB_EPTYPE_CTRL, USB_INTERFACE_DESCRIPTOR, USB_IRQn, USB_SETUP_DIR_MASK, USB_STATUS_ILLEGAL, USB_STATUS_OK, USBD_STATE_LASTMARKER, USBD_STATE_NONE, USBD_STATE_POWERED, USBTIMER_Init(), and USB_EndpointDescriptor_TypeDef::wMaxPacketSize.
Referenced by USBX_init().
| int USBD_Read | ( | int | epAddr, |
| void * | data, | ||
| int | byteCount, | ||
| USB_XferCompleteCb_TypeDef | callback | ||
| ) |
Start a read (OUT) transfer on an endpoint.
| [in] | epAddr | Endpoint address. |
| [in] | data | Pointer to transfer data buffer. |
| [in] | byteCount | Transfer length. |
| [in] | callback | Function to be called on transfer completion. Supply NULL if no callback is needed. See USB_XferCompleteCb_TypeDef. |
Definition at line 573 of file em_usbd.c.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, USB_STATUS_DEVICE_UNCONFIGURED, USB_STATUS_EP_BUSY, USB_STATUS_EP_STALLED, USB_STATUS_ILLEGAL, USB_STATUS_OK, USBD_GetUsbState(), and USBD_STATE_CONFIGURED.
Referenced by CDC_SetupCmd(), CDC_StateChangeEvent(), HIDKBD_SetupCmd(), USBX_blockRead(), and USBX_outXferCompleteCb().
| int USBD_RemoteWakeup | ( | void | ) |
Perform a remote wakeup signalling sequence.
Definition at line 661 of file em_usbd.c.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, USB_STATUS_ILLEGAL, USB_STATUS_OK, and USBD_STATE_SUSPENDED.
| bool USBD_SafeToEnterEM2 | ( | void | ) |
Check if it is ok to enter energy mode EM2.
| int USBD_StallEp | ( | int | epAddr | ) |
Set an endpoint in the stalled (halted) state.
| [in] | epAddr | The address of the endpoint to stall. |
Definition at line 737 of file em_usbd.c.
References CORE_ATOMIC_SECTION, USB_STATUS_ILLEGAL, and USB_STATUS_OK.
Referenced by MSDD_Handler().
| void USBD_Stop | ( | void | ) |
Stop USB device stack operation.
The data-line pullup resistor is turned off, USB interrupts are disabled, and finally the USB pins are disabled.
Definition at line 776 of file em_usbd.c.
References CMU, CMU_HFCORECLKEN0_USB, CMU_HFCORECLKEN0_USBC, USB_IRQn, USBD_Disconnect(), and USBD_STATE_NONE.
Referenced by USBX_disable().
| int USBD_UnStallEp | ( | int | epAddr | ) |
Reset stall state on a stalled (halted) endpoint.
| [in] | epAddr | The address of the endpoint to un-stall. |
Definition at line 799 of file em_usbd.c.
References CORE_ATOMIC_SECTION, USB_STATUS_ILLEGAL, and USB_STATUS_OK.
Referenced by MSDD_SetupCmd().
| int USBD_Write | ( | int | epAddr, |
| void * | data, | ||
| int | byteCount, | ||
| USB_XferCompleteCb_TypeDef | callback | ||
| ) |
Start a write (IN) transfer on an endpoint.
| [in] | epAddr | Endpoint address. |
| [in] | data | Pointer to transfer data buffer. This buffer must be WORD (4 byte) aligned. |
| [in] | byteCount | Transfer length. |
| [in] | callback | Function to be called on transfer completion. Supply NULL if no callback is needed. See USB_XferCompleteCb_TypeDef. |
Definition at line 851 of file em_usbd.c.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, USB_STATUS_DEVICE_UNCONFIGURED, USB_STATUS_EP_BUSY, USB_STATUS_EP_STALLED, USB_STATUS_ILLEGAL, USB_STATUS_OK, USBD_GetUsbState(), and USBD_STATE_CONFIGURED.
Referenced by CDC_SetupCmd(), HIDKBD_KeyboardEvent(), HIDKBD_SetupCmd(), MSDD_SetupCmd(), USBX_blockWrite(), USBX_inXferCompleteCb(), and USBX_SetupCmdCb().