1/*
2 * Copyright (c) 2020-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/**
17 * @addtogroup USB
18 * @{
19 *
20 * @brief Declares USB-related APIs, including the custom data types and functions
21 * used to obtain descriptors, interface objects, and request objects, and to submit requests.
22 *
23 * @since 1.0
24 * @version 1.0
25 */
26
27/**
28 * @file usb_ddk.h
29 *
30 * @brief Defines the USB-related structures.
31 *
32 * @since 1.0
33 * @version 1.0
34 */
35
36#ifndef USB_DDK_H
37#define USB_DDK_H
38
39#include "hdf_base.h"
40#include <endian.h>
41
42#ifdef __BYTE_ORDER
43#if __BYTE_ORDER == __LITTLE_ENDIAN
44/**
45 * @brief Implements 16-bit little-endian conversion.
46 */
47#define CPU_TO_LE16(x) (x)
48/**
49 * @brief Implements 32-bit little-endian conversion.
50 */
51#define CPU_TO_LE32(x) (x)
52#else
53/**
54 * @brief Implements 16-bit little-endian conversion.
55 */
56#define CPU_TO_LE16(x) ((((x) >> 8) & 0xffu) | (((x)&0xffu) << 8))
57/**
58 * @brief Implements 32-bit little-endian conversion.
59 */
60#define CPU_TO_LE32(x) \
61    ((((x)&0xff000000u) >> 24) | (((x)&0x00ff0000u) >> 8) | (((x)&0x0000ff00u) << 8) | (((x)&0x000000ffu) << 24))
62#endif
63#endif
64
65/**
66 * @brief Implements 16-bit little-endian conversion.
67 */
68#define LE16_TO_CPU CPU_TO_LE16
69/**
70 * @brief Implements 16-bit little-endian conversion.
71 */
72#define LE32_TO_CPU CPU_TO_LE32
73
74/**
75 * @brief Configures the bus power-on feature.
76 */
77#define USB_CFG_BUS_POWERED 0x80
78
79/**
80 * @brief Configures the automatic power-on feature.
81 */
82#define USB_CFG_SELF_POWERED 0x40
83
84/**
85 * @brief Configures the remote wakeup feature.
86 */
87#define USB_CFG_REMOTE_WAKEUP 0x20
88
89/**
90 * @brief Defines the data direction bit offset. For details, see {@link UsbRequestDirection}.
91 */
92#define USB_DIR_OFFSET 0x07
93
94/**
95 * @brief Defines the control request type offset. For details, see {@link UsbControlRequestType}.
96 */
97#define USB_TYPE_OFFSET 0x05
98
99/**
100 * @brief Defines the control request packet type offset. For details, see {@link UsbRequestTargetType}.
101 */
102#define USB_RECIP_OFFSET 0x00
103
104/**
105 * @brief Defines the USB string index.
106 */
107enum {
108    /** Manufacturer index */
109    USB_FUNC_MANUFACTURER_IDX,
110    /** Product index */
111    USB_FUNC_PRODUCT_IDX,
112    /** Product SN index */
113    USB_FUNC_SERIAL_IDX,
114    /** Index of the first valid string */
115    USB_FUNC_FIRST_AVAIL_IDX,
116};
117
118/**
119 * @brief Renames a descriptor structure.
120 */
121enum {
122    FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
123    FUNCTIONFS_STRINGS_MAGIC = 2,
124    FUNCTIONFS_DESCRIPTORS_MAGIC_V2 = 3,
125};
126
127enum FunctionfsFlags {
128    FUNCTIONFS_HAS_FS_DESC = 1,
129    FUNCTIONFS_HAS_HS_DESC = 2,
130    FUNCTIONFS_HAS_SS_DESC = 4,
131    FUNCTIONFS_HAS_MS_OS_DESC = 8,
132    FUNCTIONFS_VIRTUAL_ADDR = 16,
133    FUNCTIONFS_EVENTFD = 32,
134    FUNCTIONFS_ALL_CTRL_RECIP = 64,
135    FUNCTIONFS_CONFIG0_SETUP = 128,
136};
137
138enum UsbDeviceSpeed {
139    USB_DDK_SPEED_UNKNOWN = 0,
140    USB_DDK_SPEED_LOW,
141    USB_DDK_SPEED_FULL,
142    USB_DDK_SPEED_HIGH,
143    USB_DDK_SPEED_WIRELESS,
144    USB_DDK_SPEED_SUPER,
145    USB_DDK_SPEED_SUPER_PLUS,
146};
147
148struct UsbCtrlRequest {
149    uint8_t bRequestType;
150    uint8_t bRequest;
151    uint16_t wValue;
152    uint16_t wIndex;
153    uint16_t wLength;
154} __attribute__((packed));
155
156struct UsbDescriptorHeader {
157    uint8_t bLength;
158    uint8_t bDescriptorType;
159} __attribute__((packed));
160
161typedef struct UsbDeviceDescriptor {
162    uint8_t bLength;
163    uint8_t bDescriptorType;
164    uint16_t bcdUSB;
165    uint8_t bDeviceClass;
166    uint8_t bDeviceSubClass;
167    uint8_t bDeviceProtocol;
168    uint8_t bMaxPacketSize0;
169    uint16_t idVendor;
170    uint16_t idProduct;
171    uint16_t bcdDevice;
172    uint8_t iManufacturer;
173    uint8_t iProduct;
174    uint8_t iSerialNumber;
175    uint8_t bNumConfigurations;
176} __attribute__((packed)) UsbDeviceDescriptor;
177
178struct UsbConfigDescriptor {
179    uint8_t bLength;
180    uint8_t bDescriptorType;
181    uint16_t wTotalLength;
182    uint8_t bNumInterfaces;
183    uint8_t bConfigurationValue;
184    uint8_t iConfiguration;
185    uint8_t bmAttributes;
186    uint8_t bMaxPower;
187} __attribute__((packed));
188
189struct UsbStringDescriptor {
190    uint8_t bLength;
191    uint8_t bDescriptorType;
192    uint16_t wData[1];
193} __attribute__((packed));
194
195struct UsbInterfaceDescriptor {
196    uint8_t bLength;
197    uint8_t bDescriptorType;
198    uint8_t bInterfaceNumber;
199    uint8_t bAlternateSetting;
200    uint8_t bNumEndpoints;
201    uint8_t bInterfaceClass;
202    uint8_t bInterfaceSubClass;
203    uint8_t bInterfaceProtocol;
204    uint8_t iInterface;
205} __attribute__((packed));
206
207struct UsbEndpointDescriptor {
208    uint8_t bLength;
209    uint8_t bDescriptorType;
210    uint8_t bEndpointAddress;
211    uint8_t bmAttributes;
212    uint16_t wMaxPacketSize;
213    uint8_t bInterval;
214    uint8_t bRefresh;
215    uint8_t bSynchAddress;
216} __attribute__((packed));
217
218struct UsbSspIsocEpCompDescriptor {
219    uint8_t bLength;
220    uint8_t bDescriptorType;
221    uint16_t wReseved;
222    uint32_t dwBytesPerInterval;
223} __attribute__((packed));
224
225struct UsbSsEpCompDescriptor {
226    uint8_t bLength;
227    uint8_t bDescriptorType;
228    uint8_t bMaxBurst;
229    uint8_t bmAttributes;
230    uint16_t wBytesPerInterval;
231} __attribute__((packed));
232
233struct UsbQualifierDescriptor {
234    uint8_t bLength;
235    uint8_t bDescriptorType;
236    uint16_t bcdUSB;
237    uint8_t bDeviceClass;
238    uint8_t bDeviceSubClass;
239    uint8_t bDeviceProtocol;
240    uint8_t bMaxPacketSize0;
241    uint8_t bNumConfigurations;
242    uint8_t bRESERVED;
243} __attribute__((packed));
244
245struct UsbOtgDescriptor {
246    uint8_t bLength;
247    uint8_t bDescriptorType;
248    uint8_t bmAttributes;
249} __attribute__((packed));
250
251struct UsbOtg20Descriptor {
252    uint8_t bLength;
253    uint8_t bDescriptorType;
254    uint8_t bmAttributes;
255    uint16_t bcdOTG;
256} __attribute__((packed));
257
258struct UsbInterfaceAssocDescriptor {
259    uint8_t bLength;
260    uint8_t bDescriptorType;
261    uint8_t bFirstInterface;
262    uint8_t bInterfaceCount;
263    uint8_t bFunctionClass;
264    uint8_t bFunctionSubClass;
265    uint8_t bFunctionProtocol;
266    uint8_t iFunction;
267} __attribute__((packed));
268
269struct UsbFunctionfsStringsHead {
270    uint32_t magic;
271    uint32_t length;
272    uint32_t strCount;
273    uint32_t langCount;
274} __attribute__((packed));
275
276struct UsbFunctionfsDescsHeadV2 {
277    uint32_t magic;
278    uint32_t length;
279    uint32_t flags;
280} __attribute__((packed));
281
282struct UsbSecurityDescriptor {
283    uint8_t bLength;
284    uint8_t bDescriptorType;
285    uint16_t wTotalLength;
286    uint8_t bNumEncryptionTypes;
287} __attribute__((packed));
288
289struct UsbCdcLineCoding {
290    uint32_t dwDTERate;
291    uint8_t bCharFormat;
292
293#define USB_CDC_1_STOP_BITS   0
294#define USB_CDC_1_5_STOP_BITS 1
295#define USB_CDC_2_STOP_BITS   2
296    uint8_t bParityType;
297
298#define USB_CDC_NO_PARITY    0
299#define USB_CDC_ODD_PARITY   1
300#define USB_CDC_EVEN_PARITY  2
301#define USB_CDC_MARK_PARITY  3
302#define USB_CDC_SPACE_PARITY 4
303    uint8_t bDataBits;
304} __attribute__((packed));
305
306struct UsbCdcNotification {
307    uint8_t bmRequestType;
308    uint8_t bNotificationType;
309    uint16_t wValue;
310    uint16_t wIndex;
311    uint16_t wLength;
312} __attribute__((packed));
313
314struct UsbCdcHeaderDesc {
315    uint8_t bLength;
316    uint8_t bDescriptorType;
317    uint8_t bDescriptorSubType;
318    uint16_t bcdCDC;
319} __attribute__((packed));
320
321struct UsbCdcCallMgmtDescriptor {
322    uint8_t bLength;
323    uint8_t bDescriptorType;
324    uint8_t bDescriptorSubType;
325    uint8_t bmCapabilities;
326
327#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01
328#define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02
329    uint8_t bDataInterface;
330} __attribute__((packed));
331
332struct UsbCdcAcmDescriptor {
333    uint8_t bLength;
334    uint8_t bDescriptorType;
335    uint8_t bDescriptorSubType;
336    uint8_t bmCapabilities;
337} __attribute__((packed));
338
339struct UsbCdcUnionDesc {
340    uint8_t bLength;
341    uint8_t bDescriptorType;
342    uint8_t bDescriptorSubType;
343    uint8_t bMasterInterface0;
344    uint8_t bSlaveInterface0;
345} __attribute__((packed));
346
347struct UsbDebugDescriptor {
348    uint8_t bLength;
349    uint8_t bDescriptorType;
350    uint8_t bDebugInEndpoint;
351    uint8_t bDebugOutEndpoint;
352} __attribute__((packed));
353
354struct UsbCdcEtherDesc {
355    uint8_t bLength;
356    uint8_t bDescriptorType;
357    uint8_t bDescriptorSubType;
358
359    uint8_t iMACAddress;
360    uint32_t bmEthernetStatistics;
361    uint16_t wMaxSegmentSize;
362    uint16_t wNumberMCFilters;
363    uint8_t bNumberPowerFilters;
364} __attribute__((packed));
365
366#define USB_DDK_ENDPOINT_NUMBER_MASK 0x0F
367#define USB_DDK_ENDPOINT_DIR_MASK    0x80
368#define USB_DDK_DIR_OUT              0x00
369#define USB_DDK_DIR_IN               0x80
370
371#define USB_DDK_DT_DEVICE                 0x01
372#define USB_DDK_DT_CONFIG                 0x02
373#define USB_DDK_DT_STRING                 0x03
374#define USB_DDK_DT_INTERFACE              0x04
375#define USB_DDK_DT_ENDPOINT               0x05
376#define USB_DDK_DT_DEVICE_QUALIFIER       0x06
377#define USB_DDK_DT_OTHER_SPEED_CONFIG     0x07
378#define USB_DDK_DT_INTERFACE_POWER        0x08
379#define USB_DDK_DT_OTG                    0x09
380#define USB_DDK_DT_DEBUG                  0x0A
381#define USB_DDK_DT_INTERFACE_ASSOCIATION  0x0B
382#define USB_DDK_DT_SECURITY               0x0C
383#define USB_DDK_DT_KEY                    0x0D
384#define USB_DDK_DT_ENCRYPTION_TYPE        0x0E
385#define USB_DDK_DT_BOS                    0x0F
386#define USB_DDK_DT_DEVICE_CAPABILITY      0x10
387#define USB_DDK_DT_WIRELESS_ENDPOINT_COMP 0x11
388#define USB_DDK_DT_WIRE_ADAPTER           0x21
389#define USB_DDK_DT_RPIPE                  0x22
390#define USB_DDK_DT_CS_RADIO_CONTROL       0x23
391#define USB_DDK_DT_PIPE_USAGE             0x24
392#define USB_DDK_DT_SS_ENDPOINT_COMP       0x30
393#define USB_DDK_DT_SSP_ISOC_ENDPOINT_COMP 0x31
394#define USB_DDK_DT_CS_DEVICE              (USB_DDK_TYPE_CLASS | USB_DDK_DT_DEVICE)
395#define USB_DDK_DT_CS_CONFIG              (USB_DDK_TYPE_CLASS | USB_DDK_DT_CONFIG)
396#define USB_DDK_DT_CS_STRING              (USB_DDK_TYPE_CLASS | USB_DDK_DT_STRING)
397#define USB_DDK_DT_CS_INTERFACE           (USB_DDK_TYPE_CLASS | USB_DDK_DT_INTERFACE)
398#define USB_DDK_DT_CS_ENDPOINT            (USB_DDK_TYPE_CLASS | USB_DDK_DT_ENDPOINT)
399
400#define USB_DDK_DT_SS_EP_COMP_SIZE            0x06
401#define USB_DDK_DT_ENDPOINT_SIZE              0x07
402#define USB_DDK_DT_SSP_ISOC_EP_COMP_SIZE      0x08
403#define USB_DDK_DT_INTERFACE_ASSOCIATION_SIZE 0x08
404#define USB_DDK_DT_CONFIG_SIZE                0x09
405#define USB_DDK_DT_INTERFACE_SIZE             0x09
406#define USB_DDK_DT_ENDPOINT_AUDIO_SIZE        0x09
407#define USB_DDK_DT_DEVICE_SIZE                0x12
408
409#define USB_DDK_CLASS_PER_INTERFACE       0x00
410#define USB_DDK_CLASS_AUDIO               0x01
411#define USB_DDK_CLASS_COMM                0x02
412#define USB_DDK_CLASS_HID                 0x03
413#define USB_DDK_CLASS_PHYSICAL            0x05
414#define USB_DDK_CLASS_STILL_IMAGE         0x06
415#define USB_DDK_CLASS_PRINTER             0x07
416#define USB_DDK_CLASS_MASS_STORAGE        0x08
417#define USB_DDK_CLASS_HUB                 0x09
418#define USB_DDK_CLASS_CDC_DATA            0x0A
419#define USB_DDK_CLASS_CSCID               0x0B
420#define USB_DDK_CLASS_CONTENT_SEC         0x0D
421#define USB_DDK_CLASS_VIDEO               0x0E
422#define USB_DDK_CLASS_WIRELESS_CONTROLLER 0xE0
423#define USB_DDK_CLASS_MISC                0xEF
424#define USB_DDK_CLASS_APP_SPEC            0xFE
425#define USB_DDK_CLASS_VENDOR_SPEC         0xFF
426#define USB_DDK_SUBCLASS_VENDOR_SPEC      0xFF
427
428#define USB_DDK_CDC_NOTIFY_NETWORK_CONNECTION 0x00
429#define USB_DDK_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01
430#define USB_DDK_CDC_NOTIFY_SERIAL_STATE       0x20
431#define USB_DDK_CDC_NOTIFY_SPEED_CHANGE       0x2A
432
433#define USB_DDK_CDC_SEND_ENCAPSULATED_COMMAND      0x00
434#define USB_DDK_CDC_GET_ENCAPSULATED_RESPONSE      0x01
435#define USB_DDK_CDC_REQ_SET_LINE_CODING            0x20
436#define USB_DDK_CDC_REQ_GET_LINE_CODING            0x21
437#define USB_DDK_CDC_REQ_SET_CONTROL_LINE_STATE     0x22
438#define USB_DDK_CDC_REQ_SEND_BREAK                 0x23
439#define USB_DDK_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
440#define USB_DDK_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
441#define USB_DDK_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
442#define USB_DDK_CDC_SET_ETHERNET_PACKET_FILTER     0x43
443#define USB_DDK_CDC_GET_ETHERNET_STATISTIC         0x44
444#define USB_DDK_CDC_GET_NTB_PARAMETERS             0x80
445#define USB_DDK_CDC_GET_NET_ADDRESS                0x81
446#define USB_DDK_CDC_SET_NET_ADDRESS                0x82
447#define USB_DDK_CDC_GET_NTB_FORMAT                 0x83
448#define USB_DDK_CDC_SET_NTB_FORMAT                 0x84
449#define USB_DDK_CDC_GET_NTB_INPUT_SIZE             0x85
450#define USB_DDK_CDC_SET_NTB_INPUT_SIZE             0x86
451#define USB_DDK_CDC_GET_MAX_DATAGRAM_SIZE          0x87
452#define USB_DDK_CDC_SET_MAX_DATAGRAM_SIZE          0x88
453#define USB_DDK_CDC_GET_CRC_MODE                   0x89
454#define USB_DDK_CDC_SET_CRC_MODE                   0x8A
455
456#define USB_DDK_CDC_COMM_FEATURE 0x01
457#define USB_DDK_CDC_CAP_LINE     0x02
458#define USB_DDK_CDC_CAP_BRK      0x04
459#define USB_DDK_CDC_CAP_NOTIFY   0x08
460
461#define USB_DDK_CDC_HEADER_TYPE           0x00
462#define USB_DDK_CDC_CALL_MANAGEMENT_TYPE  0x01
463#define USB_DDK_CDC_ACM_TYPE              0x02
464#define USB_DDK_CDC_UNION_TYPE            0x06
465#define USB_DDK_CDC_COUNTRY_TYPE          0x07
466#define USB_DDK_CDC_NETWORK_TERMINAL_TYPE 0x0a
467#define USB_DDK_CDC_ETHERNET_TYPE         0x0f
468#define USB_DDK_CDC_WHCM_TYPE             0x11
469#define USB_DDK_CDC_MDLM_TYPE             0x12
470#define USB_DDK_CDC_MDLM_DETAIL_TYPE      0x13
471#define USB_DDK_CDC_DMM_TYPE              0x14
472#define USB_DDK_CDC_OBEX_TYPE             0x15
473#define USB_DDK_CDC_NCM_TYPE              0x1A
474#define USB_DDK_CDC_MBIM_TYPE             0x1B
475#define USB_DDK_CDC_MBIM_EXTENDED_TYPE    0x1C
476
477#define USB_DDK_CDC_PROTO_NONE                0x00
478#define USB_DDK_CDC_ACM_PROTO_AT_V25TER       0x01
479#define USB_DDK_CDC_ACM_PROTO_AT_PCCA101      0x02
480#define USB_DDK_CDC_ACM_PROTO_AT_PCCA101_WAKE 0x03
481#define USB_DDK_CDC_ACM_PROTO_AT_GSM          0x04
482#define USB_DDK_CDC_ACM_PROTO_AT_3G           0x05
483#define USB_DDK_CDC_ACM_PROTO_AT_CDMA         0x06
484#define USB_DDK_CDC_PROTO_EEM                 0x07
485
486#define USB_DDK_CDC_NCM_PROTO_NTB  0x01
487#define USB_DDK_CDC_MBIM_PROTO_NTB 0x02
488
489#define USB_DDK_CDC_SUBCLASS_ACM      0x02
490#define USB_DDK_CDC_SUBCLASS_ETHERNET 0x06
491#define USB_DDK_CDC_SUBCLASS_WHCM     0x08
492#define USB_DDK_CDC_SUBCLASS_DMM      0x09
493#define USB_DDK_CDC_SUBCLASS_MDLM     0x0A
494#define USB_DDK_CDC_SUBCLASS_OBEX     0x0B
495#define USB_DDK_CDC_SUBCLASS_EEM      0x0C
496#define USB_DDK_CDC_SUBCLASS_NCM      0x0D
497#define USB_DDK_CDC_SUBCLASS_MBIM     0x0E
498
499#define USB_DDK_CDC_PACKET_TYPE_PROMISCUOUS   (1 << 0)
500#define USB_DDK_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1)
501#define USB_DDK_CDC_PACKET_TYPE_DIRECTED      (1 << 2)
502#define USB_DDK_CDC_PACKET_TYPE_BROADCAST     (1 << 3)
503#define USB_DDK_CDC_PACKET_TYPE_MULTICAST     (1 << 4)
504
505#define USB_DDK_CDC_ACM_PROTO_VENDOR 0xFF
506
507#define USB_DDK_TYPE_MASK     (0x03 << 5)
508#define USB_DDK_TYPE_STANDARD (0x00 << 5)
509#define USB_DDK_TYPE_CLASS    (0x01 << 5)
510#define USB_DDK_TYPE_VENDOR   (0x02 << 5)
511#define USB_DDK_TYPE_RESERVED (0x03 << 5)
512
513#define USB_DDK_ENDPOINT_XFERTYPE_MASK  0x03
514#define USB_DDK_ENDPOINT_XFER_CONTROL   0x00
515#define USB_DDK_ENDPOINT_XFER_ISOC      0x01
516#define USB_DDK_ENDPOINT_XFER_BULK      0x02
517#define USB_DDK_ENDPOINT_XFER_INT       0x03
518#define USB_DDK_ENDPOINT_MAX_ADJUSTABLE 0x80
519
520#define USB_DDK_RECIP_MASK      0x1F
521#define USB_DDK_RECIP_DEVICE    0x00
522#define USB_DDK_RECIP_INTERFACE 0x01
523#define USB_DDK_RECIP_ENDPOINT  0x02
524#define USB_DDK_RECIP_OTHER     0x03
525
526#define USB_DDK_REQ_GET_STATUS        0x00
527#define USB_DDK_REQ_CLEAR_FEATURE     0x01
528#define USB_DDK_REQ_SET_FEATURE       0x03
529#define USB_DDK_REQ_SET_ADDRESS       0x05
530#define USB_DDK_REQ_GET_DESCRIPTOR    0x06
531#define USB_DDK_REQ_SET_DESCRIPTOR    0x07
532#define USB_DDK_REQ_GET_CONFIGURATION 0x08
533#define USB_DDK_REQ_SET_CONFIGURATION 0x09
534#define USB_DDK_REQ_GET_INTERFACE     0x0A
535#define USB_DDK_REQ_SET_INTERFACE     0x0B
536#define USB_DDK_REQ_SYNCH_FRAME       0x0C
537#define USB_DDK_REQ_SET_SEL           0x30
538#define USB_DDK_REQ_SET_ISOCH_DELAY   0x31
539
540/**
541 * @brief Checks whether the specified endpoint is in the input direction (the direction in
542 * which data is transferred from the device to the host). For details, see {@link UsbRequestDirection}.
543 *
544 * @param ep Indicates the endpoint address, which is in the <b>uint8_t</b> format.
545 *
546 * @return Returns <b>1</b> if the specified endpoint is in the input direction; returns <b>0</b> otherwise.
547 */
548inline int32_t UsbEndpointDirIn(uint8_t ep)
549{
550    return ((ep & USB_DDK_ENDPOINT_DIR_MASK) == USB_DDK_DIR_IN);
551}
552
553/**
554 * @brief Checks whether the specified endpoint is in the output direction (the direction in which data is
555 * transferred from the host to the device). For details, see {@link UsbRequestDirection}.
556 *
557 * @param ep Indicates the endpoint address, which is in the <b>uint8_t</b> format.
558 *
559 * @return Returns <b>1</b> if the specified endpoint is in the output direction; returns <b>0</b> otherwise.
560 */
561inline int32_t UsbEndpointDirOut(uint8_t ep)
562{
563    return ((ep & USB_DDK_ENDPOINT_DIR_MASK) == USB_DDK_DIR_OUT);
564}
565
566#endif /* USB_DDK_H */
567/** @} */
568