1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** USBX Component                                                        */
16 /**                                                                       */
17 /**   Device Printer Class                                                */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define UX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "ux_api.h"
28 #include "ux_device_class_printer.h"
29 #include "ux_device_stack.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _ux_device_class_printer_deactivate                 PORTABLE C      */
37 /*                                                           6.1.10       */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Chaoqiong Xiao, Microsoft Corporation                               */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function deactivate an instance of the printer class.          */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    command                               Pointer to a class command    */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    Completion Status                                                   */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    (ux_device_class_printer_instance_deactivate)                       */
57 /*                                          Notify deactivation           */
58 /*    _ux_device_class_printer_soft_reset   Performs software reset       */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    Device Printer Class                                                */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  01-31-2022     Chaoqiong Xiao           Initial Version 6.1.10        */
69 /*                                                                        */
70 /**************************************************************************/
_ux_device_class_printer_deactivate(UX_SLAVE_CLASS_COMMAND * command)71 UINT  _ux_device_class_printer_deactivate(UX_SLAVE_CLASS_COMMAND *command)
72 {
73 
74 UX_DEVICE_CLASS_PRINTER     *printer;
75 UX_SLAVE_CLASS              *printer_class;
76 
77     /* Get the class container.  */
78     printer_class =  command -> ux_slave_class_command_class_ptr;
79 
80     /* Get the class instance in the container.  */
81     printer = (UX_DEVICE_CLASS_PRINTER *) printer_class -> ux_slave_class_instance;
82 
83     /* Terminate the transactions pending on the endpoints.  */
84     _ux_device_class_printer_soft_reset(printer);
85 
86     /* Endpoints not ready.  */
87     printer -> ux_device_class_printer_endpoint_in = UX_NULL;
88     printer -> ux_device_class_printer_endpoint_out = UX_NULL;
89 
90     /* Reset port status.  */
91     printer -> ux_device_class_printer_port_status =  0;
92 
93     /* If there is a deactivate function call it.  */
94     if (printer -> ux_device_class_printer_parameter.ux_device_class_printer_instance_deactivate != UX_NULL)
95     {
96 
97         /* Invoke the application.  */
98         printer -> ux_device_class_printer_parameter.ux_device_class_printer_instance_deactivate(printer);
99     }
100 
101     /* If trace is enabled, insert this event into the trace buffer.  */
102     UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_PRINTER_DEACTIVATE, printer, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
103 
104     /* If trace is enabled, register this object.  */
105     UX_TRACE_OBJECT_UNREGISTER(printer);
106 
107     /* Return completion status.  */
108     return(UX_SUCCESS);
109 }
110