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