17 #if defined( USB_PRESENT ) && ( USB_COUNT == 1 )
19 #if defined( USB_HOST )
26 #if ( USB_VBUSOVRCUR_PORT != USB_VBUSOVRCUR_PORT_NONE )
32 USBH_Hc_TypeDef hcs[ NUM_HC_USED + 2 ];
33 int USBH_attachRetryCount;
35 volatile USBH_PortState_TypeDef USBH_portStatus;
36 const USBH_AttachTiming_TypeDef USBH_attachTiming[]=
44 #define PORT_VBUS_DELAY 250
45 #define DEFAULT_CTRL_TIMEOUT 1000
47 static void Timeout(
int hcnum );
49 #if defined( __ICCARM__ )
50 #pragma diag_suppress=Pe175
53 static void Timeout0(
void){ Timeout(0); }
54 static void Timeout1(
void){ Timeout(1); }
55 static void Timeout2(
void){ Timeout(2); }
56 static void Timeout3(
void){ Timeout(3); }
57 static void Timeout4(
void){ Timeout(4); }
58 static void Timeout5(
void){ Timeout(5); }
59 static void Timeout6(
void){ Timeout(6); }
60 static void Timeout7(
void){ Timeout(7); }
61 static void Timeout8(
void){ Timeout(8); }
62 static void Timeout9(
void){ Timeout(9); }
63 static void Timeout10(
void){ Timeout(10); }
64 static void Timeout11(
void){ Timeout(11); }
65 static void Timeout12(
void){ Timeout(12); }
66 static void Timeout13(
void){ Timeout(13); }
68 #if defined( __ICCARM__ )
69 #pragma diag_default=Pe175
74 Timeout0, Timeout1, Timeout2, Timeout3, Timeout4, Timeout5,
75 Timeout6, Timeout7, Timeout8, Timeout9, Timeout10, Timeout11,
79 static void Timeout(
int hcnum )
85 #if defined( __GNUC__ )
86 #pragma GCC diagnostic push
87 #pragma GCC diagnostic ignored "-Warray-bounds"
92 #if defined( __GNUC__ )
93 #pragma GCC diagnostic pop
96 hcchar = USBHHAL_GetHcChar( hcnum );
101 USBHHAL_HCHalt( hcnum, hcchar );
102 hc->status |= HCS_TIMEOUT;
112 USBHHAL_HCStart( hcnum );
122 USBHHAL_HCStart( hcnum );
125 hcTimeoutFunc[ hcnum ] );
129 USBHHAL_HCHalt( hcnum, hcchar );
130 hc->status |= HCS_TIMEOUT;
172 DEBUG_USB_API_PUTS(
"\nUSBH_AssignHostChannel(),"
173 " ep NULL pointer" );
178 if ( hcnum >= MAX_NUM_HOSTCHANNELS )
180 DEBUG_USB_API_PUTS(
"\nUSBH_AssignHostChannel(),"
181 " Illegal host channel number" );
250 uint8_t bmRequestType,
263 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), ep NULL pointer" );
270 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), No device connected" );
274 if ( (uint32_t)data & 3 )
276 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), Misaligned data buffer" );
285 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), Endpoint is busy" );
289 if ( !hcs[ ep->
hcIn ].idle || !hcs[ ep->
hcOut ].idle )
292 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsg(), Host channel is busy" );
313 timeout, hcTimeoutFunc[ ep->
hcOut ] );
316 USBH_CtlSendSetup( ep );
371 uint8_t bmRequestType,
383 DEBUG_USB_API_PUTS(
"\nUSBH_ControlMsgB() called with int's disabled" );
418 ep->
toggle = USB_PID_DATA1;
421 hc = &hcs[ ep->
hcIn ];
424 hc->remaining = length;
426 USBHHAL_HCStart( ep->
hcIn );
431 #if defined( USB_RAW_API )
432 int USBH_CtlRxRaw( uint8_t pid,
USBH_Ep_TypeDef *ep,
void *data,
int byteCount )
434 uint16_t packets, len;
436 uint32_t hcchar, status;
449 USB->HC[ hcnum ].INT = 0xFFFFFFFF;
451 USB->HAINTMSK |= 1 << hcnum;
452 USB->HC[ hcnum ].CHAR =
461 USB->HC[ hcnum ].TSIZ =
468 USB->HC[ hcnum ].DMAADDR = (uint32_t)data;
470 USB->HC[ hcnum ].CHAR = hcchar;
475 if ( USBHHAL_GetHostChannelInts() & ( 1 << hcnum ) )
477 status = USBHHAL_GetHcInts( hcnum );
479 USB->HC[ hcnum ].CHAR = hcchar;
480 USB->HC[ hcnum ].INTMSK = 0;
481 USB->HC[ hcnum ].INT = 0xFFFFFFFF;
502 ep->
toggle = USB_PID_DATA1;
505 hc = &hcs[ ep->
hcOut ];
508 hc->remaining = length;
510 USBHHAL_HCStart( ep->
hcOut );
519 hc = &hcs[ ep->
hcOut ];
520 hc->buf = (uint8_t*)&ep->
setup;
524 hcs[ ep->
hcIn ].ep = ep;
526 ep->
toggle = USB_PID_SETUP;
530 USBHHAL_HCInit( ep->
hcIn );
533 USBHHAL_HCInit( ep->
hcOut );
535 USBHHAL_HCStart( ep->
hcOut );
540 #if defined( USB_RAW_API )
541 int USBH_CtlTxRaw( uint8_t pid,
USBH_Ep_TypeDef *ep,
void *data,
int byteCount )
545 uint32_t hcchar, status;
557 USB->HC[ hcnum ].INT = 0xFFFFFFFF;
559 USB->HAINTMSK |= 1 << hcnum;
560 USB->HC[ hcnum ].CHAR =
568 USB->HC[ hcnum ].TSIZ =
572 _USB_HC_TSIZ_PKTCNT_MASK ) |
574 _USB_HC_TSIZ_PID_MASK );
575 USB->HC[ hcnum ].DMAADDR = (uint32_t)data;
577 USB->HC[ hcnum ].CHAR = hcchar;
582 if ( USBHHAL_GetHostChannelInts() & ( 1 << hcnum ) )
584 status = USBHHAL_GetHcInts( hcnum );
586 USB->HC[ hcnum ].CHAR = hcchar;
587 USB->HC[ hcnum ].INTMSK = 0;
588 USB->HC[ hcnum ].INT = 0xFFFFFFFF;
590 if ( status & USB_HC_INT_STALL )
615 return USBH_portStatus == H_PORT_CONNECTED;
650 uint8_t configIndex )
652 if ( device == NULL )
654 DEBUG_USB_API_PUTS(
"\nUSBH_GetConfigurationDescriptorB(),"
655 " device NULL pointer" );
662 DEBUG_USB_API_PUTS(
"\nUSBH_GetConfigurationDescriptorB(),"
663 " buf NULL pointer" );
676 DEFAULT_CTRL_TIMEOUT );
708 if ( device == NULL )
710 DEBUG_USB_API_PUTS(
"\nUSBH_GetDeviceDescriptorB(),"
711 " device NULL pointer" );
718 DEBUG_USB_API_PUTS(
"\nUSBH_GetDeviceDescriptorB(),"
719 " buf NULL pointer" );
732 DEFAULT_CTRL_TIMEOUT );
744 return USBHHAL_GetPortSpeed();
781 uint8_t stringIndex, uint16_t langID )
786 if ( device == NULL )
788 DEBUG_USB_API_PUTS(
"\nUSBH_GetStringB(), device NULL pointer" );
795 DEBUG_USB_API_PUTS(
"\nUSBH_GetStringB(), buf NULL pointer" );
809 DEFAULT_CTRL_TIMEOUT );
843 DEBUG_USB_API_PUTS(
"\nUSBH_Init(), init struct NULL pointer" );
848 if ( ( p->
rxFifoSize < MIN_EP_FIFO_SIZE_INBYTES )
852 (MAX_HOST_FIFO_SIZE_INWORDS * 4) ) )
854 DEBUG_USB_API_PUTS(
"\nUSBH_Init(), Illegal Tx/Rx FIFO memory configuration" );
862 USBH_portStatus = H_PORT_DISCONNECTED;
915 uint8_t deviceSpeed )
919 if ( device == NULL )
921 DEBUG_USB_API_PUTS(
"\nUSBH_InitDeviceData(), device NULL pointer" );
930 device->
numEp = numEp;
931 device->
speed = deviceSpeed;
936 memcpy( &device->
ep0,
946 for ( i=0; i<numEp; i++ )
950 device->
ep[i].
toggle = USB_PID_DATA0;
965 for ( i=0; i<numEp; i++ )
993 DEBUG_USB_API_PUTS(
"\nUSBH_PortReset() called with int's disabled" );
998 USBH_portStatus = H_PORT_CONNECTED_RESETTING;
1000 USBHHAL_PortReset(
true );
1006 USBHHAL_PortReset(
false );
1010 USBH_portStatus = H_PORT_DISCONNECTED;
1026 DEBUG_USB_API_PUTS(
"\nUSBH_PortResume() called with int's disabled" );
1027 EFM_ASSERT(
false );
1032 USBHHAL_PortResume(
true );
1038 USBHHAL_PortResume(
false );
1051 USBHHAL_PortSuspend();
1057 int USBH_PortVbusOn(
bool on )
1061 DEBUG_USB_API_PUTS(
"\nUSBH_PortVbusOn() called with int's disabled" );
1062 EFM_ASSERT(
false );
1067 USBHHAL_VbusOn( on );
1071 USBH_portStatus = H_PORT_DISCONNECTED;
1081 #if defined( USB_USE_PRINTF )
1109 if ( config == NULL )
1111 DEBUG_USB_API_PUTS(
"\nUSBH_PrintConfigurationDescriptor(),"
1112 " config NULL pointer" );
1113 EFM_ASSERT(
false );
1117 USB_PRINTF(
"\n\nConfiguration descriptor:" );
1131 if ( remaining > 0 )
1134 c = (
char*)(config + 1);
1135 while ( remaining-- )
1165 if ( device == NULL )
1167 DEBUG_USB_API_PUTS(
"\nUSBH_PrintDeviceDescriptor(),"
1168 " device NULL pointer" );
1169 EFM_ASSERT(
false );
1212 if ( endpoint == NULL )
1214 DEBUG_USB_API_PUTS(
"\nUSBH_PrintEndpointDescriptor(),"
1215 " endpoint NULL pointer" );
1216 EFM_ASSERT(
false );
1251 if ( interface == NULL )
1253 DEBUG_USB_API_PUTS(
"\nUSBH_PrintInterfaceDescriptor(),"
1254 " interface NULL pointer" );
1255 EFM_ASSERT(
false );
1274 #if defined( __ICCARM__ )
1275 #pragma diag_suppress=Pa039
1310 c = (
char*)&s->
name;
1323 #if defined( __ICCARM__ )
1324 #pragma diag_default=Pa039
1361 const uint8_t *buf,
int configIndex )
1364 const uint8_t *start, *end;
1370 if ( configIndex < dev->bNumConfigurations )
1382 while ( start < end )
1390 if ( i == configIndex )
1422 DEBUG_USB_API_PUTS(
"\nUSBH_QGetDeviceDescriptor(), buf NULL pointer" );
1423 EFM_ASSERT(
false );
1464 const uint8_t *buf,
int configIndex,
int interfaceIndex,
int endpointIndex )
1467 uint8_t *start, *end;
1473 if ( endpointIndex < itf->bNumEndpoints )
1480 buf, configIndex, interfaceIndex + 1 );
1489 while ( start < end )
1497 if ( i == endpointIndex )
1536 const uint8_t *buf,
int configIndex,
int interfaceIndex )
1539 uint8_t *start, *end;
1545 if ( interfaceIndex < conf->bNumInterfaces )
1560 while ( start < end )
1568 if ( ( i == interfaceIndex ) &&
1621 device->
speed = deviceSpeed;
1627 SL_MIN( 8U, bufsize ) ) )
1649 bufsize - (
size_t)USB_DEVICE_DESCSIZE ),
1709 USBH_Hc_TypeDef *hc = &hcs[ ep->
hcIn ];
1714 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), ep NULL pointer" );
1715 EFM_ASSERT(
false );
1721 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), No device connected" );
1725 if ( ( byteCount > MAX_XFER_LEN ) ||
1726 ( ( byteCount / ep->
packetSize ) > MAX_PACKETS_PR_XFER ) )
1728 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Illegal transfer size" );
1729 EFM_ASSERT(
false );
1733 if ( (uint32_t)data & 3 )
1735 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Misaligned data buffer" );
1736 EFM_ASSERT(
false );
1744 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Endpoint is busy" );
1751 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Illegal EP direction" );
1752 EFM_ASSERT(
false );
1759 DEBUG_USB_API_PUTS(
"\nUSBH_Read(), Host channel is busy" );
1773 hc->remaining = byteCount;
1787 timeout, hcTimeoutFunc[ ep->
hcIn ] );
1790 USBHHAL_HCInit( ep->
hcIn );
1791 USBHHAL_HCStart( ep->
hcIn );
1833 DEBUG_USB_API_PUTS(
"\nUSBH_ReadB() called with int's disabled" );
1834 EFM_ASSERT(
false );
1838 retVal =
USBH_Read( ep, data, byteCount, timeout, NULL );
1877 if ( device == NULL )
1879 DEBUG_USB_API_PUTS(
"\nUSBH_SetAddressB(), device NULL pointer" );
1880 EFM_ASSERT(
false );
1886 DEBUG_USB_API_PUTS(
"\nUSBH_SetAddressB(), Illegal device address" );
1887 EFM_ASSERT(
false );
1900 DEFAULT_CTRL_TIMEOUT );
1904 device->
addr = deviceAddress;
1931 uint8_t interfaceIndex, uint8_t alternateSetting )
1935 if ( device == NULL )
1937 DEBUG_USB_API_PUTS(
"\nUSBH_SetAltInterfaceB(), device NULL pointer" );
1938 EFM_ASSERT(
false );
1951 DEFAULT_CTRL_TIMEOUT );
1961 for ( i=0; i<device->
numEp; i++ )
1963 device->
ep[i].
toggle = USB_PID_DATA0;
1994 if ( device == NULL )
1996 DEBUG_USB_API_PUTS(
"\nUSBH_SetConfigurationB(), device NULL pointer" );
1997 EFM_ASSERT(
false );
2010 DEFAULT_CTRL_TIMEOUT );
2020 for ( i=0; i<device->
numEp; i++ )
2022 device->
ep[i].
toggle = USB_PID_DATA0;
2048 DEBUG_USB_API_PUTS(
"\nUSBH_StallEpB(), ep NULL pointer" );
2049 EFM_ASSERT(
false );
2061 DEFAULT_CTRL_TIMEOUT );
2076 for ( i = 0; i < NUM_HC_USED + 2; i++ )
2081 USBHAL_DisableGlobalInt();
2083 USBH_PortVbusOn(
false );
2084 USBHAL_DisablePhyPins();
2110 DEBUG_USB_API_PUTS(
"\nUSBH_UnStallEpB(), ep NULL pointer" );
2111 EFM_ASSERT(
false );
2123 DEFAULT_CTRL_TIMEOUT );
2127 ep->
toggle = USB_PID_DATA0;
2135 static void InitUsb(
void )
2139 memset( hcs, 0,
sizeof( hcs ) );
2140 for ( i = 0; i < NUM_HC_USED + 2; i++ )
2142 hcs[ i ].idle =
true;
2185 int accumulatedTime, deadLine;
2189 DEBUG_USB_API_PUTS(
"\nUSBH_WaitForDeviceConnectionB(),"
2190 " buf NULL pointer" );
2191 EFM_ASSERT(
false );
2196 accumulatedTime = 0;
2197 USBH_attachRetryCount = 0;
2198 deadLine = timeoutInSeconds * 1000;
2204 if ( USBHHAL_InitializedAndPowered() )
2206 USBH_PortVbusOn(
false );
2208 accumulatedTime += PORT_VBUS_DELAY;
2214 accumulatedTime += 50;
2217 USBH_PortVbusOn(
true );
2218 DEBUG_USB_INT_LO_PUTCHAR(
'1' );
2220 accumulatedTime += PORT_VBUS_DELAY;
2224 USBHHAL_EnableInts();
2225 USBHAL_EnableGlobalInt();
2234 if ( ( deadLine ) &&
2235 ( accumulatedTime >= deadLine ) )
2240 #if ( USB_VBUSOVRCUR_PORT != USB_VBUSOVRCUR_PORT_NONE )
2241 if (
GPIO_PinInGet( USB_VBUSOVRCUR_PORT, USB_VBUSOVRCUR_PIN ) ==
2242 USB_VBUSOVRCUR_POLARITY )
2244 DEBUG_USB_INT_LO_PUTCHAR(
'~' );
2245 USBHHAL_PortReset(
false );
2246 USBHHAL_VbusOn(
false );
2248 USBH_portStatus = H_PORT_OVERCURRENT;
2254 accumulatedTime += 50;
2261 accumulatedTime += 100;
2276 accumulatedTime += DEFAULT_CTRL_TIMEOUT;
2285 accumulatedTime += PORT_VBUS_DELAY;
2287 if ( ( deadLine ) &&
2288 ( accumulatedTime >= deadLine ) )
2291 USBH_attachRetryCount = ( USBH_attachRetryCount + 1 ) %
2292 (
sizeof( USBH_attachTiming ) /
2293 sizeof( USBH_AttachTiming_TypeDef ) );
2336 USBH_Hc_TypeDef *hc = &hcs[ ep->
hcOut ];
2341 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), ep NULL pointer" );
2342 EFM_ASSERT(
false );
2348 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), No device connected" );
2352 if ( ( byteCount > MAX_XFER_LEN ) ||
2353 ( ( byteCount / ep->
packetSize ) > MAX_PACKETS_PR_XFER ) )
2355 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Illegal transfer size" );
2356 EFM_ASSERT(
false );
2360 if ( (uint32_t)data & 3 )
2362 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Misaligned data buffer" );
2363 EFM_ASSERT(
false );
2371 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Endpoint is busy" );
2378 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Illegal EP direction" );
2379 EFM_ASSERT(
false );
2386 DEBUG_USB_API_PUTS(
"\nUSBH_Write(), Host channel is busy" );
2400 hc->remaining = byteCount;
2414 timeout, hcTimeoutFunc[ ep->
hcOut ] );
2417 USBHHAL_HCInit( ep->
hcOut );
2418 USBHHAL_HCStart( ep->
hcOut );
2458 DEBUG_USB_API_PUTS(
"\nUSBH_WriteB() called with int's disabled" );
2459 EFM_ASSERT(
false );
2463 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
int USBH_WriteB(USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout)
Write data to device endpoint, blocking version.
#define SET_CONFIGURATION
#define CORE_IN_IRQ_CONTEXT()
int USBH_UnStallEpB(USBH_Ep_TypeDef *ep)
Reset stall state on a stalled (halted) endpoint.
uint8_t bInterfaceProtocol
#define CORE_DECLARE_IRQ_STATE
#define _USB_HC_TSIZ_XFERSIZE_MASK
#define _USB_HC_CHAR_EPNUM_SHIFT
#define USB_SETUP_DIR_D2H
void USBTIMER_Stop(uint32_t id)
Stop a timer.
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_GINTSTS_HCHINT
#define USB_STRING_DESCRIPTOR
#define USB_SETUP_RECIPIENT_ENDPOINT
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.
#define _USB_HC_CHAR_DEVADDR_SHIFT
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.
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.
#define USB_HC_CHAR_CHDIS
#define _USB_HC_TSIZ_PID_SHIFT
#define _USB_HC_TSIZ_PID_MASK
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_HC_CHAR_EPDIR
#define CMU_CMD_USBCCLKSEL_HFCLKNODIV
#define _USB_HC_TSIZ_XFERSIZE_SHIFT
void USBTIMER_DelayMs(uint32_t msec)
Active wait millisecond delay function. Can also be used inside interrupt handlers.
USB Interface Descriptor.
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.
#define _USB_HC_TSIZ_PKTCNT_MASK
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 CORE_ENTER_ATOMIC()
USB_Status_TypeDef xferStatus
#define USB_DEVICE_DESCRIPTOR
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 CORE_ATOMIC_SECTION(yourcode)
#define CMU_HFCORECLKEN0_USBC
#define USB_CONFIG_DESCSIZE
struct USBH_Device_TypeDef * parentDevice
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.
uint8_t bAlternateSetting
#define _USB_HC_CHAR_MPS_SHIFT
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
Core interrupt handling API.
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
#define CMU_HFCORECLKEN0_USB
USB_InterfaceDescriptor_TypeDef itfDesc
uint8_t bNumConfigurations
#define USB_SETUP_TYPE_STANDARD_MASK
#define CORE_IRQ_DISABLED()
#define CORE_EXIT_ATOMIC()
int USBH_WaitForDeviceConnectionB(uint8_t *buf, int timeoutInSeconds)
Wait for device connection.
#define USB_INTERFACE_DESCRIPTOR
#define USB_ENDPOINT_DESCSIZE
#define _USB_HC_CHAR_EPTYPE_SHIFT
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_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.
#define _USB_HC_TSIZ_PKTCNT_SHIFT
void USBTIMER_Init(void)
Activate the hardware timer used to pace the 1 millisecond timer system.
#define USB_HC_CHAR_LSPDDEV
#define SL_MIN(a, b)
Macro for getting minimum value. No sideeffects, a and b are evaluated once only. ...
USB Configuration Descriptor.
#define USB_CONFIG_DESCRIPTOR
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.
#define USB_SETUP_PKT_SIZE
#define USB_HC_CHAR_CHENA
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.
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.
#define _USB_HPRT_PRTSPD_SHIFT
USBH_EpState_TypeDef state