• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_HOST_SDK_IF_TEST_H
17 #define USB_HOST_SDK_IF_TEST_H
18 
19 #include "hdf_base.h"
20 #include "hdf_device_desc.h"
21 #include "osal_atomic.h"
22 #include "usb_ddk.h"
23 #include "usb_session.h"
24 #include "usb_interface.h"
25 #include "data_fifo.h"
26 
27 typedef enum {
28     CMD_OPEN_PARM = 0,
29     CMD_CLOSE_PARM,
30     CMD_WRITE_PARM,
31     CMD_READ_PARM,
32     CMD_GET_BAUDRATE,
33     CMD_SET_BAUDRATE,
34     CMD_WRITE_DATA_SYNC,
35     CMD_READ_DATA_SYNC,
36     CMD_CLASS_CTRL_SYNC,
37     CMD_STD_CTRL_GET_DESCRIPTOR_CMD,
38     CMD_STD_CTRL_GET_STATUS_CMD,
39     CMD_STD_CTRL_GET_CONFIGURATION,
40     CMD_STD_CTRL_GET_INTERFACE,
41     CMD_STD_CTRL_GET_DESCRIPTOR_ASYNC,
42 } SerialOPCmd;
43 
44 #define DATARATE                9600
45 #define CHARFORMAT              8
46 #define ACM_NW                  16
47 #define ACM_NR                  16
48 #define TARGET_MASK             0x3
49 #define REQUEST_TYPE_MASK       0x3
50 #define DIRECTION_MASK          0x1
51 #define USB_CTRL_SET_TIMEOUT    0
52 
53 struct AcmDevice;
54 
55 struct AcmWb {
56     struct UsbRequest    *request;
57     struct AcmDevice       *instance;
58     uint8_t *buf;
59     int    len;
60     int    use;
61 };
62 
63 struct AcmRb {
64     uint8_t  *base;
65     int size;
66     int index;
67     int use;
68     struct AcmDevice *instance;
69 };
70 
71 struct SerialDevice {
72     struct AcmDevice *acm;
73     struct UsbCdcLineCoding     lineCoding;
74     struct OsalMutex            lock;
75 };
76 
77 struct AcmDevice {
78     struct IDeviceIoService service;
79     struct HdfDeviceObject *device;
80     struct UsbInterface *ctrIface;
81     struct UsbInterface *intIface;
82     struct UsbInterface *dataIface;
83     struct UsbPipeInfo  *ctrPipe;
84     struct UsbPipeInfo  *intPipe;
85     struct UsbPipeInfo  *dataInPipe;
86     struct UsbPipeInfo  *dataOutPipe;
87     struct AcmWb wb[ACM_NW];
88     struct AcmRb  rb[ACM_NR];
89     struct UsbPipeInfo  wPipeInfo;
90     struct OsalMutex      writeLock;
91     struct OsalMutex      readLock;
92     uint8_t *notificationBuffer;
93     struct UsbRequest    *notifyReq;
94     struct UsbRequest    *readReq[ACM_NR];
95     struct UsbRequest    *writeReq;
96     struct UsbRequest    *ctrlReq;
97     struct OsalMutex       lock;
98     struct UsbInterface *itface;
99     UsbInterfaceHandle *devHandle;
100     UsbInterfaceHandle *data_devHandle;
101     UsbInterfaceHandle *ctrl_devHandle;
102     UsbInterfaceHandle *int_devHandle;
103     struct UsbSession *session;
104     struct SerialDevice  *port;
105     uint32_t nbIndex;
106     uint32_t nbSize;
107     int transmitting;
108     int32_t ctrlReqNum;
109     uint8_t busNum;
110     uint8_t devAddr;
111     uint8_t interfaceIndex;
112     uint32_t ctrlSize;
113     uint32_t intSize;
114     uint32_t writeSize;
115     uint32_t readSize;
116     struct UsbCdcLineCoding   lineCoding;
117 };
118 
119 struct TestControlMsgData {
120     uint8_t request;
121     uint8_t requestType;
122     uint16_t value;
123     uint16_t index;
124     void *data;
125     uint16_t size;
126 };
127 
128 #endif
129