1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef USBD_TYPE_H 17 #define USBD_TYPE_H 18 19 #define USB_MAX_INTERFACES 32 20 21 enum UsbdDeviceAction { 22 ACT_DEVUP = 0, 23 ACT_DEVDOWN, 24 ACT_UPDEVICE, 25 ACT_DOWNDEVICE, 26 ACT_ACCESSORYUP, 27 ACT_ACCESSORYDOWN, 28 ACT_ACCESSORYSEND 29 }; 30 31 struct UsbdDescriptorHeader { 32 uint8_t bLength; 33 uint8_t bDescriptorType; 34 } __attribute__((packed)); 35 36 struct UsbdDeviceDescriptor { 37 uint8_t bLength; 38 uint8_t bDescriptorType; 39 uint16_t bcdUSB; 40 uint8_t bDeviceClass; 41 uint8_t bDeviceSubClass; 42 uint8_t bDeviceProtocol; 43 uint8_t bMaxPacketSize0; 44 uint16_t idVendor; 45 uint16_t idProduct; 46 uint16_t bcdDevice; 47 uint8_t iManufacturer; 48 uint8_t iProduct; 49 uint8_t iSerialNumber; 50 uint8_t bNumConfigurations; 51 } __attribute__((packed)); 52 53 struct UsbdConfigDescriptor { 54 uint8_t bLength; 55 uint8_t bDescriptorType; 56 uint16_t wTotalLength; 57 uint8_t bNumInterfaces; 58 uint8_t bConfigurationValue; 59 uint8_t iConfiguration; 60 uint8_t bmAttributes; 61 uint8_t bMaxPower; 62 } __attribute__((packed)); 63 64 struct UsbdInterfaceDescriptor { 65 uint8_t bLength; 66 uint8_t bDescriptorType; 67 uint8_t bInterfaceNumber; 68 uint8_t bAlternateSetting; 69 uint8_t bNumEndpoints; 70 uint8_t bInterfaceClass; 71 uint8_t bInterfaceSubClass; 72 uint8_t bInterfaceProtocol; 73 uint8_t iInterface; 74 } __attribute__((packed)); 75 76 struct UsbdEndpointDescriptor { 77 uint8_t bLength; 78 uint8_t bDescriptorType; 79 uint8_t bEndpointAddress; 80 uint8_t bmAttributes; 81 uint16_t wMaxPacketSize; 82 uint8_t bInterval; 83 } __attribute__((packed)); 84 85 #endif // USBD_TYPE_H 86