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 /** ThreadX Component */
16 /** */
17 /** Timer */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define TX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "tx_api.h"
28 #include "tx_trace.h"
29 #include "tx_timer.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _tx_timer_change PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* William E. Lamie, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function modifies an application timer as specified by the */
45 /* input. */
46 /* */
47 /* INPUT */
48 /* */
49 /* timer_ptr Pointer to timer control block */
50 /* initial_ticks Initial expiration ticks */
51 /* reschedule_ticks Reschedule ticks */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* TX_SUCCESS Successful completion status */
56 /* */
57 /* CALLS */
58 /* */
59 /* None */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* Application Code */
64 /* */
65 /* RELEASE HISTORY */
66 /* */
67 /* DATE NAME DESCRIPTION */
68 /* */
69 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
70 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
71 /* resulting in version 6.1 */
72 /* */
73 /**************************************************************************/
_tx_timer_change(TX_TIMER * timer_ptr,ULONG initial_ticks,ULONG reschedule_ticks)74 UINT _tx_timer_change(TX_TIMER *timer_ptr, ULONG initial_ticks, ULONG reschedule_ticks)
75 {
76
77 TX_INTERRUPT_SAVE_AREA
78
79
80 /* Disable interrupts to put the timer on the created list. */
81 TX_DISABLE
82
83 /* If trace is enabled, insert this event into the trace buffer. */
84 TX_TRACE_IN_LINE_INSERT(TX_TRACE_TIMER_CHANGE, timer_ptr, initial_ticks, reschedule_ticks, 0, TX_TRACE_TIMER_EVENTS)
85
86 /* Log this kernel call. */
87 TX_EL_TIMER_CHANGE_INSERT
88
89 /* Determine if the timer is active. */
90 if (timer_ptr -> tx_timer_internal.tx_timer_internal_list_head == TX_NULL)
91 {
92
93 /* Setup the new expiration fields. */
94 timer_ptr -> tx_timer_internal.tx_timer_internal_remaining_ticks = initial_ticks;
95 timer_ptr -> tx_timer_internal.tx_timer_internal_re_initialize_ticks = reschedule_ticks;
96 }
97
98 /* Restore interrupts. */
99 TX_RESTORE
100
101 /* Return TX_SUCCESS. */
102 return(TX_SUCCESS);
103 }
104
105