From aebba2bcd32481ad41ffdba8ba9af8fb96ea147e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 23 Jun 2020 13:45:00 +0200 Subject: [PATCH 1/7] vTaskDelayUntil improvement --- include/task.h | 5 ++++- tasks.c | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/task.h b/include/task.h index 3eaf6eecbf..96f77ab6cb 100644 --- a/include/task.h +++ b/include/task.h @@ -799,6 +799,9 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; * same xTimeIncrement parameter value will cause the task to execute with * a fixed interface period. * + * @param xWasDelayed Can be used to check whether the task was actually delayed. + * Will be set to pdTRUE if the task way delayed and to pdFALSE otherwise. + * * Example usage:
  // Perform an action every 10 ticks.
@@ -821,7 +824,7 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
  * \defgroup vTaskDelayUntil vTaskDelayUntil
  * \ingroup TaskCtrl
  */
-void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
+void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement, BaseType_t * xWasDelayed ) PRIVILEGED_FUNCTION;
 
 /**
  * task. h
diff --git a/tasks.c b/tasks.c
index 41b976b2fb..4862cccc98 100644
--- a/tasks.c
+++ b/tasks.c
@@ -1251,7 +1251,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
 
 #if ( INCLUDE_vTaskDelayUntil == 1 )
 
-	void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement )
+	void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement, BaseType_t * xWasDelayed )
 	{
 	TickType_t xTimeToWake;
 	BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE;
@@ -1328,6 +1328,11 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
 		{
 			mtCOVERAGE_TEST_MARKER();
 		}
+
+		if(xWasDelayed != NULL)
+		{
+			*xWasDelayed = xShouldDelay;
+		}
 	}
 
 #endif /* INCLUDE_vTaskDelayUntil */

From f2e3d1b0e072131ce59426cbaf692f712051957c Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" 
Date: Wed, 24 Jun 2020 12:30:47 +0200
Subject: [PATCH 2/7] suggestions implemented

---
 include/task.h | 7 ++++---
 tasks.c        | 7 ++-----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/task.h b/include/task.h
index 96f77ab6cb..36d71ab77b 100644
--- a/include/task.h
+++ b/include/task.h
@@ -799,8 +799,8 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
  * same xTimeIncrement parameter value will cause the task to execute with
  * a fixed interface period.
  *
- * @param xWasDelayed Can be used to check whether the task was actually delayed.
- * Will be set to pdTRUE if the task way delayed and to pdFALSE otherwise.
+ * @return Value which can be used to check whether the task was actually delayed.
+ * Will be pdTRUE if the task way delayed and pdFALSE otherwise.
  *
  * Example usage:
    
@@ -824,7 +824,8 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
  * \defgroup vTaskDelayUntil vTaskDelayUntil
  * \ingroup TaskCtrl
  */
-void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement, BaseType_t * xWasDelayed ) PRIVILEGED_FUNCTION;
+BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
+#define vTaskDelayUntil ( pxPreviousWakeTime, xTimeIncrement ) xTaskDelayUntil ( ( xPreviousWakeTime ), ( xTimeIncrement ) )
 
 /**
  * task. h
diff --git a/tasks.c b/tasks.c
index 4862cccc98..ac31a9949e 100644
--- a/tasks.c
+++ b/tasks.c
@@ -1251,7 +1251,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
 
 #if ( INCLUDE_vTaskDelayUntil == 1 )
 
-	void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement, BaseType_t * xWasDelayed )
+	BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement )
 	{
 	TickType_t xTimeToWake;
 	BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE;
@@ -1329,10 +1329,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
 			mtCOVERAGE_TEST_MARKER();
 		}
 
-		if(xWasDelayed != NULL)
-		{
-			*xWasDelayed = xShouldDelay;
-		}
+		return xShouldDelay;
 	}
 
 #endif /* INCLUDE_vTaskDelayUntil */

From ffb219116fd160ac0b9992f287e0ddcca0b61983 Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" 
Date: Wed, 24 Jun 2020 13:24:51 +0200
Subject: [PATCH 3/7] xTaskDelayUntil #define added

---
 include/task.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/task.h b/include/task.h
index 36d71ab77b..78b0b7a184 100644
--- a/include/task.h
+++ b/include/task.h
@@ -766,7 +766,7 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
 
 /**
  * task. h
- * 
void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
+ *
void xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
* * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. * See the configuration section for more information. @@ -815,17 +815,21 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; for( ;; ) { // Wait for the next cycle. - vTaskDelayUntil( &xLastWakeTime, xFrequency ); + BaseType_t xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency ); - // Perform action here. + // Perform action here. xWasDelayed value can be used to determine + // whether a deadline was missed if the code here took too long. } }
- * \defgroup vTaskDelayUntil vTaskDelayUntil + * \defgroup xTaskDelayUntil xTaskDelayUntil * \ingroup TaskCtrl */ BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; -#define vTaskDelayUntil ( pxPreviousWakeTime, xTimeIncrement ) xTaskDelayUntil ( ( xPreviousWakeTime ), ( xTimeIncrement ) ) +#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \ +{ \ + xTaskDelayUntil ( pxPreviousWakeTime , xTimeIncrement ); \ +} /** * task. h From 90dab50d9f22287cc40cb3f0d3a6ddf4a36ce0c5 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 24 Jun 2020 13:28:53 +0200 Subject: [PATCH 4/7] doc small fix --- include/task.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/task.h b/include/task.h index 78b0b7a184..56b596cc5e 100644 --- a/include/task.h +++ b/include/task.h @@ -766,7 +766,7 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; /** * task. h - *
void xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
+ *
BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
* * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. * See the configuration section for more information. From d5227abff8477f2ab0ac55b9242545254a330442 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 21:55:35 +0200 Subject: [PATCH 5/7] small formatting stuff --- include/task.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/task.h b/include/task.h index 2c9adf44b7..d68be5946e 100644 --- a/include/task.h +++ b/include/task.h @@ -780,7 +780,9 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; /** * task. h - *
BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
+ *
+ * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
+ * 
* * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. * See the configuration section for more information. From 1adc9140595e649e659e13882b103703eee26ea9 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 21:57:05 +0200 Subject: [PATCH 6/7] more small formatting stuff --- include/task.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/task.h b/include/task.h index d68be5946e..f7dd1122d4 100644 --- a/include/task.h +++ b/include/task.h @@ -819,23 +819,23 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; * Will be pdTRUE if the task way delayed and pdFALSE otherwise. * * Example usage: - *
+ * 
  * // Perform an action every 10 ticks.
  * void vTaskFunction( void * pvParameters )
  * {
  * TickType_t xLastWakeTime;
  * const TickType_t xFrequency = 10;
  *
- *	 // Initialise the xLastWakeTime variable with the current time.
- *   xLastWakeTime = xTaskGetTickCount ();
- *	 for( ;; )
- *	 {
- *		 // Wait for the next cycle.
- *		 BaseType_t xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
+ *     // Initialise the xLastWakeTime variable with the current time.
+ *     xLastWakeTime = xTaskGetTickCount ();
+ *	   for( ;; )
+ *	   {
+ *	       // Wait for the next cycle.
+ *		   BaseType_t xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
  *
- *		 // Perform action here. xWasDelayed value can be used to determine
- *		 // whether a deadline was missed if the code here took too long.
- *	 }
+ *		   // Perform action here. xWasDelayed value can be used to determine
+ *		   // whether a deadline was missed if the code here took too long.
+ *     }
  * }
  * 
* \defgroup xTaskDelayUntil xTaskDelayUntil From 1486e261662dbae3575710e75bc0f7dc1a71515d Mon Sep 17 00:00:00 2001 From: Carl Lundin Date: Thu, 8 Oct 2020 16:51:43 -0700 Subject: [PATCH 7/7] Update lexicon.txt --- lexicon.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lexicon.txt b/lexicon.txt index 8cb6e9f9be..2e6e9a9563 100644 --- a/lexicon.txt +++ b/lexicon.txt @@ -2976,6 +2976,7 @@ xtaskcreate xtaskcreaterestricted xtaskcreaterestrictedstatic xtaskcreatestatic +xtaskdelayuntil xtaskdetails xtaskendscheduler xtaskgetapplicationtasktag @@ -3076,6 +3077,7 @@ xvalueofinsertion xvtorconst xwaitforallbits xwantedsize +xwasdelayed xwritevalue xxr xyieldpending