17 #if defined( USB_PRESENT ) && ( USB_COUNT == 1 )
19 #if defined( USB_HOST )
25 #if ( USB_VBUSOVRCUR_PORT != USB_VBUSOVRCUR_PORT_NONE )
31 USBH_Hc_TypeDef hcs[ NUM_HC_USED + 2 ];
32 int USBH_attachRetryCount;
34 volatile USBH_PortState_TypeDef USBH_portStatus;
35 const USBH_AttachTiming_TypeDef USBH_attachTiming[]=
43 #define PORT_VBUS_DELAY 250
44 #define DEFAULT_CTRL_TIMEOUT 1000
46 static void Timeout(
int hcnum );
48 #if defined( __ICCARM__ )
49 #pragma diag_suppress=Pe175
52 static void Timeout0(
void){ Timeout(0); }
53 static void Timeout1(
void){ Timeout(1); }
54 static void Timeout2(
void){ Timeout(2); }
55 static void Timeout3(
void){ Timeout(3); }
56 static void Timeout4(
void){ Timeout(4); }
57 static void Timeout5(
void){ Timeout(5); }
58 static void Timeout6(
void){ Timeout(6); }
59 static void Timeout7(
void){ Timeout(7); }
60 static void Timeout8(
void){ Timeout(8); }
61 static void Timeout9(
void){ Timeout(9); }
62 static void Timeout10(
void){ Timeout(10); }
63 static void Timeout11(
void){ Timeout(11); }
64 static void Timeout12(
void){ Timeout(12); }
65 static void Timeout13(
void){ Timeout(13); }
67 #if defined( __ICCARM__ )
68 #pragma diag_default=Pe175
73 Timeout0, Timeout1, Timeout2, Timeout3, Timeout4, Timeout5,
74 Timeout6, Timeout7, Timeout8, Timeout9, Timeout10, Timeout11,
78 static void Timeout(
int hcnum )
84 #if defined( __GNUC__ )
85 #pragma GCC diagnostic push
86 #pragma GCC diagnostic ignored "-Warray-bounds"
91 #if defined( __GNUC__ )
92 #pragma GCC diagnostic pop
95 hcchar = USBHHAL_GetHcChar( hcnum );
100 USBHHAL_HCHalt( hcnum, hcchar );
101 hc->status |= HCS_TIMEOUT;
111 USBHHAL_HCStart( hcnum );
121 USBHHAL_HCStart( hcnum );
124 hcTimeoutFunc[ hcnum ] );
128 USBHHAL_HCHalt( hcnum, hcchar );
129 hc->status |= HCS_TIMEOUT;
170 DEBUG_USB_API_PUTS(
"\nUSBH_AssignHostChannel(),"
171 " ep NULL pointer" );
176 if ( hcnum >= MAX_NUM_HOSTCHANNELS )
178 DEBUG_USB_API_PUTS(
"\nUSBH_AssignHostChannel(),"
179 " Illegal host channel number" );
247 uint8_t bmRequestType,
258 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), ep NULL pointer" );
265 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), No device connected" );
269 if ( (uint32_t)data & 3 )
271 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), Misaligned data buffer" );
280 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), Endpoint is busy" );
284 if ( !hcs[ ep->
hcIn ].idle || !hcs[ ep->
hcOut ].idle )
287 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), Host channel is busy" );
308 timeout, hcTimeoutFunc[ ep->
hcOut ] );
311 USBH_CtlSendSetup( ep );
368 uint8_t bmRequestType,
381 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsgB() called with int's disabled" );
417 ep->
toggle = USB_PID_DATA1;
420 hc = &hcs[ ep->
hcIn ];
423 hc->remaining = length;
425 USBHHAL_HCStart( ep->
hcIn );
430 #if defined( USB_RAW_API )
431 int USBH_CtlRxRaw( uint8_t pid,
USBH_Ep_TypeDef *ep,
void *data,
int byteCount )
433 uint16_t packets, len;
435 uint32_t hcchar, status;
447 USB->HC[ hcnum ].INT = 0xFFFFFFFF;
449 USB->HAINTMSK |= 1 << hcnum;
450 USB->HC[ hcnum ].CHAR =
459 USB->HC[ hcnum ].TSIZ =
466 USB->HC[ hcnum ].DMAADDR = (uint32_t)data;
468 USB->HC[ hcnum ].CHAR = hcchar;
473 if ( USBHHAL_GetHostChannelInts() & ( 1 << hcnum ) )
475 status = USBHHAL_GetHcInts( hcnum );
477 USB->HC[ hcnum ].CHAR = hcchar;
478 USB->HC[ hcnum ].INTMSK = 0;
479 USB->HC[ hcnum ].INT = 0xFFFFFFFF;
501 ep->
toggle = USB_PID_DATA1;
504 hc = &hcs[ ep->
hcOut ];
507 hc->remaining = length;
509 USBHHAL_HCStart( ep->
hcOut );
518 hc = &hcs[ ep->
hcOut ];
519 hc->buf = (uint8_t*)&ep->
setup;
523 hcs[ ep->
hcIn ].ep = ep;
525 ep->
toggle = USB_PID_SETUP;
529 USBHHAL_HCInit( ep->
hcIn );
532 USBHHAL_HCInit( ep->
hcOut );
534 USBHHAL_HCStart( ep->
hcOut );
539 #if defined( USB_RAW_API )
540 int USBH_CtlTxRaw( uint8_t pid,
USBH_Ep_TypeDef *ep,
void *data,
int byteCount )
544 uint32_t hcchar, status;
555 USB->HC[ hcnum ].INT = 0xFFFFFFFF;
557 USB->HAINTMSK |= 1 << hcnum;
558 USB->HC[ hcnum ].CHAR =
566 USB->HC[ hcnum ].TSIZ =
570 _USB_HC_TSIZ_PKTCNT_MASK ) |
572 _USB_HC_TSIZ_PID_MASK );
573 USB->HC[ hcnum ].DMAADDR = (uint32_t)data;
575 USB->HC[ hcnum ].CHAR = hcchar;
580 if ( USBHHAL_GetHostChannelInts() & ( 1 << hcnum ) )
582 status = USBHHAL_GetHcInts( hcnum );
584 USB->HC[ hcnum ].CHAR = hcchar;
585 USB->HC[ hcnum ].INTMSK = 0;
586 USB->HC[ hcnum ].INT = 0xFFFFFFFF;
588 if ( status & USB_HC_INT_STALL )
614 return USBH_portStatus == H_PORT_CONNECTED;
649 uint8_t configIndex )
651 if ( device == NULL )
653 DEBUG_USB_API_PUTS(
"\nUSBH_GetConfigurationDescriptorB(),"
654 " device NULL pointer" );
661 DEBUG_USB_API_PUTS(
"\nUSBH_GetConfigurationDescriptorB(),"
662 " buf NULL pointer" );
675 DEFAULT_CTRL_TIMEOUT );
707 if ( device == NULL )
709 DEBUG_USB_API_PUTS(
"\nUSBH_GetDeviceDescriptorB(),"
710 " device NULL pointer" );
717 DEBUG_USB_API_PUTS(
"\nUSBH_GetDeviceDescriptorB(),"
718 " buf NULL pointer" );
731 DEFAULT_CTRL_TIMEOUT );
743 return USBHHAL_GetPortSpeed();
780 uint8_t stringIndex, uint16_t langID )
785 if ( device == NULL )
787 DEBUG_USB_API_PUTS(
"\nUSBH_GetStringB(), device NULL pointer" );
794 DEBUG_USB_API_PUTS(
"\nUSBH_GetStringB(), buf NULL pointer" );
808 DEFAULT_CTRL_TIMEOUT );
841 DEBUG_USB_API_PUTS(
"\nUSBH_Init(), init struct NULL pointer" );
846 if ( ( p->
rxFifoSize < MIN_EP_FIFO_SIZE_INBYTES )
850 (MAX_HOST_FIFO_SIZE_INWORDS * 4) ) )
852 DEBUG_USB_API_PUTS(
"\nUSBH_Init(), Illegal Tx/Rx FIFO memory configuration" );
860 USBH_portStatus = H_PORT_DISCONNECTED;
909 uint8_t deviceSpeed )
913 if ( device == NULL )
915 DEBUG_USB_API_PUTS(
"\nUSBH_InitDeviceData(), device NULL pointer" );
924 device->
numEp = numEp;
925 device->
speed = deviceSpeed;
930 memcpy( &device->
ep0,
940 for ( i=0; i<numEp; i++ )
944 device->
ep[i].
toggle = USB_PID_DATA0;
959 for ( i=0; i<numEp; i++ )
987 DEBUG_USB_API_PUTS(
"\nUSBH_PortReset() called with int's disabled" );
992 USBH_portStatus = H_PORT_CONNECTED_RESETTING;
993 USBHHAL_PortReset(
true );
997 USBHHAL_PortReset(
false );
1000 USBH_portStatus = H_PORT_DISCONNECTED;
1017 DEBUG_USB_API_PUTS(
"\nUSBH_PortResume() called with int's disabled" );
1018 EFM_ASSERT(
false );
1022 USBHHAL_PortResume(
true );
1026 USBHHAL_PortResume(
false );
1039 USBHHAL_PortSuspend();
1045 int USBH_PortVbusOn(
bool on )
1050 DEBUG_USB_API_PUTS(
"\nUSBH_PortVbusOn() called with int's disabled" );
1051 EFM_ASSERT(
false );
1055 USBHHAL_VbusOn( on );
1058 USBH_portStatus = H_PORT_DISCONNECTED;
1068 #if defined( USB_USE_PRINTF )
1092 if ( config == NULL )
1094 DEBUG_USB_API_PUTS(
"\nUSBH_PrintConfigurationDescriptor(),"
1095 " config NULL pointer" );
1096 EFM_ASSERT(
false );
1100 USB_PRINTF(
"\n\nConfiguration descriptor:" );
1114 if ( remaining > 0 )
1117 c = (
char*)(config + 1);
1118 while ( remaining-- )
1144 if ( device == NULL )
1146 DEBUG_USB_API_PUTS(
"\nUSBH_PrintDeviceDescriptor(),"
1147 " device NULL pointer" );
1148 EFM_ASSERT(
false );
1187 if ( endpoint == NULL )
1189 DEBUG_USB_API_PUTS(
"\nUSBH_PrintEndpointDescriptor(),"
1190 " endpoint NULL pointer" );
1191 EFM_ASSERT(
false );
1222 if ( interface == NULL )
1224 DEBUG_USB_API_PUTS(
"\nUSBH_PrintInterfaceDescriptor(),"
1225 " interface NULL pointer" );
1226 EFM_ASSERT(
false );
1245 #if defined( __ICCARM__ )
1246 #pragma diag_suppress=Pa039
1281 c = (
char*)&s->
name;
1294 #if defined( __ICCARM__ )
1295 #pragma diag_default=Pa039
1332 const uint8_t *buf,
int configIndex )
1335 const uint8_t *start, *end;
1341 if ( configIndex < dev->bNumConfigurations )
1353 while ( start < end )
1361 if ( i == configIndex )
1393 DEBUG_USB_API_PUTS(
"\nUSBH_QGetDeviceDescriptor(), buf NULL pointer" );
1394 EFM_ASSERT(
false );
1435 const uint8_t *buf,
int configIndex,
int interfaceIndex,
int endpointIndex )
1438 uint8_t *start, *end;
1444 if ( endpointIndex < itf->bNumEndpoints )
1451 buf, configIndex, interfaceIndex + 1 );
1460 while ( start < end )
1468 if ( i == endpointIndex )
1507 const uint8_t *buf,
int configIndex,
int interfaceIndex )
1510 uint8_t *start, *end;
1516 if ( interfaceIndex < conf->bNumInterfaces )
1531 while ( start < end )
1539 if ( ( i == interfaceIndex ) &&
1588 device->
speed = deviceSpeed;
1616 bufsize - (
size_t)USB_DEVICE_DESCSIZE ),
1675 USBH_Hc_TypeDef *hc = &hcs[ ep->
hcIn ];
1679 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), ep NULL pointer" );
1680 EFM_ASSERT(
false );
1686 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), No device connected" );
1690 if ( ( byteCount > MAX_XFER_LEN ) ||
1691 ( ( byteCount / ep->
packetSize ) > MAX_PACKETS_PR_XFER ) )
1693 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Illegal transfer size" );
1694 EFM_ASSERT(
false );
1698 if ( (uint32_t)data & 3 )
1700 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Misaligned data buffer" );
1701 EFM_ASSERT(
false );
1709 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Endpoint is busy" );
1716 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Illegal EP direction" );
1717 EFM_ASSERT(
false );
1724 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Host channel is busy" );
1738 hc->remaining = byteCount;
1752 timeout, hcTimeoutFunc[ ep->
hcIn ] );
1755 USBHHAL_HCInit( ep->
hcIn );
1756 USBHHAL_HCStart( ep->
hcIn );
1801 DEBUG_USB_API_PUTS(
"\nUSBH_ReadB() called with int's disabled" );
1802 EFM_ASSERT(
false );
1806 retVal =
USBH_Read( ep, data, byteCount, timeout, NULL );
1845 if ( device == NULL )
1847 DEBUG_USB_API_PUTS(
"\nUSBH_SetAddressB(), device NULL pointer" );
1848 EFM_ASSERT(
false );
1854 DEBUG_USB_API_PUTS(
"\nUSBH_SetAddressB(), Illegal device address" );
1855 EFM_ASSERT(
false );
1868 DEFAULT_CTRL_TIMEOUT );
1872 device->
addr = deviceAddress;
1898 uint8_t interfaceIndex, uint8_t alternateSetting )
1902 if ( device == NULL )
1904 DEBUG_USB_API_PUTS(
"\nUSBH_SetAltInterfaceB(), device NULL pointer" );
1905 EFM_ASSERT(
false );
1918 DEFAULT_CTRL_TIMEOUT );
1928 for ( i=0; i<device->
numEp; i++ )
1930 device->
ep[i].
toggle = USB_PID_DATA0;
1960 if ( device == NULL )
1962 DEBUG_USB_API_PUTS(
"\nUSBH_SetConfigurationB(), device NULL pointer" );
1963 EFM_ASSERT(
false );
1976 DEFAULT_CTRL_TIMEOUT );
1986 for ( i=0; i<device->
numEp; i++ )
1988 device->
ep[i].
toggle = USB_PID_DATA0;
2013 DEBUG_USB_API_PUTS(
"\nUSBH_StallEpB(), ep NULL pointer" );
2014 EFM_ASSERT(
false );
2026 DEFAULT_CTRL_TIMEOUT );
2041 for ( i = 0; i < NUM_HC_USED + 2; i++ )
2046 USBHAL_DisableGlobalInt();
2048 USBH_PortVbusOn(
false );
2049 USBHAL_DisablePhyPins();
2074 DEBUG_USB_API_PUTS(
"\nUSBH_UnStallEpB(), ep NULL pointer" );
2075 EFM_ASSERT(
false );
2087 DEFAULT_CTRL_TIMEOUT );
2091 ep->
toggle = USB_PID_DATA0;
2099 static void InitUsb(
void )
2103 memset( hcs, 0,
sizeof( hcs ) );
2104 for ( i = 0; i < NUM_HC_USED + 2; i++ )
2106 hcs[ i ].idle =
true;
2150 int accumulatedTime, deadLine;
2154 DEBUG_USB_API_PUTS(
"\nUSBH_WaitForDeviceConnectionB(),"
2155 " buf NULL pointer" );
2156 EFM_ASSERT(
false );
2161 accumulatedTime = 0;
2162 USBH_attachRetryCount = 0;
2163 deadLine = timeoutInSeconds * 1000;
2169 if ( USBHHAL_InitializedAndPowered() )
2171 USBH_PortVbusOn(
false );
2173 accumulatedTime += PORT_VBUS_DELAY;
2179 accumulatedTime += 50;
2182 USBH_PortVbusOn(
true );
2183 DEBUG_USB_INT_LO_PUTCHAR(
'1' );
2185 accumulatedTime += PORT_VBUS_DELAY;
2189 USBHHAL_EnableInts();
2190 USBHAL_EnableGlobalInt();
2199 if ( ( deadLine ) &&
2200 ( accumulatedTime >= deadLine ) )
2205 #if ( USB_VBUSOVRCUR_PORT != USB_VBUSOVRCUR_PORT_NONE )
2206 if (
GPIO_PinInGet( USB_VBUSOVRCUR_PORT, USB_VBUSOVRCUR_PIN ) ==
2207 USB_VBUSOVRCUR_POLARITY )
2209 DEBUG_USB_INT_LO_PUTCHAR(
'~' );
2210 USBHHAL_PortReset(
false );
2211 USBHHAL_VbusOn(
false );
2213 USBH_portStatus = H_PORT_OVERCURRENT;
2219 accumulatedTime += 50;
2226 accumulatedTime += 100;
2241 accumulatedTime += DEFAULT_CTRL_TIMEOUT;
2250 accumulatedTime += PORT_VBUS_DELAY;
2252 if ( ( deadLine ) &&
2253 ( accumulatedTime >= deadLine ) )
2256 USBH_attachRetryCount = ( USBH_attachRetryCount + 1 ) %
2257 (
sizeof( USBH_attachTiming ) /
2258 sizeof( USBH_AttachTiming_TypeDef ) );
2300 USBH_Hc_TypeDef *hc = &hcs[ ep->
hcOut ];
2304 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), ep NULL pointer" );
2305 EFM_ASSERT(
false );
2311 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), No device connected" );
2315 if ( ( byteCount > MAX_XFER_LEN ) ||
2316 ( ( byteCount / ep->
packetSize ) > MAX_PACKETS_PR_XFER ) )
2318 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Illegal transfer size" );
2319 EFM_ASSERT(
false );
2323 if ( (uint32_t)data & 3 )
2325 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Misaligned data buffer" );
2326 EFM_ASSERT(
false );
2334 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Endpoint is busy" );
2341 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Illegal EP direction" );
2342 EFM_ASSERT(
false );
2349 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Host channel is busy" );
2363 hc->remaining = byteCount;
2377 timeout, hcTimeoutFunc[ ep->
hcOut ] );
2380 USBHHAL_HCInit( ep->
hcOut );
2381 USBHHAL_HCStart( ep->
hcOut );
2424 DEBUG_USB_API_PUTS(
"\nUSBH_WriteB() called with int's disabled" );
2425 EFM_ASSERT(
false );
2429 retVal =
USBH_Write( ep, data, byteCount, timeout, NULL );
Clock management unit (CMU) API.
void CMU_ClockSelectSet(CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref)
Select reference clock/oscillator used for a clock branch.
#define USB_INTERFACE_DESCSIZE
#define CMU_HFCORECLKEN0_USBC
int USBH_WriteB(USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout)
Write data to device endpoint, blocking version.
#define USB_HC_CHAR_CHDIS
#define SET_CONFIGURATION
int USBH_UnStallEpB(USBH_Ep_TypeDef *ep)
Reset stall state on a stalled (halted) endpoint.
uint8_t bInterfaceProtocol
#define USB_SETUP_DIR_D2H
void USBTIMER_Stop(uint32_t id)
Stop a timer.
#define _USB_HC_TSIZ_XFERSIZE_SHIFT
uint8_t bInterfaceSubClass
USB protocol stack library API for EFM32/EZR32.
void USBH_PortSuspend(void)
Set the USB port in suspend mode.
#define USB_SETUP_DIR_H2D
#define USB_STRING_DESCRIPTOR
#define USB_SETUP_RECIPIENT_ENDPOINT
#define _USB_HC_TSIZ_PKTCNT_SHIFT
USB HOST device definition.
int USB_PRINTF(const char *format,...)
Transmit "printf" formated data on the debug serial port.
USB_DeviceDescriptor_TypeDef * USBH_QGetDeviceDescriptor(const uint8_t *buf)
Return a pointer to the device descriptor.
__STATIC_INLINE uint32_t INT_Enable(void)
Enable interrupts.
#define USB_HC_CHAR_CHENA
int USBH_ReadB(USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout)
Read data from device endpoint, blocking version.
USB Host stack initialization structure.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
USB_InterfaceDescriptor_TypeDef * USBH_QGetInterfaceDescriptor(const uint8_t *buf, int configIndex, int interfaceIndex)
Return a pointer to an interface descriptor.
int USBH_GetDeviceDescriptorB(USBH_Device_TypeDef *device, void *buf, int len)
Read a device descriptor from a device.
#define _USB_HC_CHAR_EPTYPE_SHIFT
uint8_t bConfigurationValue
int USBH_PrintConfigurationDescriptor(const USB_ConfigurationDescriptor_TypeDef *config, int maxLen)
Pretty print a configuration descriptor on the debug serial port.
#define USB_SETUP_DIR_MASK
void(* USBTIMER_Callback_TypeDef)(void)
USBTIMER callback function.
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.
#define _USB_HPRT_PRTSPD_SHIFT
void USBTIMER_DelayMs(uint32_t msec)
Active wait millisecond delay function. Can also be used inside interrupt handlers.
USB Interface Descriptor.
#define _USB_HC_CHAR_DEVADDR_SHIFT
int(* USB_XferCompleteCb_TypeDef)(USB_Status_TypeDef status, uint32_t xferred, uint32_t remaining)
USB transfer callback function.
bool USBH_DeviceConnected(void)
Check if a device is connected.
USB_Status_TypeDef
USB transfer status enumerator.
int USBH_GetConfigurationDescriptorB(USBH_Device_TypeDef *device, void *buf, int len, uint8_t configIndex)
Read a configuration descriptor from a device.
int USBH_SetAddressB(USBH_Device_TypeDef *device, uint8_t deviceAddress)
Give a device an USB address.
volatile bool xferCompleted
#define CMU_HFCORECLKEN0_USB
#define _USB_HC_TSIZ_PID_SHIFT
USB_Status_TypeDef xferStatus
#define USB_DEVICE_DESCRIPTOR
#define USB_HC_CHAR_LSPDDEV
int USBH_StallEpB(USBH_Ep_TypeDef *ep)
Set an endpoint in the stalled (halted) state.
int USBH_SetAltInterfaceB(USBH_Device_TypeDef *device, uint8_t interfaceIndex, uint8_t alternateSetting)
Activate a device interface within current device configuration.
void USBH_PrintString(const char *pre, const USB_StringDescriptor_TypeDef *s, const char *post)
Print a USB string descriptor on the debug serial port.
#define USB_CONFIG_DESCSIZE
struct USBH_Device_TypeDef * parentDevice
#define CMU_CMD_USBCCLKSEL_HFCLKNODIV
void USB_PUTS(const char *p)
Transmit a zero terminated string on the debug serial port.
General Purpose IO (GPIO) peripheral API.
struct USBH_Device_TypeDef USBH_Device_TypeDef
USB HOST device definition.
#define _USB_HC_TSIZ_XFERSIZE_MASK
uint8_t bAlternateSetting
int USBH_Init(const USBH_Init_TypeDef *p)
Initialize host protocol stack data structures.
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.
USB_ConfigurationDescriptor_TypeDef confDesc
#define CONFIG_DESC_BM_TRANSFERTYPE
USB protocol stack library API for EFM32/EZR32.
int USBH_PortReset(void)
Drive reset signalling on the USB port.
#define USB_SETUP_RECIPIENT_DEVICE
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.
#define USB_SETUP_RECIPIENT_INTERFACE
#define USB_DEVICE_DESCSIZE
USB_InterfaceDescriptor_TypeDef itfDesc
uint8_t bNumConfigurations
#define USB_SETUP_TYPE_STANDARD_MASK
int USBH_WaitForDeviceConnectionB(uint8_t *buf, int timeoutInSeconds)
Wait for device connection.
#define USB_INTERFACE_DESCRIPTOR
#define USB_ENDPOINT_DESCSIZE
int USBH_PrintDeviceDescriptor(const USB_DeviceDescriptor_TypeDef *device)
Pretty print a device descriptor on the debug serial port.
USB_EndpointDescriptor_TypeDef * USBH_QGetEndpointDescriptor(const uint8_t *buf, int configIndex, int interfaceIndex, int endpointIndex)
Return a pointer to an endpoint descriptor.
USB_DeviceDescriptor_TypeDef devDesc
uint8_t USBH_GetPortSpeed(void)
Get the bus speed of the device attached to the USB port.
int USBH_PrintEndpointDescriptor(const USB_EndpointDescriptor_TypeDef *endpoint)
Pretty print an endpoint descriptor on the debug serial port.
#define USB_MAX_DEVICE_ADDRESS
#define USB_HC_CHAR_EPDIR
#define USB_FEATURE_ENDPOINT_HALT
USB_ConfigurationDescriptor_TypeDef * USBH_QGetConfigurationDescriptor(const uint8_t *buf, int configIndex)
Return a pointer to a configuration descriptor.
USB protocol stack library, low level USB peripheral access.
int USBH_SetConfigurationB(USBH_Device_TypeDef *device, uint8_t configValue)
Activate a device configuration.
void USBTIMER_Init(void)
Activate the hardware timer used to pace the 1 millisecond timer system.
USB Configuration Descriptor.
#define USB_CONFIG_DESCRIPTOR
#define _USB_HC_CHAR_EPNUM_SHIFT
USB_EndpointDescriptor_TypeDef epDesc
USB_XferCompleteCb_TypeDef xferCompleteCb
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.
__STATIC_INLINE uint32_t INT_Disable(void)
Disable interrupts.
#define USB_SETUP_PKT_SIZE
#define _USB_HC_TSIZ_PID_MASK
USB HOST endpoint status data.
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 US...
USB protocol stack library, internal type definitions.
int USBH_PrintInterfaceDescriptor(const USB_InterfaceDescriptor_TypeDef *interface)
Pretty print an interface descriptor on the debug serial port.
int USBH_PortResume(void)
Drive resume signalling on the USB port.
#define _USB_HC_CHAR_MPS_SHIFT
#define _USB_HC_TSIZ_PKTCNT_MASK
#define USB_GINTSTS_HCHINT
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 USB_PUTCHAR(char c)
Transmit a single char on the debug serial port.
void USBTIMER_Start(uint32_t id, uint32_t timeout, USBTIMER_Callback_TypeDef callback)
Start a timer.
__STATIC_INLINE unsigned int GPIO_PinInGet(GPIO_Port_TypeDef port, unsigned int pin)
Read the pad value for a single pin in a GPIO port.
void USBH_Stop(void)
Stop USB host operation.
#define USB_ENDPOINT_DESCRIPTOR
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_AssignHostChannel(USBH_Ep_TypeDef *ep, uint8_t hcnum)
Assign a host channel to a given endpoint.
USBH_EpState_TypeDef state