1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* |
4 |
|
|
* This program and the accompanying materials are made available under the |
5 |
|
|
* terms of the MIT License which is available at |
6 |
|
|
* https://opensource.org/licenses/MIT. |
7 |
|
|
* |
8 |
|
|
* SPDX-License-Identifier: MIT |
9 |
|
|
**************************************************************************/ |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** USBX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** HID Class */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
|
22 |
|
|
|
23 |
|
|
/* Include necessary system files. */ |
24 |
|
|
|
25 |
|
|
#define UX_SOURCE_CODE |
26 |
|
|
|
27 |
|
|
#include "ux_api.h" |
28 |
|
|
#include "ux_host_class_hid.h" |
29 |
|
|
#include "ux_host_stack.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _ux_host_class_hid_periodic_report_start PORTABLE C */ |
37 |
|
|
/* 6.1.10 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function starts the interrupt endpoint to obtain the periodic */ |
45 |
|
|
/* report. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* hid Pointer to HID class */ |
50 |
|
|
/* */ |
51 |
|
|
/* OUTPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* Completion Status */ |
54 |
|
|
/* */ |
55 |
|
|
/* CALLS */ |
56 |
|
|
/* */ |
57 |
|
|
/* _ux_host_stack_class_instance_verify Verify instance is valid */ |
58 |
|
|
/* _ux_host_stack_transfer_request Process transfer request */ |
59 |
|
|
/* _ux_host_semaphore_get Get protection semaphore */ |
60 |
|
|
/* _ux_host_semaphore_put Release protection semaphore */ |
61 |
|
|
/* */ |
62 |
|
|
/* CALLED BY */ |
63 |
|
|
/* */ |
64 |
|
|
/* Application */ |
65 |
|
|
/* HID Class */ |
66 |
|
|
/* */ |
67 |
|
|
/* RELEASE HISTORY */ |
68 |
|
|
/* */ |
69 |
|
|
/* DATE NAME DESCRIPTION */ |
70 |
|
|
/* */ |
71 |
|
|
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ |
72 |
|
|
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ |
73 |
|
|
/* resulting in version 6.1 */ |
74 |
|
|
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ |
75 |
|
|
/* added standalone support, */ |
76 |
|
|
/* resulting in version 6.1.10 */ |
77 |
|
|
/* */ |
78 |
|
|
/**************************************************************************/ |
79 |
|
211 |
UINT _ux_host_class_hid_periodic_report_start(UX_HOST_CLASS_HID *hid) |
80 |
|
|
{ |
81 |
|
|
#if defined(UX_HOST_STANDALONE) |
82 |
|
|
UX_INTERRUPT_SAVE_AREA |
83 |
|
|
#endif |
84 |
|
|
UINT status; |
85 |
|
|
UX_TRANSFER *transfer_request; |
86 |
|
|
|
87 |
|
|
|
88 |
|
|
/* Ensure the instance is valid. */ |
89 |
✓✓ |
211 |
if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS) |
90 |
|
|
{ |
91 |
|
|
|
92 |
|
|
/* Error trap. */ |
93 |
|
1 |
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN); |
94 |
|
|
|
95 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
96 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0) |
97 |
|
|
|
98 |
|
1 |
return(UX_HOST_CLASS_INSTANCE_UNKNOWN); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
/* Protect thread reentry to this instance. */ |
102 |
✓✓ |
210 |
_ux_host_class_hid_lock_fail_return(hid); |
103 |
|
|
|
104 |
|
|
/* Check the status of the interrupt endpoint. */ |
105 |
✓✓ |
209 |
if (hid -> ux_host_class_hid_interrupt_endpoint_status != UX_HOST_CLASS_HID_INTERRUPT_ENDPOINT_READY) |
106 |
|
|
{ |
107 |
|
|
|
108 |
|
|
/* Unprotect thread reentry to this instance. */ |
109 |
|
3 |
_ux_host_class_hid_unlock(hid); |
110 |
|
|
|
111 |
|
|
/* Error trap. */ |
112 |
|
3 |
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR); |
113 |
|
|
|
114 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
115 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR, hid, 0, 0, UX_TRACE_ERRORS, 0, 0) |
116 |
|
|
|
117 |
|
|
/* Return error status. */ |
118 |
|
3 |
return(UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR); |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
/* Get the address of the HID associated with the interrupt endpoint. */ |
122 |
|
206 |
transfer_request = &hid -> ux_host_class_hid_interrupt_endpoint -> ux_endpoint_transfer_request; |
123 |
|
|
|
124 |
|
|
/* The transfer on the interrupt endpoint can be started. */ |
125 |
|
206 |
status = _ux_host_stack_transfer_request(transfer_request); |
126 |
|
|
|
127 |
|
|
/* Check the status. If no error, adjust the status of the periodic endpoint |
128 |
|
|
to active. */ |
129 |
✓✓ |
206 |
if (status == UX_SUCCESS) |
130 |
|
205 |
hid -> ux_host_class_hid_interrupt_endpoint_status = UX_HOST_CLASS_HID_INTERRUPT_ENDPOINT_ACTIVE; |
131 |
|
|
|
132 |
|
|
/* Unprotect thread reentry to this instance. */ |
133 |
|
206 |
_ux_host_class_hid_unlock(hid); |
134 |
|
|
|
135 |
|
|
/* Return the function status */ |
136 |
|
206 |
return(status); |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
/**************************************************************************/ |
140 |
|
|
/* */ |
141 |
|
|
/* FUNCTION RELEASE */ |
142 |
|
|
/* */ |
143 |
|
|
/* _uxe_host_class_hid_periodic_report_start PORTABLE C */ |
144 |
|
|
/* 6.3.0 */ |
145 |
|
|
/* AUTHOR */ |
146 |
|
|
/* */ |
147 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
148 |
|
|
/* */ |
149 |
|
|
/* DESCRIPTION */ |
150 |
|
|
/* */ |
151 |
|
|
/* This function checks errors in HID periodic report start function */ |
152 |
|
|
/* call. */ |
153 |
|
|
/* */ |
154 |
|
|
/* INPUT */ |
155 |
|
|
/* */ |
156 |
|
|
/* hid Pointer to HID class */ |
157 |
|
|
/* */ |
158 |
|
|
/* OUTPUT */ |
159 |
|
|
/* */ |
160 |
|
|
/* Status */ |
161 |
|
|
/* */ |
162 |
|
|
/* CALLS */ |
163 |
|
|
/* */ |
164 |
|
|
/* _ux_host_class_hid_periodic_report_start */ |
165 |
|
|
/* Start polling periodic report */ |
166 |
|
|
/* */ |
167 |
|
|
/* CALLED BY */ |
168 |
|
|
/* */ |
169 |
|
|
/* Application */ |
170 |
|
|
/* */ |
171 |
|
|
/* RELEASE HISTORY */ |
172 |
|
|
/* */ |
173 |
|
|
/* DATE NAME DESCRIPTION */ |
174 |
|
|
/* */ |
175 |
|
|
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */ |
176 |
|
|
/* */ |
177 |
|
|
/**************************************************************************/ |
178 |
|
|
UINT _uxe_host_class_hid_periodic_report_start(UX_HOST_CLASS_HID *hid) |
179 |
|
|
{ |
180 |
|
|
|
181 |
|
|
/* Sanity check. */ |
182 |
|
|
if (hid == UX_NULL) |
183 |
|
|
return(UX_INVALID_PARAMETER); |
184 |
|
|
|
185 |
|
|
/* Invoke periodic start function. */ |
186 |
|
|
return(_ux_host_class_hid_periodic_report_start(hid)); |
187 |
|
|
} |