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: 2024-12-12 17:16:36 Branches: 4 6 66.7 %

Line Branch Exec Source
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
/**************************************************************************/
14
/**                                                                       */
15
/** USBX Component                                                        */
16
/**                                                                       */
17
/**   HID Class                                                           */
18
/**                                                                       */
19
/**************************************************************************/
20
/**************************************************************************/
21
22
23
/* Include necessary system files.  */
24
25
#define UX_SOURCE_CODE
26
27
#include "ux_api.h"
28
#include "ux_host_class_hid.h"
29
#include "ux_host_stack.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_host_class_hid_periodic_report_stop             PORTABLE C      */
37
/*                                                           6.1.10       */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function stops the interrupt endpoint of the HID class         */
45
/*    instance.                                                           */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    hid                                   Pointer to HID class          */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    Completion Status                                                   */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _ux_host_stack_class_instance_verify  Verify instance is valid      */
58
/*    _ux_host_stack_endpoint_transfer_abort Abort transfer on endpoint   */
59
/*    _ux_host_semaphore_get                Get protection semaphore      */
60
/*    _ux_host_semaphore_put                Release protection semaphore  */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application                                                         */
65
/*    HID Class                                                           */
66
/*                                                                        */
67
/*  RELEASE HISTORY                                                       */
68
/*                                                                        */
69
/*    DATE              NAME                      DESCRIPTION             */
70
/*                                                                        */
71
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
72
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
73
/*                                            resulting in version 6.1    */
74
/*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
75
/*                                            added standalone support,   */
76
/*                                            resulting in version 6.1.10 */
77
/*                                                                        */
78
/**************************************************************************/
79
125
UINT  _ux_host_class_hid_periodic_report_stop(UX_HOST_CLASS_HID *hid)
80
{
81
82
    /* Ensure the instance is valid.  */
83
125
    if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS)
84
    {
85
86
        /* Error trap. */
87
1
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
88
89
        /* If trace is enabled, insert this event into the trace buffer.  */
90
        UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
91
92
1
        return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
93
    }
94
95
    /* Check the status of the interrupt endpoint.  */
96
124
    if (hid -> ux_host_class_hid_interrupt_endpoint_status != UX_HOST_CLASS_HID_INTERRUPT_ENDPOINT_ACTIVE)
97
    {
98
99
        /* Error trap. */
100
1
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR);
101
102
        /* If trace is enabled, insert this event into the trace buffer.  */
103
        UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
104
105
1
        return(UX_HOST_CLASS_HID_PERIODIC_REPORT_ERROR);
106
    }
107
108
    /* Abort the transfer going on on the endpoint now.  */
109
123
    _ux_host_stack_endpoint_transfer_abort(hid -> ux_host_class_hid_interrupt_endpoint);
110
111
    /* Regardless of the status, we update the status of the endpoint.  */
112
123
    hid -> ux_host_class_hid_interrupt_endpoint_status =  UX_HOST_CLASS_HID_INTERRUPT_ENDPOINT_READY;
113
114
    /* Return successful status.  */
115
123
    return(UX_SUCCESS);
116
}
117
118
/**************************************************************************/
119
/*                                                                        */
120
/*  FUNCTION                                               RELEASE        */
121
/*                                                                        */
122
/*    _uxe_host_class_hid_periodic_report_stop            PORTABLE C      */
123
/*                                                           6.3.0        */
124
/*  AUTHOR                                                                */
125
/*                                                                        */
126
/*    Chaoqiong Xiao, Microsoft Corporation                               */
127
/*                                                                        */
128
/*  DESCRIPTION                                                           */
129
/*                                                                        */
130
/*    This function checks errors in HID periodic report stop function   */
131
/*    call.                                                               */
132
/*                                                                        */
133
/*  INPUT                                                                 */
134
/*                                                                        */
135
/*    hid                                   Pointer to HID class          */
136
/*                                                                        */
137
/*  OUTPUT                                                                */
138
/*                                                                        */
139
/*    Status                                                              */
140
/*                                                                        */
141
/*  CALLS                                                                 */
142
/*                                                                        */
143
/*    _ux_host_class_hid_periodic_report_stop                             */
144
/*                                          Stop polling periodic report  */
145
/*                                                                        */
146
/*  CALLED BY                                                             */
147
/*                                                                        */
148
/*    Application                                                         */
149
/*                                                                        */
150
/*  RELEASE HISTORY                                                       */
151
/*                                                                        */
152
/*    DATE              NAME                      DESCRIPTION             */
153
/*                                                                        */
154
/*  10-31-2023     Chaoqiong Xiao           Initial Version 6.3.0         */
155
/*                                                                        */
156
/**************************************************************************/
157
UINT  _uxe_host_class_hid_periodic_report_stop(UX_HOST_CLASS_HID *hid)
158
{
159
160
    /* Sanity check.  */
161
    if (hid == UX_NULL)
162
        return(UX_INVALID_PARAMETER);
163
164
    /* Invoke periodic stop function.  */
165
    return(_ux_host_class_hid_periodic_report_stop(hid));
166
}
167