GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_device_classes/src/ux_device_class_cdc_acm_unitialize.c Lines: 12 12 100.0 %
Date: 2024-12-12 17:16:36 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
/**************************************************************************/
12
/**************************************************************************/
13
/**                                                                       */
14
/** USBX Component                                                        */
15
/**                                                                       */
16
/**   Device CDC Class                                                    */
17
/**                                                                       */
18
/**************************************************************************/
19
/**************************************************************************/
20
21
#define UX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "ux_api.h"
27
#include "ux_device_class_cdc_acm.h"
28
#include "ux_device_stack.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _ux_device_class_cdc_acm_uninitialize               PORTABLE C      */
36
/*                                                           6.3.0        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Chaoqiong Xiao, Microsoft Corporation                               */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function uninitialize the cdc-acm class.                       */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    command                               Pointer to a class command    */
48
/*                                                                        */
49
/*  OUTPUT                                                                */
50
/*                                                                        */
51
/*    Completion Status                                                   */
52
/*                                                                        */
53
/*  CALLS                                                                 */
54
/*                                                                        */
55
/*    _ux_device_mutex_delete               Delete Mutex                  */
56
/*    _ux_utility_memory_free               Free used local memory        */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    CDC Class                                                           */
61
/*                                                                        */
62
/*  RELEASE HISTORY                                                       */
63
/*                                                                        */
64
/*    DATE              NAME                      DESCRIPTION             */
65
/*                                                                        */
66
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
67
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
68
/*                                            resulting in version 6.1    */
69
/*  04-02-2021     Chaoqiong Xiao           Modified comment(s),          */
70
/*                                            added macro to disable      */
71
/*                                            transmission support,       */
72
/*                                            moved transmission resource */
73
/*                                            free to here (uninit),      */
74
/*                                            resulting in version 6.1.6  */
75
/*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
76
/*                                            added standalone support,   */
77
/*                                            resulting in version 6.1.10 */
78
/*  04-25-2022     Chaoqiong Xiao           Modified comment(s),          */
79
/*                                            resulting in version 6.1.11 */
80
/*  07-29-2022     Chaoqiong Xiao           Modified comment(s),          */
81
/*                                            fixed parameter/variable    */
82
/*                                            names conflict C++ keyword, */
83
/*                                            resulting in version 6.1.12 */
84
/*  10-31-2023     Chaoqiong Xiao           Modified comment(s),          */
85
/*                                            added zero copy support,    */
86
/*                                            added a new mode to manage  */
87
/*                                            endpoint buffer in classes, */
88
/*                                            resulting in version 6.3.0  */
89
/*                                                                        */
90
/**************************************************************************/
91
50
UINT  _ux_device_class_cdc_acm_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
92
{
93
94
UX_SLAVE_CLASS_CDC_ACM      *cdc_acm;
95
UX_SLAVE_CLASS              *class_ptr;
96
97
    /* Get the class container.  */
98
50
    class_ptr =  command -> ux_slave_class_command_class_ptr;
99
100
    /* Get the class instance in the container.  */
101
50
    cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class_ptr -> ux_slave_class_instance;
102
103
    /* Sanity check.  */
104
50
    if (cdc_acm != UX_NULL)
105
    {
106
107
#if !defined(UX_DEVICE_STANDALONE)
108
109
        /* Delete the IN endpoint mutex.  */
110
49
        _ux_device_mutex_delete(&cdc_acm -> ux_slave_class_cdc_acm_endpoint_in_mutex);
111
112
        /* Out Mutex. */
113
49
        _ux_device_mutex_delete(&cdc_acm -> ux_slave_class_cdc_acm_endpoint_out_mutex);
114
115
#ifndef UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE
116
117
        /* Free resources and return error.  */
118
49
        _ux_utility_thread_delete(&cdc_acm -> ux_slave_class_cdc_acm_bulkin_thread);
119
49
        _ux_utility_thread_delete(&cdc_acm -> ux_slave_class_cdc_acm_bulkout_thread);
120
49
        _ux_utility_event_flags_delete(&cdc_acm -> ux_slave_class_cdc_acm_event_flags_group);
121
49
        _ux_utility_memory_free(cdc_acm -> ux_slave_class_cdc_acm_bulkout_thread_stack);
122
#endif
123
#endif
124
125
#if defined(UX_DEVICE_CLASS_CDC_ACM_OWN_ENDPOINT_BUFFER)
126
127
        /* Free the buffer for bulk endpoints.  */
128
        _ux_utility_memory_free(cdc_acm -> ux_device_class_cdc_acm_endpoint_buffer);
129
#endif
130
131
        /* Free the resources.  */
132
49
        _ux_utility_memory_free(cdc_acm);
133
134
    }
135
136
    /* Return completion status.  */
137
50
    return(UX_SUCCESS);
138
}
139