Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define TX_SOURCE_CODE
#include "tx_api.h"
#include "tx_thread.h"
#include "tx_timer.h"
_tx_timer_system_clock
_tx_timer_expired_time_slice
_tx_timer_list
_tx_timer_list_start
_tx_timer_list_end
_tx_timer_current_ptr
_tx_timer_expired
_tx_timer_created_ptr
_tx_timer_created_count
_tx_timer_expired_timer_ptr
_tx_timer_thread
_tx_timer_stack_start
_tx_timer_stack_size
_tx_timer_priority
_tx_timer_thread_stack_area
_tx_timer_time_slice
...
...
_tx_timer_initialize()
Files
loading...
SourceVuSTM32 Libraries and Samplesthreadxcommon/src/tx_timer_initialize.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** ThreadX Component */ /** */ /** Timer */ /** */... /**************************************************************************/ /**************************************************************************/ #define TX_SOURCE_CODE /* Include necessary system files. */ #include "tx_api.h" #include "tx_thread.h" #include "tx_timer.h" /* Check for the TX_NO_TIMER option. When defined, do not define all of the timer component global variables. *//* ... */ #ifndef TX_NO_TIMER /* Define the system clock value that is continually incremented by the periodic timer interrupt processing. *//* ... */ volatile ULONG _tx_timer_system_clock; /* Define the time-slice expiration flag. This is used to indicate that a time-slice has happened. *//* ... */ UINT _tx_timer_expired_time_slice; /* Define the thread and application timer entry list. This list provides a direct access method for insertion of times less than TX_TIMER_ENTRIES. *//* ... */ TX_TIMER_INTERNAL *_tx_timer_list[TX_TIMER_ENTRIES]; /* Define the boundary pointers to the list. These are setup to easily manage wrapping the list. *//* ... */ TX_TIMER_INTERNAL **_tx_timer_list_start; TX_TIMER_INTERNAL **_tx_timer_list_end; /* Define the current timer pointer in the list. This pointer is moved sequentially through the timer list by the timer interrupt handler. *//* ... */ TX_TIMER_INTERNAL **_tx_timer_current_ptr; /* Define the timer expiration flag. This is used to indicate that a timer has expired. *//* ... */ UINT _tx_timer_expired; /* Define the created timer list head pointer. */ TX_TIMER *_tx_timer_created_ptr; /* Define the created timer count. */ ULONG _tx_timer_created_count; /* Define the pointer to the timer that has expired and is being processed. */ TX_TIMER_INTERNAL *_tx_timer_expired_timer_ptr; #ifndef TX_TIMER_PROCESS_IN_ISR /* Define the timer thread's control block. */ TX_THREAD _tx_timer_thread; /* Define the variable that holds the timer thread's starting stack address. */ VOID *_tx_timer_stack_start; /* Define the variable that holds the timer thread's stack size. */ ULONG _tx_timer_stack_size; /* Define the variable that holds the timer thread's priority. */ UINT _tx_timer_priority; /* Define the system timer thread's stack. The default size is defined in tx_port.h. *//* ... */ ULONG _tx_timer_thread_stack_area[(((UINT) TX_TIMER_THREAD_STACK_SIZE)+((sizeof(ULONG))- ((UINT) 1)))/(sizeof(ULONG))]; /* ... */ #else /* Define the busy flag that will prevent nested timer ISR processing. */ UINT _tx_timer_processing_active; /* ... */ #endif #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO /* Define the total number of timer activations. */ ULONG _tx_timer_performance_activate_count; /* Define the total number of timer reactivations. */ ULONG _tx_timer_performance_reactivate_count; /* Define the total number of timer deactivations. */ ULONG _tx_timer_performance_deactivate_count; /* Define the total number of timer expirations. */ ULONG _tx_timer_performance_expiration_count; /* Define the total number of timer expiration adjustments. These are required if the expiration time is greater than the size of the timer list. In such cases, the timer is placed at the end of the list and then reactivated as many times as necessary to finally achieve the resulting timeout. *//* ... */ ULONG _tx_timer_performance__expiration_adjust_count; /* ... */ #endif/* ... */ #endif /* Define the current time slice value. If non-zero, a time-slice is active. Otherwise, the time_slice is not active. *//* ... */ ULONG _tx_timer_time_slice; ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _tx_timer_initialize PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function initializes the various control data structures for */ /* the clock control component. */ /* */ /* INPUT */ /* */ /* None */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _tx_thread_create Create the system timer thread */ /* */ /* CALLED BY */ /* */ /* _tx_initialize_high_level High level initialization */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 William E. Lamie Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ VOID _tx_timer_initialize(VOID) { #ifndef TX_NO_TIMER #ifndef TX_TIMER_PROCESS_IN_ISR UINT status; #endif #ifndef TX_DISABLE_REDUNDANT_CLEARING /* Initialize the system clock to 0. */ _tx_timer_system_clock = ((ULONG) 0); /* Initialize the time-slice value to 0 to make sure it is disabled. */ _tx_timer_time_slice = ((ULONG) 0); /* Clear the expired flags. */ _tx_timer_expired_time_slice = TX_FALSE; _tx_timer_expired = TX_FALSE; /* Set the currently expired timer being processed pointer to NULL. */ _tx_timer_expired_timer_ptr = TX_NULL; /* Initialize the thread and application timer management control structures. */ /* First, initialize the timer list. */ TX_MEMSET(&_tx_timer_list[0], 0, (sizeof(_tx_timer_list)));/* ... */ #endif /* Initialize all of the list pointers. */ _tx_timer_list_start = &_tx_timer_list[0]; _tx_timer_current_ptr = &_tx_timer_list[0]; /* Set the timer list end pointer to one past the actual timer list. This is done to make the timer interrupt handling in assembly language a little easier. *//* ... */ _tx_timer_list_end = &_tx_timer_list[TX_TIMER_ENTRIES-((ULONG) 1)]; _tx_timer_list_end = TX_TIMER_POINTER_ADD(_tx_timer_list_end, ((ULONG) 1)); #ifndef TX_TIMER_PROCESS_IN_ISR /* Setup the variables associated with the system timer thread's stack and priority. *//* ... */ _tx_timer_stack_start = (VOID *) &_tx_timer_thread_stack_area[0]; _tx_timer_stack_size = ((ULONG) TX_TIMER_THREAD_STACK_SIZE); _tx_timer_priority = ((UINT) TX_TIMER_THREAD_PRIORITY); /* Create the system timer thread. This thread processes all of the timer expirations and reschedules. Its stack and priority are defined in the low-level initialization component. *//* ... */ do { /* Create the system timer thread. */ status = _tx_thread_create(&_tx_timer_thread, TX_CONST_CHAR_TO_CHAR_POINTER_CONVERT("System Timer Thread"), _tx_timer_thread_entry, ((ULONG) TX_TIMER_ID), _tx_timer_stack_start, _tx_timer_stack_size, _tx_timer_priority, _tx_timer_priority, TX_NO_TIME_SLICE, TX_DONT_START); #ifdef TX_SAFETY_CRITICAL /* Check return from thread create - if an error is detected throw an exception. */ if (status != TX_SUCCESS) { /* Raise safety critical exception. */ TX_SAFETY_CRITICAL_EXCEPTION(__FILE__, __LINE__, status); }if (status != TX_SUCCESS) { ... } /* ... */#endif /* Define timer initialize extension. */ TX_TIMER_INITIALIZE_EXTENSION(status) ...} while (status != TX_SUCCESS); /* ... */ #else /* Clear the timer interrupt processing active flag. */ _tx_timer_processing_active = TX_FALSE;/* ... */ #endif #ifndef TX_DISABLE_REDUNDANT_CLEARING /* Initialize the head pointer of the created application timer list. */ _tx_timer_created_ptr = TX_NULL; /* Set the created count to zero. */ _tx_timer_created_count = TX_EMPTY; #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO /* Initialize timer performance counters. */ _tx_timer_performance_activate_count = ((ULONG) 0); _tx_timer_performance_reactivate_count = ((ULONG) 0); _tx_timer_performance_deactivate_count = ((ULONG) 0); _tx_timer_performance_expiration_count = ((ULONG) 0); _tx_timer_performance__expiration_adjust_count = ((ULONG) 0);/* ... */ #endif/* ... */ #endif/* ... */ #endif }{ ... }
Details