22
22
* https://www.FreeRTOS.org
23
23
* https://github.com/FreeRTOS
24
24
*
25
+ * 1 tab == 4 spaces!
25
26
*/
26
27
27
28
/* Standard includes. */
@@ -139,9 +140,6 @@ static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter )
139
140
{
140
141
TickType_t xMinimumWindowsBlockTime ;
141
142
TIMECAPS xTimeCaps ;
142
- TickType_t xWaitTimeBetweenTicks = portTICK_PERIOD_MS ;
143
- HANDLE hTimer = NULL ;
144
- LARGE_INTEGER liDueTime ;
145
143
146
144
/* Set the timer resolution to the maximum possible. */
147
145
if ( timeGetDevCaps ( & xTimeCaps , sizeof ( xTimeCaps ) ) == MMSYSERR_NOERROR )
@@ -161,32 +159,22 @@ LARGE_INTEGER liDueTime;
161
159
/* Just to prevent compiler warnings. */
162
160
( void ) lpParameter ;
163
161
164
- /* Tick time for the timer is adjusted with the maximum available
165
- resolution. */
166
- if ( portTICK_PERIOD_MS < xMinimumWindowsBlockTime )
167
- {
168
- xWaitTimeBetweenTicks = xMinimumWindowsBlockTime ;
169
- }
170
-
171
- /* Convert the tick time in milliseconds to nanoseconds resolution
172
- for the Waitable Timer. */
173
- liDueTime .u .LowPart = xWaitTimeBetweenTicks * 1000 * 1000 ;
174
- liDueTime .u .HighPart = 0 ;
175
-
176
- /* Create a synchronization Waitable Timer.*/
177
- hTimer = CreateWaitableTimer ( NULL , FALSE, NULL );
178
-
179
- configASSERT ( hTimer != NULL );
180
-
181
- /* Set the Waitable Timer. The timer is set to run periodically at every
182
- xWaitTimeBetweenTicks milliseconds. */
183
- configASSERT ( SetWaitableTimer ( hTimer , & liDueTime , xWaitTimeBetweenTicks , NULL , NULL , 0 ) );
184
-
185
162
for ( ;; )
186
163
{
187
164
/* Wait until the timer expires and we can access the simulated interrupt
188
- variables. */
189
- WaitForSingleObject ( hTimer , INFINITE );
165
+ variables. *NOTE* this is not a 'real time' way of generating tick
166
+ events as the next wake time should be relative to the previous wake
167
+ time, not the time that Sleep() is called. It is done this way to
168
+ prevent overruns in this very non real time simulated/emulated
169
+ environment. */
170
+ if ( portTICK_PERIOD_MS < xMinimumWindowsBlockTime )
171
+ {
172
+ Sleep ( xMinimumWindowsBlockTime );
173
+ }
174
+ else
175
+ {
176
+ Sleep ( portTICK_PERIOD_MS );
177
+ }
190
178
191
179
configASSERT ( xPortRunning );
192
180
0 commit comments