提交 079e2a3b 编写于 作者: D duangavin123

hpm-part

Signed-off-by: Nduangavin123 <duanxichao@huawei.com>
上级 ec434260
......@@ -14,19 +14,19 @@
- [Third-Party Library Porting Guide for Mini and Small Systems](porting/porting-thirdparty.md)
- [Mini System SoC Porting Guide](porting/porting-minichip.md)
- [Small System SoC Porting Guide](porting/porting-smallchip.md)
- [Standard System SoC Porting Guide](porting/standard-system-porting-guide.md)
[Standard System SoC Porting Guide](porting/standard-system-porting-guide.md)
- Subsystem Development
- Kernel
- [Kernel for the Mini System](kernel/kernel-mini.md)
- [Kernel for the Small System](kernel/kernel-small.md)
- [Kernel for the Standard System](kernel/kernel-standard.md)
- [Driver](driver/Readme-EN.md)
[Driver](driver/Readme-EN.md)
- [Compilation and Building](subsystems/subsys-build.md)
- [Distributed Remote Startup](subsystems/subsys-remote-start.md)
- [Graphics](subsystems/subsys-graphics.md)
- [Multimedia](subsystems/subsys-multimedia.md)
[Graphics](subsystems/subsys-graphics.md)
[Multimedia](subsystems/subsys-multimedia.md)
- [Utils](subsystems/subsys-utils.md)
- [AI Framework](subsystems/subsys-aiframework.md)
[AI Framework](subsystems/subsys-aiframework.md)
- [Data Management](subsystems/subsys-data.md)
- [Sensor](subsystems/subsys-sensor.md)
- [USB](subsystems/subsys-usbservice.md)
......@@ -37,20 +37,20 @@
- [Startup](subsystems/subsys-boot.md)
- [DFX](subsystems/subsys-dfx.md)
- Featured Topics
- [HPM Bundle](bundles/Readme-EN.md)
- Device Development Examples
- [Mini- and Small-System Devices](guide/device-lite.md)
- [HPM Part](hpm-part/Readme-EN.md)
Device Development Examples
[Mini- and Small-System Devices](guide/device-lite.md)
- [Standard-System Devices](guide/device-standard.md)
- Debugging
- [Test Subsystem](subsystems/subsys-testguide-test.md)
- [R&D Tools](subsystems/subsys-toolchain.md)
- XTS Certification
- [XTS](subsystems/subsys-xts-guide.md)
XTS Certification
[XTS](subsystems/subsys-xts-guide.md)
- Tools
- [Docker Environment](get-code/gettools-acquire.md)
- [IDE](get-code/gettools-ide.md)
- Hands-On Tutorials
Hands-On Tutorials
- [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md)
- References
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @addtogroup USB
* @{
*
* @brief Declares USB-related APIs, including the custom data types and functions
* used to obtain descriptors, interface objects, and request objects, and to submit requests.
*
* @since 3.0
* @version 1.0
*/
/**
* @file usbd_client.h
*
* @brief Defines the usbd interface.
*
* @since 3.0
* @version 1.0
*/
#ifndef USBD_CLIENT_H
#define USBD_CLIENT_H
#include "usb_param.h"
#include "usbd_subscriber.h"
namespace OHOS {
namespace USB {
class UsbdClient {
public:
/* *
* @brief Opens a USB device to set up a connection.
*
* @param dev Indicates the USB device address.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t OpenDevice(const UsbDev &dev);
/* *
* @brief Closes a USB device to release all system resources related to the device.
*
* @param dev Indicates the USB device address.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t CloseDevice(const UsbDev &dev);
/* *
* @brief Obtains the USB device descriptor.
*
* @param dev Indicates the USB device address.
* @param descriptor Indicates the USB device descriptor.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t GetDeviceDescriptor(const UsbDev &dev, std::vector<uint8_t> &decriptor);
/* *
* @brief Obtains the string descriptor of a USB device based on the specified string ID.
*
* @param dev Indicates the USB device address.
* @param descId Indicates string descriptor ID.
* @param descriptor Indicates the string descriptor of the USB device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t GetStringDescriptor(const UsbDev &dev, uint8_t descId, std::vector<uint8_t> &decriptor);
/* *
* @brief Obtains the configuration descriptor of a USB device based on the specified config ID.
*
* @param dev Indicates the USB device address.
* @param descId Indicates configuration descriptor ID.
* @param descriptor Indicates the configuration descriptor of the USB device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t GetConfigDescriptor(const UsbDev &dev, uint8_t descId, std::vector<uint8_t> &decriptor);
/* *
* @brief Obtains the raw descriptor.
*
* @param dev Indicates the USB device address.
* @param descriptor Indicates the raw descriptor of the USB device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t GetRawDescriptor(const UsbDev &dev, std::vector<uint8_t> &decriptor);
/* *
* @brief Sets the configuration information of a USB device.
*
* @param dev Indicates the USB device address.
* @param configIndex Indicates the configuration information of the USB device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t SetConfig(const UsbDev &dev, uint8_t configIndex);
/* *
* @brief Obtains the configuration information of a USB device.
*
* @param dev Indicates the USB device address.
* @param configIndex Indicates the configuration information of the USB device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t GetConfig(const UsbDev &dev, uint8_t &configIndex);
/* *
* @brief Claims a USB interface exclusively. This must be done before data transfer.
*
* @param dev Indicates the USB device address.
* @param interfaceid Indicates the interface ID of the USB device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t ClaimInterface(const UsbDev &dev, uint8_t interfaceid);
/* *
* @brief Releases a USB interface. This is usually done after data transfer.
*
* @param dev Indicates the USB device address.
* @param interfaceid Indicates the interface ID of the USB device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t ReleaseInterface(const UsbDev &dev, uint8_t interfaceid);
/* *
* @brief Sets the alternate settings for the specified USB interface. This allows you to switch between two interfaces with the same ID but different alternate settings.
*
* @param dev Indicates the USB device address.
* @param interfaceid Indicates the interface ID of the USB device.
* @param altIndex Indicates the alternate settings of the USB interface.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t SetInterface(const UsbDev &dev, uint8_t interfaceid, uint8_t altIndex);
/* *
* @brief Reads data on a specified endpoint during bulk transfer. The endpoint must be in the data reading direction. You can specify a timeout duration if needed.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param timeout Indicates the timeout duration.
* @param data Indicates the read data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t
BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, std::vector<uint8_t> &data);
/* *
* @brief Writes data on a specified endpoint during bulk transfer. The endpoint must be in the data writing direction.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param timeout Indicates the timeout duration.
* @param data Indicates the written data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t
BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, const std::vector<uint8_t> &data);
/* *
* @brief Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the request type. If the result of <b>requestType</b>&
* <b>USB_ENDPOINT_DIR_MASK</b> is USB_DIR_OUT, the endpoint is in the data writing direction; if the result is <b>USB_DIR_IN</b>, the endpoint is in the data reading direction.
*
* @param dev Indicates the USB device address.
* @param ctrl Indicates the control data packet structure.
* @param data Indicates the read data or written.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &data);
/* *
* @brief Reads data on a specified endpoint during interrupt transfer. The endpoint must be in the data reading direction.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param timeout Indicates the timeout duration.
* @param data Indicates the read data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t
InterruptTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, std::vector<uint8_t> &data);
/* *
* @brief Writes data on a specified endpoint during interrupt transfer. The endpoint must be in the data writing direction.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param timeout Indicates the timeout duration.
* @param data Indicates the read data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t
InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, std::vector<uint8_t> &data);
/* *
* @brief Reads data on a specified endpoint during isochronous transfer. The endpoint must be in the data reading direction.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param timeout Indicates the timeout duration.
* @param data Indicates the read data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t IsoTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, std::vector<uint8_t> &data);
/* *
* @brief Writes data on a specified endpoint during isochronous transfer. The endpoint must be in the data writing direction.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param timeout Indicates the timeout duration.
* @param data Indicates the written data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t
IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, std::vector<uint8_t> &data);
/* *
* @brief Sends or receives requests for isochronous transfer on a specified endpoint. The data transfer direction is determined by the endpoint direction.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param clientData Indicates the client data.
* @param buffer Indicates the transferred data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t RequestQueue(const UsbDev &dev,
const UsbPipe &pipe,
const std::vector<uint8_t> &clientData,
const std::vector<uint8_t> &buffer);
/* *
* @brief Waits for the operation result of the requests for isochronous transfer in <b>RequestQueue</b>.
*
* @param dev Indicates the USB device address.
* @param clientData Indicates the client data.
* @param buffer Indicates the transferred data.
* @param timeout Indicates the timeout duration.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t
RequestWait(const UsbDev &dev, std::vector<uint8_t> &clientData, std::vector<uint8_t> &buffer, int32_t timeout);
/* *
* @brief Cancels the data transfer requests to be processed.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t RequestCancel(const UsbDev &dev, const UsbPipe &pipe);
/* *
* @brief Obtains the list of functions (represented by bit field) supported by the current device.
*
* @param funcs Indicates the list of functions supported by the current device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t GetCurrentFunctions(int32_t &funcs);
/* *
* @brief Sets the list of functions (represented by bit field) supported by the current device.
*
* @param funcs Indicates the list of functions supported by the current device.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t SetCurrentFunctions(int32_t funcs);
/* *
* @brief Closes a USB device to release all system resources related to the device.
*
* @param portId Indicates the port ID of the USB interface.
* @param powerRole Indicates the power role.
* @param dataRole Indicates the data role.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole);
/* *
* @brief Queries the current settings of a port.
*
* @param portId Indicates the port ID of the USB interface.
* @param powerRole Indicates the power role.
* @param dataRole Indicates the data role.
* @param mode Indicates the mode.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t QueryPort(int32_t &portId, int32_t &powerRole, int32_t &dataRole, int32_t &mode);
/* *
* @brief Binds a subscriber.
*
* @param subscriber Indicates the subscriber.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static ErrCode BindUsbdSubscriber(const sptr<UsbdSubscriber> &subscriber);
/* *
* @brief Unbinds a subscriber.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static ErrCode UnbindUsbdSubscriber();
/* *
* @brief Reads bulk data during isochronous transfer. This method is applicable to transfer of a huge amount of data.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param length Indicates the length of the data to read.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t BulkRequstDataSize(const UsbDev &dev, const UsbPipe &pipe, uint32_t &length);
/* *
* @brief Obtains the data reading result. Use this method together with <b>BulkRequstDataSize</b>.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param data Indicates the read data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t BulkReadData(const UsbDev &dev, const UsbPipe &pipe, std::vector<uint8_t> &data);
/* *
* @brief Writes bulk data during isochronous transfer. This method is applicable to transfer of a huge amount of data.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param data Indicates the written data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t BulkWriteData(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &data);
/* *
* @brief Obtains the data writing status based on <b>length</b>. Use this method together with <b>BulkWriteData</b>.
*
* @param dev Indicates the USB device address.
* @param pipe Indicates the pipe of the USB device.
* @param length Indicates the length of the written data.
*
* @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
* @since 3.0
*/
static int32_t BulkGetWriteCompleteLength(const UsbDev &dev, const UsbPipe &pipe, uint32_t &length);
private:
static void PrintBuffer(const char *title, const uint8_t *buffer, uint32_t length);
static int32_t SetDeviceMessage(MessageParcel &data, const UsbDev &dev);
static int32_t SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &tdata);
static int32_t GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &tdata);
static sptr<IRemoteObject> GetUsbdService();
static ErrCode DoDispatch(uint32_t cmd, MessageParcel &data, MessageParcel &reply);
};
} // namespace USB
} // namespace OHOS
#endif // USBD_CLIENT_H
......@@ -87,7 +87,7 @@ In addition, OpenHarmony provides a series of optional system components that ca
</td>
<td class="cellrowborder" valign="top" width="35.61356135613561%" headers="mcps1.2.4.1.2 "><p id="p45798376158"><a name="p45798376158"></a><a name="p45798376158"></a>Contributing components to <span id="text207913212498"><a name="text207913212498"></a><a name="text207913212498"></a>OpenHarmony</span></p>
</td>
<td class="cellrowborder" valign="top" width="35.91359135913591%" headers="mcps1.2.4.1.3 "><a name="ul957919379156"></a><a name="ul957919379156"></a><ul id="ul957919379156"><li><a href="bundles/bundles-standard-rules.md">HPM Bundle Development Specifications</a></li><li><a href="bundles/bundles-guide.md">HPM Bundle Development Guidelines</a></li><li><a href="bundles/bundles-demo.md">HPM Bundle Development Example</a></li></ul>
<td class="cellrowborder" valign="top" width="35.91359135913591%" headers="mcps1.2.4.1.3 "><a name="ul957919379156"></a><a name="ul957919379156"></a><ul id="ul957919379156"><li><a href="hpm-part/hpm-part-about.md">HPM Part Overview</a></li><li><a href="hpm-part/hpm-part-development.md">HPM Part Development</a></li><li><a href="hpm-part/hpm-part-reference.md">HPM Part Reference</a></li></ul>
</td>
</tr>
<tr id="row260193701512"><td class="cellrowborder" valign="top" width="28.472847284728473%" headers="mcps1.2.4.1.1 "><p id="p95794372155"><a name="p95794372155"></a><a name="p95794372155"></a>Reference</p>
......@@ -157,7 +157,7 @@ In addition, OpenHarmony provides a series of optional system components that ca
</td>
<td class="cellrowborder" valign="top" width="36.053605360536054%" headers="mcps1.2.4.1.2 "><p id="p1469115335113"><a name="p1469115335113"></a><a name="p1469115335113"></a>Contributing components to <span id="text1180831622"><a name="text1180831622"></a><a name="text1180831622"></a>OpenHarmony</span></p>
</td>
<td class="cellrowborder" valign="top" width="36.07360736073608%" headers="mcps1.2.4.1.3 "><a name="ul44949625110"></a><a name="ul44949625110"></a><ul id="ul44949625110"><li><a href="bundles/bundles-standard-rules.md">HPM Bundle Development Specifications</a></li><li><a href="bundles/bundles-guide.md">HPM Bundle Development Guidelines</a></li><li><a href="bundles/bundles-demo.md">HPM Bundle Development Example</a></li></ul>
<td class="cellrowborder" valign="top" width="36.07360736073608%" headers="mcps1.2.4.1.3 "><a name="ul44949625110"></a><a name="ul44949625110"></a><ul id="ul44949625110"><a href="hpm-part/hpm-part-about.md">HPM Part Overview</a></li><li><a href="hpm-part/hpm-part-development.md">HPM Part Development</a></li><li><a href="hpm-part/hpm-part-reference.md">HPM Part Reference</a></li></ul>
</td>
</tr>
<tr id="row1170153125110"><td class="cellrowborder" valign="top" width="27.872787278727873%" headers="mcps1.2.4.1.1 "><p id="p16701253195118"><a name="p16701253195118"></a><a name="p16701253195118"></a>Reference</p>
......
# Bundles
# HPM Part
- [HPM Part Overview](hpm-part-about.md)
- [HPM Part Development](hpm-part-development.md)
......
......@@ -384,7 +384,7 @@
- [HiSysEvent Query](subsystems/subsys-dfx-hisysevent-query.md)
- [HiSysEvent Tool Usage](subsystems/subsys-dfx-hisysevent-tool.md)
- Featured Topics
- HPM Bundle
- HPM Part
- [Development Specifications](bundles/bundles-standard-rules.md)
- Development Guidelines
- [Bundle Development](bundles/bundles-guide-overview.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册