]> git.sur5r.net Git - freertos/blob - Demo/ARM9_AT91SAM9XE_IAR/main.c
Update to IAR V5.3.
[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         vStartLEDFlashTasks( mainLED_TASK_PRIORITY );   \r
100 \r
101         /* These tasks to be added once the simple flasher is running.\r
102         \r
103         vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
104         vStartLEDFlashTasks( mainLED_TASK_PRIORITY );\r
105         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
106         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
107         vStartDynamicPriorityTasks();\r
108         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
109         vCreateBlockTimeTasks();\r
110         vStartCountingSemaphoreTasks();\r
111         vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
112         vStartQueuePeekTasks();\r
113         vStartRecursiveMutexTasks();\r
114         \r
115         The death demo tasks must be started last as the sanity checks performed\r
116         require knowledge of the number of other tasks in the system.\r
117         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); */\r
118         \r
119         /* Start the scheduler.  From this point on the execution will be under\r
120         the control of the kernel. */\r
121         vTaskStartScheduler();\r
122         \r
123         /* Will only get here if there was insufficient heap availale for the\r
124         idle task to be created. */\r
125         for( ;; );\r
126 }\r
127 /*-----------------------------------------------------------*/\r
128 \r
129 static void prvCheckTask( void * pvParameters )\r
130 {\r
131 portTickType xNextWakeTime, xPeriod = mainNO_ERROR_PERIOD;\r
132 static volatile unsigned portLONG ulErrorCode = 0UL;\r
133 \r
134         /* Initialise xNextWakeTime prior to its first use.  From this point on\r
135         the value of the variable is handled automatically by the kernel. */\r
136         xNextWakeTime = xTaskGetTickCount();\r
137         \r
138         for( ;; )\r
139         {\r
140                 vTaskDelayUntil( &xNextWakeTime, xPeriod );\r
141                 \r
142                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
143                 {\r
144                         ulErrorCode |= 0x01UL;\r
145                 }\r
146 \r
147                 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
148                 {\r
149                         ulErrorCode |= 0x02UL;\r
150                 }\r
151 \r
152                 if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
153                 {\r
154                         ulErrorCode |= 0x04UL;\r
155                 }\r
156 \r
157                 if( xIsCreateTaskStillRunning() != pdTRUE )\r
158                 {\r
159                         ulErrorCode |= 0x08UL;\r
160                 }\r
161 \r
162                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
163                 {\r
164                         ulErrorCode |= 0x10UL;\r
165                 }\r
166 \r
167                 if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
168                 {\r
169                         ulErrorCode |= 0x20UL;\r
170                 }\r
171 \r
172                 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
173                 {\r
174                         ulErrorCode |= 0x40UL;\r
175                 }\r
176 \r
177                 if( xArePollingQueuesStillRunning() != pdTRUE )\r
178                 {\r
179                         ulErrorCode |= 0x80UL;\r
180                 }\r
181 \r
182                 if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
183                 {\r
184                         ulErrorCode |= 0x100UL;\r
185                 }\r
186 \r
187                 if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
188                 {\r
189                         ulErrorCode |= 0x200UL;\r
190                 }\r
191 \r
192                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
193                 {\r
194                         ulErrorCode |= 0x400UL;\r
195                 }\r
196         }\r
197 }\r
198 /*-----------------------------------------------------------*/\r
199 \r
200 static void prvSetupHardware( void )\r
201 {\r
202         vParTestInitialise();\r
203 }\r