GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_system_timer_update.c Lines: 22 22 100.0 %
Date: 2026-03-06 19:21:09 Branches: 12 12 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
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   System Management (System)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_animation.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_system_timer_update                             PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function is called when the GUIX timers need to be updated.    */
45
/*    It updates all of the GUIX application timers, and sends events     */
46
/*    as needed.                                                          */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    None                                                                */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*   GX_ENTER_CRITICAL                      Lock system mutex             */
59
/*   GX_EXIT_CRITICAL                       Unlock system mutex           */
60
/*   [gx_widget_event_process_function]     Event handler of timer owner  */
61
/*   _gx_system_timer_stop                  Stop the system timer         */
62
/*   _gx_animation_update                   Update the animation sequence */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    tx_timer                                                            */
67
/*                                                                        */
68
/**************************************************************************/
69
8242
VOID  _gx_system_timer_update(ULONG ticks)
70
{
71
GX_TIMER  *current_timer;
72
GX_TIMER  *next_timer;
73
GX_WIDGET *timer_owner;
74
UINT       timer_id;
75
GX_EVENT   timer_event;
76
77
8242
GX_ENTER_CRITICAL
78
79
8242
    current_timer = _gx_system_active_timer_list;
80
81
8242
    timer_event.gx_event_type = GX_EVENT_TIMER;
82
83
13375
    while (current_timer)
84
    {
85
5133
        next_timer = current_timer -> gx_timer_next;
86
87
        /* has this timer expired? */
88
5133
        if (current_timer -> gx_timer_initial_ticks > ticks)
89
        {
90
            /* just decrement the timer */
91
2033
            current_timer -> gx_timer_initial_ticks -= ticks;
92
        }
93
        else
94
        {
95
            /* timer has expired, call the timer owner's event handler */
96
3100
            timer_owner = current_timer -> gx_timer_owner;
97
3100
            timer_id = current_timer -> gx_timer_id;
98
99
            /* check to see if this timer should be removed or restarted */
100
101
3100
            if (current_timer -> gx_timer_reschedule_ticks > 0)
102
            {
103
                /* reload the timer */
104
3014
                current_timer -> gx_timer_initial_ticks = current_timer -> gx_timer_reschedule_ticks;
105
            }
106
            else
107
            {
108
                /* remove the timer */
109
86
                _gx_system_timer_stop(current_timer -> gx_timer_owner, current_timer -> gx_timer_id);
110
            }
111
112

3100
            if (timer_owner != GX_NULL && timer_owner -> gx_widget_event_process_function)
113
            {
114
3094
                timer_event.gx_event_payload.gx_event_timer_id = timer_id;
115
3094
                timer_event.gx_event_target = timer_owner;
116
                /*_gx_system_event_fold(&timer_event);*/
117
3094
                _gx_system_event_send(&timer_event);
118
            }
119
        }
120
5133
        current_timer = next_timer;
121
    }
122
123
#if (GX_ANIMATION_POOL_SIZE > 0)
124
8242
    if (_gx_system_animation_list)
125
    {
126
4817
        _gx_animation_update();
127
    }
128
#endif
129
130
    /* release our lock */
131
8242
    GX_EXIT_CRITICAL
132
8242
}
133