• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 USB_DEVICE_PIPE_H
17 #define USB_DEVICE_PIPE_H
18 
19 #include "usb_config.h"
20 #include "v1_0/usb_types.h"
21 
22 namespace OHOS {
23 namespace USB {
24 class USBDevicePipe {
25 public:
26     USBDevicePipe();
~USBDevicePipe()27     ~USBDevicePipe() {}
28     USBDevicePipe(uint8_t busNum, uint8_t devAddr);
29     int32_t ClaimInterface(const UsbInterface &interface, bool force);
30     int32_t ReleaseInterface(const UsbInterface &interface);
31     int32_t BulkTransfer(const USBEndpoint &endpoint, std::vector<uint8_t> &bufferData, int32_t timeOut);
32     int32_t ControlTransfer(const HDI::Usb::V1_0::UsbCtrlTransfer &ctrl, std::vector<uint8_t> &bufferData);
33     int32_t SetConfiguration(const USBConfig &config);
34     int32_t SetInterface(const UsbInterface &interface);
35     int32_t Close();
36 
37     void SetBusNum(uint8_t busNum);
38     void SetDevAddr(uint8_t devAddr);
39     uint8_t GetBusNum() const;
40     uint8_t GetDevAddr() const;
41 
42 private:
43     uint8_t busNum_;
44     uint8_t devAddr_;
45 };
46 } // namespace USB
47 } // namespace OHOS
48 
49 #endif // USB_DEVICE_PIPE_H
50