EFM32 Giant Gecko Software Documentation
efm32gg-doc-4.2.1
|
USB HOST protocol stack, see USB host stack library page for detailed documentation.
. More...
Data Structures | |
struct | USBH_Ep_TypeDef |
USB HOST endpoint status data. More... | |
struct | USBH_Device_TypeDef |
USB HOST device definition. More... | |
struct | USBH_Init_TypeDef |
USB Host stack initialization structure. More... | |
Macros | |
#define | USB_VBUSOVRCUR_PORT_NONE -1 |
#define | USB_VBUSOVRCUR_POLARITY_LOW 0 |
#define | USB_VBUSOVRCUR_POLARITY_HIGH 1 |
#define | USBH_INIT_DEFAULT |
Typedefs | |
typedef struct USBH_Device_TypeDef | USBH_Device_TypeDef |
USB HOST device definition. More... | |
Enumerations | |
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 | |
int | USBH_AssignHostChannel (USBH_Ep_TypeDef *ep, uint8_t hcnum) |
Assign a host channel to a given endpoint. More... | |
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. More... | |
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. More... | |
bool | USBH_DeviceConnected (void) |
Check if a device is connected. More... | |
int | USBH_GetConfigurationDescriptorB (USBH_Device_TypeDef *device, void *buf, int len, uint8_t configIndex) |
Read a configuration descriptor from a device. More... | |
int | USBH_GetDeviceDescriptorB (USBH_Device_TypeDef *device, void *buf, int len) |
Read a device descriptor from a device. More... | |
uint8_t | USBH_GetPortSpeed (void) |
Get the bus speed of the device attached to the USB port. More... | |
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. More... | |
int | USBH_Init (const USBH_Init_TypeDef *p) |
Initialize host protocol stack data structures. More... | |
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. More... | |
int | USBH_PortReset (void) |
Drive reset signalling on the USB port. More... | |
int | USBH_PortResume (void) |
Drive resume signalling on the USB port. More... | |
void | USBH_PortSuspend (void) |
Set the USB port in suspend mode. | |
void | USBH_PrintString (const char *pre, const USB_StringDescriptor_TypeDef *s, const char *post) |
Print a USB string descriptor on the debug serial port. More... | |
int | USBH_PrintConfigurationDescriptor (const USB_ConfigurationDescriptor_TypeDef *config, int maxLen) |
Pretty print a configuration descriptor on the debug serial port. More... | |
int | USBH_PrintDeviceDescriptor (const USB_DeviceDescriptor_TypeDef *device) |
Pretty print a device descriptor on the debug serial port. More... | |
int | USBH_PrintEndpointDescriptor (const USB_EndpointDescriptor_TypeDef *endpoint) |
Pretty print an endpoint descriptor on the debug serial port. More... | |
int | USBH_PrintInterfaceDescriptor (const USB_InterfaceDescriptor_TypeDef *interface) |
Pretty print an interface descriptor on the debug serial port. More... | |
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. More... | |
USB_ConfigurationDescriptor_TypeDef * | USBH_QGetConfigurationDescriptor (const uint8_t *buf, int configIndex) |
Return a pointer to a configuration descriptor. More... | |
USB_DeviceDescriptor_TypeDef * | USBH_QGetDeviceDescriptor (const uint8_t *buf) |
Return a pointer to the device descriptor. More... | |
USB_EndpointDescriptor_TypeDef * | USBH_QGetEndpointDescriptor (const uint8_t *buf, int configIndex, int interfaceIndex, int endpointIndex) |
Return a pointer to an endpoint descriptor. More... | |
USB_InterfaceDescriptor_TypeDef * | USBH_QGetInterfaceDescriptor (const uint8_t *buf, int configIndex, int interfaceIndex) |
Return a pointer to an interface descriptor. More... | |
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. More... | |
int | USBH_ReadB (USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout) |
Read data from device endpoint, blocking version. More... | |
int | USBH_SetAddressB (USBH_Device_TypeDef *device, uint8_t deviceAddress) |
Give a device an USB address. More... | |
int | USBH_SetAltInterfaceB (USBH_Device_TypeDef *device, uint8_t interfaceIndex, uint8_t alternateSetting) |
Activate a device interface within current device configuration. More... | |
int | USBH_SetConfigurationB (USBH_Device_TypeDef *device, uint8_t configValue) |
Activate a device configuration. More... | |
int | USBH_StallEpB (USBH_Ep_TypeDef *ep) |
Set an endpoint in the stalled (halted) state. More... | |
void | USBH_Stop (void) |
Stop USB host operation. More... | |
int | USBH_UnStallEpB (USBH_Ep_TypeDef *ep) |
Reset stall state on a stalled (halted) endpoint. More... | |
int | USBH_WaitForDeviceConnectionB (uint8_t *buf, int timeoutInSeconds) |
Wait for device connection. More... | |
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. More... | |
int | USBH_WriteB (USBH_Ep_TypeDef *ep, void *data, int byteCount, int timeout) |
Write data to device endpoint, blocking version. More... | |
#define USB_VBUSOVRCUR_PORT_NONE -1 |
#define USB_VBUSOVRCUR_POLARITY_LOW 0 |
#define USB_VBUSOVRCUR_POLARITY_HIGH 1 |
#define USBH_INIT_DEFAULT |
Default USBH_Init_TypeDef values, provides reasonable Tx/Rx FIFO partitioning.
typedef struct USBH_Device_TypeDef USBH_Device_TypeDef |
A host application should not manipulate the contents of this struct.
enum USBH_EpState_TypeDef |
USB HOST endpoint status enumerator.
int USBH_AssignHostChannel | ( | USBH_Ep_TypeDef * | ep, |
uint8_t | hcnum | ||
) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
[in] | hcnum | Host channel number (0..). |
After assigning a host channel to an endpoint, all subsequent transfers to the endpoint will use the given host channel. Several endpoints can be assigned to the same host channel, but keep in mind that concurrent transfers can only be performed on endpoints assigned to different host channels.
The default endpoint (EP0) is assigned to host channels 0 and 1 by the host stack.
Definition at line 160 of file em_usbh.c.
References USBH_Ep_TypeDef::addr, USB_EndpointDescriptor_TypeDef::bEndpointAddress, USB_EndpointDescriptor_TypeDef::bmAttributes, CONFIG_DESC_BM_TRANSFERTYPE, USBH_Ep_TypeDef::epDesc, H_EP_IDLE, USBH_Ep_TypeDef::hcIn, USBH_Ep_TypeDef::hcOut, USBH_Ep_TypeDef::in, USBH_Ep_TypeDef::packetSize, USBH_Ep_TypeDef::state, USBH_Ep_TypeDef::type, USB_SETUP_DIR_MASK, USB_STATUS_ILLEGAL, USB_STATUS_OK, and USB_EndpointDescriptor_TypeDef::wMaxPacketSize.
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 | ||
) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
[in] | bmRequestType | SETUP command request type. A suitable combination of values USB_SETUP_DIR_D2H, USB_SETUP_DIR_H2D, USB_SETUP_TYPE_STANDARD_MASK, USB_SETUP_TYPE_CLASS_MASK, USB_SETUP_TYPE_VENDOR_MASK, USB_SETUP_RECIPIENT_DEVICE, USB_SETUP_RECIPIENT_INTERFACE, USB_SETUP_RECIPIENT_ENDPOINT or USB_SETUP_RECIPIENT_OTHER. Refer to the USB specification for details. |
[in] | bRequest | A specific SETUP command request. |
[in] | wValue | Word sized field that varies according to request. |
[in] | wIndex | Word sized field that varies according to request. Typically used to pass an index or offset. |
[in] | wLength | Number of bytes to transfer if there is a data stage. |
[in] | data | Pointer to transfer data buffer. |
[in] | timeout | Transfer timeout in milliseconds. The transfer will be terminated if not completed within timeout milliseconds. A value of 0 means infinite. |
[in] | callback | Function to be called on transfer completion. Supply NULL if no callback is needed. See USB_XferCompleteCb_TypeDef. |
Definition at line 246 of file em_usbh.c.
References USB_Setup_TypeDef::bmRequestType, USB_Setup_TypeDef::bRequest, USBH_Ep_TypeDef::buf, H_EP_IDLE, H_EP_SETUP, USBH_Ep_TypeDef::hcIn, USBH_Ep_TypeDef::hcOut, INT_Disable(), INT_Enable(), USBH_Ep_TypeDef::setup, USBH_Ep_TypeDef::setupErrCnt, USBH_Ep_TypeDef::state, USBH_Ep_TypeDef::timeout, USB_STATUS_EP_BUSY, USB_STATUS_HC_BUSY, USB_STATUS_ILLEGAL, USB_STATUS_OK, USBH_DeviceConnected(), USBTIMER_Start(), USB_Setup_TypeDef::wIndex, USB_Setup_TypeDef::wLength, USB_Setup_TypeDef::wValue, USBH_Ep_TypeDef::xferCompleteCb, USBH_Ep_TypeDef::xferCompleted, and USBH_Ep_TypeDef::xferred.
Referenced by USBH_ControlMsgB().
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 | ||
) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
[in] | bmRequestType | SETUP command request type. A suitable combination of values USB_SETUP_DIR_D2H, USB_SETUP_DIR_H2D, USB_SETUP_TYPE_STANDARD_MASK, USB_SETUP_TYPE_CLASS_MASK, USB_SETUP_TYPE_VENDOR_MASK, USB_SETUP_RECIPIENT_DEVICE, USB_SETUP_RECIPIENT_INTERFACE, USB_SETUP_RECIPIENT_ENDPOINT or USB_SETUP_RECIPIENT_OTHER. Refer to the USB specification for details. |
[in] | bRequest | A specific SETUP command request. |
[in] | wValue | Word sized field that varies according to request. |
[in] | wIndex | Word sized field that varies according to request. Typically used to pass an index or offset. |
[in] | wLength | Number of bytes to transfer if there is a data stage. |
[in] | data | Pointer to transfer data buffer. |
[in] | timeout | Transfer timeout in milliseconds. The transfer will be terminated if not completed within timeout milliseconds. A value of 0 means infinite. |
Definition at line 367 of file em_usbh.c.
References INT_Disable(), INT_Enable(), USB_STATUS_ILLEGAL, USB_STATUS_OK, USBH_ControlMsg(), USBH_Ep_TypeDef::xferCompleted, USBH_Ep_TypeDef::xferred, and USBH_Ep_TypeDef::xferStatus.
Referenced by USBH_GetConfigurationDescriptorB(), USBH_GetDeviceDescriptorB(), USBH_GetStringB(), USBH_SetAddressB(), USBH_SetAltInterfaceB(), USBH_SetConfigurationB(), USBH_StallEpB(), and USBH_UnStallEpB().
bool USBH_DeviceConnected | ( | void | ) |
Definition at line 612 of file em_usbh.c.
Referenced by USBH_ControlMsg(), USBH_Read(), USBH_WaitForDeviceConnectionB(), and USBH_Write().
int USBH_GetConfigurationDescriptorB | ( | USBH_Device_TypeDef * | device, |
void * | buf, | ||
int | len, | ||
uint8_t | configIndex | ||
) |
[in] | device | Pointer to a USBH_Device_TypeDef data structure. |
[in] | buf | Pointer to transfer data buffer. |
[in] | len | The number of bytes to request, must not exceed transfer data buffer size. |
[in] | configIndex | Configuration index, a zero based number indicating which configuration to request. |
Definition at line 647 of file em_usbh.c.
References USBH_Device_TypeDef::ep0, GET_DESCRIPTOR, USB_CONFIG_DESCRIPTOR, USB_SETUP_DIR_D2H, USB_SETUP_RECIPIENT_DEVICE, USB_SETUP_TYPE_STANDARD_MASK, USB_STATUS_ILLEGAL, and USBH_ControlMsgB().
Referenced by USBH_QueryDeviceB().
int USBH_GetDeviceDescriptorB | ( | USBH_Device_TypeDef * | device, |
void * | buf, | ||
int | len | ||
) |
[in] | device | Pointer to a USBH_Device_TypeDef data structure. |
[in] | buf | Pointer to transfer data buffer. |
[in] | len | The number of bytes to request, must not exceed transfer data buffer size. |
Definition at line 704 of file em_usbh.c.
References USBH_Device_TypeDef::ep0, GET_DESCRIPTOR, USB_DEVICE_DESCRIPTOR, USB_SETUP_DIR_D2H, USB_SETUP_RECIPIENT_DEVICE, USB_SETUP_TYPE_STANDARD_MASK, USB_STATUS_ILLEGAL, and USBH_ControlMsgB().
Referenced by USBH_QueryDeviceB(), and USBH_WaitForDeviceConnectionB().
uint8_t USBH_GetPortSpeed | ( | void | ) |
Definition at line 741 of file em_usbh.c.
Referenced by MSDH_Init(), and USBH_WaitForDeviceConnectionB().
int USBH_GetStringB | ( | USBH_Device_TypeDef * | device, |
uint8_t * | buf, | ||
int | bufLen, | ||
uint8_t | stringIndex, | ||
uint16_t | langID | ||
) |
[in] | device | Pointer to a USBH_Device_TypeDef data structure. |
[in] | buf | Pointer to transfer data buffer. |
[in] | bufLen | Transfer data buffer size. |
[in] | stringIndex | String index, a zero based number indicating which string to request. |
[in] | langID | String language ID. |
Definition at line 779 of file em_usbh.c.
References EFM32_MIN, USBH_Device_TypeDef::ep0, GET_DESCRIPTOR, USB_StringDescriptor_TypeDef::len, USB_StringDescriptor_TypeDef::name, USB_SETUP_DIR_D2H, USB_SETUP_RECIPIENT_DEVICE, USB_SETUP_TYPE_STANDARD_MASK, USB_STATUS_ILLEGAL, USB_STRING_DESCRIPTOR, and USBH_ControlMsgB().
int USBH_Init | ( | const USBH_Init_TypeDef * | p | ) |
[in] | p | Pointer to initialization structure. See USBH_Init_TypeDef. |
Host stack internal data structures are initialized, no actions will be performed on the USB port. Use this function once before starting USB host operation. USB operation is initated with USBH_WaitForDeviceConnectionB().
Definition at line 837 of file em_usbh.c.
References CMU, CMU_ClockSelectSet(), CMU_CMD_USBCCLKSEL_HFCLKNODIV, CMU_HFCORECLKEN0_USB, CMU_HFCORECLKEN0_USBC, cmuClock_HF, cmuSelect_HFXO, INT_Disable(), INT_Enable(), USBH_Init_TypeDef::nptxFifoSize, USBH_Init_TypeDef::ptxFifoSize, USBH_Init_TypeDef::rxFifoSize, USB_IRQn, USB_STATUS_ILLEGAL, USB_STATUS_OK, and USBTIMER_Init().
int USBH_InitDeviceData | ( | USBH_Device_TypeDef * | device, |
const uint8_t * | buf, | ||
USBH_Ep_TypeDef * | ep, | ||
int | numEp, | ||
uint8_t | deviceSpeed | ||
) |
[in] | device | Pointer to a USBH_Device_TypeDef data structure. |
[in] | buf | A data buffer containing enumeration data retrieved with USBH_QueryDeviceB(). |
[in] | ep | Pointer to an array of USBH_Ep_TypeDef endpoint data structures. |
[in] | numEp | Number of elements in endpoint array. |
[in] | deviceSpeed | PORT_FULL_SPEED or PORT_LOW_SPEED. |
Use this function prior to moving a device out of default state. The application itself must allocate device and endpoint structures. Data from a prior call to USBH_QueryDeviceB() must be passed in input parameter buf. The device speed can be determined with USBH_GetPortSpeed() for devices directly attached to the USB port. Devices attached via a hub must retrieve this information by querying the hub.
Definition at line 905 of file em_usbh.c.
References USBH_Device_TypeDef::addr, USBH_Device_TypeDef::confDesc, USBH_Device_TypeDef::devDesc, USBH_Device_TypeDef::ep, USBH_Device_TypeDef::ep0, USBH_Ep_TypeDef::epDesc, USBH_Ep_TypeDef::hcIn, USBH_Ep_TypeDef::hcOut, USBH_Device_TypeDef::itfDesc, USBH_Device_TypeDef::numEp, USBH_Ep_TypeDef::packetSize, USBH_Ep_TypeDef::parentDevice, USBH_Device_TypeDef::speed, USBH_Ep_TypeDef::toggle, USBH_Ep_TypeDef::type, USB_CONFIG_DESCSIZE, USB_DEVICE_DESCSIZE, USB_ENDPOINT_DESCSIZE, USB_EPTYPE_CTRL, USB_INTERFACE_DESCSIZE, USB_STATUS_ILLEGAL, USB_STATUS_OK, USBH_QGetEndpointDescriptor(), and USBH_QGetInterfaceDescriptor().
Referenced by USBH_QueryDeviceB(), and USBH_WaitForDeviceConnectionB().
int USBH_PortReset | ( | void | ) |
Definition at line 982 of file em_usbh.c.
References INT_Disable(), INT_Enable(), USB_STATUS_ILLEGAL, USB_STATUS_OK, and USBTIMER_DelayMs().
int USBH_PortResume | ( | void | ) |
Definition at line 1012 of file em_usbh.c.
References INT_Disable(), INT_Enable(), USB_STATUS_ILLEGAL, USB_STATUS_OK, and USBTIMER_DelayMs().
void USBH_PrintString | ( | const char * | pre, |
const USB_StringDescriptor_TypeDef * | s, | ||
const char * | post | ||
) |
[in] | pre | Optional text string to prepend to the string descriptor. Pass NULL if not needed. |
[in] | s | Pointer to a USB_StringDescriptor_TypeDef data structure. |
[in] | post | Optional text string to append to the string descriptor. Pass NULL if not needed. |
Definition at line 1268 of file em_usbh.c.
References USB_StringDescriptor_TypeDef::name, USB_PUTCHAR(), and USB_PUTS().
int USBH_PrintConfigurationDescriptor | ( | const USB_ConfigurationDescriptor_TypeDef * | config, |
int | maxLen | ||
) |
[in] | config | Pointer to a USB_ConfigurationDescriptor_TypeDef data structure. |
[in] | maxLen | The size of the data buffer passed as input parameter config. |
Definition at line 1085 of file em_usbh.c.
References USB_ConfigurationDescriptor_TypeDef::bConfigurationValue, USB_ConfigurationDescriptor_TypeDef::bDescriptorType, USB_ConfigurationDescriptor_TypeDef::bLength, USB_ConfigurationDescriptor_TypeDef::bmAttributes, USB_ConfigurationDescriptor_TypeDef::bMaxPower, USB_ConfigurationDescriptor_TypeDef::bNumInterfaces, EFM32_MIN, USB_ConfigurationDescriptor_TypeDef::iConfiguration, USB_PRINTF(), USB_PUTCHAR(), USB_STATUS_ILLEGAL, USB_STATUS_OK, and USB_ConfigurationDescriptor_TypeDef::wTotalLength.
int USBH_PrintDeviceDescriptor | ( | const USB_DeviceDescriptor_TypeDef * | device | ) |
[in] | device | Pointer to a USB_DeviceDescriptor_TypeDef data structure. |
Definition at line 1142 of file em_usbh.c.
References USB_DeviceDescriptor_TypeDef::bcdDevice, USB_DeviceDescriptor_TypeDef::bcdUSB, USB_DeviceDescriptor_TypeDef::bDescriptorType, USB_DeviceDescriptor_TypeDef::bDeviceClass, USB_DeviceDescriptor_TypeDef::bDeviceProtocol, USB_DeviceDescriptor_TypeDef::bDeviceSubClass, USB_DeviceDescriptor_TypeDef::bLength, USB_DeviceDescriptor_TypeDef::bMaxPacketSize0, USB_DeviceDescriptor_TypeDef::bNumConfigurations, USB_DeviceDescriptor_TypeDef::idProduct, USB_DeviceDescriptor_TypeDef::idVendor, USB_DeviceDescriptor_TypeDef::iManufacturer, USB_DeviceDescriptor_TypeDef::iProduct, USB_DeviceDescriptor_TypeDef::iSerialNumber, USB_PRINTF(), USB_STATUS_ILLEGAL, and USB_STATUS_OK.
int USBH_PrintEndpointDescriptor | ( | const USB_EndpointDescriptor_TypeDef * | endpoint | ) |
[in] | endpoint | Pointer to a USB_EndpointDescriptor_TypeDef data structure. |
Definition at line 1184 of file em_usbh.c.
References USB_EndpointDescriptor_TypeDef::bDescriptorType, USB_EndpointDescriptor_TypeDef::bEndpointAddress, USB_EndpointDescriptor_TypeDef::bInterval, USB_EndpointDescriptor_TypeDef::bLength, USB_EndpointDescriptor_TypeDef::bmAttributes, USB_PRINTF(), USB_STATUS_ILLEGAL, USB_STATUS_OK, and USB_EndpointDescriptor_TypeDef::wMaxPacketSize.
int USBH_PrintInterfaceDescriptor | ( | const USB_InterfaceDescriptor_TypeDef * | interface | ) |
[in] | interface | Pointer to a USB_InterfaceDescriptor_TypeDef data structure. |
Definition at line 1219 of file em_usbh.c.
References USB_InterfaceDescriptor_TypeDef::bAlternateSetting, USB_InterfaceDescriptor_TypeDef::bDescriptorType, USB_InterfaceDescriptor_TypeDef::bInterfaceClass, USB_InterfaceDescriptor_TypeDef::bInterfaceNumber, USB_InterfaceDescriptor_TypeDef::bInterfaceProtocol, USB_InterfaceDescriptor_TypeDef::bInterfaceSubClass, USB_InterfaceDescriptor_TypeDef::bLength, USB_InterfaceDescriptor_TypeDef::bNumEndpoints, USB_InterfaceDescriptor_TypeDef::iInterface, USB_PRINTF(), USB_STATUS_ILLEGAL, and USB_STATUS_OK.
int USBH_QueryDeviceB | ( | uint8_t * | buf, |
size_t | bufsize, | ||
uint8_t | deviceSpeed | ||
) |
[in] | buf | A data buffer with sufficent space for the descriptors. The data buffer size must be sizeof( USBH_Device_TypeDef ) + the anticipated maximum size of the entire configuration descriptor. |
[in] | bufsize | The size of the data buffer. |
[in] | deviceSpeed | PORT_FULL_SPEED or PORT_LOW_SPEED. |
The device speed can be determined with USBH_GetPortSpeed() for devices directly attached to the USB port. Devices attached via a hub must retrieve this information by querying the hub.
Definition at line 1582 of file em_usbh.c.
References USB_DeviceDescriptor_TypeDef::bMaxPacketSize0, USBH_Device_TypeDef::confDesc, USBH_Device_TypeDef::devDesc, EFM32_MIN, USBH_Device_TypeDef::ep, USBH_Device_TypeDef::ep0, USBH_Ep_TypeDef::packetSize, USBH_Device_TypeDef::speed, USB_CONFIG_DESCSIZE, USB_DEVICE_DESCSIZE, USB_INTERFACE_DESCSIZE, USB_STATUS_OK, USB_STATUS_REQ_ERR, USBH_GetConfigurationDescriptorB(), USBH_GetDeviceDescriptorB(), USBH_InitDeviceData(), and USB_ConfigurationDescriptor_TypeDef::wTotalLength.
Referenced by MSDH_Init().
USB_ConfigurationDescriptor_TypeDef* USBH_QGetConfigurationDescriptor | ( | const uint8_t * | buf, |
int | configIndex | ||
) |
[in] | buf | A data buffer containing enumeration data retrieved with USBH_QueryDeviceB(). |
[in] | configIndex | Configuration index, a zero based number indicating which configuration descriptor to find. |
Definition at line 1331 of file em_usbh.c.
References EFM32_MIN, USB_CONFIG_DESCRIPTOR, USB_CONFIG_DESCSIZE, and USBH_QGetDeviceDescriptor().
Referenced by USBH_QGetInterfaceDescriptor().
USB_DeviceDescriptor_TypeDef* USBH_QGetDeviceDescriptor | ( | const uint8_t * | buf | ) |
[in] | buf | A data buffer containing enumeration data retrieved with USBH_QueryDeviceB(). |
Definition at line 1387 of file em_usbh.c.
References USB_DeviceDescriptor_TypeDef::bDescriptorType, USB_DeviceDescriptor_TypeDef::bLength, USB_DEVICE_DESCRIPTOR, and USB_DEVICE_DESCSIZE.
Referenced by USBH_QGetConfigurationDescriptor().
USB_EndpointDescriptor_TypeDef* USBH_QGetEndpointDescriptor | ( | const uint8_t * | buf, |
int | configIndex, | ||
int | interfaceIndex, | ||
int | endpointIndex | ||
) |
[in] | buf | A data buffer containing enumeration data retrieved with USBH_QueryDeviceB(). |
[in] | configIndex | Configuration index, a zero based number indicating in which configuration descriptor to look for the interface containing the endpoint descriptor. |
[in] | interfaceIndex | Interface index, a zero based number indicating the interface descriptor to look for the correct endpoint descriptor in. |
[in] | endpointIndex | Endpoint index, a zero based number indicating which endpoint descriptor to look for. |
Definition at line 1434 of file em_usbh.c.
References USB_ENDPOINT_DESCRIPTOR, USB_ENDPOINT_DESCSIZE, USB_INTERFACE_DESCSIZE, and USBH_QGetInterfaceDescriptor().
Referenced by USBH_InitDeviceData().
USB_InterfaceDescriptor_TypeDef* USBH_QGetInterfaceDescriptor | ( | const uint8_t * | buf, |
int | configIndex, | ||
int | interfaceIndex | ||
) |
[in] | buf | A data buffer containing enumeration data retrieved with USBH_QueryDeviceB(). |
[in] | configIndex | Configuration index, a zero based number indicating in which configuration descriptor to look for the interface descriptor. |
[in] | interfaceIndex | Interface index, a zero based number indicating which interface descriptor to find. |
Definition at line 1506 of file em_usbh.c.
References USB_CONFIG_DESCSIZE, USB_INTERFACE_DESCRIPTOR, USB_INTERFACE_DESCSIZE, and USBH_QGetConfigurationDescriptor().
Referenced by USBH_InitDeviceData(), and USBH_QGetEndpointDescriptor().
int USBH_Read | ( | USBH_Ep_TypeDef * | ep, |
void * | data, | ||
int | byteCount, | ||
int | timeout, | ||
USB_XferCompleteCb_TypeDef | callback | ||
) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
[in] | data | Pointer to transfer data buffer. |
[in] | byteCount | Number of bytes to transfer (zero is a valid value). |
[in] | timeout | Transfer timeout in milliseconds. The transfer will be terminated if not completed within timeout milliseconds. A value of 0 means infinite. |
[in] | callback | Function to be called on transfer completion. Supply NULL if no callback is needed. See USB_XferCompleteCb_TypeDef. |
Definition at line 1672 of file em_usbh.c.
References USB_EndpointDescriptor_TypeDef::bInterval, USBH_Ep_TypeDef::buf, EFM32_MIN, USBH_Ep_TypeDef::epDesc, H_EP_DATA_IN, H_EP_IDLE, USBH_Ep_TypeDef::hcIn, USBH_Ep_TypeDef::in, INT_Disable(), INT_Enable(), USBH_Ep_TypeDef::packetSize, USBH_Ep_TypeDef::remaining, USBH_Ep_TypeDef::state, USBH_Ep_TypeDef::timeout, USBH_Ep_TypeDef::type, USB_EPTYPE_INTR, USB_STATUS_EP_BUSY, USB_STATUS_HC_BUSY, USB_STATUS_ILLEGAL, USB_STATUS_OK, USBH_DeviceConnected(), USBTIMER_Start(), USBH_Ep_TypeDef::xferCompleteCb, USBH_Ep_TypeDef::xferCompleted, and USBH_Ep_TypeDef::xferred.
Referenced by USBH_ReadB().
int USBH_ReadB | ( | USBH_Ep_TypeDef * | ep, |
void * | data, | ||
int | byteCount, | ||
int | timeout | ||
) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
[in] | data | Pointer to transfer data buffer. |
[in] | byteCount | Number of bytes to transfer (zero is a valid value). |
[in] | timeout | Transfer timeout in milliseconds. The transfer will be terminated if not completed within timeout milliseconds. A value of 0 means infinite. |
Definition at line 1794 of file em_usbh.c.
References INT_Disable(), INT_Enable(), USB_STATUS_ILLEGAL, USB_STATUS_OK, USBH_Read(), USBH_Ep_TypeDef::xferCompleted, USBH_Ep_TypeDef::xferred, and USBH_Ep_TypeDef::xferStatus.
Referenced by MSDBOT_Xfer().
int USBH_SetAddressB | ( | USBH_Device_TypeDef * | device, |
uint8_t | deviceAddress | ||
) |
[in] | device | Pointer to a USBH_Device_TypeDef data structure. |
[in] | deviceAddress | The new device address. Provide a value between 0 and 127. |
Definition at line 1841 of file em_usbh.c.
References USBH_Device_TypeDef::addr, USBH_Device_TypeDef::ep0, SET_ADDRESS, USB_MAX_DEVICE_ADDRESS, USB_SETUP_DIR_H2D, USB_SETUP_RECIPIENT_DEVICE, USB_SETUP_TYPE_STANDARD_MASK, USB_STATUS_ILLEGAL, USB_STATUS_OK, and USBH_ControlMsgB().
int USBH_SetAltInterfaceB | ( | USBH_Device_TypeDef * | device, |
uint8_t | interfaceIndex, | ||
uint8_t | alternateSetting | ||
) |
[in] | device | Pointer to a USBH_Device_TypeDef data structure. |
[in] | interfaceIndex | The interface index. A zero based value. |
[in] | alternateSetting | The alternate interface setting value. |
Definition at line 1897 of file em_usbh.c.
References USBH_Device_TypeDef::ep, USBH_Device_TypeDef::ep0, USBH_Device_TypeDef::numEp, SET_INTERFACE, USBH_Ep_TypeDef::toggle, USB_SETUP_DIR_H2D, USB_SETUP_RECIPIENT_INTERFACE, USB_SETUP_TYPE_STANDARD_MASK, USB_STATUS_ILLEGAL, USB_STATUS_OK, and USBH_ControlMsgB().
int USBH_SetConfigurationB | ( | USBH_Device_TypeDef * | device, |
uint8_t | configValue | ||
) |
[in] | device | Pointer to a USBH_Device_TypeDef data structure. |
[in] | configValue | The configuration value. The value can be retrieved from device->confDesc.bConfigurationValue |
Definition at line 1956 of file em_usbh.c.
References USBH_Device_TypeDef::ep, USBH_Device_TypeDef::ep0, USBH_Device_TypeDef::numEp, SET_CONFIGURATION, USBH_Ep_TypeDef::toggle, USB_SETUP_DIR_H2D, USB_SETUP_RECIPIENT_DEVICE, USB_SETUP_TYPE_STANDARD_MASK, USB_STATUS_ILLEGAL, USB_STATUS_OK, and USBH_ControlMsgB().
int USBH_StallEpB | ( | USBH_Ep_TypeDef * | ep | ) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
Definition at line 2009 of file em_usbh.c.
References USBH_Ep_TypeDef::addr, USBH_Device_TypeDef::ep0, USBH_Ep_TypeDef::parentDevice, SET_FEATURE, USB_FEATURE_ENDPOINT_HALT, USB_SETUP_DIR_H2D, USB_SETUP_RECIPIENT_ENDPOINT, USB_SETUP_TYPE_STANDARD_MASK, USB_STATUS_ILLEGAL, and USBH_ControlMsgB().
void USBH_Stop | ( | void | ) |
USB host operation is terminated and VBUS on the port is turned off.
Definition at line 2036 of file em_usbh.c.
References CMU, CMU_HFCORECLKEN0_USB, CMU_HFCORECLKEN0_USBC, INT_Disable(), INT_Enable(), and USBTIMER_Stop().
Referenced by USBH_WaitForDeviceConnectionB().
int USBH_UnStallEpB | ( | USBH_Ep_TypeDef * | ep | ) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
Definition at line 2068 of file em_usbh.c.
References USBH_Ep_TypeDef::addr, CLEAR_FEATURE, USBH_Device_TypeDef::ep0, USBH_Ep_TypeDef::parentDevice, USBH_Ep_TypeDef::toggle, USB_FEATURE_ENDPOINT_HALT, USB_SETUP_DIR_H2D, USB_SETUP_RECIPIENT_ENDPOINT, USB_SETUP_TYPE_STANDARD_MASK, USB_STATUS_ILLEGAL, USB_STATUS_OK, and USBH_ControlMsgB().
Referenced by MSDBOT_Xfer().
int USBH_WaitForDeviceConnectionB | ( | uint8_t * | buf, |
int | timeoutInSeconds | ||
) |
This function will wait for device connection and try to read the 8 first bytes of the device descriptor.
First the USB peripheral is initializet (reset) and VBUS is turned on. When a device is connected, an USB reset will be signalled on the USB port, and then a USB GetDescriptor command is performed.
This procedure is repeated until success or timeout. On each iteration the duration of USB reset signalling is varied.
[in] | buf | A data buffer with sufficent space for retrieving the first 8 bytes of a device descriptor. The data buffer size must be sizeof( USBH_Device_TypeDef ) + 8. |
[in] | timeoutInSeconds | Timeout in seconds. A value of 0 means infinite. |
Definition at line 2146 of file em_usbh.c.
References CMU, CMU_HFCORECLKEN0_USB, CMU_HFCORECLKEN0_USBC, USBH_Device_TypeDef::devDesc, GPIO_PinInGet(), INT_Disable(), INT_Enable(), USB_STATUS_DEVICE_MALFUNCTION, USB_STATUS_ILLEGAL, USB_STATUS_OK, USB_STATUS_PORT_OVERCURRENT, USB_STATUS_TIMEOUT, USBH_DeviceConnected(), USBH_GetDeviceDescriptorB(), USBH_GetPortSpeed(), USBH_InitDeviceData(), USBH_Stop(), USBTIMER_DelayMs(), and USBTIMER_Stop().
int USBH_Write | ( | USBH_Ep_TypeDef * | ep, |
void * | data, | ||
int | byteCount, | ||
int | timeout, | ||
USB_XferCompleteCb_TypeDef | callback | ||
) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
[in] | data | Pointer to transfer data buffer. |
[in] | byteCount | Number of bytes to transfer (zero is a valid value). |
[in] | timeout | Transfer timeout in milliseconds. The transfer will be terminated if not completed within timeout milliseconds. A value of 0 means infinite. |
[in] | callback | Function to be called on transfer completion. Supply NULL if no callback is needed. See USB_XferCompleteCb_TypeDef. |
Definition at line 2297 of file em_usbh.c.
References USB_EndpointDescriptor_TypeDef::bInterval, USBH_Ep_TypeDef::buf, EFM32_MIN, USBH_Ep_TypeDef::epDesc, H_EP_DATA_OUT, H_EP_IDLE, USBH_Ep_TypeDef::hcOut, USBH_Ep_TypeDef::in, INT_Disable(), INT_Enable(), USBH_Ep_TypeDef::packetSize, USBH_Ep_TypeDef::remaining, USBH_Ep_TypeDef::state, USBH_Ep_TypeDef::timeout, USBH_Ep_TypeDef::type, USB_EPTYPE_INTR, USB_STATUS_EP_BUSY, USB_STATUS_HC_BUSY, USB_STATUS_ILLEGAL, USB_STATUS_OK, USBH_DeviceConnected(), USBTIMER_Start(), USBH_Ep_TypeDef::xferCompleteCb, USBH_Ep_TypeDef::xferCompleted, and USBH_Ep_TypeDef::xferred.
Referenced by USBH_WriteB().
int USBH_WriteB | ( | USBH_Ep_TypeDef * | ep, |
void * | data, | ||
int | byteCount, | ||
int | timeout | ||
) |
[in] | ep | Pointer to a USBH_Ep_TypeDef data structure. |
[in] | data | Pointer to transfer data buffer. |
[in] | byteCount | Number of bytes to transfer (zero is a valid value). |
[in] | timeout | Transfer timeout in milliseconds. The transfer will be terminated if not completed within timeout milliseconds. A value of 0 means infinite. |
Definition at line 2417 of file em_usbh.c.
References INT_Disable(), INT_Enable(), USB_STATUS_ILLEGAL, USB_STATUS_OK, USBH_Write(), USBH_Ep_TypeDef::xferCompleted, USBH_Ep_TypeDef::xferred, and USBH_Ep_TypeDef::xferStatus.
Referenced by MSDBOT_Xfer().