1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
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.2.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 storage 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 /* RELEASE HISTORY */
69 /* */
70 /* DATE NAME DESCRIPTION */
71 /* */
72 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
73 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
74 /* resulting in version 6.1 */
75 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
76 /* refined macros names, */
77 /* resulting in version 6.1.10 */
78 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
79 /* fixed standalone compile, */
80 /* resulting in version 6.1.11 */
81 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
82 /* fixed parameter/variable */
83 /* names conflict C++ keyword, */
84 /* resulting in version 6.1.12 */
85 /* 10-31-2022 Chaoqiong Xiao Modified comment(s), */
86 /* removed internal NX pool, */
87 /* resulting in version 6.2.0 */
88 /* */
89 /**************************************************************************/
_ux_device_class_cdc_ecm_uninitialize(UX_SLAVE_CLASS_COMMAND * command)90 UINT _ux_device_class_cdc_ecm_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
91 {
92
93 UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
94 UX_SLAVE_CLASS *class_ptr;
95
96
97 /* Get the class container. */
98 class_ptr = command -> ux_slave_class_command_class_ptr;
99
100 /* Get the class instance in the container. */
101 cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
102
103 /* Sanity check. */
104 if (cdc_ecm != UX_NULL)
105 {
106
107 /* Deinitialize resources. We do not check if they have been allocated
108 because if they weren't, the class register (called by the application)
109 would have failed. */
110
111 #if !defined(UX_DEVICE_STANDALONE)
112
113 /* Delete the xmit queue mutex. */
114 _ux_device_mutex_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_mutex);
115
116 /* Delete bulk out thread . */
117 _ux_device_thread_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread);
118
119 /* Free bulk out thread stack. */
120 _ux_utility_memory_free(cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread_stack);
121
122 /* Delete interrupt thread. */
123 _ux_device_thread_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread);
124
125 /* Free interrupt thread stack. */
126 _ux_utility_memory_free(cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread_stack);
127
128 /* Delete bulk in thread. */
129 _ux_device_thread_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread);
130
131 /* Free bulk in thread stack. */
132 _ux_utility_memory_free(cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread_stack);
133
134 /* Delete the interrupt thread sync event flags group. */
135 _ux_device_event_flags_delete(&cdc_ecm -> ux_slave_class_cdc_ecm_event_flags_group);
136
137 #endif
138
139 /* Free the resources. */
140 _ux_utility_memory_free(cdc_ecm);
141 }
142
143 /* Return completion status. */
144 return(UX_SUCCESS);
145 }
146