EFM32 Happy Gecko Software Documentation
efm32hg-doc-5.1.2
|
Common parts for both HOST and DEVICE USB stacks, see USB device stack library pages for device library documentation.
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... | |
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 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... | |
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 | 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... | |
void | USBTIMER_Start (uint32_t id, uint32_t timeout, USBTIMER_Callback_TypeDef callback) |
Start a timer. More... | |
void | USBTIMER_Stop (uint32_t id) |
Stop a timer. More... | |
#define CLEAR_FEATURE 1 |
Standard setup request CLEAR_FEATURE.
Definition at line 88 of file em_usb.h.
Referenced by MSDD_SetupCmd().
#define CONFIG_DESC_BM_REMOTEWAKEUP 0x20 |
#define CONFIG_DESC_BM_RESERVED_D7 0x80 |
#define CONFIG_DESC_BM_SELFPOWERED 0x40 |
#define CONFIG_DESC_BM_TRANSFERTYPE 0x03 |
Configuration descriptor transfer type bitmask.
Definition at line 194 of file em_usb.h.
Referenced by USBD_Init().
#define CONFIG_DESC_MAXPOWER_mA | ( | x | ) | (((x)+1)/2) |
#define DEVICE_IS_SELFPOWERED 0x0001 |
#define GET_CONFIGURATION 8 |
#define GET_DESCRIPTOR 6 |
Standard setup request GET_DESCRIPTOR.
Definition at line 91 of file em_usb.h.
Referenced by HIDKBD_SetupCmd(), and USBX_SetupCmdCb().
#define GET_INTERFACE 10 |
#define HUB_FEATURE_C_PORT_CONNECTION 16 |
#define HUB_FEATURE_C_PORT_RESET 20 |
#define HUB_FEATURE_PORT_INDICATOR 22 |
#define HUB_FEATURE_PORT_POWER 8 |
#define HUB_FEATURE_PORT_RESET 4 |
#define PORT_FULL_SPEED 1 |
Full speed return value for USBH_GetPortSpeed().
Definition at line 239 of file em_usb.h.
Referenced by MSDBOT_Init().
#define PORT_LOW_SPEED 2 |
#define REMOTE_WAKEUP_ENABLED 0x0002 |
#define SET_CONFIGURATION 9 |
#define SET_DESCRIPTOR 7 |
#define SET_INTERFACE 11 |
#define SILABS_USB_VID 0x10C4 |
#define STATIC_CONST_STRING_DESC | ( | _name, | |
... | |||
) |
Macro for creating USB compliant UTF-16LE UNICODE string descriptors.
Example: STATIC_CONST_STRING_DESC(iManufacturer, 'E','n','e','r','g','y',' ','M','i','c','r','o',' ','A','S');
#define STATIC_CONST_STRING_DESC_LANGID | ( | _name, | |
x, | |||
y | |||
) |
Macro for creating USB compliant language string descriptors.
Example: STATIC_CONST_STRING_DESC_LANGID(langID, 0x04, 0x09);
#define STATIC_UBUF | ( | x, | |
y | |||
) | SL_ALIGN(4) static uint8_t x[((y)+3)&~3] SL_ATTRIBUTE_ALIGN(4) |
Macro for creating WORD (4 byte) aligned static uint8_t arrays with size which is a multiple of WORD size.
Example:
STATIC_UBUF(rxBuffer, 37); => static uint8_t rxBuffer[40];
Definition at line 315 of file em_usb.h.
Referenced by HIDKBD_SetupCmd().
#define UBUF | ( | x, | |
y | |||
) | SL_ALIGN(4) uint8_t x[((y)+3)&~3] SL_ATTRIBUTE_ALIGN(4) |
Macro for creating WORD (4 byte) aligned uint8_t array with size which is a multiple of WORD size.
Example:
UBUF(rxBuffer, 37); => uint8_t rxBuffer[40];
#define USB_AUDIO_GET_CUR 0x81 |
#define USB_AUDIO_GET_CUR 0x81 |
#define USB_AUDIO_GET_MAX 0x83 |
#define USB_AUDIO_GET_MEM 0x85 |
#define USB_AUDIO_GET_MIN 0x82 |
#define USB_AUDIO_GET_RES 0x84 |
#define USB_AUDIO_GET_STAT 0xFF |
#define USB_AUDIO_SET_CUR 0x01 |
#define USB_AUDIO_SET_MAX 0x03 |
#define USB_AUDIO_SET_MEM 0x05 |
#define USB_AUDIO_SET_MIN 0x02 |
#define USB_AUDIO_SET_RES 0x04 |
#define USB_CA_AS_GENERAL_DESCRIPTOR 1 |
#define USB_CA_AS_GENERAL_DESCSIZE 7 |
#define USB_CA_EP_GENERAL_DESCRIPTOR 1 |
#define USB_CA_EP_GENERAL_DESCSIZE 7 |
#define USB_CA_EXTENSION_UNIT_DESCRIPTOR 8 |
#define USB_CA_FEATURE_UNIT_DESCRIPTOR 6 |
#define USB_CA_FORMAT_TYPE_DESCRIPTOR 2 |
#define USB_CA_HEADER_DESCRIPTOR 1 |
#define USB_CA_INPUT_TERMINAL_DESCRIPTOR 2 |
#define USB_CA_INPUT_TERMINAL_DESCSIZE 12 |
#define USB_CA_MIXER_UNIT_DESCRIPTOR 4 |
#define USB_CA_OUTPUT_TERMINAL_DESCRIPTOR 3 |
#define USB_CA_OUTPUT_TERMINAL_DESCSIZE 9 |
#define USB_CA_PROCESSING_UNIT_DESCRIPTOR 7 |
#define USB_CA_SELECTOR_UNIT_DESCRIPTOR 5 |
#define USB_CA_STD_AS_ENDPOINT_DESCSZIE 9 |
#define USB_CDC_ACM_FND_DESCSIZE 4 |
#define USB_CDC_CALLMNG_FND_DESCSIZE 5 |
#define USB_CDC_GETLINECODING 0x21 |
CDC class setup request GET_LINE_CODING.
Definition at line 106 of file em_usb.h.
Referenced by CDC_SetupCmd().
#define USB_CDC_HEADER_FND_DESCSIZE 5 |
#define USB_CDC_SETCTRLLINESTATE 0x22 |
CDC class setup request SET_CONTROL_LINE_STATE.
Definition at line 107 of file em_usb.h.
Referenced by CDC_SetupCmd().
#define USB_CDC_SETLINECODING 0x20 |
CDC class setup request SET_LINE_CODING.
Definition at line 105 of file em_usb.h.
Referenced by CDC_SetupCmd().
#define USB_CLASS_AUDIO_CONTROL 1 |
#define USB_CLASS_AUDIO_MIDISTREAMING 3 |
#define USB_CLASS_AUDIO_STREAMING 2 |
#define USB_CLASS_CDC_ACM 2 |
#define USB_CLASS_CDC_ACMFN 2 |
#define USB_CLASS_CDC_CMNGFN 1 |
#define USB_CLASS_CDC_DATA 0x0A |
#define USB_CLASS_CDC_HFN 0 |
#define USB_CLASS_CDC_UNIONFN 6 |
#define USB_CLASS_HID_KEYBOARD 1 |
#define USB_CLASS_HID_MOUSE 2 |
#define USB_CLASS_MISC_COMMON_SUBCLASS 2 |
#define USB_CLASS_MISC_IAD_PROTOCOL 1 |
#define USB_CLASS_MISCELLANEOUS 0xEF |
#define USB_CLASS_MSD_BOT_TRANSPORT 0x50 |
#define USB_CLASS_MSD_CSW_CMDFAILED 1 |
#define USB_CLASS_MSD_CSW_CMDPASSED 0 |
MSD BOT Command status wrapper command passed code.
Definition at line 225 of file em_usb.h.
Referenced by MSDBOT_Xfer().
#define USB_CLASS_MSD_CSW_PHASEERROR 2 |
#define USB_CLASS_MSD_SCSI_CMDSET 6 |
#define USB_CONFIG_DESCRIPTOR 2 |
#define USB_CONFIG_DESCSIZE 9 |
#define USB_CS_ENDPOINT_DESCRIPTOR 0x25 |
#define USB_CS_INTERFACE_DESCRIPTOR 0x24 |
#define USB_DEVICE_QUALIFIER_DESCRIPTOR 6 |
#define USB_DEVICE_QUALIFIER_DESCSIZE 10 |
#define USB_ENDPOINT_DESCRIPTOR 5 |
#define USB_EPNUM_MASK 0x0F |
#define USB_EPSYNC_ADAPTIVE (2 << 2) |
#define USB_EPSYNC_ASYNC (1 << 2) |
#define USB_EPSYNC_NO (0 << 2) |
#define USB_EPSYNC_SYNC (3 << 2) |
#define USB_EPTYPE_CTRL 0 |
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 |
#define USB_FEATURE_ENDPOINT_HALT 0 |
Standard request CLEAR/SET_FEATURE bitmask.
Definition at line 199 of file em_usb.h.
Referenced by MSDD_SetupCmd().
#define USB_FS_BULK_EP_MAXSIZE 64 |
The max size of full speed bulk endpoints.
Definition at line 175 of file em_usb.h.
Referenced by USBX_inXferCompleteCb().
#define USB_FS_CTRL_EP_MAXSIZE 64 |
#define USB_FS_INTR_EP_MAXSIZE 64 |
#define USB_FS_ISOC_EP_MAXSIZE 1023 |
#define USB_HID_DESCRIPTOR 0x21 |
#define USB_HID_DESCSIZE 9 |
#define USB_HID_GET_IDLE 0x02 |
HID class setup request GET_IDLE.
Definition at line 101 of file em_usb.h.
Referenced by HIDKBD_SetupCmd().
#define USB_HID_GET_REPORT 0x01 |
HID class setup request GET_REPORT.
Definition at line 100 of file em_usb.h.
Referenced by HIDKBD_SetupCmd().
#define USB_HID_REPORT_DESCRIPTOR 0x22 |
HID REPORT descriptor value.
Definition at line 136 of file em_usb.h.
Referenced by HIDKBD_SetupCmd().
#define USB_HID_SET_IDLE 0x0A |
HID class setup request SET_IDLE.
Definition at line 103 of file em_usb.h.
Referenced by HIDKBD_SetupCmd().
#define USB_HID_SET_PROTOCOL 0x0B |
#define USB_HID_SET_REPORT 0x09 |
HID class setup request SET_REPORT.
Definition at line 102 of file em_usb.h.
Referenced by HIDKBD_SetupCmd().
#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR 11 |
#define USB_INTERFACE_ASSOCIATION_DESCSIZE 8 |
#define USB_INTERFACE_DESCRIPTOR 4 |
#define USB_INTERFACE_DESCSIZE 9 |
#define USB_INTERFACE_POWER_DESCRIPTOR 8 |
#define USB_LANGID_ENUS 0x0409 |
#define USB_LS_CTRL_EP_MAXSIZE 8 |
#define USB_LS_INTR_EP_MAXSIZE 8 |
#define USB_MAX_DEVICE_ADDRESS 127 |
#define USB_MAX_STRING_DESCRIPTOR_CHARS 126 |
#define USB_MSD_BOTRESET 0xFF |
MSD class setup request Bulk only transfer reset.
Definition at line 108 of file em_usb.h.
Referenced by MSDD_SetupCmd().
#define USB_MSD_GETMAXLUN 0xFE |
MSD class setup request Get Max LUN.
Definition at line 109 of file em_usb.h.
Referenced by MSDD_SetupCmd().
#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR 7 |
#define USB_OTHER_SPEED_CONFIG_DESCSIZE 9 |
#define USB_SETUP_DIR_D2H 0x80 |
Setup request data stage IN direction mask.
Definition at line 69 of file em_usb.h.
Referenced by USBX_SetupCmdCb().
#define USB_SETUP_DIR_H2D 0x00 |
#define USB_SETUP_DIR_IN 1 |
Setup request data stage IN direction value.
Definition at line 67 of file em_usb.h.
Referenced by CDC_SetupCmd(), HIDKBD_SetupCmd(), and MSDD_SetupCmd().
#define USB_SETUP_DIR_MASK 0x80 |
Setup request data stage direction mask.
Definition at line 68 of file em_usb.h.
Referenced by USBD_Init().
#define USB_SETUP_DIR_OUT 0 |
Setup request data stage OUT direction value.
Definition at line 66 of file em_usb.h.
Referenced by MSDD_SetupCmd().
#define USB_SETUP_RECIPIENT_DEVICE 0 |
Setup request device recipient value.
Definition at line 81 of file em_usb.h.
Referenced by USBX_SetupCmdCb().
#define USB_SETUP_RECIPIENT_ENDPOINT 2 |
Setup request endpoint recipient value.
Definition at line 83 of file em_usb.h.
Referenced by MSDD_SetupCmd().
#define USB_SETUP_RECIPIENT_INTERFACE 1 |
Setup request interface recipient value.
Definition at line 82 of file em_usb.h.
Referenced by CDC_SetupCmd(), HIDKBD_SetupCmd(), MSDD_SetupCmd(), and USBX_SetupCmdCb().
#define USB_SETUP_RECIPIENT_OTHER 3 |
#define USB_SETUP_TYPE_CLASS 1 |
Class setup request value.
Definition at line 74 of file em_usb.h.
Referenced by CDC_SetupCmd(), HIDKBD_SetupCmd(), and MSDD_SetupCmd().
#define USB_SETUP_TYPE_CLASS_MASK 0x20 |
#define USB_SETUP_TYPE_STANDARD 0 |
Standard setup request value.
Definition at line 73 of file em_usb.h.
Referenced by HIDKBD_SetupCmd(), MSDD_SetupCmd(), and USBX_SetupCmdCb().
#define USB_SETUP_TYPE_STANDARD_MASK 0x00 |
#define USB_SETUP_TYPE_VENDOR 2 |
Vendor setup request value.
Definition at line 75 of file em_usb.h.
Referenced by USBX_SetupCmdCb().
#define USB_SETUP_TYPE_VENDOR_MASK 0x40 |
#define USB_SMARTCARD_DESCRIPTOR 0x21 |
#define USB_STRING_DESCRIPTOR 3 |
typedef unsigned short char16_t |
typedef int(* USB_XferCompleteCb_TypeDef) (USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining) |
USB transfer callback function.
The callback function is called when a transfer has completed. An application should check the status, xferred and optionally the remaining parameters before deciding if the transfer is usable. In the case where the transfer is part of a control request data stage, the callback function should return an appropriate USB_Status_TypeDef status.
[in] | status | The transfer status. See USB_Status_TypeDef. |
[in] | xferred | Number of bytes actually transferred. |
[in] | remaining | Number of bytes not transferred. |
typedef void(* USBTIMER_Callback_TypeDef) (void) |
enum USB_Status_TypeDef |
USB transfer status enumerator.
char* USB_GetErrorMsgString | ( | int | error | ) |
Return an error message string for a given error code.
[in] | error | Error code, see USB_Status_TypeDef. |
Definition at line 72 of file em_usbhal.c.
Referenced by USB_PrintErrorMsgString().
void USB_PrintErrorMsgString | ( | char * | pre, |
int | error | ||
) |
Format and print a text string given an error code, prepends an optional user supplied leader string.
[in] | pre | Optional leader string to prepend to error message string. |
[in] | error | Error code, see USB_Status_TypeDef. |
Definition at line 93 of file em_usbhal.c.
References USB_GetErrorMsgString(), USB_PRINTF(), and USB_STATUS_OK.
int USB_PRINTF | ( | const char * | format, |
... | |||
) |
Transmit "printf" formated data on the debug serial port.
[in] | format | Format string (as in printf). No floating point format support. |
Referenced by MSDH_Init(), and USB_PrintErrorMsgString().
int USB_PUTCHAR | ( | char | c | ) |
Transmit a single char on the debug serial port.
[in] | c | Char to transmit. |
void USB_PUTS | ( | const char * | p | ) |
Transmit a zero terminated string on the debug serial port.
[in] | p | Pointer to string to transmit. |
void USBTIMER_DelayMs | ( | uint32_t | msec | ) |
Active wait millisecond delay function. Can also be used inside interrupt handlers.
[in] | msec | Number of milliseconds to wait. |
Definition at line 138 of file em_usbtimer.c.
Referenced by MSDH_Init().
void USBTIMER_DelayUs | ( | uint32_t | usec | ) |
Active wait microsecond delay function. Can also be used inside interrupt handlers.
[in] | usec | Number of microseconds to wait. |
Definition at line 159 of file em_usbtimer.c.
void USBTIMER_Init | ( | void | ) |
Activate the hardware timer used to pace the 1 millisecond timer system.
Call this function whenever the HFPERCLK frequency is changed. This function is initially called by HOST and DEVICE stack xxxx_Init() functions.
Definition at line 193 of file em_usbtimer.c.
References CMU_ClockEnable(), CMU_ClockFreqGet(), cmuClock_HFPER, TIMER_InitCC_TypeDef::mode, TIMER_CompareSet(), TIMER_CounterGet(), TIMER_IEN_CC0, TIMER_Init(), TIMER_INIT_DEFAULT, TIMER_InitCC(), TIMER_INITCC_DEFAULT, TIMER_IntClear(), TIMER_IntEnable(), TIMER_TopSet(), and timerCCModeCompare.
Referenced by USBD_Init().
void USBTIMER_Start | ( | uint32_t | id, |
uint32_t | timeout, | ||
USBTIMER_Callback_TypeDef | callback | ||
) |
Start a timer.
If the timer is already running, it will be restarted with new timeout.
[in] | id | Timer id (0..). |
[in] | timeout | Number of milliseconds before timer will elapse. |
[in] | callback | Function to be called on timer elapse, ref. USBTIMER_Callback_TypeDef. |
Definition at line 237 of file em_usbtimer.c.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, and USBTIMER_Stop().
Referenced by CDC_StateChangeEvent(), and HIDKBD_StateChangeEvent().
void USBTIMER_Stop | ( | uint32_t | id | ) |
Stop a timer.
[in] | id | Timer id (0..). |
Definition at line 306 of file em_usbtimer.c.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, and CORE_EXIT_ATOMIC.
Referenced by CDC_StateChangeEvent(), HIDKBD_SetupCmd(), HIDKBD_StateChangeEvent(), and USBTIMER_Start().