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