1
10
13
14
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
133
134
135
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_class_hid.h"
#include "ux_host_stack.h"
...
...
UINT _ux_host_class_hid_interrupt_endpoint_search(UX_HOST_CLASS_HID *hid)
{
UINT status = UX_ENDPOINT_HANDLE_UNKNOWN;
UX_INTERFACE *interface;
UX_ENDPOINT *endpoint;
UX_TRANSFER *transfer_request;
interface = hid -> ux_host_class_hid_interface;
endpoint = interface -> ux_interface_first_endpoint;
while(endpoint != UX_NULL)
{
if (((endpoint -> ux_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) == UX_ENDPOINT_IN) &&
((endpoint -> ux_endpoint_descriptor.bmAttributes & UX_MASK_ENDPOINT_TYPE) == UX_INTERRUPT_ENDPOINT))
{
hid -> ux_host_class_hid_interrupt_endpoint = endpoint;
transfer_request = &endpoint -> ux_endpoint_transfer_request;
transfer_request -> ux_transfer_request_requested_length = hid -> ux_host_class_hid_interrupt_endpoint -> ux_endpoint_descriptor.wMaxPacketSize;
transfer_request -> ux_transfer_request_actual_length = 0;
transfer_request -> ux_transfer_request_type = UX_REQUEST_IN;
transfer_request -> ux_transfer_request_class_instance = (VOID *) hid;
transfer_request -> ux_transfer_request_completion_function = _ux_host_class_hid_transfer_request_completed;
transfer_request -> ux_transfer_request_timeout_value = UX_WAIT_FOREVER;
transfer_request -> ux_transfer_request_data_pointer = _ux_utility_memory_allocate(UX_SAFE_ALIGN, UX_CACHE_SAFE_MEMORY,
transfer_request -> ux_transfer_request_requested_length);
if (transfer_request -> ux_transfer_request_data_pointer != UX_NULL)
{
hid -> ux_host_class_hid_interrupt_endpoint_status = UX_HOST_CLASS_HID_INTERRUPT_ENDPOINT_READY;
status = UX_SUCCESS;
#if !defined(UX_HOST_CLASS_HID_INTERRUPT_OUT_SUPPORT)
break;/* ... */
#endif
}if (transfer_request -> ux_transfer_request_data_pointer != UX_NULL) { ... }
else
{
status = UX_MEMORY_INSUFFICIENT;
break;
}else { ... }
}if (((endpoint -> ux_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) == UX_ENDPOINT_IN) && ((endpoint -> ux_endpoint_descriptor.bmAttributes & UX_MASK_ENDPOINT_TYPE) == UX_INTERRUPT_ENDPOINT)) { ... }
#if defined(UX_HOST_CLASS_HID_INTERRUPT_OUT_SUPPORT)
else if (((endpoint -> ux_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) == UX_ENDPOINT_OUT) &&
((endpoint -> ux_endpoint_descriptor.bmAttributes & UX_MASK_ENDPOINT_TYPE) == UX_INTERRUPT_ENDPOINT))
{
hid -> ux_host_class_hid_interrupt_out_endpoint = endpoint;
}else if (((endpoint -> ux_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) == UX_ENDPOINT_OUT) && ((endpoint -> ux_endpoint_descriptor.bmAttributes & UX_MASK_ENDPOINT_TYPE) == UX_INTERRUPT_ENDPOINT)) { ... }
/* ... */#endif
endpoint = endpoint -> ux_endpoint_next_endpoint;
}while (endpoint != UX_NULL) { ... }
return(status);
}{ ... }