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 Printer 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_printer.h"
28 #include "ux_device_stack.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_device_class_printer_deactivate PORTABLE C */
36 /* 6.1.10 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function deactivate an instance of the printer 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_class_printer_instance_deactivate) */
56 /* Notify deactivation */
57 /* _ux_device_class_printer_soft_reset Performs software reset */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* Device Printer Class */
62 /* */
63 /* RELEASE HISTORY */
64 /* */
65 /* DATE NAME DESCRIPTION */
66 /* */
67 /* 01-31-2022 Chaoqiong Xiao Initial Version 6.1.10 */
68 /* */
69 /**************************************************************************/
_ux_device_class_printer_deactivate(UX_SLAVE_CLASS_COMMAND * command)70 UINT _ux_device_class_printer_deactivate(UX_SLAVE_CLASS_COMMAND *command)
71 {
72
73 UX_DEVICE_CLASS_PRINTER *printer;
74 UX_SLAVE_CLASS *printer_class;
75
76 /* Get the class container. */
77 printer_class = command -> ux_slave_class_command_class_ptr;
78
79 /* Get the class instance in the container. */
80 printer = (UX_DEVICE_CLASS_PRINTER *) printer_class -> ux_slave_class_instance;
81
82 /* Terminate the transactions pending on the endpoints. */
83 _ux_device_class_printer_soft_reset(printer);
84
85 /* Endpoints not ready. */
86 printer -> ux_device_class_printer_endpoint_in = UX_NULL;
87 printer -> ux_device_class_printer_endpoint_out = UX_NULL;
88
89 /* Reset port status. */
90 printer -> ux_device_class_printer_port_status = 0;
91
92 /* If there is a deactivate function call it. */
93 if (printer -> ux_device_class_printer_parameter.ux_device_class_printer_instance_deactivate != UX_NULL)
94 {
95
96 /* Invoke the application. */
97 printer -> ux_device_class_printer_parameter.ux_device_class_printer_instance_deactivate(printer);
98 }
99
100 /* If trace is enabled, insert this event into the trace buffer. */
101 UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_PRINTER_DEACTIVATE, printer, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
102
103 /* If trace is enabled, register this object. */
104 UX_TRACE_OBJECT_UNREGISTER(printer);
105
106 /* Return completion status. */
107 return(UX_SUCCESS);
108 }
109