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 |
|
|
/** Host Stack */ |
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_stack.h" |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _ux_host_stack_endpoint_reset PORTABLE C */ |
36 |
|
|
/* 6.1 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* This function resets an endpoint after a stall or other error */ |
44 |
|
|
/* condition. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* endpoint Endpoint to abort transfer */ |
49 |
|
|
/* */ |
50 |
|
|
/* OUTPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* Completion Status */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLS */ |
55 |
|
|
/* */ |
56 |
|
|
/* _ux_host_stack_transfer_request Send transfer request */ |
57 |
|
|
/* (ux_hcd_entry_function) HCD entry function */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLED BY */ |
60 |
|
|
/* */ |
61 |
|
|
/* USBX Components */ |
62 |
|
|
/* */ |
63 |
|
|
/* RELEASE HISTORY */ |
64 |
|
|
/* */ |
65 |
|
|
/* DATE NAME DESCRIPTION */ |
66 |
|
|
/* */ |
67 |
|
|
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ |
68 |
|
|
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ |
69 |
|
|
/* optimized based on compile */ |
70 |
|
|
/* definitions, */ |
71 |
|
|
/* resulting in version 6.1 */ |
72 |
|
|
/* */ |
73 |
|
|
/**************************************************************************/ |
74 |
|
1448 |
UINT _ux_host_stack_endpoint_reset(UX_ENDPOINT *endpoint) |
75 |
|
|
{ |
76 |
|
|
|
77 |
|
|
UX_ENDPOINT *control_endpoint; |
78 |
|
|
UX_TRANSFER *transfer_request; |
79 |
|
|
UX_DEVICE *device; |
80 |
|
|
UX_HCD *hcd; |
81 |
|
|
UINT status; |
82 |
|
|
|
83 |
|
|
|
84 |
|
|
/* Get the device container from the endpoint */ |
85 |
|
1448 |
device = endpoint -> ux_endpoint_device; |
86 |
|
|
|
87 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
88 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_RESET, device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) |
89 |
|
|
|
90 |
|
|
/* Get the control endpoint attached to the device. */ |
91 |
|
1448 |
control_endpoint = &device -> ux_device_control_endpoint; |
92 |
|
|
|
93 |
|
|
/* Retrieve the transfer_request pointer. */ |
94 |
|
1448 |
transfer_request = &control_endpoint -> ux_endpoint_transfer_request; |
95 |
|
|
|
96 |
|
|
/* Create a transfer_request for the CLEAR_FEATURE request. */ |
97 |
|
1448 |
transfer_request -> ux_transfer_request_data_pointer = UX_NULL; |
98 |
|
1448 |
transfer_request -> ux_transfer_request_requested_length = 0; |
99 |
|
1448 |
transfer_request -> ux_transfer_request_function = UX_CLEAR_FEATURE; |
100 |
|
1448 |
transfer_request -> ux_transfer_request_type = UX_REQUEST_OUT| UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_ENDPOINT; |
101 |
|
1448 |
transfer_request -> ux_transfer_request_value = UX_ENDPOINT_HALT; |
102 |
|
1448 |
transfer_request -> ux_transfer_request_index = endpoint -> ux_endpoint_descriptor.bEndpointAddress; |
103 |
|
|
|
104 |
|
|
/* Send request to HCD layer. */ |
105 |
|
1448 |
status = _ux_host_stack_transfer_request(transfer_request); |
106 |
|
|
|
107 |
|
|
/* Reset the endpoint at the HCD level. */ |
108 |
✓✓ |
1448 |
if (status == UX_SUCCESS) |
109 |
|
|
{ |
110 |
|
|
|
111 |
|
|
/* Pickup HCD pointer. */ |
112 |
|
1421 |
hcd = UX_DEVICE_HCD_GET(device); |
113 |
|
|
|
114 |
|
|
/* Call HCD entry function. */ |
115 |
|
1421 |
status = hcd -> ux_hcd_entry_function(hcd, UX_HCD_RESET_ENDPOINT, endpoint); |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
/* And return the completion status. */ |
119 |
|
1448 |
return(status); |
120 |
|
|
} |
121 |
|
|
|