]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC/main.c
Finalise XMC1000 Keil demos.
[freertos] / FreeRTOS / Demo / CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC / main.c
index 6707792fe0db1b714b7da4e87f7c863ff7e06da6..c7912ffeb4a2ca502b71221890d90893cc400e52 100644 (file)
 /* 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
@@ -120,7 +122,7 @@ int main( void )
 {\r
        /* Prepare the hardware to run this demo. */\r
        prvSetupHardware();\r
-\r
+       \r
        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
        of this file. */\r
        #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1\r
@@ -194,7 +196,39 @@ void vApplicationTickHook( void )
        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