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 /**                                                                       */
16 /** USBX Component                                                        */
17 /**                                                                       */
18 /**   Generic Serial Host module class                                    */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /* Include necessary system files.  */
25 
26 #define UX_SOURCE_CODE
27 
28 #include "ux_api.h"
29 #include "ux_host_class_gser.h"
30 #include "ux_host_stack.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _ux_host_class_gser_entry                           PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function is the entry point of the gser class. It will be      */
46 /*    called by the USBX stack enumeration module when there is a new     */
47 /*    gser on the bus or when the USB gser is removed.                    */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    command                                     gser class command      */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    Completion Status                                                   */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    _ux_host_class_gser_activate         Activate gser class            */
60 /*    _ux_host_class_gser_deactivate       Deactivate gser class          */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Data pump Class                                                     */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
71 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*                                                                        */
74 /**************************************************************************/
_ux_host_class_gser_entry(UX_HOST_CLASS_COMMAND * command)75 UINT  _ux_host_class_gser_entry(UX_HOST_CLASS_COMMAND *command)
76 {
77 
78 UINT    status;
79 
80 
81     /* The command request will tell us we need to do here, either a enumeration
82        query, an activation or a deactivation.  */
83     switch (command -> ux_host_class_command_request)
84     {
85 
86     case UX_HOST_CLASS_COMMAND_QUERY:
87 
88         /* The query command is used to let the stack enumeration process know if we want to own
89            this device or not.  */
90         if(((command -> ux_host_class_command_usage == UX_HOST_CLASS_COMMAND_USAGE_PIDVID) &&
91                              (command -> ux_host_class_command_pid == UX_HOST_CLASS_GSER_PRODUCT_ID) &&
92                              (command -> ux_host_class_command_vid == UX_HOST_CLASS_GSER_VENDOR_ID )))
93             return(UX_SUCCESS);
94         else
95             return(UX_NO_CLASS_MATCH);
96 
97     case UX_HOST_CLASS_COMMAND_ACTIVATE:
98 
99         /* The activate command is used when the device inserted has found a parent and
100            is ready to complete the enumeration.  */
101         status =  _ux_host_class_gser_activate(command);
102         return(status);
103 
104     case UX_HOST_CLASS_COMMAND_DEACTIVATE:
105 
106         /* The deactivate command is used when the device has been extracted either
107            directly or when its parents has been extracted.  */
108         status =  _ux_host_class_gser_deactivate(command);
109         return(status);
110 
111     default:
112 
113         /* Error trap. */
114         _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_FUNCTION_NOT_SUPPORTED);
115 
116         /* If trace is enabled, insert this event into the trace buffer.  */
117         UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, 0, 0, 0, UX_TRACE_ERRORS, 0, 0)
118 
119         return(UX_FUNCTION_NOT_SUPPORTED);
120     }
121 }
122 
123