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 HID 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_hid.h"
28 #include "ux_device_stack.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_device_class_hid_deactivate PORTABLE C */
36 /* 6.1.12 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function deactivate an instance of the hid 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 /* HID 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 /* */
73 /**************************************************************************/
_ux_device_class_hid_deactivate(UX_SLAVE_CLASS_COMMAND * command)74 UINT _ux_device_class_hid_deactivate(UX_SLAVE_CLASS_COMMAND *command)
75 {
76
77 UX_SLAVE_CLASS_HID *hid;
78 UX_SLAVE_CLASS *class_ptr;
79
80 /* Get the class container. */
81 class_ptr = command -> ux_slave_class_command_class_ptr;
82
83 /* Get the class instance in the container. */
84 hid = (UX_SLAVE_CLASS_HID *) class_ptr -> ux_slave_class_instance;
85
86 /* Terminate the transactions pending on the endpoints. */
87 _ux_device_stack_transfer_all_request_abort(hid -> ux_device_class_hid_interrupt_endpoint, UX_TRANSFER_BUS_RESET);
88
89 /* If there is a deactivate function call it. */
90 if (hid -> ux_slave_class_hid_instance_deactivate != UX_NULL)
91 {
92 /* Invoke the application. */
93 hid -> ux_slave_class_hid_instance_deactivate(hid);
94 }
95 /* If trace is enabled, insert this event into the trace buffer. */
96 UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_HID_DEACTIVATE, hid, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
97
98 /* If trace is enabled, register this object. */
99 UX_TRACE_OBJECT_UNREGISTER(hid);
100
101 /* Return completion status. */
102 return(UX_SUCCESS);
103 }
104
105