GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_device_classes/src/ux_device_class_cdc_acm_activate.c Lines: 9 9 100.0 %
Date: 2026-03-06 18:57:10 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
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
/**************************************************************************/
62
90
UINT  _ux_device_class_cdc_acm_activate(UX_SLAVE_CLASS_COMMAND *command)
63
{
64
65
UX_SLAVE_INTERFACE                      *interface_ptr;
66
UX_SLAVE_CLASS                          *class_ptr;
67
UX_SLAVE_CLASS_CDC_ACM                  *cdc_acm;
68
69
    /* Get the class container.  */
70
90
    class_ptr =  command -> ux_slave_class_command_class_ptr;
71
72
    /* Get the class instance in the container.  */
73
90
    cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class_ptr -> ux_slave_class_instance;
74
75
    /* Get the interface that owns this instance.  */
76
90
    interface_ptr =  (UX_SLAVE_INTERFACE  *) command -> ux_slave_class_command_interface;
77
78
    /* Store the class instance into the interface.  */
79
90
    interface_ptr -> ux_slave_interface_class_instance =  (VOID *)cdc_acm;
80
81
    /* Now the opposite, store the interface in the class instance.  */
82
90
    cdc_acm -> ux_slave_class_cdc_acm_interface =  interface_ptr;
83
84
    /* If there is a activate function call it.  */
85
90
    if (cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_instance_activate != UX_NULL)
86
    {
87
        /* Invoke the application.  */
88
85
        cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_instance_activate(cdc_acm);
89
    }
90
91
    /* If trace is enabled, insert this event into the trace buffer.  */
92
    UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_CDC_ACM_ACTIVATE, cdc_acm, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
93
94
    /* If trace is enabled, register this object.  */
95
    UX_TRACE_OBJECT_REGISTER(UX_TRACE_DEVICE_OBJECT_TYPE_INTERFACE, cdc_acm, 0, 0, 0)
96
97
    /* Return completion status.  */
98
90
    return(UX_SUCCESS);
99
}
100