GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_host_stack_interface_set.c Lines: 12 12 100.0 %
Date: 2026-03-06 18:57:10 Branches: 0 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
/**************************************************************************/
15
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   Host Stack                                                          */
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_stack.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_host_stack_interface_set                        PORTABLE C      */
37
/*                                                           6.1.12       */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function performs a setting of an alternate setting for a      */
45
/*    specific interface.                                                 */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    interface                             Pointer to interface          */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    Completion Status                                                   */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _ux_host_stack_hcd_transfer_request   HCD transfer request          */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    USBX Components                                                     */
62
/*                                                                        */
63
/**************************************************************************/
64
159
UINT  _ux_host_stack_interface_set(UX_INTERFACE *interface_ptr)
65
{
66
67
UX_DEVICE               *device;
68
UX_CONFIGURATION        *configuration;
69
UX_TRANSFER             *transfer_request;
70
UINT                    status;
71
UX_ENDPOINT             *control_endpoint;
72
73
    /* If trace is enabled, insert this event into the trace buffer.  */
74
    UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_SET, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
75
76
    /* Retrieve the pointer to the control endpoint and its transfer_request.
77
       From the interface we go back to the configuration, then the device.
78
       The device contains the default control endpoint container.  */
79
159
    configuration =     interface_ptr -> ux_interface_configuration;
80
159
    device =            configuration -> ux_configuration_device;
81
159
    control_endpoint =  &device -> ux_device_control_endpoint;
82
159
    transfer_request =  &control_endpoint -> ux_endpoint_transfer_request;
83
84
    /* Create a transfer_request for the SET_INTERFACE request. No data for this request */
85
159
    transfer_request -> ux_transfer_request_requested_length =  0;
86
159
    transfer_request -> ux_transfer_request_function =          UX_SET_INTERFACE;
87
159
    transfer_request -> ux_transfer_request_type =              UX_REQUEST_OUT | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_INTERFACE;
88
159
    transfer_request -> ux_transfer_request_index =             (USHORT) interface_ptr -> ux_interface_descriptor.bInterfaceNumber;
89
159
    transfer_request -> ux_transfer_request_value =             (USHORT) interface_ptr -> ux_interface_descriptor.bAlternateSetting;
90
91
    /* Send request.  */
92
159
    status = _ux_host_stack_transfer_request(transfer_request);
93
94
    /* Return status completion.  */
95
159
    return(status);
96
}
97