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 DFU 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_dfu.h"
28 #include "ux_device_stack.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_device_class_dfu_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 dfu 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 /* DFU 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 /* 04-02-2021 Chaoqiong Xiao Modified comment(s), */
69 /* removed endpoints aborting, */
70 /* resulting in version 6.1.6 */
71 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
72 /* fixed parameter/variable */
73 /* names conflict C++ keyword, */
74 /* resulting in version 6.1.12 */
75 /* */
76 /**************************************************************************/
_ux_device_class_dfu_deactivate(UX_SLAVE_CLASS_COMMAND * command)77 UINT _ux_device_class_dfu_deactivate(UX_SLAVE_CLASS_COMMAND *command)
78 {
79
80 UX_SLAVE_CLASS_DFU *dfu;
81 UX_SLAVE_CLASS *class_ptr;
82
83
84 /* Get the class container. */
85 class_ptr = command -> ux_slave_class_command_class_ptr;
86
87 /* Get the class instance in the container. */
88 dfu = (UX_SLAVE_CLASS_DFU *) class_ptr -> ux_slave_class_instance;
89
90 /* If there is a deactivate function call it. */
91 if (dfu -> ux_slave_class_dfu_instance_deactivate != UX_NULL)
92 {
93 /* Invoke the application. */
94 dfu -> ux_slave_class_dfu_instance_deactivate(dfu);
95 }
96
97 /* If trace is enabled, insert this event into the trace buffer. */
98 UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_DFU_DEACTIVATE, dfu, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
99
100 /* If trace is enabled, register this object. */
101 UX_TRACE_OBJECT_UNREGISTER(dfu);
102
103 /* Return completion status. */
104 return(UX_SUCCESS);
105 }
106
107