1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** USBX Component                                                        */
17 /**                                                                       */
18 /**   Generic Serial Host module class                                    */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  COMPONENT DEFINITION                                   RELEASE        */
27 /*                                                                        */
28 /*    ux_host_class_gser.h                                PORTABLE C      */
29 /*                                                           6.1.8        */
30 /*  AUTHOR                                                                */
31 /*                                                                        */
32 /*    Chaoqiong Xiao, Microsoft Corporation                               */
33 /*                                                                        */
34 /*  DESCRIPTION                                                           */
35 /*                                                                        */
36 /*    This file contains all the header and extern functions used by the  */
37 /*    USBX Generic Serial Class.                                          */
38 /*                                                                        */
39 /*  RELEASE HISTORY                                                       */
40 /*                                                                        */
41 /*    DATE              NAME                      DESCRIPTION             */
42 /*                                                                        */
43 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
44 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
45 /*                                            used UX prefix to refer to  */
46 /*                                            TX symbols instead of using */
47 /*                                            them directly,              */
48 /*                                            resulting in version 6.1    */
49 /*  08-02-2021     Wen Wang                 Modified comment(s),          */
50 /*                                            added extern "C" keyword    */
51 /*                                            for compatibility with C++, */
52 /*                                            resulting in version 6.1.8  */
53 /*                                                                        */
54 /**************************************************************************/
55 
56 #ifndef UX_HOST_CLASS_GSER_H
57 #define UX_HOST_CLASS_GSER_H
58 
59 /* Determine if a C++ compiler is being used.  If so, ensure that standard
60    C is used to process the API information.  */
61 
62 #ifdef   __cplusplus
63 
64 /* Yes, C++ compiler is present.  Use standard C.  */
65 extern   "C" {
66 
67 #endif
68 
69 
70 /* Define Sierra Wireless AR Class constants.  */
71 
72 #define UX_HOST_CLASS_GSER_CLASS_TRANSFER_TIMEOUT               300000
73 #ifndef UX_HOST_CLASS_GSER_VENDOR_ID
74 #define UX_HOST_CLASS_GSER_VENDOR_ID                            0X05C6
75 #define UX_HOST_CLASS_GSER_PRODUCT_ID                           0X9002
76 #endif
77 
78 /* Define  serial interfaces equivalences.  */
79 #define UX_HOST_CLASS_GSER_INTERFACE_NUMBER                     3
80 
81 /* Define  packet equivalences.  */
82 #define UX_HOST_CLASS_GSER_PACKET_SIZE                          128
83 
84 /* Define Generic AR IOCTL functions.  */
85 
86 #define UX_HOST_CLASS_GSER_REQ_SEND_ENCAPSULATED_COMMAND        0x00
87 #define UX_HOST_CLASS_GSER_REQ_GET_ENCAPSULATED_COMMAND         0x01
88 #define UX_HOST_CLASS_GSER_REQ_SET_COMM_FEATURE                 0x02
89 #define UX_HOST_CLASS_GSER_REQ_GET_COMM_FEATURE                 0x03
90 #define UX_HOST_CLASS_GSER_REQ_CLEAR_COMM_FEATURE               0x04
91 #define UX_HOST_CLASS_GSER_REQ_SET_AUX_LINE_STATE               0x10
92 #define UX_HOST_CLASS_GSER_REQ_SET_HOOK_STATE                   0x11
93 #define UX_HOST_CLASS_GSER_REQ_PULSE_SETUP                      0x12
94 #define UX_HOST_CLASS_GSER_REQ_SEND_PULSE                       0x13
95 #define UX_HOST_CLASS_GSER_REQ_SET_PUSLE_TIME                   0x14
96 #define UX_HOST_CLASS_GSER_REQ_RING_AUX_JACK                    0x15
97 #define UX_HOST_CLASS_GSER_REQ_SET_LINE_CODING                  0x20
98 #define UX_HOST_CLASS_GSER_REQ_GET_LINE_CODING                  0x21
99 #define UX_HOST_CLASS_GSER_REQ_SET_LINE_STATE                   0x22
100 #define UX_HOST_CLASS_GSER_REQ_SEND_BREAK                       0x23
101 #define UX_HOST_CLASS_GSER_REQ_SET_RINGER_PARMS                 0x30
102 #define UX_HOST_CLASS_GSER_REQ_GET_RINGER_PARMS                 0x31
103 #define UX_HOST_CLASS_GSER_REQ_SET_OPERATION_PARMS              0x32
104 #define UX_HOST_CLASS_GSER_REQ_GET_OPERATION_PARMS              0x33
105 #define UX_HOST_CLASS_GSER_REQ_SET_LINE_PARMS                   0x34
106 #define UX_HOST_CLASS_GSER_REQ_GET_LINE_PARMS                   0x35
107 
108 /* Define CDC ACM line output control values.  */
109 
110 #define UX_HOST_CLASS_GSER_CTRL_DTR                             0x01
111 #define UX_HOST_CLASS_GSER_CTRL_RTS                             0x02
112 
113 /* Define CDC ACM line input control values.  */
114 
115 #define UX_HOST_CLASS_GSER_CTRL_DCD                             0x01
116 #define UX_HOST_CLASS_GSER_CTRL_DSR                             0x02
117 #define UX_HOST_CLASS_GSER_CTRL_BRK                             0x04
118 #define UX_HOST_CLASS_GSER_CTRL_RI                              0x08
119 
120 #define UX_HOST_CLASS_GSER_CTRL_FRAMING                         0x10
121 #define UX_HOST_CLASS_GSER_CTRL_PARITY                          0x20
122 #define UX_HOST_CLASS_GSER_CTRL_OVERRUN                         0x40
123 
124 /* Define CDC ACM default values.  */
125 
126 #define UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_RATE             9600
127 #define UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_DATA_BIT         8
128 
129 /* Define CDC ACM line coding definitions.  */
130 
131 #define UX_HOST_CLASS_GSER_LINE_CODING_STOP_BIT_0               0
132 #define UX_HOST_CLASS_GSER_LINE_CODING_STOP_BIT_15              1
133 #define UX_HOST_CLASS_GSER_LINE_CODING_STOP_BIT_2               2
134 
135 #define UX_HOST_CLASS_GSER_LINE_CODING_PARITY_NONE              0
136 #define UX_HOST_CLASS_GSER_LINE_CODING_PARITY_ODD               1
137 #define UX_HOST_CLASS_GSER_LINE_CODING_PARITY_EVEN              2
138 #define UX_HOST_CLASS_GSER_LINE_CODING_PARITY_MARK              3
139 #define UX_HOST_CLASS_GSER_LINE_CODING_PARITY_SPACE             4
140 
141 #define UX_HOST_CLASS_GSER_LINE_CODING_LENGTH                   7
142 #define UX_HOST_CLASS_GSER_LINE_CODING_RATE                     0
143 #define UX_HOST_CLASS_GSER_LINE_CODING_STOP_BIT                 4
144 #define UX_HOST_CLASS_GSER_LINE_CODING_PARITY                   5
145 #define UX_HOST_CLASS_GSER_LINE_CODING_DATA_BIT                 6
146 
147 /* Define CDC ACM line state definitions.  */
148 
149 #define UX_HOST_CLASS_GSER_LINE_STATE_STOP_BIT_0                0
150 #define UX_HOST_CLASS_GSER_LINE_CODING_STOP_BIT_15              1
151 
152 /* Define CDC ACM IOCTL Functions. */
153 
154 #define UX_HOST_CLASS_GSER_IOCTL_SET_LINE_CODING                0
155 #define UX_HOST_CLASS_GSER_IOCTL_GET_LINE_CODING                1
156 #define UX_HOST_CLASS_GSER_IOCTL_SET_LINE_STATE                 2
157 #define UX_HOST_CLASS_GSER_IOCTL_SEND_BREAK                     3
158 #define UX_HOST_CLASS_GSER_IOCTL_ABORT_IN_PIPE                  5
159 #define UX_HOST_CLASS_GSER_IOCTL_ABORT_OUT_PIPE                 6
160 #define UX_HOST_CLASS_GSER_IOCTL_NOTIFICATION_CALLBACK          7
161 #define UX_HOST_CLASS_GSER_IOCTL_GET_DEVICE_STATUS              8
162 
163 /* Define Reception States. */
164 
165 #define UX_HOST_CLASS_GSER_RECEPTION_STATE_STOPPED              0
166 #define UX_HOST_CLASS_GSER_RECEPTION_STATE_STARTED              1
167 #define UX_HOST_CLASS_GSER_RECEPTION_STATE_IN_TRANSFER          2
168 
169 /* Define the interface structures.  */
170 
171 typedef struct UX_HOST_CLASS_GSER_INTERFACE_STRUCT
172 {
173 
174     UX_INTERFACE                                *ux_host_class_gser_interface;
175     UX_ENDPOINT                                 *ux_host_class_gser_bulk_out_endpoint;
176     UX_ENDPOINT                                 *ux_host_class_gser_bulk_in_endpoint;
177     UX_SEMAPHORE                                ux_host_class_gser_semaphore;
178     struct UX_HOST_CLASS_GSER_RECEPTION_STRUCT  *ux_host_class_gser_reception;
179     ULONG                                       ux_host_class_gser_notification_count;
180 } UX_HOST_CLASS_GSER_INTERFACE;
181 
182 /* Define Generic Serial Class instance structure.  */
183 
184 typedef struct UX_HOST_CLASS_GSER_STRUCT
185 {
186 
187     struct UX_HOST_CLASS_GSER_STRUCT            *ux_host_class_gser_next_instance;
188     UX_HOST_CLASS                               *ux_host_class_gser_class;
189     UX_DEVICE                                   *ux_host_class_gser_device;
190     UINT                                        ux_host_class_gser_state;
191     struct UX_HOST_CLASS_GSER_INTERFACE_STRUCT  ux_host_class_gser_interface_array[UX_HOST_CLASS_GSER_INTERFACE_NUMBER];
192     ULONG                                       ux_host_class_gser_device_state;
193     VOID                                        (*ux_host_class_gser_device_status_change_callback)(struct UX_HOST_CLASS_GSER_STRUCT *gser,
194                                                                     ULONG  notification_type, ULONG notification_value);
195 } UX_HOST_CLASS_GSER;
196 
197 /* Define generic serial class reception structure. */
198 
199 
200 typedef struct UX_HOST_CLASS_GSER_RECEPTION_STRUCT
201 {
202 
203     ULONG           ux_host_class_gser_reception_interface_index;
204     ULONG           ux_host_class_gser_reception_state;
205     ULONG           ux_host_class_gser_reception_block_size;
206     UCHAR           *ux_host_class_gser_reception_data_buffer;
207     ULONG           ux_host_class_gser_reception_data_buffer_size;
208     UCHAR           *ux_host_class_gser_reception_data_head;
209     UCHAR           *ux_host_class_gser_reception_data_tail;
210     VOID            (*ux_host_class_gser_reception_callback)(struct UX_HOST_CLASS_GSER_STRUCT *gser,
211                                                                 UINT  status,
212                                                                 UCHAR *reception_buffer,
213                                                                 ULONG reception_size);
214 
215 } UX_HOST_CLASS_GSER_RECEPTION;
216 
217 
218 /* Define GSER Line Coding IOCTL structure.  */
219 
220 typedef struct UX_HOST_CLASS_GSER_LINE_CODING_STRUCT
221 {
222 
223     ULONG           ux_host_class_gser_line_coding_dter;
224     ULONG           ux_host_class_gser_line_coding_stop_bit;
225     ULONG           ux_host_class_gser_line_coding_parity;
226     ULONG           ux_host_class_gser_line_coding_data_bits;
227 
228 } UX_HOST_CLASS_GSER_LINE_CODING;
229 
230 /* Define GSER Line State IOCTL structure.  */
231 
232 typedef struct UX_HOST_CLASS_GSER_LINE_STATE_STRUCT
233 {
234 
235     ULONG           ux_host_class_gser_line_state_rts;
236     ULONG           ux_host_class_gser_line_state_dtr;
237 
238 } UX_HOST_CLASS_GSER_LINE_STATE;
239 
240 /* Define GSER Line break IOCTL structure.  */
241 
242 typedef struct UX_HOST_CLASS_GSER_LINE_BREAK_STRUCT
243 {
244 
245     ULONG           ux_host_class_gser_line_break;
246 
247 } UX_HOST_CLASS_GSER_LINE_BREAK;
248 
249 
250 /* Define  GSER Class function prototypes.  */
251 
252 UINT    _ux_host_class_gser_activate(UX_HOST_CLASS_COMMAND *command);
253 UINT    _ux_host_class_gser_configure(UX_HOST_CLASS_GSER *gser);
254 UINT    _ux_host_class_gser_deactivate(UX_HOST_CLASS_COMMAND *command);
255 UINT    _ux_host_class_gser_endpoints_get(UX_HOST_CLASS_GSER *gser);
256 UINT    _ux_host_class_gser_entry(UX_HOST_CLASS_COMMAND *command);
257 UINT    _ux_host_class_gser_read (UX_HOST_CLASS_GSER *gser, ULONG interface_index,UCHAR *data_pointer,
258                                     ULONG requested_length, ULONG *actual_length);
259 UINT    _ux_host_class_gser_write(UX_HOST_CLASS_GSER *gser, ULONG interface_index,UCHAR *data_pointer,
260                                     ULONG requested_length, ULONG *actual_length);
261 UINT    _ux_host_class_gser_command(UX_HOST_CLASS_GSER *gser, ULONG interface_index, ULONG command,
262                                     ULONG value, UCHAR *data_buffer, ULONG data_length);
263 UINT    _ux_host_class_gser_ioctl(UX_HOST_CLASS_GSER *gser, ULONG interface_index, ULONG ioctl_function,
264                                     VOID *parameter);
265 VOID    _ux_host_class_gser_reception_callback (UX_TRANSFER *transfer_request);
266 UINT    _ux_host_class_gser_reception_stop (UX_HOST_CLASS_GSER *gser,
267                                     UX_HOST_CLASS_GSER_RECEPTION *gser_reception);
268 UINT    _ux_host_class_gser_reception_start (UX_HOST_CLASS_GSER *gser,
269                                     UX_HOST_CLASS_GSER_RECEPTION *gser_reception);
270 
271 /* Define GSER Class API prototypes.  */
272 
273 #define ux_host_class_gser_entry                     _ux_host_class_gser_entry
274 #define ux_host_class_gser_read                      _ux_host_class_gser_read
275 #define ux_host_class_gser_write                     _ux_host_class_gser_write
276 #define ux_host_class_gser_ioctl                     _ux_host_class_gser_ioctl
277 #define ux_host_class_gser_reception_start           _ux_host_class_gser_reception_start
278 #define ux_host_class_gser_reception_stop            _ux_host_class_gser_reception_stop
279 
280 /* Determine if a C++ compiler is being used.  If so, complete the standard
281    C conditional started above.  */
282 #ifdef __cplusplus
283 }
284 #endif
285 
286 #endif
287