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 PIMA 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_pima.h"
28 #include "ux_device_stack.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_device_class_pima_deactivate PORTABLE C */
36 /* 6.3.0 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function deactivate an instance of the pima 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 Abort all transfers */
56 /* */
57 /* CALLED BY */
58 /* */
59 /* PIMA Class */
60 /* */
61 /* RELEASE HISTORY */
62 /* */
63 /* DATE NAME DESCRIPTION */
64 /* */
65 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
66 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
67 /* resulting in version 6.1 */
68 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
69 /* fixed parameter/variable */
70 /* names conflict C++ keyword, */
71 /* resulting in version 6.1.12 */
72 /* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
73 /* supported optional INT EP, */
74 /* resulting in version 6.3.0 */
75 /* */
76 /**************************************************************************/
_ux_device_class_pima_deactivate(UX_SLAVE_CLASS_COMMAND * command)77 UINT _ux_device_class_pima_deactivate(UX_SLAVE_CLASS_COMMAND *command)
78 {
79
80 UX_SLAVE_CLASS_PIMA *pima;
81 UX_SLAVE_CLASS *class_ptr;
82
83 /* Get the class container. */
84 class_ptr = command -> ux_slave_class_command_class_ptr;
85
86 /* Store the class instance in the container. */
87 pima = (UX_SLAVE_CLASS_PIMA *) class_ptr -> ux_slave_class_instance;
88
89 /* Terminate the transactions pending on the endpoints. */
90 _ux_device_stack_transfer_all_request_abort(pima -> ux_device_class_pima_bulk_in_endpoint, UX_TRANSFER_BUS_RESET);
91 _ux_device_stack_transfer_all_request_abort(pima -> ux_device_class_pima_bulk_out_endpoint, UX_TRANSFER_BUS_RESET);
92 if (pima -> ux_device_class_pima_interrupt_endpoint)
93 _ux_device_stack_transfer_all_request_abort(pima -> ux_device_class_pima_interrupt_endpoint, UX_TRANSFER_BUS_RESET);
94
95 /* Session is now closed. */
96 pima -> ux_device_class_pima_session_id = 0;
97
98 /* If there is a deactivate function call it. */
99 if (pima -> ux_device_class_pima_instance_deactivate != UX_NULL)
100 {
101 /* Invoke the application. */
102 pima -> ux_device_class_pima_instance_deactivate(pima);
103 }
104
105 /* If trace is enabled, insert this event into the trace buffer. */
106 UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_PIMA_DEACTIVATE, pima, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
107
108 /* If trace is enabled, register this object. */
109 UX_TRACE_OBJECT_UNREGISTER(pima);
110
111 /* Return completion status. */
112 return(UX_SUCCESS);
113 }
114
115