GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_host_classes/src/ux_host_class_hid_periodic_report_stop.c Lines: 10 14 71.4 %
Date: 2026-03-06 18:57:10 Branches: 4 6 66.7 %

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
/**   HID 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_hid.h"
30
#include "ux_host_stack.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _ux_host_class_hid_periodic_report_stop             PORTABLE C      */
38
/*                                                           6.1.10       */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Chaoqiong Xiao, Microsoft Corporation                               */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function stops the interrupt endpoint of the HID class         */
46
/*    instance.                                                           */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    hid                                   Pointer to HID class          */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    Completion Status                                                   */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _ux_host_stack_class_instance_verify  Verify instance is valid      */
59
/*    _ux_host_stack_endpoint_transfer_abort Abort transfer on endpoint   */
60
/*    _ux_host_semaphore_get                Get protection semaphore      */
61
/*    _ux_host_semaphore_put                Release protection semaphore  */
62
/*                                                                        */
63
/*  CALLED BY                                                             */
64
/*                                                                        */
65
/*    Application                                                         */
66
/*    HID Class                                                           */
67
/*                                                                        */
68
/**************************************************************************/
69
125
UINT  _ux_host_class_hid_periodic_report_stop(UX_HOST_CLASS_HID *hid)
70
{
71
72
    /* Ensure the instance is valid.  */
73
125
    if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS)
74
    {
75
76
        /* Error trap. */
77
1
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
78
79
        /* If trace is enabled, insert this event into the trace buffer.  */
80
        UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
81
82
1
        return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
83
    }
84
85
    /* Check the status of the interrupt endpoint.  */
86
124
    if (hid -> ux_host_class_hid_interrupt_endpoint_status != UX_HOST_CLASS_HID_INTERRUPT_ENDPOINT_ACTIVE)
87
    {
88
89
        /* Error trap. */
90
1
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR);
91
92
        /* If trace is enabled, insert this event into the trace buffer.  */
93
        UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
94
95
1
        return(UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR);
96
    }
97
98
    /* Abort the transfer going on on the endpoint now.  */
99
123
    _ux_host_stack_endpoint_transfer_abort(hid -> ux_host_class_hid_interrupt_endpoint);
100
101
    /* Regardless of the status, we update the status of the endpoint.  */
102
123
    hid -> ux_host_class_hid_interrupt_endpoint_status =  UX_HOST_CLASS_HID_INTERRUPT_ENDPOINT_READY;
103
104
    /* Return successful status.  */
105
123
    return(UX_SUCCESS);
106
}
107
108
/**************************************************************************/
109
/*                                                                        */
110
/*  FUNCTION                                               RELEASE        */
111
/*                                                                        */
112
/*    _uxe_host_class_hid_periodic_report_stop            PORTABLE C      */
113
/*                                                           6.3.0        */
114
/*  AUTHOR                                                                */
115
/*                                                                        */
116
/*    Chaoqiong Xiao, Microsoft Corporation                               */
117
/*                                                                        */
118
/*  DESCRIPTION                                                           */
119
/*                                                                        */
120
/*    This function checks errors in HID periodic report stop function   */
121
/*    call.                                                               */
122
/*                                                                        */
123
/*  INPUT                                                                 */
124
/*                                                                        */
125
/*    hid                                   Pointer to HID class          */
126
/*                                                                        */
127
/*  OUTPUT                                                                */
128
/*                                                                        */
129
/*    Status                                                              */
130
/*                                                                        */
131
/*  CALLS                                                                 */
132
/*                                                                        */
133
/*    _ux_host_class_hid_periodic_report_stop                             */
134
/*                                          Stop polling periodic report  */
135
/*                                                                        */
136
/*  CALLED BY                                                             */
137
/*                                                                        */
138
/*    Application                                                         */
139
/*                                                                        */
140
/**************************************************************************/
141
UINT  _uxe_host_class_hid_periodic_report_stop(UX_HOST_CLASS_HID *hid)
142
{
143
144
    /* Sanity check.  */
145
    if (hid == UX_NULL)
146
        return(UX_INVALID_PARAMETER);
147
148
    /* Invoke periodic stop function.  */
149
    return(_ux_host_class_hid_periodic_report_stop(hid));
150
}
151