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 /** Pima 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_pima.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_host_class_pima_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 pima class. It will be */
46 /* called by the USBX stack enumeration module when there is a new */
47 /* pima on the bus or when the USB pima is removed. */
48 /* */
49 /* */
50 /* INPUT */
51 /* */
52 /* command Pima class command */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* Completion Status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _ux_host_class_pima_activate Activate pima class */
61 /* _ux_host_class_pima_deactivate Deactivate pima class */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* USBX stack */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
72 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
73 /* resulting in version 6.1 */
74 /* */
75 /**************************************************************************/
_ux_host_class_pima_entry(UX_HOST_CLASS_COMMAND * command)76 UINT _ux_host_class_pima_entry(UX_HOST_CLASS_COMMAND *command)
77 {
78
79 UINT status;
80
81
82 /* The command request will tell us we need to do here, either a enumeration
83 query, an activation or a deactivation. */
84 switch (command -> ux_host_class_command_request)
85 {
86
87 case UX_HOST_CLASS_COMMAND_QUERY:
88
89 /* The query command is used to let the stack enumeration process know if we want to own
90 this device or not. */
91 if((command -> ux_host_class_command_usage == UX_HOST_CLASS_COMMAND_USAGE_CSP) &&
92 ((command -> ux_host_class_command_class == UX_HOST_CLASS_PIMA_CLASS) &&
93 (command -> ux_host_class_command_subclass == UX_HOST_CLASS_PIMA_SUBCLASS) &&
94 (command -> ux_host_class_command_protocol == UX_HOST_CLASS_PIMA_PROTOCOL)))
95 return(UX_SUCCESS);
96 else
97 return(UX_NO_CLASS_MATCH);
98
99 case UX_HOST_CLASS_COMMAND_ACTIVATE:
100
101 /* The activate command is used when the device inserted has found a parent and
102 is ready to complete the enumeration. */
103 status = _ux_host_class_pima_activate(command);
104 return(status);
105
106 case UX_HOST_CLASS_COMMAND_DEACTIVATE:
107
108 /* The deactivate command is used when the device has been extracted either
109 directly or when its parents has been extracted. */
110 status = _ux_host_class_pima_deactivate(command);
111 return(status);
112
113 default:
114
115 /* Error trap. */
116 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_FUNCTION_NOT_SUPPORTED);
117
118 /* If trace is enabled, insert this event into the trace buffer. */
119 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, 0, 0, 0, UX_TRACE_ERRORS, 0, 0)
120
121 return(UX_FUNCTION_NOT_SUPPORTED);
122 }
123 }
124
125