/*\r
- FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+ FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+ All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
/* FreeRTOS includes. */\r
#include "FreeRTOS.h"\r
#include "task.h"\r
+#include "semphr.h"\r
\r
/* Demo application include. */\r
#include "ParTest.h"\r
+#include "QueueSet.h"\r
\r
/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
or 0 to run the more comprehensive test and demo application. */\r
-#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0\r
+#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 1\r
\r
\r
/*-----------------------------------------------------------*/\r
configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be\r
added here, but the tick hook is called from an interrupt context, so\r
code must not attempt to block, and only the interrupt safe FreeRTOS API\r
- functions can be used (those that end in FromISR()). */\r
+ functions can be used (those that end in FromISR()). The code in this\r
+ tick hook implementation is for demonstration only - it has no real\r
+ purpose. It just gives a semaphore every 50ms. The semaphore unblocks a\r
+ task that then toggles an LED. Additionally, the call to\r
+ vQueueSetAccessQueueSetFromISR() is part of the "standard demo tasks"\r
+ functionality. */\r
+\r
+ /* The semaphore and associated task are not created when the simple blinky\r
+ demo is used. */\r
+ #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0\r
+ {\r
+ static unsigned long ulLastGiveTime = 0UL;\r
+ const unsigned long ulRate = 50UL / portTICK_RATE_MS;\r
+ extern xSemaphoreHandle xLEDSemaphore;\r
+\r
+ configASSERT( xLEDSemaphore );\r
+\r
+ if( ( xTaskGetTickCountFromISR() - ulLastGiveTime ) > ulRate )\r
+ {\r
+ /* The second parameter is normally used to determine if a context\r
+ switch should be performed or not. In this case the function is\r
+ being performed from the tick hook, so the scheduler will make that\r
+ assessment before returning to a task anyway - so the parameter is\r
+ not needed and is just set to NULL. */\r
+ xSemaphoreGiveFromISR( xLEDSemaphore, NULL );\r
+ ulLastGiveTime += ulRate;\r
+ }\r
+\r
+ /* Write to a queue that is in use as part of the queue set demo to\r
+ demonstrate using queue sets from an ISR. */\r
+ vQueueSetAccessQueueSetFromISR();\r
+ }\r
+ #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */\r
}\r
/*-----------------------------------------------------------*/\r
\r