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_soft_reset                 PORTABLE C      */
37 /*                                                           6.2.0        */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Chaoqiong Xiao, Microsoft Corporation                               */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function Perform Soft Reset on the Printer class.              */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    printer                               Address of printer class      */
49 /*                                            instance                    */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _ux_device_stack_transfer_all_request_abort                         */
58 /*                                          Abort transfers on endpoint   */
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 /*  10-31-2022     Yajun Xia                Modified comment(s),          */
70 /*                                            added standalone support,   */
71 /*                                            resulting in version 6.2.0  */
72 /*                                                                        */
73 /**************************************************************************/
_ux_device_class_printer_soft_reset(UX_DEVICE_CLASS_PRINTER * printer)74 VOID _ux_device_class_printer_soft_reset(UX_DEVICE_CLASS_PRINTER *printer)
75 {
76 
77 UX_SLAVE_ENDPOINT                       *endpoint;
78 
79     /* Stop OUT.  */
80     endpoint = printer -> ux_device_class_printer_endpoint_out;
81     _ux_device_stack_transfer_all_request_abort(endpoint, UX_ENDPOINT_RESET);
82 #if defined(UX_DEVICE_STANDALONE)
83     printer -> ux_device_class_printer_write_state = UX_STATE_RESET;
84 #endif
85 
86     /* Stop IN (optional).  */
87     endpoint = printer -> ux_device_class_printer_endpoint_in;
88     if (endpoint != UX_NULL)
89     {
90         _ux_device_stack_transfer_all_request_abort(endpoint, UX_ENDPOINT_RESET);
91 #if defined(UX_DEVICE_STANDALONE)
92         printer -> ux_device_class_printer_read_state = UX_STATE_RESET;
93 #endif
94     }
95 }
96