• 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 USBSerialDDK
18  * @{
19  *
20  * @brief Provides USB SERIAL DDK types and declares the macros, enumerated variables, and\n
21  * data structures required by the USB SERIAL DDK APIs.
22  *
23  * @since 18
24  */
25 
26 /**
27  * @file usb_serial_types.h
28  *
29  * @brief Provides the enumerated variables, structures, and macros used in USB SERIAL DDK APIs.
30  *
31  * @kit DriverDevelopmentKit
32  * @library libusb_serial.z.so
33  * @syscap SystemCapability.Driver.UsbSerial.Extension
34  * @since 18
35  */
36 
37 #ifndef DDK_USB_SERIAL_TYPES_H
38 #define DDK_USB_SERIAL_TYPES_H
39 
40 #include <stddef.h>
41 #include <stdint.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /**
48  * @brief Opaque usb serial device structure.
49  *
50  * @since 18
51  */
52 typedef struct UsbSerial_Device UsbSerial_Device;
53 
54 /**
55  * @brief Defines Return codes for USB SERIAL DDK.
56  *
57  * @since 18
58  */
59 typedef enum {
60     /** @error Permission denied */
61     USB_SERIAL_DDK_NO_PERM = 201,
62     /** @error Invalid parameter */
63     USB_SERIAL_DDK_INVALID_PARAMETER = 401,
64     /** @error Operation successful */
65     USB_SERIAL_DDK_SUCCESS = 31600000,
66     /** @error Invalid operation */
67     USB_SERIAL_DDK_INVALID_OPERATION = 31600001,
68     /** @error Init operation */
69     USB_SERIAL_DDK_INIT_ERROR = 31600002,
70     /** @error Service Error operation */
71     USB_SERIAL_DDK_SERVICE_ERROR = 31600003,
72     /** @error Memory-related error, for example, insufficient memory, memory data copy failure,\n
73      * or memory application failure.
74      */
75     USB_SERIAL_DDK_MEMORY_ERROR = 31600004,
76     /** @error I/O Error */
77     USB_SERIAL_DDK_IO_ERROR = 31600005,
78     /** @error Device not found */
79     USB_SERIAL_DDK_DEVICE_NOT_FOUND = 31600006,
80 } UsbSerial_DdkRetCode;
81 
82 /**
83  * @brief Defines USB Serial Port Params for USB SERIAL DDK.
84  *
85  * @since 18
86  */
87 typedef struct UsbSerial_Params {
88     /** The baud rate requested by the system */
89     uint32_t baudRate;
90     /** The number of data bits to transmit */
91     uint8_t nDataBits;
92     /** The number of half stop bits. */
93     uint8_t nStopBits;
94     /** The parity setting to use during communication */
95     uint8_t parity;
96 } __attribute__((aligned(8))) UsbSerial_Params;
97 
98 /**
99  * @brief Defines flow control for USB SERIAL DDK.
100  *
101  * @since 18
102  */
103 typedef enum {
104     /** No flow control */
105     USB_SERIAL_NO_FLOW_CONTROL = 0,
106     /** Software flow control */
107     USB_SERIAL_SOFTWARE_FLOW_CONTROL = 1,
108     /** Hardware flow control */
109     USB_SERIAL_HARDWARE_FLOW_CONTROL = 2,
110 } UsbSerial_FlowControl;
111 
112 /**
113  * @brief Defines parity for USB SERIAL DDK.
114  *
115  * @since 18
116  */
117 typedef enum {
118     /** No parity */
119     USB_SERIAL_PARITY_NONE = 0,
120     /** Odd parity */
121     USB_SERIAL_PARITY_ODD = 1,
122     /** Even parity */
123     USB_SERIAL_PARITY_EVEN = 2,
124 } UsbSerial_Parity;
125 
126 #ifdef __cplusplus
127 }
128 #endif /* __cplusplus */
129 #endif // DDK_USB_SERIAL_TYPES_H
130 /** @} */
131