]> git.sur5r.net Git - freertos/blob - Demo/ARM9_AT91SAM9XE_IAR/main.c
Still a work in progress.
[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         /* Just to remove the compiler warning. */\r
134         ( void ) pvParameters;\r
135 \r
136         /* Initialise xNextWakeTime prior to its first use.  From this point on\r
137         the value of the variable is handled automatically by the kernel. */\r
138         xNextWakeTime = xTaskGetTickCount();\r
139         \r
140         for( ;; )\r
141         {\r
142                 vTaskDelayUntil( &xNextWakeTime, xPeriod );\r
143                 \r
144                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
145                 {\r
146                         ulErrorCode |= 0x01UL;\r
147                 }\r
148 \r
149                 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
150                 {\r
151                         ulErrorCode |= 0x02UL;\r
152                 }\r
153 \r
154                 if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
155                 {\r
156                         ulErrorCode |= 0x04UL;\r
157                 }\r
158 \r
159                 if( xIsCreateTaskStillRunning() != pdTRUE )\r
160                 {\r
161                         ulErrorCode |= 0x08UL;\r
162                 }\r
163 \r
164                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
165                 {\r
166                         ulErrorCode |= 0x10UL;\r
167                 }\r
168 \r
169                 if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
170                 {\r
171                         ulErrorCode |= 0x20UL;\r
172                 }\r
173 \r
174                 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
175                 {\r
176                         ulErrorCode |= 0x40UL;\r
177                 }\r
178 \r
179                 if( xArePollingQueuesStillRunning() != pdTRUE )\r
180                 {\r
181                         ulErrorCode |= 0x80UL;\r
182                 }\r
183 \r
184                 if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
185                 {\r
186                         ulErrorCode |= 0x100UL;\r
187                 }\r
188 \r
189                 if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
190                 {\r
191                         ulErrorCode |= 0x200UL;\r
192                 }\r
193 \r
194                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
195                 {\r
196                         ulErrorCode |= 0x400UL;\r
197                 }\r
198                 \r
199                 if( ulErrorCode != 0x00 )\r
200                 {\r
201                         xPeriod = mainERROR_PERIOD;\r
202                 }\r
203                 \r
204                 vParTestToggleLED( LED_DS1 );\r
205         }\r
206 }\r
207 /*-----------------------------------------------------------*/\r
208 \r
209 static void prvSetupHardware( void )\r
210 {\r
211         vParTestInitialise();\r
212 }\r