2 FreeRTOS V7.0.0 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
5 FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by:
\r
6 Atollic AB - Atollic provides professional embedded systems development
\r
7 tools for C/C++ development, code analysis and test automation.
\r
8 See http://www.atollic.com
\r
11 ***************************************************************************
\r
13 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
14 * Complete, revised, and edited pdf reference manuals are also *
\r
17 * Purchasing FreeRTOS documentation will not only help you, by *
\r
18 * ensuring you get running as quickly as possible and with an *
\r
19 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
20 * the FreeRTOS project to continue with its mission of providing *
\r
21 * professional grade, cross platform, de facto standard solutions *
\r
22 * for microcontrollers - completely free of charge! *
\r
24 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
26 * Thank you for using FreeRTOS, and thank you for your support! *
\r
28 ***************************************************************************
\r
31 This file is part of the FreeRTOS distribution.
\r
33 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
34 the terms of the GNU General Public License (version 2) as published by the
\r
35 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
36 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
37 distribute a combined work that includes FreeRTOS without being obliged to
\r
38 provide the source code for proprietary components outside of the FreeRTOS
\r
39 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
40 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
41 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
42 more details. You should have received a copy of the GNU General Public
\r
43 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
44 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
45 by writing to Richard Barry, contact details for whom are available on the
\r
50 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
53 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
56 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
57 licensing and training services.
\r
61 * main-blinky.c is included when the "Blinky" build configuration is used.
\r
62 * main-full.c is included when the "Full" build configuration is used.
\r
64 * main-full.c (this file) defines a comprehensive demo that creates many
\r
65 * tasks, queues, semaphores and timers. It also demonstrates how Cortex-M3
\r
66 * interrupts can interact with FreeRTOS tasks/timers, and implements a simple
\r
67 * and small interactive web server.
\r
69 * This project runs on the SmartFusion A2F-EVAL-KIT evaluation board, which
\r
70 * is populated with an A2F200M3F SmartFusion mixed signal FPGA. The A2F200M3F
\r
71 * incorporates a Cortex-M3 microcontroller.
\r
73 * The main() Function:
\r
74 * main() creates three demo specific software timers, one demo specific queue,
\r
75 * and two demo specific tasks. It then creates a whole host of 'standard demo'
\r
76 * tasks/queues/semaphores, before starting the scheduler. The demo specific
\r
77 * tasks and timers are described in the comments here. The standard demo
\r
78 * tasks are described on the FreeRTOS.org web site.
\r
80 * The standard demo tasks provide no specific functionality. They are
\r
81 * included to both test the FreeRTOS port, and provide examples of how the
\r
82 * various FreeRTOS API functions can be used.
\r
84 * The Demo Specific Queue Send Task:
\r
85 * The queue send task is implemented by the prvQueueSendTask() function in
\r
86 * this file. prvQueueSendTask() sits in a loop that causes it to repeatedly
\r
87 * block for 200 milliseconds, before sending the value 100 to the queue that
\r
88 * was created within main(). Once the value is sent, the task loops back
\r
89 * around to block for another 200 milliseconds.
\r
91 * The Demo Specific Queue Receive Task:
\r
92 * The queue receive task is implemented by the prvQueueReceiveTask() function
\r
93 * in this file. prvQueueReceiveTask() sits in a loop that causes it to
\r
94 * repeatedly attempt to read data from the queue that was created within
\r
95 * main(). When data is received, the task checks the value of the data, and
\r
96 * if the value equals the expected 100, toggles the green LED. The 'block
\r
97 * time' parameter passed to the queue receive function specifies that the task
\r
98 * should be held in the Blocked state indefinitely to wait for data to be
\r
99 * available on the queue. The queue receive task will only leave the Blocked
\r
100 * state when the queue send task writes to the queue. As the queue send task
\r
101 * writes to the queue every 200 milliseconds, the queue receive task leaves
\r
102 * the Blocked state every 200 milliseconds, and therefore toggles the LED
\r
103 * every 200 milliseconds.
\r
105 * The Demo Specific LED Software Timer and the Button Interrupt:
\r
106 * The user button SW1 is configured to generate an interrupt each time it is
\r
107 * pressed. The interrupt service routine switches an LED on, and resets the
\r
108 * LED software timer. The LED timer has a 5000 millisecond (5 second) period,
\r
109 * and uses a callback function that is defined to just turn the LED off again.
\r
110 * Therefore, pressing the user button will turn the LED on, and the LED will
\r
111 * remain on until a full five seconds pass without the button being pressed.
\r
113 * The Demo Specific OLED Software Timer:
\r
114 * The OLED software timer is responsible for drawing a scrolling text message
\r
117 * The Demo Specific "Check" Callback Function:
\r
118 * This is called each time the 'check' timer expires. The check timer
\r
119 * callback function inspects all the standard demo tasks to see if they are
\r
120 * all executing as expected. The check timer is initially configured to
\r
121 * expire every three seconds, but will shorted this to every 500ms if an error
\r
122 * is ever discovered. The check timer callback toggles the LED defined by
\r
123 * the mainCHECK_LED definition each time it executes. Therefore, if LED
\r
124 * mainCHECK_LED is toggling every three seconds, then no error have been found.
\r
125 * If LED mainCHECK_LED is toggling every 500ms, then at least one error has
\r
126 * been found. The task in which the error was discovered is displayed at the
\r
127 * bottom of the "task stats" page that is served by the embedded web server.
\r
129 * The Demo Specific Idle Hook Function:
\r
130 * The idle hook function demonstrates how to query the amount of FreeRTOS heap
\r
131 * space that is remaining (see vApplicationIdleHook() defined in this file).
\r
133 * The Web Server Task:
\r
134 * The IP address used by the SmartFusion target is configured by the
\r
135 * definitions configIP_ADDR0 to configIP_ADDR3, which are located in the
\r
136 * FreeRTOSConfig.h header file. See the documentation page for this example
\r
137 * on the http://www.FreeRTOS.org web site for further connection information.
\r
140 /* Kernel includes. */
\r
141 #include "FreeRTOS.h"
\r
144 #include "timers.h"
\r
146 /* Microsemi drivers/libraries includes. */
\r
147 #include "mss_gpio.h"
\r
148 #include "mss_watchdog.h"
\r
151 /* Common demo includes. */
\r
152 #include "partest.h"
\r
154 #include "BlockQ.h"
\r
156 #include "blocktim.h"
\r
157 #include "semtest.h"
\r
158 #include "GenQTest.h"
\r
160 #include "recmutex.h"
\r
161 #include "TimerDemo.h"
\r
163 /* Priorities at which the tasks are created. */
\r
164 #define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
165 #define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
167 /* The rate at which data is sent to the queue, specified in milliseconds, and
\r
168 converted to ticks using the portTICK_RATE_MS constant. */
\r
169 #define mainQUEUE_SEND_FREQUENCY_MS ( 200 / portTICK_RATE_MS )
\r
171 /* The number of items the queue can hold. This is 1 as the receive task
\r
172 will remove items as they are added, meaning the send task should always find
\r
173 the queue empty. */
\r
174 #define mainQUEUE_LENGTH ( 1 )
\r
176 /* The LED toggled by the check timer callback function. */
\r
177 #define mainCHECK_LED 0x07UL
\r
179 /* The LED turned on by the button interrupt, and turned off by the LED timer. */
\r
180 #define mainTIMER_CONTROLLED_LED 0x06UL
\r
182 /* The LED toggle by the queue receive task. */
\r
183 #define mainTASK_CONTROLLED_LED 0x05UL
\r
185 /* Constant used by the standard timer test functions. */
\r
186 #define mainTIMER_TEST_PERIOD ( 50 )
\r
188 /* Priorities used by the various different tasks. */
\r
189 #define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
\r
190 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
191 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
192 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
193 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
194 #define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
195 #define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
196 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
197 #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
199 /* The WEB server uses string handling functions, which in turn use a bit more
\r
200 stack than most of the other tasks. */
\r
201 #define mainuIP_STACK_SIZE ( configMINIMAL_STACK_SIZE * 3 )
\r
203 /* The period at which the check timer will expire, in ms, provided no errors
\r
204 have been reported by any of the standard demo tasks. */
\r
205 #define mainCHECK_TIMER_PERIOD_ms ( 3000UL )
\r
207 /* The period at which the OLED timer will expire. Each time it expires, it's
\r
208 callback function updates the OLED text. */
\r
209 #define mainOLED_PERIOD_ms ( 75UL )
\r
211 /* The period at which the check timer will expire, in ms, if an error has been
\r
212 reported in one of the standard demo tasks. */
\r
213 #define mainERROR_CHECK_TIMER_PERIOD_ms ( 500UL )
\r
215 /* A zero block time. */
\r
216 #define mainDONT_BLOCK ( 0UL )
\r
217 /*-----------------------------------------------------------*/
\r
220 * Setup the NVIC, LED outputs, and button inputs.
\r
222 static void prvSetupHardware( void );
\r
225 * The tasks as described in the comments at the top of this file.
\r
227 static void prvQueueReceiveTask( void *pvParameters );
\r
228 static void prvQueueSendTask( void *pvParameters );
\r
231 * The LED timer callback function. This does nothing but switch the red LED
\r
234 static void vLEDTimerCallback( xTimerHandle xTimer );
\r
237 * The check timer callback function, as described at the top of this file.
\r
239 static void vCheckTimerCallback( xTimerHandle xTimer );
\r
242 * The OLED timer callback function, as described at the top of this file.
\r
244 static void vOLEDTimerCallback( xTimerHandle xHandle );
\r
247 * This is not a 'standard' partest function, so the prototype is not in
\r
248 * partest.h, and is instead included here.
\r
250 void vParTestSetLEDFromISR( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue );
\r
253 * Contains the implementation of the WEB server.
\r
255 extern void vuIP_Task( void *pvParameters );
\r
257 /*-----------------------------------------------------------*/
\r
259 /* The queue used by both application specific demo tasks defined in this file. */
\r
260 static xQueueHandle xQueue = NULL;
\r
262 /* The LED software timer. This uses vLEDTimerCallback() as it's callback
\r
264 static xTimerHandle xLEDTimer = NULL;
\r
266 /* The check timer. This uses vCheckTimerCallback() as it's callback
\r
268 static xTimerHandle xCheckTimer = NULL;
\r
270 /* The OLED software timer. Writes a moving text string to the OLED. */
\r
271 static xTimerHandle xOLEDTimer = NULL;
\r
273 /* The status message that is displayed at the bottom of the "task stats" web
\r
274 page, which is served by the uIP task. This will report any errors picked up
\r
275 by the check timer callback. */
\r
276 static const char *pcStatusMessage = NULL;
\r
278 /*-----------------------------------------------------------*/
\r
282 /* Configure the NVIC, LED outputs and button inputs. */
\r
283 prvSetupHardware();
\r
285 /* Create the queue. */
\r
286 xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
\r
288 if( xQueue != NULL )
\r
290 /* Start the two application specific demo tasks, as described in the
\r
291 comments at the top of this file. */
\r
292 xTaskCreate( prvQueueReceiveTask, ( signed char * ) "Rx", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_RECEIVE_TASK_PRIORITY, NULL );
\r
293 xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL );
\r
295 /* Create the software timer that is responsible for turning off the LED
\r
296 if the button is not pushed within 5000ms, as described at the top of
\r
298 xLEDTimer = xTimerCreate( ( const signed char * ) "LEDTimer", /* A text name, purely to help debugging. */
\r
299 ( 5000 / portTICK_RATE_MS ), /* The timer period, in this case 5000ms (5s). */
\r
300 pdFALSE, /* This is a one shot timer, so xAutoReload is set to pdFALSE. */
\r
301 ( void * ) 0, /* The ID is not used, so can be set to anything. */
\r
302 vLEDTimerCallback /* The callback function that switches the LED off. */
\r
305 /* Create the software timer that performs the 'check' functionality,
\r
306 as described at the top of this file. */
\r
307 xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer", /* A text name, purely to help debugging. */
\r
308 ( mainCHECK_TIMER_PERIOD_ms / portTICK_RATE_MS ),/* The timer period, in this case 3000ms (3s). */
\r
309 pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
\r
310 ( void * ) 0, /* The ID is not used, so can be set to anything. */
\r
311 vCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */
\r
314 /* Create the OLED timer as described at the top of this file. */
\r
315 xOLEDTimer = xTimerCreate( ( const signed char * ) "OLEDTimer", ( mainOLED_PERIOD_ms / portTICK_RATE_MS ), pdTRUE, ( void * ) 0, vOLEDTimerCallback );
\r
317 /* Create a lot of 'standard demo' tasks. */
\r
318 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
319 vCreateBlockTimeTasks();
\r
320 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
321 vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
\r
322 vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
\r
323 vStartQueuePeekTasks();
\r
324 vStartRecursiveMutexTasks();
\r
325 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
\r
327 /* Create the web server task. */
\r
328 xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );
\r
330 /* The suicide tasks must be created last, as they need to know how many
\r
331 tasks were running prior to their creation in order to ascertain whether
\r
332 or not the correct/expected number of tasks are running at any given
\r
334 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
336 /* Start the tasks and timer running. */
\r
337 vTaskStartScheduler();
\r
340 /* If all is well, the scheduler will now be running, and the following line
\r
341 will never be reached. If the following line does execute, then there was
\r
342 insufficient FreeRTOS heap memory available for the idle and/or timer tasks
\r
343 to be created. See the memory management section on the FreeRTOS web site
\r
344 for more details. */
\r
347 /*-----------------------------------------------------------*/
\r
349 static void vCheckTimerCallback( xTimerHandle xTimer )
\r
351 /* Check the standard demo tasks are running without error. Latch the
\r
352 latest reported error in the pcStatusMessage character pointer. */
\r
353 if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
355 pcStatusMessage = "Error: GenQueue";
\r
358 if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
360 pcStatusMessage = "Error: QueuePeek\r\n";
\r
363 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
365 pcStatusMessage = "Error: BlockQueue\r\n";
\r
368 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
370 pcStatusMessage = "Error: BlockTime\r\n";
\r
373 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
375 pcStatusMessage = "Error: SemTest\r\n";
\r
378 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
380 pcStatusMessage = "Error: Death\r\n";
\r
383 if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
385 pcStatusMessage = "Error: RecMutex\r\n";
\r
388 if( xAreTimerDemoTasksStillRunning( ( mainCHECK_TIMER_PERIOD_ms / portTICK_RATE_MS ) ) != pdTRUE )
\r
390 pcStatusMessage = "Error: TimerDemo";
\r
393 /* Toggle the check LED to give an indication of the system status. If
\r
394 the LED toggles every mainCHECK_TIMER_PERIOD_ms milliseconds then
\r
395 everything is ok. A faster toggle indicates an error. */
\r
396 vParTestToggleLED( mainCHECK_LED );
\r
398 /* Have any errors been latch in pcStatusMessage? If so, shorten the
\r
399 period of the check timer to mainERROR_CHECK_TIMER_PERIOD_ms milliseconds.
\r
400 This will result in an increase in the rate at which mainCHECK_LED
\r
402 if( pcStatusMessage != NULL )
\r
404 /* This call to xTimerChangePeriod() uses a zero block time. Functions
\r
405 called from inside of a timer callback function must *never* attempt
\r
407 xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_ms / portTICK_RATE_MS ), mainDONT_BLOCK );
\r
410 /*-----------------------------------------------------------*/
\r
412 static void vLEDTimerCallback( xTimerHandle xTimer )
\r
414 /* The timer has expired - so no button pushes have occurred in the last
\r
415 five seconds - turn the LED off. */
\r
416 vParTestSetLED( mainTIMER_CONTROLLED_LED, pdFALSE );
\r
418 /*-----------------------------------------------------------*/
\r
420 /* The ISR executed when the user button is pushed. */
\r
421 void GPIO8_IRQHandler( void )
\r
423 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
\r
425 /* The button was pushed, so ensure the LED is on before resetting the
\r
426 LED timer. The LED timer will turn the LED off if the button is not
\r
427 pushed within 5000ms. */
\r
428 vParTestSetLEDFromISR( mainTIMER_CONTROLLED_LED, pdTRUE );
\r
430 /* This interrupt safe FreeRTOS function can be called from this interrupt
\r
431 because the interrupt priority is below the
\r
432 configMAX_SYSCALL_INTERRUPT_PRIORITY setting in FreeRTOSConfig.h. */
\r
433 xTimerResetFromISR( xLEDTimer, &xHigherPriorityTaskWoken );
\r
435 /* Clear the interrupt before leaving. */
\r
436 MSS_GPIO_clear_irq( MSS_GPIO_8 );
\r
438 /* If calling xTimerResetFromISR() caused a task (in this case the timer
\r
439 service/daemon task) to unblock, and the unblocked task has a priority
\r
440 higher than or equal to the task that was interrupted, then
\r
441 xHigherPriorityTaskWoken will now be set to pdTRUE, and calling
\r
442 portEND_SWITCHING_ISR() will ensure the unblocked task runs next. */
\r
443 portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
\r
445 /*-----------------------------------------------------------*/
\r
447 static void prvQueueSendTask( void *pvParameters )
\r
449 portTickType xNextWakeTime;
\r
450 const unsigned long ulValueToSend = 100UL;
\r
452 /* The timer command queue will have been filled when the timer test tasks
\r
453 were created in main() (this is part of the test they perform). Therefore,
\r
454 while the check and OLED timers can be created in main(), they cannot be
\r
455 started from main(). Once the scheduler has started, the timer service
\r
456 task will drain the command queue, and now the check and OLED timers can be
\r
457 started successfully. */
\r
458 xTimerStart( xCheckTimer, portMAX_DELAY );
\r
459 xTimerStart( xOLEDTimer, portMAX_DELAY );
\r
461 /* Initialise xNextWakeTime - this only needs to be done once. */
\r
462 xNextWakeTime = xTaskGetTickCount();
\r
466 /* Place this task in the blocked state until it is time to run again.
\r
467 The block time is specified in ticks, the constant used converts ticks
\r
468 to ms. While in the Blocked state this task will not consume any CPU
\r
470 vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
\r
472 /* Send to the queue - causing the queue receive task to unblock and
\r
473 toggle an LED. 0 is used as the block time so the sending operation
\r
474 will not block - it shouldn't need to block as the queue should always
\r
475 be empty at this point in the code. */
\r
476 xQueueSend( xQueue, &ulValueToSend, 0 );
\r
479 /*-----------------------------------------------------------*/
\r
481 static void prvQueueReceiveTask( void *pvParameters )
\r
483 unsigned long ulReceivedValue;
\r
487 /* Wait until something arrives in the queue - this task will block
\r
488 indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
\r
489 FreeRTOSConfig.h. */
\r
490 xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
\r
492 /* To get here something must have been received from the queue, but
\r
493 is it the expected value? If it is, toggle the LED. */
\r
494 if( ulReceivedValue == 100UL )
\r
496 vParTestToggleLED( mainTASK_CONTROLLED_LED );
\r
500 /*-----------------------------------------------------------*/
\r
502 static void vOLEDTimerCallback( xTimerHandle xHandle )
\r
504 static struct oled_data xOLEDData;
\r
505 static unsigned char ucOffset1 = 0, ucOffset2 = 5;
\r
507 xOLEDData.line1 = FIRST_LINE;
\r
508 xOLEDData.char_offset1 = ucOffset1++;
\r
509 xOLEDData.string1 = " www.FreeRTOS.org";
\r
511 xOLEDData.line2 = SECOND_LINE;
\r
512 xOLEDData.char_offset2 = ucOffset2++;
\r
513 xOLEDData.string2 = " www.FreeRTOS.org";
\r
515 xOLEDData.contrast_val = OLED_CONTRAST_VAL;
\r
516 xOLEDData.on_off = OLED_HORIZ_SCROLL_OFF;
\r
517 xOLEDData.column_scrool_per_step = OLED_HORIZ_SCROLL_STEP;
\r
518 xOLEDData.start_page = OLED_START_PAGE;
\r
519 xOLEDData.time_intrval_btw_scroll_step = OLED_HORIZ_SCROLL_TINVL;
\r
520 xOLEDData.end_page = OLED_END_PAGE;
\r
522 OLED_write_data( &xOLEDData, BOTH_LINES );
\r
524 /*-----------------------------------------------------------*/
\r
526 static void prvSetupHardware( void )
\r
528 SystemCoreClockUpdate();
\r
530 /* Disable the Watch Dog Timer */
\r
533 /* Configure the GPIO for the LEDs. */
\r
534 vParTestInitialise();
\r
536 /* Initialise the display. */
\r
539 /* Setup the GPIO and the NVIC for the switch used in this simple demo. */
\r
540 NVIC_SetPriority( GPIO8_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
\r
541 NVIC_EnableIRQ( GPIO8_IRQn );
\r
542 MSS_GPIO_config( MSS_GPIO_8, MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_NEGATIVE );
\r
543 MSS_GPIO_enable_irq( MSS_GPIO_8 );
\r
545 /*-----------------------------------------------------------*/
\r
547 void vApplicationMallocFailedHook( void )
\r
549 /* Called if a call to pvPortMalloc() fails because there is insufficient
\r
550 free memory available in the FreeRTOS heap. pvPortMalloc() is called
\r
551 internally by FreeRTOS API functions that create tasks, queues, software
\r
552 timers, and semaphores. The size of the FreeRTOS heap is set by the
\r
553 configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
\r
556 /*-----------------------------------------------------------*/
\r
558 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
\r
560 ( void ) pcTaskName;
\r
563 /* Run time stack overflow checking is performed if
\r
564 configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
\r
565 function is called if a stack overflow is detected. */
\r
566 taskDISABLE_INTERRUPTS();
\r
569 /*-----------------------------------------------------------*/
\r
571 void vApplicationIdleHook( void )
\r
573 volatile size_t xFreeStackSpace;
\r
575 /* This function is called on each cycle of the idle task. In this case it
\r
576 does nothing useful, other than report the amount of FreeRTOS heap that
\r
577 remains unallocated. */
\r
578 xFreeStackSpace = xPortGetFreeHeapSize();
\r
580 if( xFreeStackSpace > 100 )
\r
582 /* By now, the kernel has allocated everything it is going to, so
\r
583 if there is a lot of heap remaining unallocated then
\r
584 the value of configTOTAL_HEAP_SIZE in FreeRTOSConfig.h can be
\r
585 reduced accordingly. */
\r
588 /*-----------------------------------------------------------*/
\r
590 char *pcGetTaskStatusMessage( void )
\r
592 /* Not bothered about a critical section here although technically because
\r
593 of the task priorities the pointer could change it will be atomic if not
\r
594 near atomic and its not critical. */
\r
595 if( pcStatusMessage == NULL )
\r
597 return "All tasks running without error";
\r
601 return ( char * ) pcStatusMessage;
\r
604 /*-----------------------------------------------------------*/
\r