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.
          | 
       |
         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 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.
          | 
       |
         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.
          | 
       |
| 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.
          | 
       |