• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17 * @addtogroup HdiUsb
18 * @
19 *
20 * @brief Provides unified APIs for usb services to access usb drivers.
21 *
22 * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to
23 * access different types of usb devices based on the usb IDs, thereby obtaining usb information,
24 * subscribing to or unsubscribing from usb data, enabling or disabling a usb,
25 * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range.
26 *
27 * @since 5.1
28 * @version 1.0
29 */
30
31/**
32 * @file UsbTypes.idl
33 *
34 * @brief Defines the data used by the usb module, including the usb information,
35 * and reported usb data.
36 *
37 * @since 5.1
38 * @version 1.0
39 */
40
41package ohos.hdi.usb.v2_0;
42
43/**
44 * @brief Defines the ControlTransfer Params, which is used by {@link IUsbHostInterface::ControlTransferReadwithLength}.
45 * @since 5.1
46 * @version 1.0
47 */
48struct UsbCtrlTransferParams {
49    int requestType;
50    int requestCmd;
51    int value;
52    int index;
53    int length;
54    int timeout;
55};
56
57/**
58 * @brief Defines the UsbDev Params.
59 * @since 5.1
60 * @version 1.0
61 */
62struct UsbDev {
63    unsigned char busNum;
64    unsigned char devAddr;
65};
66
67/**
68 * @brief Defines the UsbPipe Params.
69 * @since 5.1
70 * @version 1.0
71 */
72struct UsbPipe {
73    unsigned char intfId;
74    unsigned char endpointId;
75};
76
77/**
78 * @brief Defines the UsbCtrlTransfer Params.
79 * @since 5.1
80 * @version 1.0
81 */
82struct UsbCtrlTransfer {
83    int requestType;
84    int requestCmd;
85    int value;
86    int index;
87    int timeout;
88};
89
90/**
91 * @brief Defines the USBDeviceInfo Params.
92 * @since 5.1
93 * @version 1.0
94 */
95struct USBDeviceInfo {
96    int status;
97    int busNum;
98    int devNum;
99};
100
101/**
102 * @brief Defines the RoleCombinations Params.
103 * @since 5.1
104 * @version 1.0
105 */
106struct RoleCombinations {
107    int powerRole;
108    int dataRole;
109};
110
111/**
112 * @brief Defines the PortInfo Params.
113 * @since 5.1
114 * @version 1.0
115 */
116struct PortInfo {
117    int portId;
118    int powerRole;
119    int dataRole;
120    int mode;
121};
122
123/**
124 * @brief Defines the UsbPortStatus Params.
125 * @since 5.1
126 * @version 1.0
127 */
128struct UsbPortStatus {
129    int currentMode;
130    int currentPowerRole;
131    int currentDataRole;
132    int isConnected;
133    RoleCombinations[] supportedRoleCombinations;
134};
135
136/**
137 * @brief Defines the UsbPort Params.
138 * @since 5.1
139 * @version 1.0
140 */
141struct UsbPort {
142    int id;
143    int supportedModes;
144    UsbPortStatus usbPortStatus;
145};
146
147/**
148 * @brief Defines the USB iso packet descriptor params.
149 * @since 5.1
150 * @version 1.0
151 */
152struct UsbIsoPacketDescriptor {
153    int isoLength;
154    int isoActualLength;
155    int isoStatus;
156};
157
158/**
159 * @brief Defines the USB transferInfo Params.
160 * @since 5.1
161 * @version 1.0
162 */
163struct USBTransferInfo {
164    int endpoint;
165    int flags;
166    int type;
167    int timeOut;
168    int length;
169    unsigned long userData;
170    unsigned int numIsoPackets;
171};
172