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 /** GUIX Component                                                        */
16 /**                                                                       */
17 /**   System Management (System)                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_system.h"
28 #include "gx_animation.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_system_timer_expiration                         PORTABLE C      */
36 /*                                                           6.1.3        */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This is the callback function for the gx_system_timer. This         */
44 /*    function updates all of the GUIX application timers, and sends      */
45 /*    events as needed                                                    */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    None                                                                */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*   _gx_system_event_send                   Send GUI event               */
58 /*   tx_timer_deactivate                     Deactivate a timer           */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    tx_timer                                                            */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*  12-31-2020     Kenneth Maxwell          Modified comment(s),          */
72 /*                                            added GX_DISABLE_THREADX_   */
73 /*                                            TIMER_SOURCE configuration, */
74 /*                                            resulting in version 6.1.3  */
75 /*                                                                        */
76 /**************************************************************************/
_gx_system_timer_expiration(ULONG val)77 VOID  _gx_system_timer_expiration(ULONG val)
78 {
79 GX_EVENT timer_event;
80 
81     GX_PARAMETER_NOT_USED(val);
82 
83     /* if there are no active timers just stop the timer from running */
84     if (_gx_system_active_timer_list == GX_NULL &&
85         _gx_system_animation_list == GX_NULL)
86     {
87 #ifdef GX_THREADX_BINDING
88 #ifndef GX_DISABLE_THREADX_TIMER_SOURCE
89         tx_timer_deactivate(&_gx_system_timer);
90 #endif
91 #else
92         GX_TIMER_STOP;
93 #endif
94         return;
95     }
96 
97     timer_event.gx_event_type = GX_EVENT_TIMER;
98     timer_event.gx_event_sender = 0;
99     timer_event.gx_event_target = GX_NULL;
100     timer_event.gx_event_payload.gx_event_ulongdata = 1;
101     _gx_system_event_fold(&timer_event);
102 }
103 
104