]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c
Kernel changes:
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4S_Atmel_Studio / src / main_full.c
index 2067f66bbf3e5a32a342f59e611022e31b82af8b..4e4495cec286c84e42122d4e52320401565d132a 100644 (file)
 #include "comtest2.h"\r
 #include "QueueSet.h"\r
 #include "IntQueue.h"\r
+#include "TaskNotify.h"\r
+#include "TimerDemo.h"\r
+#include "EventGroupsDemo.h"\r
+#include "IntSemTest.h"\r
 \r
 /* Atmel library includes. */\r
 #include "asf.h"\r
 /* The period after which the check timer will expire, in ms, provided no errors\r
 have been reported by any of the standard demo tasks.  ms are converted to the\r
 equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
-#define mainCHECK_TIMER_PERIOD_MS                      ( 3000UL / portTICK_PERIOD_MS )\r
+#define mainCHECK_TIMER_PERIOD_MS                      ( pdMS_TO_TICKS( 3000UL ) )\r
 \r
 /* The period at which the check timer will expire, in ms, if an error has been\r
 reported in one of the standard demo tasks.  ms are converted to the equivalent\r
 in ticks using the portTICK_PERIOD_MS constant. */\r
-#define mainERROR_CHECK_TIMER_PERIOD_MS        ( 200UL / portTICK_PERIOD_MS )\r
+#define mainERROR_CHECK_TIMER_PERIOD_MS        ( pdMS_TO_TICKS( 200UL ) )\r
 \r
 /* The standard demo flash timers can be used to flash any number of LEDs.  In\r
 this case, because only three LEDs are available, and one is in use by the\r
@@ -165,8 +169,23 @@ standard demo flash timers. */
 for the comtest, so the LED number is deliberately out of range. */\r
 #define mainCOM_TEST_LED                                       ( 3 )\r
 \r
+/* Used by the standard demo timer tasks. */\r
+#define mainTIMER_TEST_PERIOD                          ( 50 )\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
+/*\r
+ * Called by the idle hook function when the project is configured to run the\r
+ * full (as opposed to the blinky) demo.\r
+ */\r
+void vFullDemoIdleHook( void );\r
+\r
+/*\r
+ * Called by the tick hook function when the project is configured to run the\r
+ * full (as opposed to the blinky) demo.\r
+ */\r
+void vFullDemoTickHook( void );\r
+\r
 /*\r
  * The check timer callback function, as described at the top of this file.\r
  */\r
@@ -176,8 +195,6 @@ static void prvCheckTimerCallback( TimerHandle_t xTimer );
 \r
 void main_full( void )\r
 {\r
-TimerHandle_t xCheckTimer = NULL;\r
-\r
        /* Start all the other standard demo/test tasks.  The have not particular\r
        functionality, but do demonstrate how to use the FreeRTOS API and test the\r
        kernel port. */\r
@@ -191,23 +208,12 @@ TimerHandle_t xCheckTimer = NULL;
        vStartRecursiveMutexTasks();\r
        vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
        vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
-       vStartLEDFlashTimers( mainNUMBER_OF_FLASH_TIMERS_LEDS );\r
        vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );\r
        vStartQueueSetTasks();\r
-\r
-       /* Create the software timer that performs the 'check' functionality,\r
-       as described at the top of this file. */\r
-       xCheckTimer = xTimerCreate( "CheckTimer",                                       /* A text name, purely to help debugging. */\r
-                                                               ( mainCHECK_TIMER_PERIOD_MS ),  /* The timer period, in this case 3000ms (3s). */\r
-                                                               pdTRUE,                                                 /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
-                                                               ( void * ) 0,                                   /* The ID is not used, so can be set to anything. */\r
-                                                               prvCheckTimerCallback                   /* The callback function that inspects the status of all the other tasks. */\r
-                                                         );\r
-\r
-       if( xCheckTimer != NULL )\r
-       {\r
-               xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
-       }\r
+       vStartTaskNotifyTask();\r
+       vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
+       vStartEventGroupTasks();\r
+       vStartInterruptSemaphoreTasks();\r
 \r
        /* The set of tasks created by the following function call have to be\r
        created last as they keep account of the number of tasks they expect to see\r
@@ -236,63 +242,84 @@ unsigned long ulErrorFound = pdFALSE;
 \r
        if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 0UL;\r
        }\r
 \r
        if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 1UL;\r
        }\r
 \r
        if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 2UL;\r
        }\r
 \r
        if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 3UL;\r
        }\r
 \r
        if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 4UL;\r
        }\r
 \r
        if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 5UL;\r
        }\r
 \r
        if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 6UL;\r
        }\r
 \r
        if( xIsCreateTaskStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 7UL;\r
        }\r
 \r
        if( xArePollingQueuesStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 8UL;\r
        }\r
 \r
        if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 9UL;\r
        }\r
 \r
        if( xAreComTestTasksStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 10UL;\r
        }\r
 \r
-       if( xAreQueueSetTasksStillRunning() != pdPASS )\r
+       if( xAreQueueSetTasksStillRunning() != pdTRUE )\r
+       {\r
+               ulErrorFound |= 1UL << 11UL;\r
+       }\r
+       \r
+       if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
+       {\r
+               ulErrorFound |= 1UL << 12UL;\r
+       }\r
+       \r
+       if( xAreTimerDemoTasksStillRunning( mainCHECK_TIMER_PERIOD_MS ) != pdTRUE )\r
+       {\r
+               ulErrorFound |= 1UL << 13UL;\r
+       }\r
+       \r
+       if( xAreEventGroupTasksStillRunning() != pdTRUE )\r
+       {\r
+               ulErrorFound |= 1UL << 14UL;\r
+       }\r
+       \r
+       if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
        {\r
-               ulErrorFound = pdTRUE;\r
+               ulErrorFound |= 1UL << 15UL;\r
        }\r
+       \r
 \r
        /* Toggle the check LED to give an indication of the system status.  If\r
        the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then\r
@@ -318,3 +345,49 @@ unsigned long ulErrorFound = pdFALSE;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+void vFullDemoIdleHook( void )\r
+{\r
+static TimerHandle_t xCheckTimer = NULL;\r
+               \r
+       if( xCheckTimer == NULL )\r
+       {\r
+               /* Create the software timer that performs the 'check' \r
+               functionality, in the full demo.  This is not done before the\r
+               scheduler is started as to do so would prevent the standard demo\r
+               timer tasks from passing their tests (they expect the timer\r
+               command queue to be empty. */\r
+               xCheckTimer = xTimerCreate( "CheckTimer",                               /* A text name, purely to help debugging. */\r
+                                                                       mainCHECK_TIMER_PERIOD_MS,      /* The timer period, in this case 3000ms (3s). */\r
+                                                                       pdTRUE,                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
+                                                                       ( void * ) 0,                           /* The ID is not used, so can be set to anything. */\r
+                                                                       prvCheckTimerCallback           /* The callback function that inspects the status of all the other tasks. */\r
+                                                                       );\r
+\r
+               if( xCheckTimer != NULL )\r
+               {\r
+                       xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
+               }\r
+               \r
+               /* Also start some timers that just flash LEDs. */\r
+               vStartLEDFlashTimers( mainNUMBER_OF_FLASH_TIMERS_LEDS );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vFullDemoTickHook( void )\r
+{\r
+       /* In this case the tick hook is used as part of the queue set test. */\r
+       vQueueSetAccessQueueSetFromISR();\r
+               \r
+       /* Use task notifications from an interrupt. */\r
+       xNotifyTaskFromISR();\r
+               \r
+       /* Use timers from an interrupt. */\r
+       vTimerPeriodicISRTests();\r
+       \r
+       /* Use event groups from an interrupt. */\r
+       vPeriodicEventGroupsProcessing();\r
+       \r
+       /* Use mutexes from interrupts. */\r
+       vInterruptSemaphorePeriodicTest();\r
+}\r