Update USB licenses and format code

Update USB licenses from MIT to Apache 2 and run astyle on the code.
feature-hal-spec-usb-device
Russ Butler 2018-02-26 09:32:14 -06:00
parent 61a575af23
commit 14b0c313ed
4 changed files with 285 additions and 347 deletions

View File

@ -1,20 +1,18 @@
/* Copyright (c) 2010-2011 mbed.org, MIT License /* mbed Microcontroller Library
* * Copyright (c) 2018-2018 ARM Limited
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software *
* and associated documentation files (the "Software"), to deal in the Software without * Licensed under the Apache License, Version 2.0 (the "License");
* restriction, including without limitation the rights to use, copy, modify, merge, publish, * you may not use this file except in compliance with the License.
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * You may obtain a copy of the License at
* Software is furnished to do so, subject to the following conditions: *
* * http://www.apache.org/licenses/LICENSE-2.0
* The above copyright notice and this permission notice shall be included in all copies or *
* substantial portions of the Software. * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * See the License for the specific language governing permissions and
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * limitations under the License.
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* Standard descriptor types */ /* Standard descriptor types */
#define DEVICE_DESCRIPTOR (1) #define DEVICE_DESCRIPTOR (1)

View File

@ -1,20 +1,18 @@
/* Copyright (c) 2010-2011 mbed.org, MIT License /* mbed Microcontroller Library
* * Copyright (c) 2018-2018 ARM Limited
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software *
* and associated documentation files (the "Software"), to deal in the Software without * Licensed under the Apache License, Version 2.0 (the "License");
* restriction, including without limitation the rights to use, copy, modify, merge, publish, * you may not use this file except in compliance with the License.
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * You may obtain a copy of the License at
* Software is furnished to do so, subject to the following conditions: *
* * http://www.apache.org/licenses/LICENSE-2.0
* The above copyright notice and this permission notice shall be included in all copies or *
* substantial portions of the Software. * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * See the License for the specific language governing permissions and
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * limitations under the License.
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "stdint.h" #include "stdint.h"
@ -46,38 +44,33 @@ bool USBDevice::requestGetDescriptor(void)
#ifdef DEBUG #ifdef DEBUG
printf("get descr: type: %d\r\n", DESCRIPTOR_TYPE(transfer.setup.wValue)); printf("get descr: type: %d\r\n", DESCRIPTOR_TYPE(transfer.setup.wValue));
#endif #endif
switch (DESCRIPTOR_TYPE(transfer.setup.wValue)) switch (DESCRIPTOR_TYPE(transfer.setup.wValue)) {
{
case DEVICE_DESCRIPTOR: case DEVICE_DESCRIPTOR:
if (deviceDesc() != NULL) if (deviceDesc() != NULL) {
{
if ((deviceDesc()[0] == DEVICE_DESCRIPTOR_LENGTH) \ if ((deviceDesc()[0] == DEVICE_DESCRIPTOR_LENGTH) \
&& (deviceDesc()[1] == DEVICE_DESCRIPTOR)) && (deviceDesc()[1] == DEVICE_DESCRIPTOR)) {
{
#ifdef DEBUG #ifdef DEBUG
printf("device descr\r\n"); printf("device descr\r\n");
#endif #endif
transfer.remaining = DEVICE_DESCRIPTOR_LENGTH; transfer.remaining = DEVICE_DESCRIPTOR_LENGTH;
transfer.ptr = (uint8_t*)deviceDesc(); transfer.ptr = (uint8_t *)deviceDesc();
transfer.direction = DEVICE_TO_HOST; transfer.direction = DEVICE_TO_HOST;
success = true; success = true;
} }
} }
break; break;
case CONFIGURATION_DESCRIPTOR: case CONFIGURATION_DESCRIPTOR:
if (configurationDesc() != NULL) if (configurationDesc() != NULL) {
{
if ((configurationDesc()[0] == CONFIGURATION_DESCRIPTOR_LENGTH) \ if ((configurationDesc()[0] == CONFIGURATION_DESCRIPTOR_LENGTH) \
&& (configurationDesc()[1] == CONFIGURATION_DESCRIPTOR)) && (configurationDesc()[1] == CONFIGURATION_DESCRIPTOR)) {
{
#ifdef DEBUG #ifdef DEBUG
printf("conf descr request\r\n"); printf("conf descr request\r\n");
#endif #endif
/* Get wTotalLength */ /* Get wTotalLength */
transfer.remaining = configurationDesc()[2] \ transfer.remaining = configurationDesc()[2] \
| (configurationDesc()[3] << 8); | (configurationDesc()[3] << 8);
transfer.ptr = (uint8_t*)configurationDesc(); transfer.ptr = (uint8_t *)configurationDesc();
transfer.direction = DEVICE_TO_HOST; transfer.direction = DEVICE_TO_HOST;
success = true; success = true;
} }
@ -87,62 +80,61 @@ bool USBDevice::requestGetDescriptor(void)
#ifdef DEBUG #ifdef DEBUG
printf("str descriptor\r\n"); printf("str descriptor\r\n");
#endif #endif
switch (DESCRIPTOR_INDEX(transfer.setup.wValue)) switch (DESCRIPTOR_INDEX(transfer.setup.wValue)) {
{ case STRING_OFFSET_LANGID:
case STRING_OFFSET_LANGID:
#ifdef DEBUG #ifdef DEBUG
printf("1\r\n"); printf("1\r\n");
#endif #endif
transfer.remaining = stringLangidDesc()[0]; transfer.remaining = stringLangidDesc()[0];
transfer.ptr = (uint8_t*)stringLangidDesc(); transfer.ptr = (uint8_t *)stringLangidDesc();
transfer.direction = DEVICE_TO_HOST; transfer.direction = DEVICE_TO_HOST;
success = true; success = true;
break; break;
case STRING_OFFSET_IMANUFACTURER: case STRING_OFFSET_IMANUFACTURER:
#ifdef DEBUG #ifdef DEBUG
printf("2\r\n"); printf("2\r\n");
#endif #endif
transfer.remaining = stringImanufacturerDesc()[0]; transfer.remaining = stringImanufacturerDesc()[0];
transfer.ptr = (uint8_t*)stringImanufacturerDesc(); transfer.ptr = (uint8_t *)stringImanufacturerDesc();
transfer.direction = DEVICE_TO_HOST; transfer.direction = DEVICE_TO_HOST;
success = true; success = true;
break; break;
case STRING_OFFSET_IPRODUCT: case STRING_OFFSET_IPRODUCT:
#ifdef DEBUG #ifdef DEBUG
printf("3\r\n"); printf("3\r\n");
#endif #endif
transfer.remaining = stringIproductDesc()[0]; transfer.remaining = stringIproductDesc()[0];
transfer.ptr = (uint8_t*)stringIproductDesc(); transfer.ptr = (uint8_t *)stringIproductDesc();
transfer.direction = DEVICE_TO_HOST; transfer.direction = DEVICE_TO_HOST;
success = true; success = true;
break; break;
case STRING_OFFSET_ISERIAL: case STRING_OFFSET_ISERIAL:
#ifdef DEBUG #ifdef DEBUG
printf("4\r\n"); printf("4\r\n");
#endif #endif
transfer.remaining = stringIserialDesc()[0]; transfer.remaining = stringIserialDesc()[0];
transfer.ptr = (uint8_t*)stringIserialDesc(); transfer.ptr = (uint8_t *)stringIserialDesc();
transfer.direction = DEVICE_TO_HOST; transfer.direction = DEVICE_TO_HOST;
success = true; success = true;
break; break;
case STRING_OFFSET_ICONFIGURATION: case STRING_OFFSET_ICONFIGURATION:
#ifdef DEBUG #ifdef DEBUG
printf("5\r\n"); printf("5\r\n");
#endif #endif
transfer.remaining = stringIConfigurationDesc()[0]; transfer.remaining = stringIConfigurationDesc()[0];
transfer.ptr = (uint8_t*)stringIConfigurationDesc(); transfer.ptr = (uint8_t *)stringIConfigurationDesc();
transfer.direction = DEVICE_TO_HOST; transfer.direction = DEVICE_TO_HOST;
success = true; success = true;
break; break;
case STRING_OFFSET_IINTERFACE: case STRING_OFFSET_IINTERFACE:
#ifdef DEBUG #ifdef DEBUG
printf("6\r\n"); printf("6\r\n");
#endif #endif
transfer.remaining = stringIinterfaceDesc()[0]; transfer.remaining = stringIinterfaceDesc()[0];
transfer.ptr = (uint8_t*)stringIinterfaceDesc(); transfer.ptr = (uint8_t *)stringIinterfaceDesc();
transfer.direction = DEVICE_TO_HOST; transfer.direction = DEVICE_TO_HOST;
success = true; success = true;
break; break;
} }
break; break;
case INTERFACE_DESCRIPTOR: case INTERFACE_DESCRIPTOR:
@ -185,18 +177,16 @@ bool USBDevice::controlOut(void)
uint32_t packetSize; uint32_t packetSize;
/* Check we should be transferring data OUT */ /* Check we should be transferring data OUT */
if (transfer.direction != HOST_TO_DEVICE) if (transfer.direction != HOST_TO_DEVICE) {
{ /* for other platforms, count on the HAL to handle this case */
/* for other platforms, count on the HAL to handle this case */ return false;
return false;
} }
/* Read from endpoint */ /* Read from endpoint */
packetSize = EP0getReadResult(buffer); packetSize = EP0getReadResult(buffer);
/* Check if transfer size is valid */ /* Check if transfer size is valid */
if (packetSize > transfer.remaining) if (packetSize > transfer.remaining) {
{
/* Too big */ /* Too big */
return false; return false;
} }
@ -206,20 +196,16 @@ bool USBDevice::controlOut(void)
transfer.remaining -= packetSize; transfer.remaining -= packetSize;
/* Check if transfer has completed */ /* Check if transfer has completed */
if (transfer.remaining == 0) if (transfer.remaining == 0) {
{
/* Transfer completed */ /* Transfer completed */
if (transfer.notify) if (transfer.notify) {
{
/* Notify class layer. */ /* Notify class layer. */
USBCallback_requestCompleted(buffer, packetSize); USBCallback_requestCompleted(buffer, packetSize);
transfer.notify = false; transfer.notify = false;
} }
/* Status stage */ /* Status stage */
EP0write(NULL, 0); EP0write(NULL, 0);
} } else {
else
{
EP0read(); EP0read();
} }
@ -233,18 +219,15 @@ bool USBDevice::controlIn(void)
/* Check if transfer has completed (status stage transactions */ /* Check if transfer has completed (status stage transactions */
/* also have transfer.remaining == 0) */ /* also have transfer.remaining == 0) */
if (transfer.remaining == 0) if (transfer.remaining == 0) {
{ if (transfer.zlp) {
if (transfer.zlp)
{
/* Send zero length packet */ /* Send zero length packet */
EP0write(NULL, 0); EP0write(NULL, 0);
transfer.zlp = false; transfer.zlp = false;
} }
/* Transfer completed */ /* Transfer completed */
if (transfer.notify) if (transfer.notify) {
{
/* Notify class layer. */ /* Notify class layer. */
USBCallback_requestCompleted(NULL, 0); USBCallback_requestCompleted(NULL, 0);
transfer.notify = false; transfer.notify = false;
@ -258,15 +241,13 @@ bool USBDevice::controlIn(void)
} }
/* Check we should be transferring data IN */ /* Check we should be transferring data IN */
if (transfer.direction != DEVICE_TO_HOST) if (transfer.direction != DEVICE_TO_HOST) {
{
return false; return false;
} }
packetSize = transfer.remaining; packetSize = transfer.remaining;
if (packetSize > MAX_PACKET_SIZE_EP0) if (packetSize > MAX_PACKET_SIZE_EP0) {
{
packetSize = MAX_PACKET_SIZE_EP0; packetSize = MAX_PACKET_SIZE_EP0;
} }
@ -285,12 +266,9 @@ bool USBDevice::requestSetAddress(void)
/* Set the device address */ /* Set the device address */
setAddress(transfer.setup.wValue); setAddress(transfer.setup.wValue);
if (transfer.setup.wValue == 0) if (transfer.setup.wValue == 0) {
{
device.state = DEFAULT; device.state = DEFAULT;
} } else {
else
{
device.state = ADDRESS; device.state = ADDRESS;
} }
@ -302,22 +280,16 @@ bool USBDevice::requestSetConfiguration(void)
device.configuration = transfer.setup.wValue; device.configuration = transfer.setup.wValue;
/* Set the device configuration */ /* Set the device configuration */
if (device.configuration == 0) if (device.configuration == 0) {
{
/* Not configured */ /* Not configured */
unconfigureDevice(); unconfigureDevice();
device.state = ADDRESS; device.state = ADDRESS;
} } else {
else if (USBCallback_setConfiguration(device.configuration)) {
{
if (USBCallback_setConfiguration(device.configuration))
{
/* Valid configuration */ /* Valid configuration */
configureDevice(); configureDevice();
device.state = CONFIGURED; device.state = CONFIGURED;
} } else {
else
{
return false; return false;
} }
} }
@ -338,8 +310,7 @@ bool USBDevice::requestGetInterface(void)
{ {
/* Return the selected alternate setting for an interface */ /* Return the selected alternate setting for an interface */
if (device.state != CONFIGURED) if (device.state != CONFIGURED) {
{
return false; return false;
} }
@ -354,8 +325,7 @@ bool USBDevice::requestGetInterface(void)
bool USBDevice::requestSetInterface(void) bool USBDevice::requestSetInterface(void)
{ {
bool success = false; bool success = false;
if(USBCallback_setInterface(transfer.setup.wIndex, transfer.setup.wValue)) if (USBCallback_setInterface(transfer.setup.wIndex, transfer.setup.wValue)) {
{
success = true; success = true;
currentInterface = transfer.setup.wIndex; currentInterface = transfer.setup.wIndex;
currentAlternate = transfer.setup.wValue; currentAlternate = transfer.setup.wValue;
@ -367,23 +337,19 @@ bool USBDevice::requestSetFeature()
{ {
bool success = false; bool success = false;
if (device.state != CONFIGURED) if (device.state != CONFIGURED) {
{
/* Endpoint or interface must be zero */ /* Endpoint or interface must be zero */
if (transfer.setup.wIndex != 0) if (transfer.setup.wIndex != 0) {
{
return false; return false;
} }
} }
switch (transfer.setup.bmRequestType.Recipient) switch (transfer.setup.bmRequestType.Recipient) {
{
case DEVICE_RECIPIENT: case DEVICE_RECIPIENT:
/* TODO: Remote wakeup feature not supported */ /* TODO: Remote wakeup feature not supported */
break; break;
case ENDPOINT_RECIPIENT: case ENDPOINT_RECIPIENT:
if (transfer.setup.wValue == ENDPOINT_HALT) if (transfer.setup.wValue == ENDPOINT_HALT) {
{
/* TODO: We should check that the endpoint number is valid */ /* TODO: We should check that the endpoint number is valid */
stallEndpoint( stallEndpoint(
WINDEX_TO_PHYSICAL(transfer.setup.wIndex)); WINDEX_TO_PHYSICAL(transfer.setup.wIndex));
@ -401,25 +367,21 @@ bool USBDevice::requestClearFeature()
{ {
bool success = false; bool success = false;
if (device.state != CONFIGURED) if (device.state != CONFIGURED) {
{
/* Endpoint or interface must be zero */ /* Endpoint or interface must be zero */
if (transfer.setup.wIndex != 0) if (transfer.setup.wIndex != 0) {
{
return false; return false;
} }
} }
switch (transfer.setup.bmRequestType.Recipient) switch (transfer.setup.bmRequestType.Recipient) {
{
case DEVICE_RECIPIENT: case DEVICE_RECIPIENT:
/* TODO: Remote wakeup feature not supported */ /* TODO: Remote wakeup feature not supported */
break; break;
case ENDPOINT_RECIPIENT: case ENDPOINT_RECIPIENT:
/* TODO: We should check that the endpoint number is valid */ /* TODO: We should check that the endpoint number is valid */
if (transfer.setup.wValue == ENDPOINT_HALT) if (transfer.setup.wValue == ENDPOINT_HALT) {
{ unstallEndpoint(WINDEX_TO_PHYSICAL(transfer.setup.wIndex));
unstallEndpoint( WINDEX_TO_PHYSICAL(transfer.setup.wIndex));
success = true; success = true;
} }
break; break;
@ -435,17 +397,14 @@ bool USBDevice::requestGetStatus(void)
static uint16_t status; static uint16_t status;
bool success = false; bool success = false;
if (device.state != CONFIGURED) if (device.state != CONFIGURED) {
{
/* Endpoint or interface must be zero */ /* Endpoint or interface must be zero */
if (transfer.setup.wIndex != 0) if (transfer.setup.wIndex != 0) {
{
return false; return false;
} }
} }
switch (transfer.setup.bmRequestType.Recipient) switch (transfer.setup.bmRequestType.Recipient) {
{
case DEVICE_RECIPIENT: case DEVICE_RECIPIENT:
/* TODO: Currently only supports self powered devices */ /* TODO: Currently only supports self powered devices */
status = DEVICE_STATUS_SELF_POWERED; status = DEVICE_STATUS_SELF_POWERED;
@ -458,12 +417,9 @@ bool USBDevice::requestGetStatus(void)
case ENDPOINT_RECIPIENT: case ENDPOINT_RECIPIENT:
/* TODO: We should check that the endpoint number is valid */ /* TODO: We should check that the endpoint number is valid */
if (getEndpointStallState( if (getEndpointStallState(
WINDEX_TO_PHYSICAL(transfer.setup.wIndex))) WINDEX_TO_PHYSICAL(transfer.setup.wIndex))) {
{
status = ENDPOINT_STATUS_HALT; status = ENDPOINT_STATUS_HALT;
} } else {
else
{
status = 0; status = 0;
} }
success = true; success = true;
@ -472,8 +428,7 @@ bool USBDevice::requestGetStatus(void)
break; break;
} }
if (success) if (success) {
{
/* Send the status */ /* Send the status */
transfer.ptr = (uint8_t *)&status; /* Assumes little endian */ transfer.ptr = (uint8_t *)&status; /* Assumes little endian */
transfer.remaining = sizeof(status); transfer.remaining = sizeof(status);
@ -488,43 +443,41 @@ bool USBDevice::requestSetup(void)
bool success = false; bool success = false;
/* Process standard requests */ /* Process standard requests */
if ((transfer.setup.bmRequestType.Type == STANDARD_TYPE)) if ((transfer.setup.bmRequestType.Type == STANDARD_TYPE)) {
{ switch (transfer.setup.bRequest) {
switch (transfer.setup.bRequest) case GET_STATUS:
{ success = requestGetStatus();
case GET_STATUS: break;
success = requestGetStatus(); case CLEAR_FEATURE:
break; success = requestClearFeature();
case CLEAR_FEATURE: break;
success = requestClearFeature(); case SET_FEATURE:
break; success = requestSetFeature();
case SET_FEATURE: break;
success = requestSetFeature(); case SET_ADDRESS:
break;
case SET_ADDRESS:
success = requestSetAddress(); success = requestSetAddress();
break; break;
case GET_DESCRIPTOR: case GET_DESCRIPTOR:
success = requestGetDescriptor(); success = requestGetDescriptor();
break; break;
case SET_DESCRIPTOR: case SET_DESCRIPTOR:
/* TODO: Support is optional, not implemented here */ /* TODO: Support is optional, not implemented here */
success = false; success = false;
break; break;
case GET_CONFIGURATION: case GET_CONFIGURATION:
success = requestGetConfiguration(); success = requestGetConfiguration();
break; break;
case SET_CONFIGURATION: case SET_CONFIGURATION:
success = requestSetConfiguration(); success = requestSetConfiguration();
break; break;
case GET_INTERFACE: case GET_INTERFACE:
success = requestGetInterface(); success = requestGetInterface();
break; break;
case SET_INTERFACE: case SET_INTERFACE:
success = requestSetInterface(); success = requestSetInterface();
break; break;
default: default:
break; break;
} }
} }
@ -549,23 +502,21 @@ bool USBDevice::controlSetup(void)
transfer.notify = false; transfer.notify = false;
#ifdef DEBUG #ifdef DEBUG
printf("dataTransferDirection: %d\r\nType: %d\r\nRecipient: %d\r\nbRequest: %d\r\nwValue: %d\r\nwIndex: %d\r\nwLength: %d\r\n",transfer.setup.bmRequestType.dataTransferDirection, printf("dataTransferDirection: %d\r\nType: %d\r\nRecipient: %d\r\nbRequest: %d\r\nwValue: %d\r\nwIndex: %d\r\nwLength: %d\r\n", transfer.setup.bmRequestType.dataTransferDirection,
transfer.setup.bmRequestType.Type, transfer.setup.bmRequestType.Type,
transfer.setup.bmRequestType.Recipient, transfer.setup.bmRequestType.Recipient,
transfer.setup.bRequest, transfer.setup.bRequest,
transfer.setup.wValue, transfer.setup.wValue,
transfer.setup.wIndex, transfer.setup.wIndex,
transfer.setup.wLength); transfer.setup.wLength);
#endif #endif
/* Class / vendor specific */ /* Class / vendor specific */
success = USBCallback_request(); success = USBCallback_request();
if (!success) if (!success) {
{
/* Standard requests */ /* Standard requests */
if (!requestSetup()) if (!requestSetup()) {
{
#ifdef DEBUG #ifdef DEBUG
printf("fail!!!!\r\n"); printf("fail!!!!\r\n");
#endif #endif
@ -574,62 +525,47 @@ bool USBDevice::controlSetup(void)
} }
/* Check transfer size and direction */ /* Check transfer size and direction */
if (transfer.setup.wLength>0) if (transfer.setup.wLength > 0) {
{
if (transfer.setup.bmRequestType.dataTransferDirection \ if (transfer.setup.bmRequestType.dataTransferDirection \
== DEVICE_TO_HOST) == DEVICE_TO_HOST) {
{
/* IN data stage is required */ /* IN data stage is required */
if (transfer.direction != DEVICE_TO_HOST) if (transfer.direction != DEVICE_TO_HOST) {
{
return false; return false;
} }
/* Transfer must be less than or equal to the size */ /* Transfer must be less than or equal to the size */
/* requested by the host */ /* requested by the host */
if (transfer.remaining > transfer.setup.wLength) if (transfer.remaining > transfer.setup.wLength) {
{
transfer.remaining = transfer.setup.wLength; transfer.remaining = transfer.setup.wLength;
} }
} } else {
else
{
/* OUT data stage is required */ /* OUT data stage is required */
if (transfer.direction != HOST_TO_DEVICE) if (transfer.direction != HOST_TO_DEVICE) {
{
return false; return false;
} }
/* Transfer must be equal to the size requested by the host */ /* Transfer must be equal to the size requested by the host */
if (transfer.remaining != transfer.setup.wLength) if (transfer.remaining != transfer.setup.wLength) {
{
return false; return false;
} }
} }
} } else {
else
{
/* No data stage; transfer size must be zero */ /* No data stage; transfer size must be zero */
if (transfer.remaining != 0) if (transfer.remaining != 0) {
{
return false; return false;
} }
} }
/* Data or status stage if applicable */ /* Data or status stage if applicable */
if (transfer.setup.wLength>0) if (transfer.setup.wLength > 0) {
{
if (transfer.setup.bmRequestType.dataTransferDirection \ if (transfer.setup.bmRequestType.dataTransferDirection \
== DEVICE_TO_HOST) == DEVICE_TO_HOST) {
{
/* Check if we'll need to send a zero length packet at */ /* Check if we'll need to send a zero length packet at */
/* the end of this transfer */ /* the end of this transfer */
if (transfer.setup.wLength > transfer.remaining) if (transfer.setup.wLength > transfer.remaining) {
{
/* Device wishes to transfer less than host requested */ /* Device wishes to transfer less than host requested */
if ((transfer.remaining % MAX_PACKET_SIZE_EP0) == 0) if ((transfer.remaining % MAX_PACKET_SIZE_EP0) == 0) {
{
/* Transfer is a multiple of EP0 max packet size */ /* Transfer is a multiple of EP0 max packet size */
transfer.zlp = true; transfer.zlp = true;
} }
@ -637,15 +573,11 @@ bool USBDevice::controlSetup(void)
/* IN stage */ /* IN stage */
controlIn(); controlIn();
} } else {
else
{
/* OUT stage */ /* OUT stage */
EP0read(); EP0read();
} }
} } else {
else
{
/* Status stage */ /* Status stage */
EP0write(NULL, 0); EP0write(NULL, 0);
} }
@ -666,8 +598,7 @@ void USBDevice::busReset(void)
void USBDevice::EP0setupCallback(void) void USBDevice::EP0setupCallback(void)
{ {
/* Endpoint 0 setup event */ /* Endpoint 0 setup event */
if (!controlSetup()) if (!controlSetup()) {
{
/* Protocol stall */ /* Protocol stall */
EP0stall(); EP0stall();
} }
@ -678,8 +609,7 @@ void USBDevice::EP0setupCallback(void)
void USBDevice::EP0out(void) void USBDevice::EP0out(void)
{ {
/* Endpoint 0 OUT data event */ /* Endpoint 0 OUT data event */
if (!controlOut()) if (!controlOut()) {
{
/* Protocol stall; this will stall both endpoints */ /* Protocol stall; this will stall both endpoints */
EP0stall(); EP0stall();
} }
@ -691,8 +621,7 @@ void USBDevice::EP0in(void)
printf("EP0IN\r\n"); printf("EP0IN\r\n");
#endif #endif
/* Endpoint 0 IN data event */ /* Endpoint 0 IN data event */
if (!controlIn()) if (!controlIn()) {
{
/* Protocol stall; this will stall both endpoints */ /* Protocol stall; this will stall both endpoints */
EP0stall(); EP0stall();
} }
@ -726,7 +655,7 @@ void USBDevice::disconnect(void)
device.suspended = false; device.suspended = false;
} }
CONTROL_TRANSFER * USBDevice::getTransferPtr(void) CONTROL_TRANSFER *USBDevice::getTransferPtr(void)
{ {
return &transfer; return &transfer;
} }
@ -742,40 +671,37 @@ bool USBDevice::addRateFeedbackEndpoint(uint8_t endpoint, uint32_t maxPacket)
return realiseEndpoint(endpoint, maxPacket, RATE_FEEDBACK_MODE); return realiseEndpoint(endpoint, maxPacket, RATE_FEEDBACK_MODE);
} }
uint8_t * USBDevice::findDescriptor(uint8_t descriptorType) uint8_t *USBDevice::findDescriptor(uint8_t descriptorType)
{ {
/* Find a descriptor within the list of descriptors */ /* Find a descriptor within the list of descriptors */
/* following a configuration descriptor. */ /* following a configuration descriptor. */
uint16_t wTotalLength; uint16_t wTotalLength;
uint8_t *ptr; uint8_t *ptr;
if (configurationDesc() == NULL) if (configurationDesc() == NULL) {
{
return NULL; return NULL;
} }
/* Check this is a configuration descriptor */ /* Check this is a configuration descriptor */
if ((configurationDesc()[0] != CONFIGURATION_DESCRIPTOR_LENGTH) \ if ((configurationDesc()[0] != CONFIGURATION_DESCRIPTOR_LENGTH) \
|| (configurationDesc()[1] != CONFIGURATION_DESCRIPTOR)) || (configurationDesc()[1] != CONFIGURATION_DESCRIPTOR)) {
{
return NULL; return NULL;
} }
wTotalLength = configurationDesc()[2] | (configurationDesc()[3] << 8); wTotalLength = configurationDesc()[2] | (configurationDesc()[3] << 8);
/* Check there are some more descriptors to follow */ /* Check there are some more descriptors to follow */
if (wTotalLength <= (CONFIGURATION_DESCRIPTOR_LENGTH+2)) if (wTotalLength <= (CONFIGURATION_DESCRIPTOR_LENGTH + 2))
/* +2 is for bLength and bDescriptorType of next descriptor */ /* +2 is for bLength and bDescriptorType of next descriptor */
{ {
return NULL; return NULL;
} }
/* Start at first descriptor after the configuration descriptor */ /* Start at first descriptor after the configuration descriptor */
ptr = &(((uint8_t*)configurationDesc())[CONFIGURATION_DESCRIPTOR_LENGTH]); ptr = &(((uint8_t *)configurationDesc())[CONFIGURATION_DESCRIPTOR_LENGTH]);
do { do {
if (ptr[1] /* bDescriptorType */ == descriptorType) if (ptr[1] /* bDescriptorType */ == descriptorType) {
{
/* Found */ /* Found */
return ptr; return ptr;
} }
@ -798,7 +724,8 @@ void USBDevice::suspendStateChanged(unsigned int suspended)
} }
USBDevice::USBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_release){ USBDevice::USBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_release)
{
VENDOR_ID = vendor_id; VENDOR_ID = vendor_id;
PRODUCT_ID = product_id; PRODUCT_ID = product_id;
PRODUCT_RELEASE = product_release; PRODUCT_RELEASE = product_release;
@ -816,25 +743,23 @@ bool USBDevice::readStart(uint8_t endpoint, uint32_t maxSize)
} }
bool USBDevice::write(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint32_t maxSize) bool USBDevice::write(uint8_t endpoint, uint8_t *buffer, uint32_t size, uint32_t maxSize)
{ {
EP_STATUS result; EP_STATUS result;
if (size > maxSize) if (size > maxSize) {
{
return false; return false;
} }
if(!configured()) { if (!configured()) {
return false; return false;
} }
/* Send report */ /* Send report */
result = endpointWrite(endpoint, buffer, size); result = endpointWrite(endpoint, buffer, size);
if (result != EP_PENDING) if (result != EP_PENDING) {
{
return false; return false;
} }
@ -847,24 +772,22 @@ bool USBDevice::write(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint32_
} }
bool USBDevice::writeNB(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint32_t maxSize) bool USBDevice::writeNB(uint8_t endpoint, uint8_t *buffer, uint32_t size, uint32_t maxSize)
{ {
EP_STATUS result; EP_STATUS result;
if (size > maxSize) if (size > maxSize) {
{
return false; return false;
} }
if(!configured()) { if (!configured()) {
return false; return false;
} }
/* Send report */ /* Send report */
result = endpointWrite(endpoint, buffer, size); result = endpointWrite(endpoint, buffer, size);
if (result != EP_PENDING) if (result != EP_PENDING) {
{
return false; return false;
} }
@ -875,11 +798,11 @@ bool USBDevice::writeNB(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint3
bool USBDevice::readEP(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint32_t maxSize) bool USBDevice::readEP(uint8_t endpoint, uint8_t *buffer, uint32_t *size, uint32_t maxSize)
{ {
EP_STATUS result; EP_STATUS result;
if(!configured()) { if (!configured()) {
return false; return false;
} }
@ -892,11 +815,11 @@ bool USBDevice::readEP(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint
} }
bool USBDevice::readEP_NB(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint32_t maxSize) bool USBDevice::readEP_NB(uint8_t endpoint, uint8_t *buffer, uint32_t *size, uint32_t maxSize)
{ {
EP_STATUS result; EP_STATUS result;
if(!configured()) { if (!configured()) {
return false; return false;
} }
@ -907,7 +830,8 @@ bool USBDevice::readEP_NB(uint8_t endpoint, uint8_t * buffer, uint32_t * size, u
const uint8_t * USBDevice::deviceDesc() { const uint8_t *USBDevice::deviceDesc()
{
uint8_t deviceDescriptorTemp[] = { uint8_t deviceDescriptorTemp[] = {
DEVICE_DESCRIPTOR_LENGTH, /* bLength */ DEVICE_DESCRIPTOR_LENGTH, /* bLength */
DEVICE_DESCRIPTOR, /* bDescriptorType */ DEVICE_DESCRIPTOR, /* bDescriptorType */
@ -933,56 +857,62 @@ const uint8_t * USBDevice::deviceDesc() {
return deviceDescriptor; return deviceDescriptor;
} }
const uint8_t * USBDevice::stringLangidDesc() { const uint8_t *USBDevice::stringLangidDesc()
{
static const uint8_t stringLangidDescriptor[] = { static const uint8_t stringLangidDescriptor[] = {
0x04, /*bLength*/ 0x04, /*bLength*/
STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ STRING_DESCRIPTOR, /*bDescriptorType 0x03*/
0x09,0x04, /*bString Lang ID - 0x0409 - English*/ 0x09, 0x04, /*bString Lang ID - 0x0409 - English*/
}; };
return (uint8_t *)stringLangidDescriptor; return (uint8_t *)stringLangidDescriptor;
} }
const uint8_t * USBDevice::stringImanufacturerDesc() { const uint8_t *USBDevice::stringImanufacturerDesc()
{
static const uint8_t stringImanufacturerDescriptor[] = { static const uint8_t stringImanufacturerDescriptor[] = {
0x12, /*bLength*/ 0x12, /*bLength*/
STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ STRING_DESCRIPTOR, /*bDescriptorType 0x03*/
'm',0,'b',0,'e',0,'d',0,'.',0,'o',0,'r',0,'g',0, /*bString iManufacturer - mbed.org*/ 'm', 0, 'b', 0, 'e', 0, 'd', 0, '.', 0, 'o', 0, 'r', 0, 'g', 0, /*bString iManufacturer - mbed.org*/
}; };
return stringImanufacturerDescriptor; return stringImanufacturerDescriptor;
} }
const uint8_t * USBDevice::stringIserialDesc() { const uint8_t *USBDevice::stringIserialDesc()
{
static const uint8_t stringIserialDescriptor[] = { static const uint8_t stringIserialDescriptor[] = {
0x16, /*bLength*/ 0x16, /*bLength*/
STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ STRING_DESCRIPTOR, /*bDescriptorType 0x03*/
'0',0,'1',0,'2',0,'3',0,'4',0,'5',0,'6',0,'7',0,'8',0,'9',0, /*bString iSerial - 0123456789*/ '0', 0, '1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0, '8', 0, '9', 0, /*bString iSerial - 0123456789*/
}; };
return stringIserialDescriptor; return stringIserialDescriptor;
} }
const uint8_t * USBDevice::stringIConfigurationDesc() { const uint8_t *USBDevice::stringIConfigurationDesc()
{
static const uint8_t stringIconfigurationDescriptor[] = { static const uint8_t stringIconfigurationDescriptor[] = {
0x06, /*bLength*/ 0x06, /*bLength*/
STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ STRING_DESCRIPTOR, /*bDescriptorType 0x03*/
'0',0,'1',0, /*bString iConfiguration - 01*/ '0', 0, '1', 0, /*bString iConfiguration - 01*/
}; };
return stringIconfigurationDescriptor; return stringIconfigurationDescriptor;
} }
const uint8_t * USBDevice::stringIinterfaceDesc() { const uint8_t *USBDevice::stringIinterfaceDesc()
{
static const uint8_t stringIinterfaceDescriptor[] = { static const uint8_t stringIinterfaceDescriptor[] = {
0x08, /*bLength*/ 0x08, /*bLength*/
STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ STRING_DESCRIPTOR, /*bDescriptorType 0x03*/
'U',0,'S',0,'B',0, /*bString iInterface - USB*/ 'U', 0, 'S', 0, 'B', 0, /*bString iInterface - USB*/
}; };
return stringIinterfaceDescriptor; return stringIinterfaceDescriptor;
} }
const uint8_t * USBDevice::stringIproductDesc() { const uint8_t *USBDevice::stringIproductDesc()
{
static const uint8_t stringIproductDescriptor[] = { static const uint8_t stringIproductDescriptor[] = {
0x16, /*bLength*/ 0x16, /*bLength*/
STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ STRING_DESCRIPTOR, /*bDescriptorType 0x03*/
'U',0,'S',0,'B',0,' ',0,'D',0,'E',0,'V',0,'I',0,'C',0,'E',0 /*bString iProduct - USB DEVICE*/ 'U', 0, 'S', 0, 'B', 0, ' ', 0, 'D', 0, 'E', 0, 'V', 0, 'I', 0, 'C', 0, 'E', 0 /*bString iProduct - USB DEVICE*/
}; };
return stringIproductDescriptor; return stringIproductDescriptor;
} }

View File

@ -1,20 +1,18 @@
/* Copyright (c) 2010-2011 mbed.org, MIT License /* mbed Microcontroller Library
* * Copyright (c) 2018-2018 ARM Limited
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software *
* and associated documentation files (the "Software"), to deal in the Software without * Licensed under the Apache License, Version 2.0 (the "License");
* restriction, including without limitation the rights to use, copy, modify, merge, publish, * you may not use this file except in compliance with the License.
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * You may obtain a copy of the License at
* Software is furnished to do so, subject to the following conditions: *
* * http://www.apache.org/licenses/LICENSE-2.0
* The above copyright notice and this permission notice shall be included in all copies or *
* substantial portions of the Software. * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * See the License for the specific language governing permissions and
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * limitations under the License.
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef USBDEVICE_H #ifndef USBDEVICE_H
#define USBDEVICE_H #define USBDEVICE_H
@ -23,8 +21,7 @@
#include "USBDevice_Types.h" #include "USBDevice_Types.h"
#include "USBHAL.h" #include "USBHAL.h"
class USBDevice: public USBHAL class USBDevice: public USBHAL {
{
public: public:
USBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_release); USBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
@ -78,7 +75,7 @@ public:
* @param maxSize the maximum length that can be read * @param maxSize the maximum length that can be read
* @returns true if successful * @returns true if successful
*/ */
bool readEP(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint32_t maxSize); bool readEP(uint8_t endpoint, uint8_t *buffer, uint32_t *size, uint32_t maxSize);
/* /*
* Read a certain endpoint. * Read a certain endpoint.
@ -91,7 +88,7 @@ public:
* @param maxSize the maximum length that can be read * @param maxSize the maximum length that can be read
* @returns true if successful * @returns true if successful
*/ */
bool readEP_NB(uint8_t endpoint, uint8_t * buffer, uint32_t * size, uint32_t maxSize); bool readEP_NB(uint8_t endpoint, uint8_t *buffer, uint32_t *size, uint32_t maxSize);
/* /*
* Write a certain endpoint. * Write a certain endpoint.
@ -103,7 +100,7 @@ public:
* @param size the number of bytes to write * @param size the number of bytes to write
* @param maxSize the maximum length that can be written on this endpoint * @param maxSize the maximum length that can be written on this endpoint
*/ */
bool write(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint32_t maxSize); bool write(uint8_t endpoint, uint8_t *buffer, uint32_t size, uint32_t maxSize);
/* /*
@ -116,7 +113,7 @@ public:
* @param size the number of bytes to write * @param size the number of bytes to write
* @param maxSize the maximum length that can be written on this endpoint * @param maxSize the maximum length that can be written on this endpoint
*/ */
bool writeNB(uint8_t endpoint, uint8_t * buffer, uint32_t size, uint32_t maxSize); bool writeNB(uint8_t endpoint, uint8_t *buffer, uint32_t size, uint32_t maxSize);
/* /*
@ -133,7 +130,10 @@ public:
* *
* @returns true if class handles this request * @returns true if class handles this request
*/ */
virtual bool USBCallback_request() { return false; }; virtual bool USBCallback_request()
{
return false;
};
/* /*
* Called by USBDevice on Endpoint0 request completion * Called by USBDevice on Endpoint0 request completion
@ -145,7 +145,7 @@ public:
* @param buf buffer received on endpoint 0 * @param buf buffer received on endpoint 0
* @param length length of this buffer * @param length length of this buffer
*/ */
virtual void USBCallback_requestCompleted(uint8_t * buf, uint32_t length) {}; virtual void USBCallback_requestCompleted(uint8_t *buf, uint32_t length) {};
/* /*
* Called by USBDevice layer. Set configuration of the device. * Called by USBDevice layer. Set configuration of the device.
@ -153,7 +153,10 @@ public:
* *
* @param configuration Number of the configuration * @param configuration Number of the configuration
*/ */
virtual bool USBCallback_setConfiguration(uint8_t configuration) { return false; }; virtual bool USBCallback_setConfiguration(uint8_t configuration)
{
return false;
};
/* /*
* Called by USBDevice layer. Set interface/alternate of the device. * Called by USBDevice layer. Set interface/alternate of the device.
@ -162,70 +165,79 @@ public:
* @param alternate Number of the alternate to be configured * @param alternate Number of the alternate to be configured
* @returns true if class handles this request * @returns true if class handles this request
*/ */
virtual bool USBCallback_setInterface(uint16_t interface, uint8_t alternate) { return false; }; virtual bool USBCallback_setInterface(uint16_t interface, uint8_t alternate)
{
return false;
};
/* /*
* Get device descriptor. * Get device descriptor.
* *
* @returns pointer to the device descriptor * @returns pointer to the device descriptor
*/ */
virtual const uint8_t * deviceDesc(); virtual const uint8_t *deviceDesc();
/* /*
* Get configuration descriptor * Get configuration descriptor
* *
* @returns pointer to the configuration descriptor * @returns pointer to the configuration descriptor
*/ */
virtual const uint8_t * configurationDesc(){return NULL;}; virtual const uint8_t *configurationDesc()
{
return NULL;
};
/* /*
* Get string lang id descriptor * Get string lang id descriptor
* *
* @return pointer to the string lang id descriptor * @return pointer to the string lang id descriptor
*/ */
virtual const uint8_t * stringLangidDesc(); virtual const uint8_t *stringLangidDesc();
/* /*
* Get string manufacturer descriptor * Get string manufacturer descriptor
* *
* @returns pointer to the string manufacturer descriptor * @returns pointer to the string manufacturer descriptor
*/ */
virtual const uint8_t * stringImanufacturerDesc(); virtual const uint8_t *stringImanufacturerDesc();
/* /*
* Get string product descriptor * Get string product descriptor
* *
* @returns pointer to the string product descriptor * @returns pointer to the string product descriptor
*/ */
virtual const uint8_t * stringIproductDesc(); virtual const uint8_t *stringIproductDesc();
/* /*
* Get string serial descriptor * Get string serial descriptor
* *
* @returns pointer to the string serial descriptor * @returns pointer to the string serial descriptor
*/ */
virtual const uint8_t * stringIserialDesc(); virtual const uint8_t *stringIserialDesc();
/* /*
* Get string configuration descriptor * Get string configuration descriptor
* *
* @returns pointer to the string configuration descriptor * @returns pointer to the string configuration descriptor
*/ */
virtual const uint8_t * stringIConfigurationDesc(); virtual const uint8_t *stringIConfigurationDesc();
/* /*
* Get string interface descriptor * Get string interface descriptor
* *
* @returns pointer to the string interface descriptor * @returns pointer to the string interface descriptor
*/ */
virtual const uint8_t * stringIinterfaceDesc(); virtual const uint8_t *stringIinterfaceDesc();
/* /*
* Get the length of the report descriptor * Get the length of the report descriptor
* *
* @returns length of the report descriptor * @returns length of the report descriptor
*/ */
virtual uint16_t reportDescLength() { return 0; }; virtual uint16_t reportDescLength()
{
return 0;
};
@ -236,8 +248,8 @@ protected:
virtual void EP0in(void); virtual void EP0in(void);
virtual void connectStateChanged(unsigned int connected); virtual void connectStateChanged(unsigned int connected);
virtual void suspendStateChanged(unsigned int suspended); virtual void suspendStateChanged(unsigned int suspended);
uint8_t * findDescriptor(uint8_t descriptorType); uint8_t *findDescriptor(uint8_t descriptorType);
CONTROL_TRANSFER * getTransferPtr(void); CONTROL_TRANSFER *getTransferPtr(void);
uint16_t VENDOR_ID; uint16_t VENDOR_ID;
uint16_t PRODUCT_ID; uint16_t PRODUCT_ID;

View File

@ -1,20 +1,18 @@
/* Copyright (c) 2010-2011 mbed.org, MIT License /* mbed Microcontroller Library
* * Copyright (c) 2018-2018 ARM Limited
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software *
* and associated documentation files (the "Software"), to deal in the Software without * Licensed under the Apache License, Version 2.0 (the "License");
* restriction, including without limitation the rights to use, copy, modify, merge, publish, * you may not use this file except in compliance with the License.
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * You may obtain a copy of the License at
* Software is furnished to do so, subject to the following conditions: *
* * http://www.apache.org/licenses/LICENSE-2.0
* The above copyright notice and this permission notice shall be included in all copies or *
* substantial portions of the Software. * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * See the License for the specific language governing permissions and
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * limitations under the License.
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef USBDEVICE_TYPES_H #ifndef USBDEVICE_TYPES_H
#define USBDEVICE_TYPES_H #define USBDEVICE_TYPES_H