1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
10 |
|
|
**************************************************************************/ |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/** */ |
16 |
|
|
/** USBX Component */ |
17 |
|
|
/** */ |
18 |
|
|
/** Host Stack */ |
19 |
|
|
/** */ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
/**************************************************************************/ |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#define UX_SOURCE_CODE |
27 |
|
|
|
28 |
|
|
#include "ux_api.h" |
29 |
|
|
#include "ux_host_stack.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _ux_host_stack_endpoint_reset PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function resets an endpoint after a stall or other error */ |
45 |
|
|
/* condition. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* endpoint Endpoint to abort transfer */ |
50 |
|
|
/* */ |
51 |
|
|
/* OUTPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* Completion Status */ |
54 |
|
|
/* */ |
55 |
|
|
/* CALLS */ |
56 |
|
|
/* */ |
57 |
|
|
/* _ux_host_stack_transfer_request Send transfer request */ |
58 |
|
|
/* (ux_hcd_entry_function) HCD entry function */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLED BY */ |
61 |
|
|
/* */ |
62 |
|
|
/* USBX Components */ |
63 |
|
|
/* */ |
64 |
|
|
/**************************************************************************/ |
65 |
|
1448 |
UINT _ux_host_stack_endpoint_reset(UX_ENDPOINT *endpoint) |
66 |
|
|
{ |
67 |
|
|
|
68 |
|
|
UX_ENDPOINT *control_endpoint; |
69 |
|
|
UX_TRANSFER *transfer_request; |
70 |
|
|
UX_DEVICE *device; |
71 |
|
|
UX_HCD *hcd; |
72 |
|
|
UINT status; |
73 |
|
|
|
74 |
|
|
|
75 |
|
|
/* Get the device container from the endpoint */ |
76 |
|
1448 |
device = endpoint -> ux_endpoint_device; |
77 |
|
|
|
78 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
79 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_RESET, device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) |
80 |
|
|
|
81 |
|
|
/* Get the control endpoint attached to the device. */ |
82 |
|
1448 |
control_endpoint = &device -> ux_device_control_endpoint; |
83 |
|
|
|
84 |
|
|
/* Retrieve the transfer_request pointer. */ |
85 |
|
1448 |
transfer_request = &control_endpoint -> ux_endpoint_transfer_request; |
86 |
|
|
|
87 |
|
|
/* Create a transfer_request for the CLEAR_FEATURE request. */ |
88 |
|
1448 |
transfer_request -> ux_transfer_request_data_pointer = UX_NULL; |
89 |
|
1448 |
transfer_request -> ux_transfer_request_requested_length = 0; |
90 |
|
1448 |
transfer_request -> ux_transfer_request_function = UX_CLEAR_FEATURE; |
91 |
|
1448 |
transfer_request -> ux_transfer_request_type = UX_REQUEST_OUT| UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_ENDPOINT; |
92 |
|
1448 |
transfer_request -> ux_transfer_request_value = UX_ENDPOINT_HALT; |
93 |
|
1448 |
transfer_request -> ux_transfer_request_index = endpoint -> ux_endpoint_descriptor.bEndpointAddress; |
94 |
|
|
|
95 |
|
|
/* Send request to HCD layer. */ |
96 |
|
1448 |
status = _ux_host_stack_transfer_request(transfer_request); |
97 |
|
|
|
98 |
|
|
/* Reset the endpoint at the HCD level. */ |
99 |
✓✓ |
1448 |
if (status == UX_SUCCESS) |
100 |
|
|
{ |
101 |
|
|
|
102 |
|
|
/* Pickup HCD pointer. */ |
103 |
|
1421 |
hcd = UX_DEVICE_HCD_GET(device); |
104 |
|
|
|
105 |
|
|
/* Call HCD entry function. */ |
106 |
|
1421 |
status = hcd -> ux_hcd_entry_function(hcd, UX_HCD_RESET_ENDPOINT, endpoint); |
107 |
|
|
} |
108 |
|
|
|
109 |
|
|
/* And return the completion status. */ |
110 |
|
1448 |
return(status); |
111 |
|
|
} |
112 |
|
|
|