]> git.sur5r.net Git - freertos/blob - Demo/ARM9_AT91SAM9XE_IAR/main.c
Work in progress only.
[freertos] / Demo / ARM9_AT91SAM9XE_IAR / main.c
1 /*\r
2         FreeRTOS.org V5.1.1 - Copyright (C) 2003-2008 Richard Barry.\r
3 \r
4         This file is part of the FreeRTOS.org distribution.\r
5 \r
6         FreeRTOS.org is free software; you can redistribute it and/or modify\r
7         it under the terms of the GNU General Public License as published by\r
8         the Free Software Foundation; either version 2 of the License, or\r
9         (at your option) any later version.\r
10 \r
11         FreeRTOS.org is distributed in the hope that it will be useful,\r
12         but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14         GNU General Public License for more details.\r
15 \r
16         You should have received a copy of the GNU General Public License\r
17         along with FreeRTOS.org; if not, write to the Free Software\r
18         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19 \r
20         A special exception to the GPL can be applied should you wish to distribute\r
21         a combined work that includes FreeRTOS.org, without being obliged to provide\r
22         the source code for any proprietary components.  See the licensing section\r
23         of http://www.FreeRTOS.org for full details of how and when the exception\r
24         can be applied.\r
25 \r
26     ***************************************************************************\r
27     ***************************************************************************\r
28     *                                                                         *\r
29     * SAVE TIME AND MONEY!  We can port FreeRTOS.org to your own hardware,    *\r
30     * and even write all or part of your application on your behalf.          *\r
31     * See http://www.OpenRTOS.com for details of the services we provide to   *\r
32     * expedite your project.                                                  *\r
33     *                                                                         *\r
34     ***************************************************************************\r
35     ***************************************************************************\r
36 \r
37         Please ensure to read the configuration and relevant port sections of the\r
38         online documentation.\r
39 \r
40         http://www.FreeRTOS.org - Documentation, latest information, license and\r
41         contact details.\r
42 \r
43         http://www.SafeRTOS.com - A version that is certified for use in safety\r
44         critical systems.\r
45 \r
46         http://www.OpenRTOS.com - Commercial support, development, porting,\r
47         licensing and training services.\r
48 */\r
49 \r
50 /* FreeRTOS includes. */\r
51 #include "FreeRTOS.h"\r
52 #include "task.h"\r
53 \r
54 /* Standard demo includes. */\r
55 #include "BlockQ.h"\r
56 #include "blocktim.h"\r
57 #include "countsem.h"\r
58 #include "death.h"\r
59 #include "dynamic.h"\r
60 #include "flash.h"\r
61 #include "GenQTest.h"\r
62 #include "integer.h"\r
63 #include "PollQ.h"\r
64 #include "QPeek.h"\r
65 #include "recmutex.h"\r
66 #include "semtest.h"\r
67 #include "ParTest.h"\r
68 \r
69 /* Standard includes. */\r
70 #include <stdio.h>\r
71 \r
72 /* Priorities for the demo application tasks. */\r
73 #define mainLED_TASK_PRIORITY           ( tskIDLE_PRIORITY + 3 )\r
74 #define mainCOM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
75 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 0 )\r
76 #define mainCHECK_TASK_PRIORITY         ( tskIDLE_PRIORITY + 4 )\r
77 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 0 )\r
78 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
79 #define mainCREATOR_TASK_PRIORITY       ( tskIDLE_PRIORITY + 3 )\r
80 #define mainGENERIC_QUEUE_PRIORITY      ( tskIDLE_PRIORITY )\r
81 \r
82 /* The period of the check task both in and out of the presense of an error. */\r
83 #define mainNO_ERROR_PERIOD                     ( 5000 / portTICK_RATE_MS )\r
84 #define mainERROR_PERIOD                        ( 500 / portTICK_RATE_MS );\r
85 /*-----------------------------------------------------------*/\r
86 \r
87 /* Simple hardware setup required by the demo. */\r
88 static void prvSetupHardware( void );\r
89 \r
90 /* The check task as described at the top of this file. */\r
91 static void prvCheckTask( void *pvParameters );\r
92 \r
93 /*-----------------------------------------------------------*/\r
94 int main()\r
95 {\r
96         prvSetupHardware();\r
97         \r
98         /* Start the standard demo tasks. */\r
99         vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
100         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
101         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
102         vStartDynamicPriorityTasks();\r
103         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
104         vCreateBlockTimeTasks();\r
105         vStartCountingSemaphoreTasks();\r
106         vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
107         vStartQueuePeekTasks();\r
108         vStartRecursiveMutexTasks();\r
109         \r
110         /* Create the check task - this is the task that checks all the other tasks\r
111         are executing as expected and without reporting any errors. */\r
112         xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );\r
113         \r
114         /* The death demo tasks must be started last as the sanity checks performed\r
115         require knowledge of the number of other tasks in the system. */\r
116         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
117         \r
118         /* Start the scheduler.  From this point on the execution will be under\r
119         the control of the kernel. */\r
120         vTaskStartScheduler();\r
121         \r
122         /* Will only get here if there was insufficient heap availale for the\r
123         idle task to be created. */\r
124         for( ;; );\r
125 }\r
126 /*-----------------------------------------------------------*/\r
127 \r
128 static void prvCheckTask( void * pvParameters )\r
129 {\r
130 portTickType xNextWakeTime, xPeriod = mainNO_ERROR_PERIOD;\r
131 static volatile unsigned portLONG ulErrorCode = 0UL;\r
132 \r
133         /* Initialise xNextWakeTime prior to its first use.  From this point on\r
134         the value of the variable is handled automatically by the kernel. */\r
135         xNextWakeTime = xTaskGetTickCount();\r
136         \r
137         for( ;; )\r
138         {\r
139                 vTaskDelayUntil( &xNextWakeTime, xPeriod );\r
140                 \r
141                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
142                 {\r
143                         ulErrorCode |= 0x01UL;\r
144                 }\r
145 \r
146                 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
147                 {\r
148                         ulErrorCode |= 0x02UL;\r
149                 }\r
150 \r
151                 if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
152                 {\r
153                         ulErrorCode |= 0x04UL;\r
154                 }\r
155 \r
156                 if( xIsCreateTaskStillRunning() != pdTRUE )\r
157                 {\r
158                         ulErrorCode |= 0x08UL;\r
159                 }\r
160 \r
161                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
162                 {\r
163                         ulErrorCode |= 0x10UL;\r
164                 }\r
165 \r
166                 if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
167                 {\r
168                         ulErrorCode |= 0x20UL;\r
169                 }\r
170 \r
171                 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
172                 {\r
173                         ulErrorCode |= 0x40UL;\r
174                 }\r
175 \r
176                 if( xArePollingQueuesStillRunning() != pdTRUE )\r
177                 {\r
178                         ulErrorCode |= 0x80UL;\r
179                 }\r
180 \r
181                 if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
182                 {\r
183                         ulErrorCode |= 0x100UL;\r
184                 }\r
185 \r
186                 if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
187                 {\r
188                         ulErrorCode |= 0x200UL;\r
189                 }\r
190 \r
191                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
192                 {\r
193                         ulErrorCode |= 0x400UL;\r
194                 }\r
195                 \r
196                 if( ulErrorCode != 0x00 )\r
197                 {\r
198                         xPeriod = mainERROR_PERIOD;\r
199                 }\r
200                 \r
201                 vParTestToggleLED( LED_DS1 );\r
202         }\r
203 }\r
204 /*-----------------------------------------------------------*/\r
205 \r
206 static void prvSetupHardware( void )\r
207 {\r
208         vParTestInitialise();\r
209 }\r