GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_delay_ms.c Lines: 5 5 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
/**   Host Stack                                                          */
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_delay_ms                                PORTABLE C      */
36
/*                                                           6.1.10       */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Chaoqiong Xiao, Microsoft Corporation                               */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function causes the calling thread to sleep for the            */
44
/*    specified number of milliseconds                                    */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    ms_wait                               Number of milliseconds to     */
49
/*                                            wait for                    */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    None                                                                */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _ux_utility_thread_sleep              RTOS sleep function           */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    USBX Components                                                     */
62
/*                                                                        */
63
/**************************************************************************/
64
14211
VOID  _ux_utility_delay_ms(ULONG ms_wait)
65
{
66
67
ULONG   ticks;
68
69
#if defined(UX_STANDALONE)
70
71
    /* Get current time.  */
72
    ticks = _ux_utility_time_get();
73
74
    /* Wait until timeout.  */
75
    while(_ux_utility_time_elapsed(ticks, _ux_utility_time_get()) <
76
            UX_MS_TO_TICK_NON_ZERO(ms_wait));
77
#else
78
79
    /* translate ms into ticks. */
80
14211
    ticks = (ULONG)(ms_wait * UX_PERIODIC_RATE) / 1000;
81
82
    /* For safety add 1 to ticks.  */
83
14211
    ticks++;
84
85
    /* Call RTOS sleep function.  */
86
14211
    _ux_utility_thread_sleep(ticks);
87
#endif
88
89
    /* Return completion status.  */
90
14149
    return;
91
}