1 /*****************************************************************************
2  * Copyright (c) 2022, Nations Technologies Inc.
3  *
4  * All rights reserved.
5  * ****************************************************************************
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * - Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the disclaimer below.
12  *
13  * Nations' name may not be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
19  * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  * ****************************************************************************/
27 
28 /**
29  * @file usb_def.h
30  * @author Nations
31  * @version v1.2.0
32  *
33  * @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
34  */
35 #ifndef __USB_DEF_H__
36 #define __USB_DEF_H__
37 
38 /**
39  * @addtogroup N32L40X_USB_Driver
40  * @{
41  */
42 
43 typedef enum _RECIPIENT_TYPE
44 {
45     DEVICE_RECIPIENT,    /* Recipient device */
46     INTERFACE_RECIPIENT, /* Recipient interface */
47     ENDPOINT_RECIPIENT,  /* Recipient endpoint */
48     OTHER_RECIPIENT
49 } RECIPIENT_TYPE;
50 
51 typedef enum _STANDARD_REQUESTS
52 {
53     GET_STATUS = 0,
54     CLR_FEATURE,
55     RESERVED1,
56     SET_FEATURE,
57     RESERVED2,
58     SET_ADDRESS,
59     GET_DESCRIPTOR,
60     SET_DESCRIPTOR,
61     GET_CONFIGURATION,
62     SET_CONFIGURATION,
63     GET_INTERFACE,
64     SET_INTERFACE,
65     TOTAL_SREQUEST, /* Total number of Standard request */
66     SYNCH_FRAME = 12
67 } STANDARD_REQUESTS;
68 
69 /* Definition of "USBwValue" */
70 typedef enum _DESCRIPTOR_TYPE
71 {
72     DEVICE_DESCRIPTOR = 1,
73     CONFIG_DESCRIPTOR,
74     STRING_DESCRIPTOR,
75     INTERFACE_DESCRIPTOR,
76     ENDPOINT_DESCRIPTOR
77 } DESCRIPTOR_TYPE;
78 
79 /* Feature selector of a SET_FEATURE or CLR_FEATURE */
80 typedef enum _FEATURE_SELECTOR
81 {
82     ENDPOINT_STALL,
83     DEVICE_REMOTE_WAKEUP
84 } FEATURE_SELECTOR;
85 
86 /* Definition of "bmRequestType" */
87 #define REQUEST_TYPE     0x60 /* Mask to get request type */
88 #define STANDARD_REQUEST 0x00 /* Standard request */
89 #define CLASS_REQUEST    0x20 /* Class request */
90 #define VENDOR_REQUEST   0x40 /* Vendor request */
91 
92 #define RECIPIENT 0x1F /* Mask to get recipient */
93 
94 /**
95  * @}
96  */
97 
98 #endif /* __USB_DEF_H__ */
99