]> git.sur5r.net Git - freertos/blob - Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/main-full.c
385f0873a9db57cebb20902cf52e1b18ef8e875a
[freertos] / Demo / MicroBlaze_Spartan-6_EthernetLite / SDKProjects / RTOSDemoSource / main-full.c
1 /*\r
2     FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
3         \r
4 \r
5     ***************************************************************************\r
6      *                                                                       *\r
7      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
8      *    Complete, revised, and edited pdf reference manuals are also       *\r
9      *    available.                                                         *\r
10      *                                                                       *\r
11      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
12      *    ensuring you get running as quickly as possible and with an        *\r
13      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
14      *    the FreeRTOS project to continue with its mission of providing     *\r
15      *    professional grade, cross platform, de facto standard solutions    *\r
16      *    for microcontrollers - completely free of charge!                  *\r
17      *                                                                       *\r
18      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
19      *                                                                       *\r
20      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
21      *                                                                       *\r
22     ***************************************************************************\r
23 \r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     >>>NOTE<<< The modification to the GPL is included to allow you to\r
31     distribute a combined work that includes FreeRTOS without being obliged to\r
32     provide the source code for proprietary components outside of the FreeRTOS\r
33     kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
34     WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
35     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public\r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it\r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43 \r
44     http://www.FreeRTOS.org - Documentation, latest information, license and\r
45     contact details.\r
46 \r
47     http://www.SafeRTOS.com - A version that is certified for use in safety\r
48     critical systems.\r
49 \r
50     http://www.OpenRTOS.com - Commercial support, development, porting,\r
51     licensing and training services.\r
52 */\r
53 \r
54 /* ****************************************************************************\r
55  * This project includes a lot of tasks and tests and is therefore complex.\r
56  * If you would prefer a much simpler project to get started with then select\r
57  * the 'Blinky' build configuration within the Embedded Workbench IDE.\r
58  * ****************************************************************************\r
59  *\r
60  * Creates all the demo application tasks, then starts the scheduler.  The web\r
61  * documentation provides more details of the standard demo application tasks,\r
62  * which provide no particular functionality but do provide a good example of\r
63  * how to use the FreeRTOS API.  The tasks defined in flop.c are included in the\r
64  * set of standard demo tasks to ensure the floating point unit gets some\r
65  * exercise.\r
66  *\r
67  * In addition to the standard demo tasks, the following tasks and tests are\r
68  * defined and/or created within this file:\r
69  *\r
70  * Webserver ("uIP") task - This serves a number of dynamically generated WEB\r
71  * pages to a standard WEB browser.  The IP and MAC addresses are configured by\r
72  * constants defined at the bottom of FreeRTOSConfig.h.  Use either a standard\r
73  * Ethernet cable to connect through a hug, or a cross over (point to point)\r
74  * cable to connect directly.  Ensure the IP address used is compatible with the\r
75  * IP address of the machine running the browser - the easiest way to achieve\r
76  * this is to ensure the first three octets of the IP addresses are the same.\r
77  *\r
78  * "Reg test" tasks - These fill the registers with known values, then check\r
79  * that each register still contains its expected value.  Each task uses\r
80  * different values.  The tasks run with very low priority so get preempted\r
81  * very frequently.  A check variable is incremented on each iteration of the\r
82  * test loop.  A register containing an unexpected value is indicative of an\r
83  * error in the context switching mechanism and will result in a branch to a\r
84  * null loop - which in turn will prevent the check variable from incrementing\r
85  * any further and allow the check task (described below) to determine that an\r
86  * error has occurred.  The nature of the reg test tasks necessitates that they\r
87  * are written in assembly code.\r
88  *\r
89  * "Check" task - This only executes every five seconds but has a high priority\r
90  * to ensure it gets processor time.  Its main function is to check that all the\r
91  * standard demo tasks are still operational.  While no errors have been\r
92  * discovered the check task will toggle LED 5 every 5 seconds - the toggle\r
93  * rate increasing to 200ms being a visual indication that at least one task has\r
94  * reported unexpected behaviour.\r
95  *\r
96  * "High frequency timer test" - A high frequency periodic interrupt is\r
97  * generated using a timer - the interrupt is assigned a priority above\r
98  * configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything\r
99  * the kernel is doing.  The frequency and priority of the interrupt, in\r
100  * combination with other standard tests executed in this demo, should result\r
101  * in interrupts nesting at least 3 and probably 4 deep.  This test is only\r
102  * included in build configurations that have the optimiser switched on.  In\r
103  * optimised builds the count of high frequency ticks is used as the time base\r
104  * for the run time stats.\r
105  *\r
106  * *NOTE 1* If LED5 is toggling every 5 seconds then all the demo application\r
107  * tasks are executing as expected and no errors have been reported in any\r
108  * tasks.  The toggle rate increasing to 200ms indicates that at least one task\r
109  * has reported unexpected behaviour.\r
110  *\r
111  * *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let\r
112  * the application set up a timer to generate the tick interrupt.  In this\r
113  * example a compare match timer is used for this purpose.\r
114  *\r
115  * *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.\r
116  * The PowerON_Reset_PC() supplied in resetprg.c with this demo has\r
117  * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.\r
118  *\r
119  * *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use\r
120  * of all the 8bit timers (as two cascaded 16bit units).\r
121 */\r
122 \r
123 /* Standard includes. */\r
124 #include <string.h>\r
125 #include <stdio.h>\r
126 \r
127 /* BSP includes. */\r
128 #include "xenv_standalone.h"\r
129 #include "xtmrctr.h"\r
130 #include "xil_exception.h"\r
131 #include "microblaze_exceptions_g.h"\r
132 #include "xgpio.h"\r
133 \r
134 /* Kernel includes. */\r
135 #include "FreeRTOS.h"\r
136 #include "task.h"\r
137 #include "timers.h"\r
138 \r
139 /* Standard demo includes. */\r
140 #include "partest.h"\r
141 #include "flash.h"\r
142 #include "BlockQ.h"\r
143 #include "death.h"\r
144 #include "blocktim.h"\r
145 #include "semtest.h"\r
146 #include "PollQ.h"\r
147 #include "GenQTest.h"\r
148 #include "QPeek.h"\r
149 #include "recmutex.h"\r
150 #include "flop.h"\r
151 #include "dynamic.h"\r
152 \r
153 #define xPrintf( x )\r
154 \r
155 /* Priorities at which the tasks are created. */\r
156 #define mainCHECK_TASK_PRIORITY         ( configMAX_PRIORITIES - 1 )\r
157 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
158 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
159 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
160 #define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )\r
161 #define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
162 #define mainuIP_TASK_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
163 #define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )\r
164 #define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )\r
165 #define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )\r
166 \r
167 /* The WEB server uses string handling functions, which in turn use a bit more\r
168 stack than most of the other tasks. */\r
169 #define mainuIP_STACK_SIZE                      ( configMINIMAL_STACK_SIZE * 3 )\r
170 \r
171 /* The LED toggled by the check task. */\r
172 #define mainCHECK_LED                           ( 3 )\r
173 \r
174 /* The rate at which mainCHECK_LED will toggle when all the tasks are running\r
175 without error.  Controlled by the check task as described at the top of this\r
176 file. */\r
177 #define mainNO_ERROR_CHECK_TIMER_PERIOD         ( 5000 / portTICK_RATE_MS )\r
178 \r
179 /* The rate at which mainCHECK_LED will toggle when an error has been reported\r
180 by at least one task.  Controlled by the check task as described at the top of\r
181 this file. */\r
182 #define mainERROR_CHECK_TIMER_PERIOD            ( 200 / portTICK_RATE_MS )\r
183 \r
184 /* A block time of zero means "don't block". */
185 #define mainDONT_BLOCK                          ( ( portTickType ) 0 )\r
186 \r
187 /*\r
188  * vApplicationMallocFailedHook() will only be called if\r
189  * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
190  * function that will execute if a call to pvPortMalloc() fails.\r
191  * pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
192  * semaphore is created.  It is also called by various parts of the demo\r
193  * application.\r
194  */\r
195 void vApplicationMallocFailedHook( void );\r
196 \r
197 /*\r
198  * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1\r
199  * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration\r
200  * of the idle task.  It is essential that code added to this hook function\r
201  * never attempts to block in any way (for example, call xQueueReceive() with\r
202  * a block time specified).  If the application makes use of the vTaskDelete()\r
203  * API function (as this demo application does) then it is also important that\r
204  * vApplicationIdleHook() is permitted to return to its calling function because\r
205  * it is the responsibility of the idle task to clean up memory allocated by the\r
206  * kernel to any task that has since been deleted.\r
207  */\r
208 void vApplicationIdleHook( void );\r
209 \r
210 /*\r
211  * vApplicationStackOverflowHook() will only be called if\r
212  * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and\r
213  * name of the offending task should be passed in the function parameters, but\r
214  * it is possible that the stack overflow will have corrupted these - in which\r
215  * case pxCurrentTCB can be inspected to find the same information.\r
216  */\r
217 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName );\r
218 \r
219 /*\r
220  * The reg test tasks as described at the top of this file.\r
221  */\r
222 extern void vRegisterTest1( void *pvParameters );\r
223 extern void vRegisterTest2( void *pvParameters );\r
224 \r
225 /*\r
226  * Defines the 'check' functionality as described at the top of this file.  This\r
227  * function is the callback function for the 'check' timer.\r
228  */\r
229 static void vCheckTimerCallback( xTimerHandle xTimer );\r
230 \r
231 \r
232 static void prvSetupHardware( void );\r
233 \r
234 /*\r
235  * Contains the implementation of the WEB server.\r
236  */\r
237 //_RB_extern void vuIP_Task( void *pvParameters );\r
238 \r
239 /*-----------------------------------------------------------*/\r
240 \r
241 /* The status message that is displayed at the bottom of the "task stats" web\r
242 page, which is served by the uIP task.  This will report any errors picked up\r
243 by the reg test task. */\r
244 static const char *pcStatusMessage = NULL;\r
245 \r
246 static XTmrCtr xTimer0Instance;\r
247 \r
248 /* The 'check' timer, as described at the top of this file. */\r
249 static xTimerHandle xCheckTimer = NULL;\r
250 \r
251 /*-----------------------------------------------------------*/\r
252 \r
253 int main( void )\r
254 {\r
255         /* Configure the interrupt controller, LED outputs and button inputs. */\r
256         prvSetupHardware();\r
257 \r
258         /* Start the reg test tasks which test the context switching mechanism. */\r
259         xTaskCreate( vRegisterTest1, ( const signed char * const ) "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) 0, tskIDLE_PRIORITY, NULL );\r
260         xTaskCreate( vRegisterTest2, ( const signed char * const ) "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) 0, tskIDLE_PRIORITY, NULL );\r
261 \r
262         /* The web server task. */\r
263 //_RB_  xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );\r
264 \r
265         /* Create the standard demo tasks. */\r
266         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
267         vCreateBlockTimeTasks();\r
268         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
269         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
270         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
271         vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
272         vStartQueuePeekTasks();\r
273         vStartRecursiveMutexTasks();\r
274         vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
275 \r
276         /* The suicide tasks must be created last as they need to know how many\r
277         tasks were running prior to their creation in order to ascertain whether\r
278         or not the correct/expected number of tasks are running at any given time. */\r
279 //      vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
280 \r
281         /* Create the 'check' timer - the timer that periodically calls the\r
282         check function as described at the top of this file.  Note that, for\r
283         the reasons stated in the comments above the call to\r
284         vStartTimerDemoTask(), that the check timer is not actually started\r
285         until after the scheduler has been started. */\r
286         xCheckTimer = xTimerCreate( ( const signed char * ) "Check timer", mainNO_ERROR_CHECK_TIMER_PERIOD, pdTRUE, ( void * ) 0, vCheckTimerCallback );\r
287 \r
288         /* Ensure the check timer will start running as soon as the scheduler\r
289         starts.  The block time is set to 0 (mainDONT_BLOCK), but would be\r
290         ingnored at this point anyway as block times can only be specified when\r
291         the scheduler is running. */\r
292         xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
293 \r
294         /* Start the tasks running. */\r
295         vTaskStartScheduler();\r
296 \r
297         /* If all is well we will never reach here as the scheduler will now be\r
298         running.  If we do reach here then it is likely that there was insufficient\r
299         heap available for the idle task to be created. */\r
300         for( ;; );\r
301 }\r
302 /*-----------------------------------------------------------*/\r
303 \r
304 static void vCheckTimerCallback( xTimerHandle xTimer )\r
305 {\r
306 extern unsigned long ulRegTest1CycleCount, ulRegTest2CycleCount;\r
307 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;\r
308 static long lErrorAlreadyLatched = pdFALSE;\r
309 \r
310         /* This is the callback function used by the 'check' timer, as described\r
311         at the top of this file. */\r
312 \r
313 #if 0\r
314         /* Check the standard demo tasks are running without error. */\r
315         if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
316         {\r
317                 /* Increase the rate at which this task cycles, which will increase the\r
318                 rate at which mainCHECK_LED flashes to give visual feedback that an error\r
319                 has occurred. */\r
320                 pcStatusMessage = "Error: GenQueue";\r
321                 xPrintf( pcStatusMessage );\r
322         }\r
323 \r
324         if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
325         {\r
326                 pcStatusMessage = "Error: QueuePeek\r\n";\r
327                 xPrintf( pcStatusMessage );\r
328         }\r
329 \r
330         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
331         {\r
332                 pcStatusMessage = "Error: BlockQueue\r\n";\r
333                 xPrintf( pcStatusMessage );\r
334         }\r
335 \r
336         if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
337         {\r
338                 pcStatusMessage = "Error: BlockTime\r\n";\r
339                 xPrintf( pcStatusMessage );\r
340         }\r
341 \r
342         if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
343         {\r
344                 pcStatusMessage = "Error: SemTest\r\n";\r
345                 xPrintf( pcStatusMessage );\r
346         }\r
347 \r
348         if( xArePollingQueuesStillRunning() != pdTRUE )\r
349         {\r
350                 pcStatusMessage = "Error: PollQueue\r\n";\r
351                 xPrintf( pcStatusMessage );\r
352         }\r
353 \r
354         if( xIsCreateTaskStillRunning() != pdTRUE )\r
355         {\r
356                 pcStatusMessage = "Error: Death\r\n";\r
357                 xPrintf( pcStatusMessage );\r
358         }\r
359 \r
360         if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
361         {\r
362                 pcStatusMessage = "Error: RecMutex\r\n";\r
363                 xPrintf( pcStatusMessage );\r
364         }\r
365 \r
366         if( xAreMathsTaskStillRunning() != pdPASS )\r
367         {\r
368                 pcStatusMessage = "Error: Flop\r\n";\r
369                 xPrintf( pcStatusMessage );\r
370         }\r
371 #endif //_RB_\r
372         /* Check the reg test tasks are still cycling.  They will stop incrementing\r
373         their loop counters if they encounter an error. */\r
374         if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )\r
375         {\r
376                 pcStatusMessage = "Error: RegTest1\r\n";\r
377                 xPrintf( pcStatusMessage );\r
378         }\r
379 \r
380         if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )\r
381         {\r
382                 pcStatusMessage = "Error: RegTest2\r\n";\r
383                 xPrintf( pcStatusMessage );\r
384         }\r
385 \r
386         ulLastRegTest1CycleCount = ulRegTest1CycleCount;\r
387         ulLastRegTest2CycleCount = ulRegTest2CycleCount;\r
388 \r
389         /* Toggle the check LED to give an indication of the system status.  If\r
390         the LED toggles every 5 seconds then everything is ok.  A faster toggle\r
391         indicates an error. */\r
392         vParTestToggleLED( mainCHECK_LED );\r
393 \r
394         if( pcStatusMessage != NULL )\r
395         {\r
396                 if( lErrorAlreadyLatched == pdFALSE )\r
397                 {\r
398                         /* Ensure the LED toggles at a faster rate if an error has occurred.\r
399                         This is called from a timer callback so must not attempt to block. */
400                         xTimerChangePeriod( xTimer, mainERROR_CHECK_TIMER_PERIOD, mainDONT_BLOCK );\r
401 \r
402                         /* Just to ensure the timer period is not changed on each execution\r
403                         of the callback. */
404                         lErrorAlreadyLatched = pdTRUE;\r
405                 }\r
406         }\r
407 }\r
408 /*-----------------------------------------------------------*/\r
409 \r
410 void vApplicationSetupTimerInterrupt( void )\r
411 {\r
412 portBASE_TYPE xStatus;\r
413 const unsigned char ucTimerCounterNumber = ( unsigned char ) 0U;\r
414 //const unsigned long ulCounterValue = ( ( XPAR_AXI_TIMER_0_CLOCK_FREQ_HZ / configTICK_RATE_HZ ) - 1UL );\r
415 const unsigned long ulCounterValue = ( ( ( XPAR_AXI_TIMER_0_CLOCK_FREQ_HZ / configTICK_RATE_HZ ) - 1UL ) ) * 2UL; //_RB_ there is a clock set up incorrectly somwehre, the *2 should not be required.\r
416 extern void vTickISR( void *pvUnused );\r
417 \r
418         /* Initialise the timer/counter. */\r
419         xStatus = XTmrCtr_Initialize( &xTimer0Instance, XPAR_AXI_TIMER_0_DEVICE_ID );\r
420 \r
421         if( xStatus == XST_SUCCESS )\r
422         {\r
423                 /* Install the tick interrupt handler as the timer ISR. */\r
424                 xStatus = xPortInstallInterruptHandler( XPAR_MICROBLAZE_0_INTC_AXI_TIMER_0_INTERRUPT_INTR, vTickISR, NULL );\r
425         }\r
426 \r
427         if( xStatus == pdPASS )\r
428         {\r
429                 vPortEnableInterrupt( XPAR_MICROBLAZE_0_INTC_AXI_TIMER_0_INTERRUPT_INTR );\r
430 \r
431                 /* Configure the timer interrupt handler. */\r
432                 XTmrCtr_SetHandler( &xTimer0Instance, ( void * ) vTickISR, NULL );\r
433 \r
434                 /* Set the correct period for the timer. */\r
435                 XTmrCtr_SetResetValue( &xTimer0Instance, ucTimerCounterNumber, ulCounterValue );\r
436 \r
437                 /* Enable the interrupts.  Auto-reload mode is used to generate a\r
438                 periodic tick.  Note that interrupts are disabled when this function is\r
439                 called, so interrupts will not start to be processed until the first\r
440                 task has started to run. */\r
441                 XTmrCtr_SetOptions( &xTimer0Instance, ucTimerCounterNumber, ( XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_DOWN_COUNT_OPTION ) );\r
442 \r
443                 /* Start the timer. */\r
444                 XTmrCtr_Start( &xTimer0Instance, ucTimerCounterNumber );\r
445         }\r
446 \r
447         configASSERT( ( xStatus == pdPASS ) );\r
448 }\r
449 /*-----------------------------------------------------------*/\r
450 \r
451 void vApplicationClearTimerInterrupt( void )\r
452 {\r
453 unsigned long ulCSR;\r
454 \r
455         /* Increment the RTOS tick - this might cause a task to unblock. */\r
456         vTaskIncrementTick();\r
457 \r
458         /* Clear the timer interrupt */\r
459         ulCSR = XTmrCtr_GetControlStatusReg( XPAR_AXI_TIMER_0_BASEADDR, 0 );\r
460         XTmrCtr_SetControlStatusReg( XPAR_AXI_TIMER_0_BASEADDR, 0, ulCSR );\r
461 }\r
462 /*-----------------------------------------------------------*/\r
463 \r
464 /* This function is explained by the comments above its prototype at the top\r
465 of this file. */\r
466 void vApplicationMallocFailedHook( void )\r
467 {\r
468         for( ;; );\r
469 }\r
470 /*-----------------------------------------------------------*/\r
471 \r
472 /* This function is explained by the comments above its prototype at the top\r
473 of this file. */\r
474 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )\r
475 {\r
476         for( ;; );\r
477 }\r
478 /*-----------------------------------------------------------*/\r
479 \r
480 /* This function is explained by the comments above its prototype at the top\r
481 of this file. */\r
482 void vApplicationIdleHook( void )\r
483 {\r
484 }\r
485 /*-----------------------------------------------------------*/\r
486 \r
487 char *pcGetTaskStatusMessage( void )\r
488 {\r
489         /* Not bothered about a critical section here although technically because of\r
490         the task priorities the pointer could change it will be atomic if not near\r
491         atomic and its not critical. */\r
492         if( pcStatusMessage == NULL )\r
493         {\r
494                 return "All tasks running without error";\r
495         }\r
496         else\r
497         {\r
498                 return ( char * ) pcStatusMessage;\r
499         }\r
500 }\r
501 /*-----------------------------------------------------------*/\r
502 \r
503 static void prvSetupHardware( void )\r
504 {\r
505 #if 0\r
506 portBASE_TYPE xStatus;\r
507 const unsigned char ucSetToOutput = 0U;\r
508 \r
509         /* Set up the GPIO port for the LED outputs. */\r
510         vParTestInitialise();\r
511 \r
512         /* Initialise the GPIO for the button inputs. */\r
513         if( xStatus == XST_SUCCESS )\r
514         {\r
515                 xStatus = XGpio_Initialize( &xInputGPIOInstance, XPAR_PUSH_BUTTONS_4BITS_DEVICE_ID );\r
516         }\r
517 \r
518         if( xStatus == XST_SUCCESS )\r
519         {\r
520                 /* Install the handler defined in this task for the button input. */\r
521                 xStatus = xPortInstallInterruptHandler( XPAR_MICROBLAZE_0_INTC_PUSH_BUTTONS_4BITS_IP2INTC_IRPT_INTR, prvButtonInputInterruptHandler, NULL );\r
522 \r
523                 if( xStatus == pdPASS )\r
524                 {\r
525                         /* Set buttons to input. */\r
526                         XGpio_SetDataDirection( &xInputGPIOInstance, uxGPIOInputChannel, ~( ucSetToOutput ) );\r
527 \r
528 \r
529                         vPortEnableInterrupt( XPAR_MICROBLAZE_0_INTC_PUSH_BUTTONS_4BITS_IP2INTC_IRPT_INTR );\r
530 \r
531                         /* Enable GPIO channel interrupts. */\r
532                         XGpio_InterruptEnable( &xInputGPIOInstance, uxGPIOInputChannel ); //_RB_\r
533                         XGpio_InterruptGlobalEnable( &xInputGPIOInstance );\r
534                 }\r
535         }\r
536 \r
537         configASSERT( ( xStatus == pdPASS ) );\r
538 #else\r
539         taskDISABLE_INTERRUPTS();\r
540         vParTestInitialise();\r
541 #endif //_RB_\r
542 \r
543         #ifdef MICROBLAZE_EXCEPTIONS_ENABLED\r
544 //_RB_          microblaze_enable_exceptions();\r
545         #endif\r
546 }\r
547 /*-----------------------------------------------------------*/\r
548 \r