Skip to content

Commit 385c710

Browse files
cobusveAlfred Gedeon
authored and
Alfred Gedeon
committed
Revert "Fix inaccurate ticks in windows port (FreeRTOS#142)" (FreeRTOS#143)
This reverts commit d85fd46.
1 parent 7c56708 commit 385c710

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

portable/MSVC-MingW/port.c

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25+
* 1 tab == 4 spaces!
2526
*/
2627

2728
/* Standard includes. */
@@ -139,9 +140,6 @@ static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter )
139140
{
140141
TickType_t xMinimumWindowsBlockTime;
141142
TIMECAPS xTimeCaps;
142-
TickType_t xWaitTimeBetweenTicks = portTICK_PERIOD_MS;
143-
HANDLE hTimer = NULL;
144-
LARGE_INTEGER liDueTime;
145143

146144
/* Set the timer resolution to the maximum possible. */
147145
if( timeGetDevCaps( &xTimeCaps, sizeof( xTimeCaps ) ) == MMSYSERR_NOERROR )
@@ -161,32 +159,22 @@ LARGE_INTEGER liDueTime;
161159
/* Just to prevent compiler warnings. */
162160
( void ) lpParameter;
163161

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-
185162
for( ;; )
186163
{
187164
/* 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+
}
190178

191179
configASSERT( xPortRunning );
192180

0 commit comments

Comments
 (0)