EZR32 Wonder Gecko Software Documentation
ezr32wg-doc-5.1.2
|
USB protocol stack library API for EFM32/EZR32.
(C) Copyright 2014 Silicon Labs, http://www.silabs.com
This file is licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.
Definition in file em_usb.h.
#include "em_device.h"
#include "em_assert.h"
#include "usbconfig.h"
#include <string.h>
#include <stddef.h>
#include "em_common.h"
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | USB_ConfigurationDescriptor_TypeDef |
USB Configuration Descriptor. More... | |
struct | USB_DeviceDescriptor_TypeDef |
USB Device Descriptor. More... | |
struct | USB_EndpointDescriptor_TypeDef |
USB Endpoint Descriptor. More... | |
struct | USB_InterfaceDescriptor_TypeDef |
USB Interface Descriptor. More... | |
struct | USB_Setup_TypeDef |
USB Setup request package. More... | |
struct | USB_StringDescriptor_TypeDef |
USB String Descriptor. More... | |
struct | USBD_Callbacks_TypeDef |
USB Device stack callback structure. More... | |
struct | USBD_Init_TypeDef |
USB Device stack initialization structure. More... | |
struct | USBH_Device_TypeDef |
USB HOST device definition. More... | |
struct | USBH_Ep_TypeDef |
USB HOST endpoint status data. More... | |
struct | USBH_Init_TypeDef |
USB Host stack initialization structure. More... | |
Typedefs | |
typedef unsigned short | char16_t |
typedef int(* | USB_XferCompleteCb_TypeDef) (USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining) |
USB transfer callback function. More... | |
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... | |
typedef struct USBH_Device_TypeDef | USBH_Device_TypeDef |
USB HOST device definition. More... | |
typedef void(* | USBTIMER_Callback_TypeDef) (void) |
USBTIMER callback function. More... | |
Enumerations | |
enum | USB_Status_TypeDef { USB_STATUS_OK = 0, USB_STATUS_REQ_ERR = -1, USB_STATUS_EP_BUSY = -2, USB_STATUS_REQ_UNHANDLED = -3, USB_STATUS_ILLEGAL = -4, USB_STATUS_EP_STALLED = -5, USB_STATUS_EP_ABORTED = -6, USB_STATUS_EP_ERROR = -7, USB_STATUS_EP_NAK = -8, USB_STATUS_DEVICE_UNCONFIGURED = -9, USB_STATUS_DEVICE_SUSPENDED = -10, USB_STATUS_DEVICE_RESET = -11, USB_STATUS_TIMEOUT = -12, USB_STATUS_DEVICE_REMOVED = -13, USB_STATUS_HC_BUSY = -14, USB_STATUS_DEVICE_MALFUNCTION = -15, USB_STATUS_PORT_OVERCURRENT = -16 } |
USB transfer status enumerator. More... | |
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... | |
enum | USBH_EpState_TypeDef { H_EP_IDLE = 0, H_EP_SETUP = 1, H_EP_DATA_IN = 2, H_EP_DATA_OUT = 3, H_EP_STATUS_IN = 4, H_EP_STATUS_OUT = 5 } |
Functions | |
char * | USB_GetErrorMsgString (int error) |
Return an error message string for a given error code. More... | |
void | USB_PrintErrorMsgString (char *pre, int error) |
Format and print a text string given an error code, prepends an optional user supplied leader string. More... | |
int | USB_PRINTF (const char *format,...) |
Transmit "printf" formated data on the debug serial port. More... | |
int | USB_PUTCHAR (char c) |
Transmit a single char on the debug serial port. More... | |
void | USB_PUTS (const char *p) |
Transmit a zero terminated string on the debug serial port. More... | |
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... | |
int | USBH_AssignHostChannel (USBH_Ep_TypeDef *ep, uint8_t hcnum) |
Assign a host channel to a given endpoint. More... | |
int | USBH_ControlMsg (USBH_Ep_TypeDef *ep, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength, void *data, int timeout, USB_XferCompleteCb_TypeDef callback) |
Send a SETUP command to a device, non-blocking version. More... | |
int | USBH_ControlMsgB (USBH_Ep_TypeDef *ep, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength, void *data, int timeout) |
Send a SETUP command to a device, blocking version. More... | |
bool | USBH_DeviceConnected (void) |
Check if a device is connected. More... | |
int | USBH_GetConfigurationDescriptorB (USBH_Device_TypeDef *device, void *buf, int len, uint8_t configIndex) |
Read a configuration descriptor from a device. More... | |
int | USBH_GetDeviceDescriptorB (USBH_Device_TypeDef *device, void *buf, int len) |
Read a device descriptor from a device. More... | |
uint8_t | USBH_GetPortSpeed (void) |
Get the bus speed of the device attached to the USB port. More... | |
int | USBH_GetStringB (USBH_Device_TypeDef *device, uint8_t *buf, int bufLen, uint8_t stringIndex, uint16_t langID) |
Read a string descriptor from a device. More... | |
int | USBH_Init (const USBH_Init_TypeDef *p) |
Initialize host protocol stack data structures. More... | |
int | USBH_InitDeviceData (USBH_Device_TypeDef *device, const uint8_t *buf, USBH_Ep_TypeDef *ep, int numEp, uint8_t deviceSpeed) |
Populate device and endpoint data structures with data retrieved during device enumeration. More... | |
int | USBH_PortReset (void) |
Drive reset signalling on the USB port. More... | |
int | USBH_PortResume (void) |
Drive resume signalling on the USB port. More... | |
void | USBH_PortSuspend (void) |
Set the USB port in suspend mode. | |
int | USBH_PrintConfigurationDescriptor (const USB_ConfigurationDescriptor_TypeDef *config, int maxLen) |
Pretty print a configuration descriptor on the debug serial port. More... | |
int | USBH_PrintDeviceDescriptor (const USB_DeviceDescriptor_TypeDef *device) |
Pretty print a device descriptor on the debug serial port. More... | |
int | USBH_PrintEndpointDescriptor (const USB_EndpointDescriptor_TypeDef *endpoint) |
Pretty print an endpoint descriptor on the debug serial port. More... | |
int | USBH_PrintInterfaceDescriptor (const USB_InterfaceDescriptor_TypeDef *interface) |
Pretty print an interface descriptor on the debug serial port. More... | |
void | USBH_PrintString (const char *pre, const USB_StringDescriptor_TypeDef *s, const char *post) |
Print a USB string descriptor on the debug serial port. More... | |
USB_ConfigurationDescriptor_TypeDef * | USBH_QGetConfigurationDescriptor (const uint8_t *buf, int configIndex) |
Return a pointer to a configuration descriptor. More... | |
USB_DeviceDescriptor_TypeDef * | USBH_QGetDeviceDescriptor (const uint8_t *buf) |
Return a pointer to the device descriptor. More... | |
USB_EndpointDescriptor_TypeDef * | USBH_QGetEndpointDescriptor (const uint8_t *buf, int configIndex, int interfaceIndex, int endpointIndex) |
Return a pointer to an endpoint descriptor. More... | |
USB_InterfaceDescriptor_TypeDef * | USBH_QGetInterfaceDescriptor (const uint8_t *buf, int configIndex, int interfaceIndex) |
Return a pointer to an interface descriptor. More... | |
int | USBH_QueryDeviceB (uint8_t *buf, size_t bufsize, uint8_t deviceSpeed) |
Will request both the device descriptor and the entire configuration descriptor from the device at USB address 0. More... | |
int | USBH_Read (USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout, USB_XferCompleteCb_TypeDef callback) |
Read data from device endpoint, non-blocking version. More... | |
int | USBH_ReadB (USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout) |
Read data from device endpoint, blocking version. More... | |
int | USBH_SetAddressB (USBH_Device_TypeDef *device, uint8_t deviceAddress) |
Give a device an USB address. More... | |
int | USBH_SetAltInterfaceB (USBH_Device_TypeDef *device, uint8_t interfaceIndex, uint8_t alternateSetting) |
Activate a device interface within current device configuration. More... | |
int | USBH_SetConfigurationB (USBH_Device_TypeDef *device, uint8_t configValue) |
Activate a device configuration. More... | |
int | USBH_StallEpB (USBH_Ep_TypeDef *ep) |
Set an endpoint in the stalled (halted) state. More... | |
void | USBH_Stop (void) |
Stop USB host operation. More... | |
int | USBH_UnStallEpB (USBH_Ep_TypeDef *ep) |
Reset stall state on a stalled (halted) endpoint. More... | |
int | USBH_WaitForDeviceConnectionB (uint8_t *buf, int timeoutInSeconds) |
Wait for device connection. More... | |
int | USBH_Write (USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout, USB_XferCompleteCb_TypeDef callback) |
Write data to device endpoint, non-blocking version. More... | |
int | USBH_WriteB (USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout) |
Write data to device endpoint, blocking version. More... | |
void | USBTIMER_DelayMs (uint32_t msec) |
Active wait millisecond delay function. Can also be used inside interrupt handlers. More... | |
void | USBTIMER_DelayUs (uint32_t usec) |
Active wait microsecond delay function. Can also be used inside interrupt handlers. More... | |
void | USBTIMER_Init (void) |
Activate the hardware timer used to pace the 1 millisecond timer system. More... | |