Skip to content

Commit 5fb26de

Browse files
authored
Recently vTaskDelayUntil() was updated to xTaskDelayUntil() because the function now returns a value. The PR didn't make the same change in the MPU port, or update the constants required to include the xTaskDelayUntil() function in the build. (#199)
This PR: Changes the INCLUDE_vTaskDelayUntil compile time constant to INCLUDE_xTaskDelayUntil. Updates FreeRTOS.h to ensure backward compatibility for projects that already have INCLUDE_vTaskDelayUntil defined. Updates the MPU prototypes, wrapper and implementation to use the updated xTaskDelayUntil() function. Tests to be checked into the FreeRTOS/FreeRTOS repository after this PR.
1 parent 71be31b commit 5fb26de

File tree

6 files changed

+45
-19
lines changed

6 files changed

+45
-19
lines changed

include/FreeRTOS.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,28 @@
126126
#define INCLUDE_vTaskSuspend 0
127127
#endif
128128

129-
#ifndef INCLUDE_vTaskDelayUntil
130-
#define INCLUDE_vTaskDelayUntil 0
129+
#ifdef INCLUDE_xTaskDelayUntil
130+
#ifdef INCLUDE_vTaskDelayUntil
131+
/* INCLUDE_vTaskDelayUntil was replaced by INCLUDE_xTaskDelayUntil. Backward
132+
* compatibility is maintained if only one or the other is defined, but
133+
* there is a conflict if both are defined. */
134+
#error INCLUDE_vTaskDelayUntil and INCLUDE_xTaskDelayUntil are both defined. INCLUDE_vTaskDelayUntil is no longer required and should be removed
135+
#endif
136+
#endif
137+
138+
#ifndef INCLUDE_xTaskDelayUntil
139+
#ifdef INCLUDE_vTaskDelayUntil
140+
/* If INCLUDE_vTaskDelayUntil is set but INCLUDE_xTaskDelayUntil is not then
141+
* the project's FreeRTOSConfig.h probably pre-dates the introduction of
142+
* xTaskDelayUntil and setting INCLUDE_xTaskDelayUntil to whatever
143+
* INCLUDE_vTaskDelayUntil is set to will ensure backward compatibility.
144+
*/
145+
#define INCLUDE_xTaskDelayUntil INCLUDE_vTaskDelayUntil
146+
#endif
147+
#endif
148+
149+
#ifndef INCLUDE_xTaskDelayUntil
150+
#define INCLUDE_xTaskDelayUntil 0
131151
#endif
132152

133153
#ifndef INCLUDE_vTaskDelay

include/mpu_prototypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask,
5858
const MemoryRegion_t * const pxRegions ) FREERTOS_SYSTEM_CALL;
5959
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL;
6060
void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL;
61-
void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
61+
BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
6262
const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL;
6363
BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
6464
UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;

include/mpu_wrappers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
5252
#define vTaskDelete MPU_vTaskDelete
5353
#define vTaskDelay MPU_vTaskDelay
54-
#define vTaskDelayUntil MPU_vTaskDelayUntil
54+
#define xTaskDelayUntil MPU_xTaskDelayUntil
5555
#define xTaskAbortDelay MPU_xTaskAbortDelay
5656
#define uxTaskPriorityGet MPU_uxTaskPriorityGet
5757
#define eTaskGetState MPU_eTaskGetState

include/task.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
750750
* of controlling the frequency of a periodic task as the path taken through the
751751
* code, as well as other task and interrupt activity, will effect the frequency
752752
* at which vTaskDelay() gets called and therefore the time at which the task
753-
* next executes. See vTaskDelayUntil() for an alternative API function designed
753+
* next executes. See xTaskDelayUntil() for an alternative API function designed
754754
* to facilitate fixed frequency execution. It does this by specifying an
755755
* absolute time (rather than a relative time) at which the calling task should
756756
* unblock.
@@ -784,7 +784,7 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
784784
* BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
785785
* </pre>
786786
*
787-
* INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available.
787+
* INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
788788
* See the configuration section for more information.
789789
*
790790
* Delay a task until a specified time. This function can be used by periodic
@@ -802,8 +802,8 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
802802
* is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
803803
* unblock.
804804
*
805-
* The constant portTICK_PERIOD_MS can be used to calculate real time from the tick
806-
* rate - with the resolution of one tick period.
805+
* The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
806+
* time specified in milliseconds with a resolution of one tick period.
807807
*
808808
* @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
809809
* task was last unblocked. The variable must be initialised with the current time
@@ -846,6 +846,10 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
846846
BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
847847
const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
848848

849+
/*
850+
* vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
851+
* return a value.
852+
*/
849853
#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
850854
{ \
851855
( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \
@@ -1311,7 +1315,7 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
13111315
* made.
13121316
*
13131317
* API functions that have the potential to cause a context switch (for example,
1314-
* vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
1318+
* xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
13151319
* is suspended.
13161320
*
13171321
* Example usage:

portable/Common/mpu_wrappers.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,16 @@ void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask,
171171
#endif
172172
/*-----------------------------------------------------------*/
173173

174-
#if ( INCLUDE_vTaskDelayUntil == 1 )
175-
void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
176-
TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */
174+
#if ( INCLUDE_xTaskDelayUntil == 1 )
175+
BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
176+
TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */
177177
{
178178
BaseType_t xRunningPrivileged = xPortRaisePrivilege();
179+
BaseType_t xReturn;
179180

180-
vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
181+
xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
181182
vPortResetPrivilege( xRunningPrivileged );
183+
return xReturn;
182184
}
183185
#endif
184186
/*-----------------------------------------------------------*/

tasks.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,10 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
12441244
#endif /* INCLUDE_vTaskDelete */
12451245
/*-----------------------------------------------------------*/
12461246

1247-
#if ( INCLUDE_vTaskDelayUntil == 1 )
1247+
#if ( INCLUDE_xTaskDelayUntil == 1 )
12481248

12491249
BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
1250-
const TickType_t xTimeIncrement )
1250+
const TickType_t xTimeIncrement )
12511251
{
12521252
TickType_t xTimeToWake;
12531253
BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE;
@@ -1324,11 +1324,11 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
13241324
{
13251325
mtCOVERAGE_TEST_MARKER();
13261326
}
1327-
1327+
13281328
return xShouldDelay;
13291329
}
13301330

1331-
#endif /* INCLUDE_vTaskDelayUntil */
1331+
#endif /* INCLUDE_xTaskDelayUntil */
13321332
/*-----------------------------------------------------------*/
13331333

13341334
#if ( INCLUDE_vTaskDelay == 1 )
@@ -2100,8 +2100,8 @@ void vTaskStartScheduler( void )
21002100
/* Prevent compiler warnings if INCLUDE_xTaskGetIdleTaskHandle is set to 0,
21012101
* meaning xIdleTaskHandle is not used anywhere else. */
21022102
( void ) xIdleTaskHandle;
2103-
2104-
/* OpenOCD makes use of uxTopUsedPriority for thread debugging. Prevent uxTopUsedPriority
2103+
2104+
/* OpenOCD makes use of uxTopUsedPriority for thread debugging. Prevent uxTopUsedPriority
21052105
* from getting optimized out as it is no longer used by the kernel. */
21062106
( void ) uxTopUsedPriority;
21072107
}

0 commit comments

Comments
 (0)