em_usb.h File Reference
USB protocol stack library API for EFM32/EZR32.
- Version
- 5.4.0
License
(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>
Data Structures |
|
struct | USB_ConfigurationDescriptor_TypeDef |
USB Configuration Descriptor.
|
|
struct | USB_DeviceDescriptor_TypeDef |
USB Device Descriptor.
|
|
struct | USB_EndpointDescriptor_TypeDef |
USB Endpoint Descriptor.
|
|
struct | USB_InterfaceDescriptor_TypeDef |
USB Interface Descriptor.
|
|
struct | USB_Setup_TypeDef |
USB Setup request package.
|
|
struct | USB_StringDescriptor_TypeDef |
USB String Descriptor.
|
|
struct | USBD_Callbacks_TypeDef |
USB Device stack callback structure.
|
|
struct | USBD_Init_TypeDef |
USB Device stack initialization structure.
|
|
struct | USBH_Device_TypeDef |
USB HOST device definition.
|
|
struct | USBH_Ep_TypeDef |
USB HOST endpoint status data.
|
|
struct | USBH_Init_TypeDef |
USB Host stack initialization structure.
|
|
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.
|
|
typedef struct USBD_Callbacks_TypeDef | USBD_Callbacks_TypeDef |
USB Device stack callback structure.
|
|
typedef void(* | USBD_DeviceStateChangeCb_TypeDef ) ( USBD_State_TypeDef oldState, USBD_State_TypeDef newState) |
USB State change callback function.
|
|
typedef bool(* | USBD_IsSelfPoweredCb_TypeDef ) (void) |
USB power mode callback function.
|
|
typedef int(* | USBD_SetupCmdCb_TypeDef ) (const USB_Setup_TypeDef *setup) |
USB setup request callback function.
|
|
typedef void(* | USBD_SofIntCb_TypeDef ) (uint16_t sofNr) |
USB Start Of Frame (SOF) interrupt callback function.
|
|
typedef void(* | USBD_UsbResetCb_TypeDef ) (void) |
USB Reset callback function.
|
|
typedef struct USBH_Device_TypeDef | USBH_Device_TypeDef |
USB HOST device definition.
|
|
typedef void(* | USBTIMER_Callback_TypeDef ) (void) |
USBTIMER callback function.
|
|
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.
|
|
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.
|
|
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.
|
|
void | USB_PrintErrorMsgString (char *pre, int error) |
Format and print a text string given an error code, prepends an optional user supplied leader string.
|
|
int | USB_PRINTF (const char *format,...) |
Transmit "printf" formated data on the debug serial port.
|
|
int | USB_PUTCHAR (char c) |
Transmit a single char on the debug serial port.
|
|
void | USB_PUTS (const char *p) |
Transmit a zero terminated string on the debug serial port.
|
|
void | USBD_AbortAllTransfers (void) |
Abort all pending transfers.
|
|
int | USBD_AbortTransfer (int epAddr) |
Abort a pending transfer on a specific endpoint.
|
|
void | USBD_Connect (void) |
Start USB device operation.
|
|
void | USBD_Disconnect (void) |
Stop USB device operation.
|
|
bool | USBD_EpIsBusy (int epAddr) |
Check if an endpoint is busy doing a transfer.
|
|
USBD_State_TypeDef | USBD_GetUsbState (void) |
Get current USB device state.
|
|
const char * | USBD_GetUsbStateName ( USBD_State_TypeDef state) |
Get a string naming a device USB state.
|
|
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.
|
|
int | USBD_Read (int epAddr, void *data, int byteCount, USB_XferCompleteCb_TypeDef callback) |
Start a read (OUT) transfer on an endpoint.
|
|
int | USBD_RemoteWakeup (void) |
Perform a remote wakeup signalling sequence.
|
|
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.
|
|
void | USBD_Stop (void) |
Stop USB device stack operation.
|
|
int | USBD_UnStallEp (int epAddr) |
Reset stall state on a stalled (halted) endpoint.
|
|
int | USBD_Write (int epAddr, void *data, int byteCount, USB_XferCompleteCb_TypeDef callback) |
Start a write (IN) transfer on an endpoint.
|
|
int | USBH_AssignHostChannel ( USBH_Ep_TypeDef *ep, uint8_t hcnum) |
Assign a host channel to a given endpoint.
|
|
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.
|
|
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.
|
|
bool | USBH_DeviceConnected (void) |
Check if a device is connected.
|
|
int | USBH_GetConfigurationDescriptorB ( USBH_Device_TypeDef *device, void *buf, int len, uint8_t configIndex) |
Read a configuration descriptor from a device.
|
|
int | USBH_GetDeviceDescriptorB ( USBH_Device_TypeDef *device, void *buf, int len) |
Read a device descriptor from a device.
|
|
uint8_t | USBH_GetPortSpeed (void) |
Get the bus speed of the device attached to the USB port.
|
|
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.
|
|
int | USBH_Init (const USBH_Init_TypeDef *p) |
Initialize host protocol stack data structures.
|
|
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.
|
|
int | USBH_PortReset (void) |
Drive reset signalling on the USB port.
|
|
int | USBH_PortResume (void) |
Drive resume signalling on the USB port.
|
|
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.
|
|
int | USBH_PrintDeviceDescriptor (const USB_DeviceDescriptor_TypeDef *device) |
Pretty print a device descriptor on the debug serial port.
|
|
int | USBH_PrintEndpointDescriptor (const USB_EndpointDescriptor_TypeDef *endpoint) |
Pretty print an endpoint descriptor on the debug serial port.
|
|
int | USBH_PrintInterfaceDescriptor (const USB_InterfaceDescriptor_TypeDef *interface) |
Pretty print an interface descriptor on the debug serial port.
|
|
void | USBH_PrintString (const char *pre, const USB_StringDescriptor_TypeDef *s, const char *post) |
Print a USB string descriptor on the debug serial port.
|
|
USB_ConfigurationDescriptor_TypeDef * | USBH_QGetConfigurationDescriptor (const uint8_t *buf, int configIndex) |
Return a pointer to a configuration descriptor.
|
|
USB_DeviceDescriptor_TypeDef * | USBH_QGetDeviceDescriptor (const uint8_t *buf) |
Return a pointer to the device descriptor.
|
|
USB_EndpointDescriptor_TypeDef * | USBH_QGetEndpointDescriptor (const uint8_t *buf, int configIndex, int interfaceIndex, int endpointIndex) |
Return a pointer to an endpoint descriptor.
|
|
USB_InterfaceDescriptor_TypeDef * | USBH_QGetInterfaceDescriptor (const uint8_t *buf, int configIndex, int interfaceIndex) |
Return a pointer to an interface descriptor.
|
|
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.
|
|
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.
|
|
int | USBH_ReadB ( USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout) |
Read data from device endpoint, blocking version.
|
|
int | USBH_SetAddressB ( USBH_Device_TypeDef *device, uint8_t deviceAddress) |
Give a device an USB address.
|
|
int | USBH_SetAltInterfaceB ( USBH_Device_TypeDef *device, uint8_t interfaceIndex, uint8_t alternateSetting) |
Activate a device interface within current device configuration.
|
|
int | USBH_SetConfigurationB ( USBH_Device_TypeDef *device, uint8_t configValue) |
Activate a device configuration.
|
|
int | USBH_StallEpB ( USBH_Ep_TypeDef *ep) |
Set an endpoint in the stalled (halted) state.
|
|
void | USBH_Stop (void) |
Stop USB host operation.
|
|
int | USBH_UnStallEpB ( USBH_Ep_TypeDef *ep) |
Reset stall state on a stalled (halted) endpoint.
|
|
int | USBH_WaitForDeviceConnectionB (uint8_t *buf, int timeoutInSeconds) |
Wait for device connection.
|
|
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.
|
|
int | USBH_WriteB ( USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout) |
Write data to device endpoint, blocking version.
|
|
void | USBTIMER_DelayMs (uint32_t msec) |
Active wait millisecond delay function. Can also be used inside interrupt handlers.
|
|
void | USBTIMER_DelayUs (uint32_t usec) |
Active wait microsecond delay function. Can also be used inside interrupt handlers.
|
|
void | USBTIMER_Init (void) |
Activate the hardware timer used to pace the 1 millisecond timer system.
|
|