GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_host_classes/src/ux_host_class_hub_port_change_process.c Lines: 15 15 100.0 %
Date: 2026-03-06 18:57:10 Branches: 12 12 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
/**************************************************************************/
15
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   HUB 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_hub.h"
30
#include "ux_host_stack.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _ux_host_class_hub_port_change_process              PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Chaoqiong Xiao, Microsoft Corporation                               */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function will process a port change indication.                */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    hub                                   Pointer to HUB class          */
50
/*    port                                  Port number                   */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    Completion Status                                                   */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _ux_host_class_hub_port_change_connection_process                   */
59
/*                                          Process connection            */
60
/*    _ux_host_class_hub_port_change_enable_process                       */
61
/*                                          Enable process                */
62
/*    _ux_host_class_hub_port_change_over_current_process                 */
63
/*                                          Change over current process   */
64
/*    _ux_host_class_hub_port_change_reset_process                        */
65
/*                                          Reset process                 */
66
/*    _ux_host_class_hub_port_change_suspend_process                      */
67
/*                                          Suspend process               */
68
/*    _ux_host_class_hub_status_get         Get HUB status                */
69
/*                                                                        */
70
/*  CALLED BY                                                             */
71
/*                                                                        */
72
/*    HUB Class                                                           */
73
/*                                                                        */
74
/**************************************************************************/
75
27
UINT  _ux_host_class_hub_port_change_process(UX_HOST_CLASS_HUB *hub, UINT port)
76
{
77
78
USHORT      port_status;
79
USHORT      port_change;
80
UINT        status;
81
82
83
    /* First step is to retrieve the status on the port with a GET_STATUS.  */
84
27
    status =  _ux_host_class_hub_status_get(hub, port, &port_status, &port_change);
85
27
    if (status != UX_SUCCESS)
86
2
        return(status);
87
88
    /* On return of the GET_STATUS, the port change field has been updated
89
       check for each of the bits it may contain.  */
90
25
    if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_CONNECTION)
91
21
        _ux_host_class_hub_port_change_connection_process(hub, port, port_status);
92
93
25
    if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_ENABLE)
94
1
        _ux_host_class_hub_port_change_enable_process(hub, port, port_status);
95
96
25
    if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_SUSPEND)
97
1
        _ux_host_class_hub_port_change_suspend_process(hub, port, port_status);
98
99
25
    if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_OVER_CURRENT)
100
1
        _ux_host_class_hub_port_change_over_current_process(hub, port, port_status);
101
102
25
    if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_RESET)
103
1
        _ux_host_class_hub_port_change_reset_process(hub, port, port_status);
104
105
    /* Return successful completion.  */
106
25
    return(UX_SUCCESS);
107
}
108