GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_host_classes/src/ux_host_class_hid_item_data_get.c Lines: 14 14 100.0 %
Date: 2026-03-06 18:57:10 Branches: 4 4 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
/**   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_item_data_get                    PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Chaoqiong Xiao, Microsoft Corporation                               */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function returns a data from the descriptor based on its size, */
46
/*    format and whether it is signed or not.                             */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    descriptor                            Pointer to descriptor         */
51
/*    item                                  Pointer to item               */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    ULONG data value                                                    */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _ux_utility_short_get                 Get 16-bit value              */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    HID Class                                                           */
64
/*                                                                        */
65
/**************************************************************************/
66
13510
ULONG  _ux_host_class_hid_item_data_get(UCHAR *descriptor, UX_HOST_CLASS_HID_ITEM *item)
67
{
68
69
ULONG       value;
70
71
72
    /* Get the length of the item.  */
73

13510
    switch (item -> ux_host_class_hid_item_report_length)
74
    {
75
76
13449
    case 1:
77
78
13449
        value =  (ULONG) *descriptor;
79
13449
        break;
80
81
82
28
    case 2:
83
84
28
        value =  (ULONG) _ux_utility_short_get(descriptor);
85
28
        break;
86
87
88
31
    case 4:
89
90
31
        value =  (ULONG) _ux_utility_long_get(descriptor);
91
31
        break;
92
93
94
2
    default:
95
96
2
        return(0);
97
    }
98
99
    /* Return the value.  */
100
13508
    return(value);
101
}
102