GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_short_put_big_endian.c Lines: 7 7 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
/**   Utility                                                             */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
24
/* Include necessary system files.  */
25
26
#define UX_SOURCE_CODE
27
28
#include "ux_api.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _ux_utility_short_put_big_endian                    PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Chaoqiong Xiao, Microsoft Corporation                               */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function writes a 16-bit value in big endian format.           */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    address                               Destination address           */
48
/*    value                                 16-bit value                  */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    None                                                                */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    USBX Components                                                     */
61
/*                                                                        */
62
/**************************************************************************/
63
1370
VOID  _ux_utility_short_put_big_endian(UCHAR * address, USHORT value)
64
{
65
66
USHORT  low_byte_value;
67
USHORT  high_byte_value;
68
69
70
    /* First we swap the value bytes. */
71
1370
    low_byte_value =  value >> 8;
72
1370
    high_byte_value =  (USHORT)(value<< 8);
73
1370
    value =  high_byte_value | low_byte_value;
74
75
    /* In order to make this function endian agnostic and memory alignment
76
       independent, we write a byte at a time from the address.  */
77
1370
    *address++ =  (UCHAR) (value & 0xff);
78
1370
    *address=     (UCHAR) ((value >> 8) & 0xff);
79
80
    /* Return to caller. */
81
1370
    return;
82
}
83