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 CCID 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_ccid.h"
28 #include "ux_device_stack.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_device_class_ccid_deactivate PORTABLE C */
36 /* 6.1.11 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function deactivate an instance of the ccid 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_stack_transfer_all_request_abort */
56 /* Abort all transfers */
57 /* */
58 /* CALLED BY */
59 /* */
60 /* CCID Class */
61 /* */
62 /* RELEASE HISTORY */
63 /* */
64 /* DATE NAME DESCRIPTION */
65 /* */
66 /* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
67 /* */
68 /**************************************************************************/
_ux_device_class_ccid_deactivate(UX_SLAVE_CLASS_COMMAND * command)69 UINT _ux_device_class_ccid_deactivate(UX_SLAVE_CLASS_COMMAND *command)
70 {
71
72 UX_DEVICE_CLASS_CCID *ccid;
73 UX_SLAVE_CLASS *ccid_class;
74 UX_SLAVE_ENDPOINT *endpoint;
75
76 /* Get the class container. */
77 ccid_class = command -> ux_slave_class_command_class_ptr;
78
79 /* Get the class instance in the container. */
80 ccid = (UX_DEVICE_CLASS_CCID *) ccid_class -> ux_slave_class_instance;
81
82 /* Terminate the transactions pending on the endpoints. */
83 endpoint = ccid -> ux_device_class_ccid_endpoint_out;
84 _ux_device_stack_transfer_all_request_abort(endpoint, UX_TRANSFER_BUS_RESET);
85
86 endpoint = ccid -> ux_device_class_ccid_endpoint_in;
87 _ux_device_stack_transfer_all_request_abort(endpoint, UX_TRANSFER_BUS_RESET);
88
89 endpoint = ccid -> ux_device_class_ccid_endpoint_notify;
90 if (endpoint)
91 _ux_device_stack_transfer_all_request_abort(endpoint, UX_TRANSFER_BUS_RESET);
92
93 /* If there is a deactivate function call it. */
94 if (ccid -> ux_device_class_ccid_parameter.ux_device_class_ccid_instance_deactivate != UX_NULL)
95 {
96
97 /* Invoke the application. */
98 ccid -> ux_device_class_ccid_parameter.ux_device_class_ccid_instance_deactivate(ccid);
99 }
100
101 /* If trace is enabled, insert this event into the trace buffer. */
102 UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_CCID_DEACTIVATE, ccid, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
103
104 /* If trace is enabled, register this object. */
105 UX_TRACE_OBJECT_UNREGISTER(ccid);
106
107 /* Return completion status. */
108 return(UX_SUCCESS);
109 }
110