diff --git a/usb/bundle.json b/usb/bundle.json
index 8fdca89e462c86820fdfaabe810191152b625471..491a2ab5f1e1d6dacc1f00ec1084cc32bfb29278 100644
--- a/usb/bundle.json
+++ b/usb/bundle.json
@@ -120,6 +120,27 @@
"header_files": [],
"header_base": "//drivers/interface/usb"
}
+ },
+ {
+ "name": "//drivers/interface/usb/usb_serial_ddk/v1_0:libusb_serial_ddk_proxy_1.0",
+ "header": {
+ "header_files": [],
+ "header_base": "//drivers/interface/usb/usb_serial_ddk"
+ }
+ },
+ {
+ "name": "//drivers/interface/usb/usb_serial_ddk/v1_0:libusb_serial_ddk_stub_1.0",
+ "header": {
+ "header_files": [],
+ "header_base": "//drivers/interface/usb/usb_serial_ddk"
+ }
+ },
+ {
+ "name": "//drivers/interface/usb/usb_serial_ddk/v1_0:usb_serial_ddk_idl_headers",
+ "header": {
+ "header_files": [],
+ "header_base": "//drivers/interface/usb/usb_serial_ddk"
+ }
}
]
}
diff --git a/usb/usb_serial_ddk/v1_0/BUILD.gn b/usb/usb_serial_ddk/v1_0/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..945d1fd34e29e12ca4a2eef996f72f5688c1cd28
--- /dev/null
+++ b/usb/usb_serial_ddk/v1_0/BUILD.gn
@@ -0,0 +1,29 @@
+# Copyright (c) 2024 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.
+
+import("//build/config/components/hdi/hdi.gni")
+
+hdi("usb_serial_ddk") {
+ module_name = "usb_serial_ddk"
+
+ sources = [
+ "IUsbSerialDdk.idl",
+ "UsbSerialDdkTypes.idl",
+ ]
+
+ language = "cpp"
+ mode = "ipc"
+ subsystem_name = "hdf"
+ part_name = "drivers_interface_usb"
+}
+
diff --git a/usb/usb_serial_ddk/v1_0/IUsbSerialDdk.idl b/usb/usb_serial_ddk/v1_0/IUsbSerialDdk.idl
new file mode 100644
index 0000000000000000000000000000000000000000..991b68d465c5d73d55601c9681f53597e5aa92ad
--- /dev/null
+++ b/usb/usb_serial_ddk/v1_0/IUsbSerialDdk.idl
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2024 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 HdiUsbUsbSerialDdk
+ * @{
+ *
+ * @brief Provides USB SERIAL DDK types and declares the macros, enumerated variables, and\n
+ * data structures required by the USB SERIAL DDK APIs.
+ *
+ * @syscap SystemCapability.Driver.SERIAL.Extension
+ * @since 16
+ */
+
+/**
+ * @file IUsbSerialDdk.idl
+ *
+ * @brief Declares the USB SERIAL DDK APIs used by the USB serial host to access USB serial devices.
+ *
+ * @since 16
+ */
+package ohos.hdi.usb.usb_serial_ddk.v1_0;
+
+import ohos.hdi.usb.usb_serial_ddk.v1_0.UsbSerialDdkTypes;
+
+/* *
+ * @brief Declares the USB DDK APIs used by the USB host to access USB devices.
+ */
+interface IUsbSerialDdk
+{
+
+ /* *
+ * @brief Initializes the USB serial DDK.
+ *
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ Init();
+
+ /* *
+ * @brief Releases the DDK.
+ *
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ Release();
+
+ /**
+ * @brief Open USB serial device by deviceId.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param deviceId ID of the device to be operated.
+ * @param interfaceIndex Interface index, which corresponds to interface which supports USB Protocol ACM.
+ * @param dev Device handle.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ Open([in] unsigned long deviceId, [in] unsigned long interfaceIndex, [out] struct UsbSerial_Device dev);
+
+ /**
+ * @brief Close USB serial device.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ Close([in] struct UsbSerial_Device dev);
+
+ /**
+ * @brief Read bytesRead into buff from UsbSerial device.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @param bufferSize Max buff size.
+ * @param buff Received data from a serial device.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ Read([in] struct UsbSerial_Device dev, [in] unsigned int bufferSize, [out] List buff);
+
+ /**
+ * @brief Write bytesWritten from buff to UsbSerial device.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @param buff Serial information write to device.
+ * @param bytesWritten Actual bytes written.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ *
+ */
+ Write([in] struct UsbSerial_Device dev, [in] List buff, [out] unsigned int bytesWritten);
+
+ /**
+ * @brief Set the serial port baud rate.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @param baudRate Serial port baud rate set to connect device.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ SetBaudRate([in] struct UsbSerial_Device dev, [in] unsigned int baudRate);
+
+ /**
+ * @brief Set the serial port parameters.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @param params Serial port params set to connect device.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ SetParams([in] struct UsbSerial_Device dev, [in] struct UsbSerialPeripheral_Params params);
+
+ /**
+ * @brief Sets the read timeout (in milliseconds)/blocking mode
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @param timeout Set to -1 to infinite timeout, 0 to return immediately with any data (non
+ blocking, or >0 to wait for data for a specified number of milliseconds). Timeout will
+ be rounded to the nearest 100ms (a Linux API restriction). Maximum value limited to
+ 25500ms (another Linux API restriction).
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ SetTimeout([in] struct UsbSerial_Device dev, [in] int timeout);
+
+ /**
+ * @brief Sets FlowControl params.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @param flowControl flow control mode.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ SetFlowControl([in] struct UsbSerial_Device dev, [in] int flowControl);
+
+ /**
+ * @brief flush buffers after write.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ Flush([in] struct UsbSerial_Device dev);
+
+ /**
+ * @brief flush read buffers.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ FlushInput([in] struct UsbSerial_Device dev);
+
+ /**
+ * @brief flush write buffers.
+ *
+ * @permission ohos.permission.ACCESS_DDK_USB_SERIAL
+ * @param dev Device handle.
+ * @return 0 if the operation is successful; a negative value otherwise.
+ * @since 16
+ */
+ FlushOutput([in] struct UsbSerial_Device dev);
+}
diff --git a/usb/usb_serial_ddk/v1_0/UsbSerialDdkTypes.idl b/usb/usb_serial_ddk/v1_0/UsbSerialDdkTypes.idl
new file mode 100644
index 0000000000000000000000000000000000000000..304706beb66af9e8a7a463c9732e86cbc2bb88d2
--- /dev/null
+++ b/usb/usb_serial_ddk/v1_0/UsbSerialDdkTypes.idl
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2024 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 HdiUsbSerialDdk
+ * @{
+ *
+ * @brief Provides USB SERIAL DDK types and declares the macros, enumerated variables, and\n
+ * data structures required by the USB SERIAL DDK APIs.
+ *
+ * @syscap SystemCapability.Driver.SERIAL.Extension
+ * @since 16
+ */
+
+ /**
+ * @file UsbSerialDdkTypes.idl
+ *
+ * @brief Defines the enumeration values and data structures of the user_auth driver.
+ *
+ * @since 16
+ */
+
+package ohos.hdi.usb.usb_serial_ddk.v1_0;
+
+ /**
+ * @brief Defines USB Serial UsbSerial_Device for USB SERIAL DDK.
+ *
+ * @since 16
+ */
+struct UsbSerial_Device {
+ /** The usb serial device fd */
+ unsigned int fd;
+};
+
+/**
+ * @brief Defines flow control for USB SERIAL DDK.
+ *
+ * @since 16
+ */
+enum UsbSerial_FlowControl{
+ /** No flow control */
+ USB_SERIAL_FLOWCONTROL_NONE = 0,
+ /** Software flow control */
+ USB_SERIAL_FLOWCONTROL_SOFTWARE = 1,
+ /** Hardware flow control */
+ USB_SERIAL_FLOWCONTROL_HARDWARE = 2,
+};
+
+/**
+ * @brief Defines parity for USB SERIAL DDK.
+ *
+ * @since 16
+ */
+enum UsbSerial_Parity{
+ /** No parity */
+ USB_SERIAL_PARITY_NONE = 0,
+ /** Odd parity */
+ USB_SERIAL_PARITY_ODD = 1,
+ /** Even parity */
+ USB_SERIAL_PARITY_EVEN = 2,
+};
+
+ /**
+ * @brief Defines USB Serial Port Params for USB SERIAL DDK.
+ *
+ * @since 16
+ */
+struct UsbSerialPeripheral_Params {
+ /** The baud rate requested by the system */
+ unsigned int baudRate;
+ /** The number of data bits to transmit */
+ unsigned char nDataBits;
+ /** The number of half stop bits. */
+ unsigned char nStopBits;
+ /** The parity setting to use during communication */
+ unsigned char parity;
+};
+/** @} */