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 |
|
|
/** Device CDC-ECM Class */ |
19 |
|
|
/** */ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
/**************************************************************************/ |
22 |
|
|
|
23 |
|
|
#define UX_SOURCE_CODE |
24 |
|
|
|
25 |
|
|
|
26 |
|
|
/* Include necessary system files. */ |
27 |
|
|
|
28 |
|
|
#include "ux_api.h" |
29 |
|
|
#include "ux_device_class_cdc_ecm.h" |
30 |
|
|
#include "ux_device_stack.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _ux_device_class_cdc_ecm_uninitialize PORTABLE C */ |
38 |
|
|
/* 6.3.0 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function deinitializes the resources for the specified CDC-ECM */ |
46 |
|
|
/* instance. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* command Pointer to cdc ecm command */ |
51 |
|
|
/* */ |
52 |
|
|
/* OUTPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* Completion Status */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLS */ |
57 |
|
|
/* */ |
58 |
|
|
/* _ux_device_mutex_delete Delete mutex */ |
59 |
|
|
/* _ux_device_thread_delete Delete thread */ |
60 |
|
|
/* _ux_utility_memory_free Free memory */ |
61 |
|
|
/* _ux_utility_event_flags_delete Delete event flags */ |
62 |
|
|
/* _ux_device_semaphore_delete Delete semaphore */ |
63 |
|
|
/* */ |
64 |
|
|
/* CALLED BY */ |
65 |
|
|
/* */ |
66 |
|
|
/* Device CDC-ECM Class */ |
67 |
|
|
/* */ |
68 |
|
|
/**************************************************************************/ |
69 |
|
7 |
UINT _ux_device_class_cdc_ecm_uninitialize(UX_SLAVE_CLASS_COMMAND *command) |
70 |
|
|
{ |
71 |
|
|
|
72 |
|
|
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm; |
73 |
|
|
UX_SLAVE_CLASS *class_ptr; |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
/* Get the class container. */ |
77 |
|
7 |
class_ptr = command -> ux_slave_class_command_class_ptr; |
78 |
|
|
|
79 |
|
|
/* Get the class instance in the container. */ |
80 |
|
7 |
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance; |
81 |
|
|
|
82 |
|
|
/* Sanity check. */ |
83 |
✓✓ |
7 |
if (cdc_ecm != UX_NULL) |
84 |
|
|
{ |
85 |
|
|
|
86 |
|
|
/* Deinitialize resources. We do not check if they have been allocated |
87 |
|
|
because if they weren't, the class register (called by the application) |
88 |
|
|
would have failed. */ |
89 |
|
|
|
90 |
|
|
#if !defined(UX_DEVICE_STANDALONE) |
91 |
|
|
|
92 |
|
|
/* Delete the xmit queue mutex. */ |
93 |
|
6 |
_ux_device_mutex_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_mutex); |
94 |
|
|
|
95 |
|
|
/* Delete bulk out thread . */ |
96 |
|
6 |
_ux_device_thread_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread); |
97 |
|
|
|
98 |
|
|
/* Free bulk out thread stack. */ |
99 |
|
6 |
_ux_utility_memory_free(cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread_stack); |
100 |
|
|
|
101 |
|
|
/* Delete interrupt thread. */ |
102 |
|
6 |
_ux_device_thread_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread); |
103 |
|
|
|
104 |
|
|
/* Free interrupt thread stack. */ |
105 |
|
6 |
_ux_utility_memory_free(cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread_stack); |
106 |
|
|
|
107 |
|
|
/* Delete bulk in thread. */ |
108 |
|
6 |
_ux_device_thread_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread); |
109 |
|
|
|
110 |
|
|
/* Free bulk in thread stack. */ |
111 |
|
6 |
_ux_utility_memory_free(cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread_stack); |
112 |
|
|
|
113 |
|
|
/* Delete the interrupt thread sync event flags group. */ |
114 |
|
6 |
_ux_device_event_flags_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_event_flags_group); |
115 |
|
|
|
116 |
|
|
#endif |
117 |
|
|
|
118 |
|
|
/* Free the resources. */ |
119 |
|
|
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1 |
120 |
|
|
_ux_utility_memory_free(cdc_ecm -> ux_device_class_cdc_ecm_endpoint_buffer); |
121 |
|
|
#endif |
122 |
|
6 |
_ux_utility_memory_free(cdc_ecm); |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
/* Return completion status. */ |
126 |
|
7 |
return(UX_SUCCESS); |
127 |
|
|
} |