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
87
88
89
90
91
92
93
94
95
96
97
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
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_stack.h"
...
...
UINT _ux_host_stack_role_swap(UX_DEVICE *device)
{
#if !defined(UX_OTG_SUPPORT)
UX_PARAMETER_NOT_USED(device);
return(UX_FUNCTION_NOT_SUPPORTED);/* ... */
#else
UX_ENDPOINT *control_endpoint;
UX_TRANSFER *transfer_request;
UINT status;
control_endpoint = &device -> ux_device_control_endpoint;
transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
/* ... */
status = _ux_host_semaphore_get(&device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
transfer_request -> ux_transfer_request_requested_length = 0;
transfer_request -> ux_transfer_request_function = UX_SET_FEATURE;
transfer_request -> ux_transfer_request_type = UX_REQUEST_OUT | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_DEVICE;
transfer_request -> ux_transfer_request_value = UX_OTG_FEATURE_B_HNP_ENABLE;
transfer_request -> ux_transfer_request_index = 0;
status = _ux_host_stack_transfer_request(transfer_request);
if (status != UX_SUCCESS)
return(status);
_ux_system_otg -> ux_system_otg_change_mode_event = UX_OTG_HOST_TO_SLAVE;
_ux_system_otg -> ux_system_otg_function(UX_OTG_HOST_TO_SLAVE);
_ux_system_otg -> ux_system_otg_change_mode_event = 0;
return(UX_SUCCESS);/* ... */
#endif
}{ ... }