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 /** USBX Component */
15 /** */
16 /** Device CDC 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_cdc_acm.h"
28 #include "ux_device_stack.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_device_class_cdc_acm_activate PORTABLE C */
36 /* 6.1.12 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function initializes the USB CDC device. */
44 /* */
45 /* INPUT */
46 /* */
47 /* command Pointer to cdc_acm command */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* Completion Status */
52 /* */
53 /* CALLS */
54 /* */
55 /* None */
56 /* */
57 /* CALLED BY */
58 /* */
59 /* USBX Source Code */
60 /* */
61 /* RELEASE HISTORY */
62 /* */
63 /* DATE NAME DESCRIPTION */
64 /* */
65 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
66 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
67 /* resulting in version 6.1 */
68 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
69 /* fixed parameter/variable */
70 /* names conflict C++ keyword, */
71 /* resulting in version 6.1.12 */
72 /* */
73 /**************************************************************************/
_ux_device_class_cdc_acm_activate(UX_SLAVE_CLASS_COMMAND * command)74 UINT _ux_device_class_cdc_acm_activate(UX_SLAVE_CLASS_COMMAND *command)
75 {
76
77 UX_SLAVE_INTERFACE *interface_ptr;
78 UX_SLAVE_CLASS *class_ptr;
79 UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
80
81 /* Get the class container. */
82 class_ptr = command -> ux_slave_class_command_class_ptr;
83
84 /* Get the class instance in the container. */
85 cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class_ptr -> ux_slave_class_instance;
86
87 /* Get the interface that owns this instance. */
88 interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
89
90 /* Store the class instance into the interface. */
91 interface_ptr -> ux_slave_interface_class_instance = (VOID *)cdc_acm;
92
93 /* Now the opposite, store the interface in the class instance. */
94 cdc_acm -> ux_slave_class_cdc_acm_interface = interface_ptr;
95
96 /* If there is a activate function call it. */
97 if (cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_instance_activate != UX_NULL)
98 {
99 /* Invoke the application. */
100 cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_instance_activate(cdc_acm);
101 }
102
103 /* If trace is enabled, insert this event into the trace buffer. */
104 UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_CDC_ACM_ACTIVATE, cdc_acm, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
105
106 /* If trace is enabled, register this object. */
107 UX_TRACE_OBJECT_REGISTER(UX_TRACE_DEVICE_OBJECT_TYPE_INTERFACE, cdc_acm, 0, 0, 0)
108
109 /* Return completion status. */
110 return(UX_SUCCESS);
111 }
112
113