1 /* 2 * Copyright (C) 2023 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 #ifndef USB_TYPES_H 16 #define USB_TYPES_H 17 18 #include <cstdint> 19 20 struct USBHead { 21 uint8_t flag[2]; 22 uint8_t option; 23 uint32_t sessionId; 24 uint32_t dataSize; 25 }; 26 27 struct HdcUSB { 28 #ifdef HDC_HOST 29 #else 30 // usb accessory FunctionFS 31 // USB main thread use, sub-thread disable, sub-thread uses the main thread USB handle 32 int bulkOut; // EP1 device recv 33 int bulkIn; // EP2 device send 34 #endif 35 uint32_t payloadSize; 36 uint16_t wMaxPacketSizeSend; 37 bool resetIO; // if true, must break write and read,default false 38 }; 39 40 constexpr uint16_t MAX_PACKET_SIZE_HISPEED = 512; 41 constexpr uint16_t DEVICE_CHECK_INTERVAL = 3000; // ms 42 constexpr uint16_t MAX_USBFFS_BULK = 62464; 43 const std::string USB_PACKET_FLAG = "UB"; // must 2bytes 44 45 constexpr int ERR_GENERIC = -1; 46 constexpr int ERR_SUCCESS = 0; 47 constexpr int ERR_API_FAIL = -13000; 48 49 #endif // USB_TYPES_H 50