2 FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
13 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
14 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
15 >>! obliged to provide the source code for proprietary components !<<
\r
16 >>! outside of the FreeRTOS kernel. !<<
\r
18 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
19 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
20 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
21 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * Having a problem? Start by reading the FAQ "My application does *
\r
28 * not run, what could be wrong?". Have you defined configASSERT()? *
\r
30 * http://www.FreeRTOS.org/FAQHelp.html *
\r
32 ***************************************************************************
\r
34 ***************************************************************************
\r
36 * FreeRTOS provides completely free yet professionally developed, *
\r
37 * robust, strictly quality controlled, supported, and cross *
\r
38 * platform software that is more than just the market leader, it *
\r
39 * is the industry's de facto standard. *
\r
41 * Help yourself get started quickly while simultaneously helping *
\r
42 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
43 * tutorial book, reference manual, or both: *
\r
44 * http://www.FreeRTOS.org/Documentation *
\r
46 ***************************************************************************
\r
48 ***************************************************************************
\r
50 * Investing in training allows your team to be as productive as *
\r
51 * possible as early as possible, lowering your overall development *
\r
52 * cost, and enabling you to bring a more robust product to market *
\r
53 * earlier than would otherwise be possible. Richard Barry is both *
\r
54 * the architect and key author of FreeRTOS, and so also the world's *
\r
55 * leading authority on what is the world's most popular real time *
\r
56 * kernel for deeply embedded MCU designs. Obtaining your training *
\r
57 * from Richard ensures your team will gain directly from his in-depth *
\r
58 * product knowledge and years of usage experience. Contact Real Time *
\r
59 * Engineers Ltd to enquire about the FreeRTOS Masterclass, presented *
\r
60 * by Richard Barry: http://www.FreeRTOS.org/contact
\r
62 ***************************************************************************
\r
64 ***************************************************************************
\r
66 * You are receiving this top quality software for free. Please play *
\r
67 * fair and reciprocate by reporting any suspected issues and *
\r
68 * participating in the community forum: *
\r
69 * http://www.FreeRTOS.org/support *
\r
73 ***************************************************************************
\r
75 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
76 license and Real Time Engineers Ltd. contact details.
\r
78 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
79 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
80 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
82 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
83 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
85 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
86 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
87 licenses offer ticketed support, indemnification and commercial middleware.
\r
89 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
90 engineered and independently SIL3 certified version for use in safety and
\r
91 mission critical applications that require provable dependability.
\r
97 * main-blinky.c is included when the "Blinky" build configuration is used.
\r
98 * main-full.c is included when the "Full" build configuration is used.
\r
100 * main-blinky.c (this file) defines a very simple demo that creates two tasks,
\r
101 * one queue, and one timer. It also demonstrates how MicroBlaze interrupts
\r
102 * can interact with FreeRTOS tasks/timers.
\r
104 * This simple demo project was developed and tested on the Spartan-6 SP605
\r
105 * development board, using the hardware configuration found in the hardware
\r
106 * project that is already included in the Eclipse project.
\r
108 * The idle hook function:
\r
109 * The idle hook function demonstrates how to query the amount of FreeRTOS heap
\r
110 * space that is remaining (see vApplicationIdleHook() defined in this file).
\r
112 * The main() Function:
\r
113 * main() creates one software timer, one queue, and two tasks. It then starts
\r
116 * The Queue Send Task:
\r
117 * The queue send task is implemented by the prvQueueSendTask() function in
\r
118 * this file. prvQueueSendTask() sits in a loop that causes it to repeatedly
\r
119 * block for 200 milliseconds, before sending the value 100 to the queue that
\r
120 * was created within main(). Once the value is sent, the task loops back
\r
121 * around to block for another 200 milliseconds.
\r
123 * The Queue Receive Task:
\r
124 * The queue receive task is implemented by the prvQueueReceiveTask() function
\r
125 * in this file. prvQueueReceiveTask() sits in a loop that causes it to
\r
126 * repeatedly attempt to read data from the queue that was created within
\r
127 * main(). When data is received, the task checks the value of the data, and
\r
128 * if the value equals the expected 100, toggles an LED. The 'block time'
\r
129 * parameter passed to the queue receive function specifies that the task
\r
130 * should be held in the Blocked state indefinitely to wait for data to be
\r
131 * available on the queue. The queue receive task will only leave the Blocked
\r
132 * state when the queue send task writes to the queue. As the queue send task
\r
133 * writes to the queue every 200 milliseconds, the queue receive task leaves
\r
134 * the Blocked state every 200 milliseconds, and therefore toggles the LED
\r
135 * every 200 milliseconds.
\r
137 * The LED Software Timer and the Button Interrupt:
\r
138 * The user buttons are configured to generate an interrupt each time one is
\r
139 * pressed. The interrupt service routine switches an LED on, and resets the
\r
140 * LED software timer. The LED timer has a 5000 millisecond (5 second) period,
\r
141 * and uses a callback function that is defined to just turn the LED off again.
\r
142 * Therefore, pressing the user button will turn the LED on, and the LED will
\r
143 * remain on until a full five seconds pass without the button being pressed.
\r
146 /* Kernel includes. */
\r
147 #include "FreeRTOS.h"
\r
150 #include "timers.h"
\r
152 /* BSP includes. */
\r
153 #include "xtmrctr.h"
\r
156 /* Priorities at which the tasks are created. */
\r
157 #define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
158 #define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
160 /* The rate at which data is sent to the queue, specified in milliseconds, and
\r
161 converted to ticks using the portTICK_PERIOD_MS constant. */
\r
162 #define mainQUEUE_SEND_FREQUENCY_MS ( 200 / portTICK_PERIOD_MS )
\r
164 /* The number of items the queue can hold. This is 1 as the receive task
\r
165 will remove items as they are added because it has the higher priority, meaning
\r
166 the send task should always find the queue empty. */
\r
167 #define mainQUEUE_LENGTH ( 1 )
\r
169 /* The LED toggled by the queue receive task. */
\r
170 #define mainTASK_CONTROLLED_LED 0x01UL
\r
172 /* The LED turned on by the button interrupt, and turned off by the LED timer. */
\r
173 #define mainTIMER_CONTROLLED_LED 0x02UL
\r
175 /* A block time of 0 simply means, "don't block". */
\r
176 #define mainDONT_BLOCK ( TickType_t ) 0
\r
178 /*-----------------------------------------------------------*/
\r
181 * Setup the NVIC, LED outputs, and button inputs.
\r
183 static void prvSetupHardware( void );
\r
186 * The tasks as described in the comments at the top of this file.
\r
188 static void prvQueueReceiveTask( void *pvParameters );
\r
189 static void prvQueueSendTask( void *pvParameters );
\r
192 * The LED timer callback function. This does nothing but switch off the
\r
193 * LED defined by the mainTIMER_CONTROLLED_LED constant.
\r
195 static void vLEDTimerCallback( TimerHandle_t xTimer );
\r
198 * The handler executed each time a button interrupt is generated. This ensures
\r
199 * the LED defined by mainTIMER_CONTROLLED_LED is on, and resets the timer so
\r
200 * the timer will not turn the LED off for a full 5 seconds after the button
\r
201 * interrupt occurred.
\r
203 static void prvButtonInputInterruptHandler( void *pvUnused );
\r
205 /*-----------------------------------------------------------*/
\r
207 /* The queue used by the queue send and queue receive tasks. */
\r
208 static QueueHandle_t xQueue = NULL;
\r
210 /* The LED software timer. This uses vLEDTimerCallback() as its callback
\r
212 static TimerHandle_t xLEDTimer = NULL;
\r
214 /* Maintains the current LED output state. */
\r
215 static volatile unsigned char ucGPIOState = 0U;
\r
217 /*-----------------------------------------------------------*/
\r
219 /* Structures that hold the state of the various peripherals used by this demo.
\r
220 These are used by the Xilinx peripheral driver API functions. */
\r
221 static XTmrCtr xTimer0Instance;
\r
222 static XGpio xOutputGPIOInstance, xInputGPIOInstance;
\r
224 /* Constants required by the Xilinx peripheral driver API functions that are
\r
225 relevant to the particular hardware set up. */
\r
226 static const unsigned long ulGPIOOutputChannel = 1UL, ulGPIOInputChannel = 1UL;
\r
228 /*-----------------------------------------------------------*/
\r
232 /* *************************************************************************
\r
233 This is a very simple project suitable for getting started with FreeRTOS.
\r
234 If you would prefer a more complex project that demonstrates a lot more
\r
235 features and tests, then select the 'Full' build configuration within the
\r
237 ***************************************************************************/
\r
239 /* Configure the interrupt controller, LED outputs and button inputs. */
\r
240 prvSetupHardware();
\r
242 /* Create the queue used by the queue send and queue receive tasks as
\r
243 described in the comments at the top of this file. */
\r
244 xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
\r
246 /* Sanity check that the queue was created. */
\r
247 configASSERT( xQueue );
\r
249 /* Start the two tasks as described in the comments at the top of this
\r
251 xTaskCreate( prvQueueReceiveTask, "Rx", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_RECEIVE_TASK_PRIORITY, NULL );
\r
252 xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL );
\r
254 /* Create the software timer that is responsible for turning off the LED
\r
255 if the button is not pushed within 5000ms, as described at the top of
\r
256 this file. The timer is not actually started until a button interrupt is
\r
257 pushed, as it is not until that point that the LED is turned on. */
\r
258 xLEDTimer = xTimerCreate( "LEDTimer", /* A text name, purely to help debugging. */
\r
259 ( 5000 / portTICK_PERIOD_MS ),/* The timer period, in this case 5000ms (5s). */
\r
260 pdFALSE, /* This is a one shot timer, so xAutoReload is set to pdFALSE. */
\r
261 ( void * ) 0, /* The ID is not used, so can be set to anything. */
\r
262 vLEDTimerCallback /* The callback function that switches the LED off. */
\r
265 /* Start the tasks and timer running. */
\r
266 vTaskStartScheduler();
\r
268 /* If all is well, the scheduler will now be running, and the following line
\r
269 will never be reached. If the following line does execute, then there was
\r
270 insufficient FreeRTOS heap memory available for the idle and/or timer tasks
\r
271 to be created. See the memory management section on the FreeRTOS web site
\r
272 for more details. */
\r
275 /*-----------------------------------------------------------*/
\r
277 /* The callback is executed when the LED timer expires. */
\r
278 static void vLEDTimerCallback( TimerHandle_t xTimer )
\r
280 /* The timer has expired - so no button pushes have occurred in the last
\r
281 five seconds - turn the LED off. NOTE - accessing the LED port should use
\r
282 a critical section because it is accessed from multiple tasks, and the
\r
283 button interrupt - in this trivial case, for simplicity, the critical
\r
284 section is omitted. */
\r
285 ucGPIOState &= ~mainTIMER_CONTROLLED_LED;
\r
286 XGpio_DiscreteWrite( &xOutputGPIOInstance, ulGPIOOutputChannel, ucGPIOState );
\r
288 /*-----------------------------------------------------------*/
\r
290 /* The ISR is executed when the user button is pushed. */
\r
291 static void prvButtonInputInterruptHandler( void *pvUnused )
\r
293 long lHigherPriorityTaskWoken = pdFALSE;
\r
295 /* The button was pushed, so ensure the LED is on before resetting the
\r
296 LED timer. The LED timer will turn the LED off if the button is not
\r
297 pushed within 5000ms. */
\r
298 ucGPIOState |= mainTIMER_CONTROLLED_LED;
\r
299 XGpio_DiscreteWrite( &xOutputGPIOInstance, ulGPIOOutputChannel, ucGPIOState );
\r
301 /* Ensure only the ISR safe reset API function is used, as this is executed
\r
302 in an interrupt context. */
\r
303 xTimerResetFromISR( xLEDTimer, &lHigherPriorityTaskWoken );
\r
305 /* Clear the interrupt before leaving. */
\r
306 XGpio_InterruptClear( &xInputGPIOInstance, ulGPIOInputChannel );
\r
308 /* If calling xTimerResetFromISR() caused a task (in this case the timer
\r
309 service/daemon task) to unblock, and the unblocked task has a priority
\r
310 higher than or equal to the task that was interrupted, then
\r
311 lHigherPriorityTaskWoken will now be set to pdTRUE, and calling
\r
312 portEND_SWITCHING_ISR() will ensure the unblocked task runs next. */
\r
313 portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
\r
315 /*-----------------------------------------------------------*/
\r
317 static void prvQueueSendTask( void *pvParameters )
\r
319 TickType_t xNextWakeTime;
\r
320 const unsigned long ulValueToSend = 100UL;
\r
322 /* Initialise xNextWakeTime - this only needs to be done once. */
\r
323 xNextWakeTime = xTaskGetTickCount();
\r
327 /* Place this task in the blocked state until it is time to run again.
\r
328 The block time is specified in ticks, the constant used converts ticks
\r
329 to ms. While in the Blocked state this task will not consume any CPU
\r
331 vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
\r
333 /* Send to the queue - causing the queue receive task to unblock and
\r
334 toggle an LED. 0 is used as the block time so the sending operation
\r
335 will not block - it shouldn't need to block as the queue should always
\r
336 be empty at this point in the code. */
\r
337 xQueueSend( xQueue, &ulValueToSend, mainDONT_BLOCK );
\r
340 /*-----------------------------------------------------------*/
\r
342 static void prvQueueReceiveTask( void *pvParameters )
\r
344 unsigned long ulReceivedValue;
\r
348 /* Wait until something arrives in the queue - this task will block
\r
349 indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
\r
350 FreeRTOSConfig.h. */
\r
351 xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
\r
353 /* To get here something must have been received from the queue, but
\r
354 is it the expected value? If it is, toggle the green LED. */
\r
355 if( ulReceivedValue == 100UL )
\r
357 /* NOTE - accessing the LED port should use a critical section
\r
358 because it is accessed from multiple tasks, and the button interrupt
\r
359 - in this trivial case, for simplicity, the critical section is
\r
361 if( ( ucGPIOState & mainTASK_CONTROLLED_LED ) != 0 )
\r
363 ucGPIOState &= ~mainTASK_CONTROLLED_LED;
\r
367 ucGPIOState |= mainTASK_CONTROLLED_LED;
\r
370 XGpio_DiscreteWrite( &xOutputGPIOInstance, ulGPIOOutputChannel, ucGPIOState );
\r
374 /*-----------------------------------------------------------*/
\r
376 static void prvSetupHardware( void )
\r
378 portBASE_TYPE xStatus;
\r
379 const unsigned char ucSetToOutput = 0U;
\r
381 /* Initialize the GPIO for the LEDs. */
\r
382 xStatus = XGpio_Initialize( &xOutputGPIOInstance, XPAR_LEDS_4BITS_DEVICE_ID );
\r
383 if( xStatus == XST_SUCCESS )
\r
385 /* All bits on this channel are going to be outputs (LEDs). */
\r
386 XGpio_SetDataDirection( &xOutputGPIOInstance, ulGPIOOutputChannel, ucSetToOutput );
\r
388 /* Start with all LEDs off. */
\r
390 XGpio_DiscreteWrite( &xOutputGPIOInstance, ulGPIOOutputChannel, ucGPIOState );
\r
393 /* Initialise the GPIO for the button inputs. */
\r
394 if( xStatus == XST_SUCCESS )
\r
396 xStatus = XGpio_Initialize( &xInputGPIOInstance, XPAR_PUSH_BUTTONS_4BITS_DEVICE_ID );
\r
399 if( xStatus == XST_SUCCESS )
\r
401 /* Install the handler defined in this task for the button input.
\r
402 *NOTE* The FreeRTOS defined xPortInstallInterruptHandler() API function
\r
403 must be used for this purpose. */
\r
404 xStatus = xPortInstallInterruptHandler( XPAR_MICROBLAZE_0_INTC_PUSH_BUTTONS_4BITS_IP2INTC_IRPT_INTR, prvButtonInputInterruptHandler, NULL );
\r
406 if( xStatus == pdPASS )
\r
408 /* Set buttons to input. */
\r
409 XGpio_SetDataDirection( &xInputGPIOInstance, ulGPIOInputChannel, ~( ucSetToOutput ) );
\r
411 /* Enable the button input interrupts in the interrupt controller.
\r
412 *NOTE* The vPortEnableInterrupt() API function must be used for this
\r
414 vPortEnableInterrupt( XPAR_MICROBLAZE_0_INTC_PUSH_BUTTONS_4BITS_IP2INTC_IRPT_INTR );
\r
416 /* Enable GPIO channel interrupts. */
\r
417 XGpio_InterruptEnable( &xInputGPIOInstance, ulGPIOInputChannel );
\r
418 XGpio_InterruptGlobalEnable( &xInputGPIOInstance );
\r
422 configASSERT( ( xStatus == pdPASS ) );
\r
424 /*-----------------------------------------------------------*/
\r
426 void vApplicationMallocFailedHook( void )
\r
428 /* vApplicationMallocFailedHook() will only be called if
\r
429 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
430 function that will get called if a call to pvPortMalloc() fails.
\r
431 pvPortMalloc() is called internally by the kernel whenever a task, queue or
\r
432 semaphore is created. It is also called by various parts of the demo
\r
433 application. If heap_1.c or heap_2.c are used, then the size of the heap
\r
434 available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
\r
435 FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
\r
436 to query the size of free heap space that remains (although it does not
\r
437 provide information on how the remaining heap might be fragmented). */
\r
438 taskDISABLE_INTERRUPTS();
\r
441 /*-----------------------------------------------------------*/
\r
443 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
\r
445 ( void ) pcTaskName;
\r
448 /* vApplicationStackOverflowHook() will only be called if
\r
449 configCHECK_FOR_STACK_OVERFLOW is set to either 1 or 2. The handle and name
\r
450 of the offending task will be passed into the hook function via its
\r
451 parameters. However, when a stack has overflowed, it is possible that the
\r
452 parameters will have been corrupted, in which case the pxCurrentTCB variable
\r
453 can be inspected directly. */
\r
454 taskDISABLE_INTERRUPTS();
\r
457 /*-----------------------------------------------------------*/
\r
459 void vApplicationIdleHook( void )
\r
461 #ifdef EXAMPLE_CODE_ONLY
\r
463 The following code can only be included if heap_1.c or heap_2.c is used in
\r
464 the project. By default, heap_3.c is used, so the example code is
\r
465 excluded. See http://www.freertos.org/a00111.html for more information on
\r
466 memory management options.
\r
468 volatile size_t xFreeHeapSpace;
\r
470 /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
\r
471 to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
\r
472 task. It is essential that code added to this hook function never attempts
\r
473 to block in any way (for example, call xQueueReceive() with a block time
\r
474 specified, or call vTaskDelay()). If the application makes use of the
\r
475 vTaskDelete() API function (as this demo application does) then it is also
\r
476 important that vApplicationIdleHook() is permitted to return to its calling
\r
477 function, because it is the responsibility of the idle task to clean up
\r
478 memory allocated by the kernel to any task that has since been deleted. */
\r
480 /* This implementation of vApplicationIdleHook() simply demonstrates how
\r
481 the xPortGetFreeHeapSize() function can be used. */
\r
482 xFreeHeapSpace = xPortGetFreeHeapSize();
\r
484 if( xFreeHeapSpace > 100 )
\r
486 /* By now, the kernel has allocated everything it is going to, so
\r
487 if there is a lot of heap remaining unallocated then
\r
488 the value of configTOTAL_HEAP_SIZE in FreeRTOSConfig.h can be
\r
489 reduced accordingly. */
\r
493 /*-----------------------------------------------------------*/
\r
495 /* This is an application defined callback function used to install the tick
\r
496 interrupt handler. It is provided as an application callback because the kernel
\r
497 will run on lots of different MicroBlaze and FPGA configurations - not all of
\r
498 which will have the same timer peripherals defined or available. This example
\r
499 uses the AXI Timer 0. If that is available on your hardware platform then this
\r
500 example callback implementation should not require modification. The name of
\r
501 the interrupt handler that should be installed is vPortTickISR(), which the
\r
502 function below declares as an extern. */
\r
503 void vApplicationSetupTimerInterrupt( void )
\r
505 portBASE_TYPE xStatus;
\r
506 const unsigned char ucTimerCounterNumber = ( unsigned char ) 0U;
\r
507 const unsigned long ulCounterValue = ( ( XPAR_AXI_TIMER_0_CLOCK_FREQ_HZ / configTICK_RATE_HZ ) - 1UL );
\r
508 extern void vPortTickISR( void *pvUnused );
\r
510 /* Initialise the timer/counter. */
\r
511 xStatus = XTmrCtr_Initialize( &xTimer0Instance, XPAR_AXI_TIMER_0_DEVICE_ID );
\r
513 if( xStatus == XST_SUCCESS )
\r
515 /* Install the tick interrupt handler as the timer ISR.
\r
516 *NOTE* The xPortInstallInterruptHandler() API function must be used for
\r
518 xStatus = xPortInstallInterruptHandler( XPAR_INTC_0_TMRCTR_0_VEC_ID, vPortTickISR, NULL );
\r
521 if( xStatus == pdPASS )
\r
523 /* Enable the timer interrupt in the interrupt controller.
\r
524 *NOTE* The vPortEnableInterrupt() API function must be used for this
\r
526 vPortEnableInterrupt( XPAR_INTC_0_TMRCTR_0_VEC_ID );
\r
528 /* Configure the timer interrupt handler. */
\r
529 XTmrCtr_SetHandler( &xTimer0Instance, ( void * ) vPortTickISR, NULL );
\r
531 /* Set the correct period for the timer. */
\r
532 XTmrCtr_SetResetValue( &xTimer0Instance, ucTimerCounterNumber, ulCounterValue );
\r
534 /* Enable the interrupts. Auto-reload mode is used to generate a
\r
535 periodic tick. Note that interrupts are disabled when this function is
\r
536 called, so interrupts will not start to be processed until the first
\r
537 task has started to run. */
\r
538 XTmrCtr_SetOptions( &xTimer0Instance, ucTimerCounterNumber, ( XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_DOWN_COUNT_OPTION ) );
\r
540 /* Start the timer. */
\r
541 XTmrCtr_Start( &xTimer0Instance, ucTimerCounterNumber );
\r
544 /* Sanity check that the function executed as expected. */
\r
545 configASSERT( ( xStatus == pdPASS ) );
\r
547 /*-----------------------------------------------------------*/
\r
549 /* This is an application defined callback function used to clear whichever
\r
550 interrupt was installed by the the vApplicationSetupTimerInterrupt() callback
\r
551 function - in this case the interrupt generated by the AXI timer. It is
\r
552 provided as an application callback because the kernel will run on lots of
\r
553 different MicroBlaze and FPGA configurations - not all of which will have the
\r
554 same timer peripherals defined or available. This example uses the AXI Timer 0.
\r
555 If that is available on your hardware platform then this example callback
\r
556 implementation should not require modification provided the example definition
\r
557 of vApplicationSetupTimerInterrupt() is also not modified. */
\r
558 void vApplicationClearTimerInterrupt( void )
\r
560 unsigned long ulCSR;
\r
562 /* Clear the timer interrupt */
\r
563 ulCSR = XTmrCtr_GetControlStatusReg( XPAR_AXI_TIMER_0_BASEADDR, 0 );
\r
564 XTmrCtr_SetControlStatusReg( XPAR_AXI_TIMER_0_BASEADDR, 0, ulCSR );
\r
566 /*-----------------------------------------------------------*/
\r
568 /* These functions are not used by the Blinky build configuration. However,
\r
569 they need to be defined because the Blinky and Full build configurations share
\r
570 a FreeRTOSConifg.h configuration file. */
\r
571 void vMainConfigureTimerForRunTimeStats( void ) {}
\r
572 unsigned long ulMainGetRunTimeCounterValue( void ) { return 1; }
\r