]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/Common/Minimal/TaskNotify.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / Common / Minimal / TaskNotify.c
index 9e187c93460b0c28f3d7db384a8512a5d3da284e..1afdde76083640c07c173f486fc6a36792a8fbbf 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
- * FreeRTOS Kernel V10.1.0\r
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ * FreeRTOS Kernel V10.3.0\r
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
  *\r
  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
  * this software and associated documentation files (the "Software"), to deal in\r
 /* Demo program include files. */\r
 #include "TaskNotify.h"\r
 \r
+/* Allow parameters to be overridden on a demo by demo basis. */\r
+#ifndef notifyNOTIFIED_TASK_STACK_SIZE\r
+       #define notifyNOTIFIED_TASK_STACK_SIZE configMINIMAL_STACK_SIZE\r
+#endif\r
+\r
 #define notifyTASK_PRIORITY            ( tskIDLE_PRIORITY )\r
-#define notifyUINT32_MAX       ( ( uint32_t ) 0xffffffff )\r
+\r
+/* Constants used in tests when setting/clearing bits. */\r
+#define notifyUINT32_MAX               ( ( uint32_t ) 0xffffffff )\r
+#define notifyUINT32_HIGH_BYTE ( ( uint32_t ) 0xff000000 )\r
+#define notifyUINT32_LOW_BYTE  ( ( uint32_t ) 0x000000ff )\r
+\r
 #define notifySUSPENDED_TEST_TIMER_PERIOD pdMS_TO_TICKS( 50 )\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -104,7 +114,12 @@ void vStartTaskNotifyTask( void  )
 {\r
        /* Create the task that performs some tests by itself, then loops around\r
        being notified by both a software timer and an interrupt. */\r
-       xTaskCreate( prvNotifiedTask, "Notified", configMINIMAL_STACK_SIZE, NULL, notifyTASK_PRIORITY, &xTaskToNotify );\r
+       xTaskCreate( prvNotifiedTask, /* Function that implements the task. */\r
+                                "Notified", /* Text name for the task - for debugging only - not used by the kernel. */\r
+                                notifyNOTIFIED_TASK_STACK_SIZE, /* Task's stack size in words, not bytes!. */\r
+                                NULL, /* Task parameter, not used in this case. */\r
+                                notifyTASK_PRIORITY, /* Task priority, 0 is the lowest. */\r
+                                &xTaskToNotify ); /* Used to pass a handle to the task out is needed, otherwise set to NULL. */\r
 \r
        /* Pseudo seed the random number generator. */\r
        uxNextRand = ( size_t ) prvRand;\r
@@ -393,6 +408,37 @@ TimerHandle_t xSingleTaskTimer;
 \r
 \r
 \r
+       /* ------------------------------------------------------------------------\r
+       Clear bits in the notification value. */\r
+\r
+       /* Get the task to set all bits its own notification value.  This is not a\r
+       normal thing to do, and is only done here for test purposes. */\r
+       xTaskNotify( xTaskToNotify, notifyUINT32_MAX, eSetBits );\r
+\r
+       /* Now clear the top bytes - the returned value from the first call should\r
+       indicate that previously all bits were set. */\r
+       configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_HIGH_BYTE ) == notifyUINT32_MAX );\r
+\r
+       /* Next clear the bottom bytes - the returned value this time should indicate\r
+       that the top byte was clear (before the bottom byte was cleared. */\r
+       configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_LOW_BYTE ) == ( notifyUINT32_MAX & ~notifyUINT32_HIGH_BYTE ) );\r
+\r
+       /* Next clear all bytes - the returned value should indicate that previously the\r
+       high and low bytes were clear. */\r
+       configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_MAX ) == ( notifyUINT32_MAX & ~notifyUINT32_HIGH_BYTE & ~notifyUINT32_LOW_BYTE ) );\r
+\r
+       /* Now all bits should be clear. */\r
+       configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_MAX ) == 0 );\r
+       configASSERT( ulTaskNotifyValueClear( xTaskToNotify, 0UL ) == 0 );\r
+       configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_MAX ) == 0 );\r
+\r
+       /* Now the notification state should be eNotified, so it should now be\r
+       possible to clear the notification state. */\r
+       configASSERT( xTaskNotifyStateClear( NULL ) == pdTRUE );\r
+       configASSERT( xTaskNotifyStateClear( NULL ) == pdFALSE );\r
+\r
+\r
+\r
        /* ------------------------------------------------------------------------\r
        Create a timer that will try notifying this task while it is suspended. */\r
        xSingleTaskTimer = xTimerCreate( "SingleNotify", notifySUSPENDED_TEST_TIMER_PERIOD, pdFALSE, NULL, prvSuspendedTaskTimerTestCallback );\r
@@ -599,6 +645,9 @@ const BaseType_t xCallInterval = pdMS_TO_TICKS( 50 );
 uint32_t ulPreviousValue;\r
 const uint32_t ulUnexpectedValue = 0xff;\r
 \r
+       /* Check the task notification demo tasks were actually created. */\r
+       configASSERT( xTaskToNotify );\r
+\r
        /* The task performs some tests before starting the timer that gives the\r
        notification from this interrupt.  If the timer has not been created yet\r
        then the initial tests have not yet completed and the notification should\r