Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_device_class_cdc_ecm.h"
#include "ux_device_stack.h"
...
...
_ux_device_class_cdc_ecm_interrupt_thread(ULONG)
Files
loading...
CodeScopeSTM32 Libraries and Samplesusbxcommon/usbx_device_classes/src/ux_device_class_cdc_ecm_interrupt_thread.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ /**************************************************************************/ /**************************************************************************/ /** */ /** USBX Component */ /** */ /** Device CDC_ECM Class */ /** */... /**************************************************************************/ /**************************************************************************/ #define UX_SOURCE_CODE /* Include necessary system files. */ #include "ux_api.h" #include "ux_device_class_cdc_ecm.h" #include "ux_device_stack.h" ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_device_class_cdc_ecm_interrupt_thread PORTABLE C */ /* 6.1.10 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function is the thread of the cdc_ecm interrupt endpoint */ /* */ /* INPUT */ /* */ /* cdc_ecm_class Address of cdc_ecm class */ /* container */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _ux_device_stack_transfer_request Request transfer */ /* _ux_utility_event_flags_get Get event flags */ /* _ux_utility_short_put Put 16-bit value to buffer */ /* _ux_device_thread_suspend Suspend thread */ /* */ /* CALLED BY */ /* */ /* ThreadX */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* used UX prefix to refer to */ /* TX symbols instead of using */ /* them directly, */ /* resulting in version 6.1 */ /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ /* refined macros names, */ /* resulting in version 6.1.10 */ /* */... /**************************************************************************/ VOID _ux_device_class_cdc_ecm_interrupt_thread(ULONG cdc_ecm_class) { UX_SLAVE_CLASS *class; UX_SLAVE_CLASS_CDC_ECM *cdc_ecm; UX_SLAVE_DEVICE *device; UX_SLAVE_TRANSFER *transfer_request; UINT status; ULONG actual_flags; UCHAR *notification_buffer; /* Cast properly the cdc_ecm instance. */ UX_THREAD_EXTENSION_PTR_GET(class, UX_SLAVE_CLASS, cdc_ecm_class) /* Get the cdc_ecm instance from this class container. */ cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance; /* Get the pointer to the device. */ device = &_ux_system_slave -> ux_system_slave_device; /* This thread runs forever but can be suspended or resumed. */ while(1) { /* All CDC_ECM events are on the interrupt endpoint IN, from the host. */ transfer_request = &cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_endpoint -> ux_slave_endpoint_transfer_request; /* As long as the device is in the CONFIGURED state. */ while (device -> ux_slave_device_state == UX_DEVICE_CONFIGURED) { /* Wait until we have a event sent by the application. We do not treat yet the case where a timeout based on the interrupt pipe frequency or a change in the idle state forces us to send an empty report. *//* ... */ _ux_utility_event_flags_get(&cdc_ecm -> ux_slave_class_cdc_ecm_event_flags_group, UX_DEVICE_CLASS_CDC_ECM_NETWORK_NOTIFICATION_EVENT, UX_OR_CLEAR, &actual_flags, UX_WAIT_FOREVER); /* Build the Network Notification response. */ notification_buffer = transfer_request -> ux_slave_transfer_request_data_pointer; /* Set the request type. */ *(notification_buffer + UX_SETUP_REQUEST_TYPE) = UX_REQUEST_IN | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_INTERFACE; /* Set the request itself. */ *(notification_buffer + UX_SETUP_REQUEST) = 0; /* Set the value. It is the network link. */ _ux_utility_short_put(notification_buffer + UX_SETUP_VALUE, (USHORT)(cdc_ecm -> ux_slave_class_cdc_ecm_link_state)); /* Set the Index. It is interface. The interface used is the DATA interface. Here we simply take the interface number of the CONTROL and add 1 to it as it is assumed the classes are contiguous in number. *//* ... */ _ux_utility_short_put(notification_buffer + UX_SETUP_INDEX, (USHORT)(cdc_ecm -> ux_slave_class_cdc_ecm_interface -> ux_slave_interface_descriptor.bInterfaceNumber + 1)); /* And the length is zero. */ *(notification_buffer + UX_SETUP_LENGTH) = 0; /* Send the request to the device controller. */ status = _ux_device_stack_transfer_request(transfer_request, UX_DEVICE_CLASS_CDC_ECM_INTERRUPT_RESPONSE_LENGTH, UX_DEVICE_CLASS_CDC_ECM_INTERRUPT_RESPONSE_LENGTH); /* Check error code. */ if (status != UX_SUCCESS) { /* Since bus resets are expected, we do not treat it as an error. */ if (status != UX_TRANSFER_BUS_RESET) { /* Error trap. */ _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, status); }if (status != UX_TRANSFER_BUS_RESET) { ... } }if (status != UX_SUCCESS) { ... } }while (device -> ux_slave_device_state == UX_DEVICE_CONFIGURED) { ... } /* We need to suspend ourselves. We will be resumed by the device enumeration module. */ _ux_device_thread_suspend(&cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread); }while (1) { ... } }{ ... }