-/*
- FreeRTOS V6.0.4 - Copyright (C) 2010 Real Time Engineers Ltd.
-
- ***************************************************************************
- * *
- * If you are: *
- * *
- * + New to FreeRTOS, *
- * + Wanting to learn FreeRTOS or multitasking in general quickly *
- * + Looking for basic training, *
- * + Wanting to improve your FreeRTOS skills and productivity *
- * *
- * then take a look at the FreeRTOS eBook *
- * *
- * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
- * http://www.FreeRTOS.org/Documentation *
- * *
- * A pdf reference manual is also available. Both are usually delivered *
- * to your inbox within 20 minutes to two hours when purchased between 8am *
- * and 8pm GMT (although please allow up to 24 hours in case of *
- * exceptional circumstances). Thank you for your support! *
- * *
- ***************************************************************************
-
- This file is part of the FreeRTOS distribution.
-
- FreeRTOS is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License (version 2) as published by the
- Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
- ***NOTE*** The exception to the GPL is included to allow you to distribute
- a combined work that includes FreeRTOS without being obliged to provide the
- source code for proprietary components outside of the FreeRTOS kernel.
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details. You should have received a copy of the GNU General Public
- License and the FreeRTOS license exception along with FreeRTOS; if not it
- can be viewed here: http://www.freertos.org/a00114.html and also obtained
- by writing to Richard Barry, contact details for whom are available on the
- FreeRTOS WEB site.
-
- 1 tab == 4 spaces!
-
- http://www.FreeRTOS.org - Documentation, latest information, license and
- contact details.
-
- http://www.SafeRTOS.com - A version that is certified for use in safety
- critical systems.
-
- http://www.OpenRTOS.com - Commercial support, development, porting,
- licensing and training services.
-*/
-
-/*
- * Creates all the demo application tasks, then starts the scheduler.
- *
- * Main.c also creates a task called "Check". This only executes every three
- * seconds but has the highest priority so is guaranteed to get processor time.
- * Its main function is to check that all the other tasks are still operational.
- * Each task (other than the "flash" tasks) maintains a unique count that is
- * incremented each time the task successfully completes its function. Should
- * any error occur within such a task the count is permanently halted. The
- * check task inspects the count of each task to ensure it has changed since
- * the last time the check task executed. If all the count variables have
- * changed all the tasks are still executing error free, and the check task
- * toggles the on board LED. Should any task contain an error at any time
- * the LED toggle rate will change from 3 seconds to 500ms.
- *
- * NOTE: The demo application includes tasks that send and receive characters
- * over the UART. The characters sent by one task are received by another -
- * with an error condition being flagged should any characters be missed or
- * received out of order. A loopback connector is required on the 9way D socket
- * for this mechanism to operation (pins 2 and 3 the socket should be connected
- * together - a paper clip is normally sufficient).
- *
- */
-
-/* Standard includes. */
-#include <stdlib.h>
-#include <string.h>
-
-/* Scheduler includes. */
-#include "FreeRTOS.h"
-#include "task.h"
-
-/* Demo application includes. */
-#include "partest.h"
-#include "flash.h"
-#include "integer.h"
-#include "PollQ.h"
-#include "comtest2.h"
-#include "semtest.h"
-#include "flop.h"
-#include "dynamic.h"
-#include "BlockQ.h"
-#include "serial.h"
-#include "demoGpio.h"
-#include "7seg.h"
-
-/*-----------------------------------------------------------*/
-
-/* Constants for the ComTest tasks. */
-#define mainCOM_TEST_BAUD_RATE ( ( unsigned long ) 115200 )
-#define mainCOM_TEST_LED ( 5 )
-
-/* Priorities for the demo application tasks. */
-#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
-#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
-#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
-#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
-#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
-#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
-#define main7SEG_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
-
-/* The rate at which the on board LED will toggle when there is/is not an
-error. */
-#define mainNO_ERROR_FLASH_PERIOD ( ( portTickType ) 3000 / portTICK_RATE_MS )
-#define mainERROR_FLASH_PERIOD ( ( portTickType ) 500 / portTICK_RATE_MS )
-#define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 )
-
-/* The size of the memory blocks allocated by the vMemCheckTask() task. */
-#define mainMEM_CHECK_SIZE_1 ( ( size_t ) 51 )
-#define mainMEM_CHECK_SIZE_2 ( ( size_t ) 52 )
-#define mainMEM_CHECK_SIZE_3 ( ( size_t ) 151 )
-
-/*-----------------------------------------------------------*/
-
-/*
- * Checks that all the demo application tasks are still executing without error
- * - as described at the top of the file.
- */
-static long prvCheckOtherTasksAreStillRunning( void );
-
-/*
- * The task that executes at the highest priority and calls
- * prvCheckOtherTasksAreStillRunning(). See the description at the top
- * of the file.
- */
-static void vErrorChecks( void *pvParameters );
-
-/*
- * Configure the processor for use with the Olimex demo board. This includes
- * setup for the I/O, system clock, and access timings.
- */
-static void prvSetupHardware( void );
-
-/*-----------------------------------------------------------*/
-
-/*
- * Starts all the other tasks, then starts the scheduler.
- */
-int main( void )
-{
- /* Setup the hardware for use with the Xilinx evaluation board. */
- prvSetupHardware();
-
- /* Start the demo/test application tasks. */
- vStartIntegerMathTasks( tskIDLE_PRIORITY );
- vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
- vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
- vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
- vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
- vStartDynamicPriorityTasks();
- vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
- vStart7SegTasks( main7SEG_TASK_PRIORITY );
-
- /* Start the check task - which is defined in this file. */
- xTaskCreate( vErrorChecks, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
-
- /* Now all the tasks have been started - start the scheduler. */
- vTaskStartScheduler();
-
- /* Should never reach here! */
- for( ;; );
-}
-/*-----------------------------------------------------------*/
-
-static void vErrorChecks( void *pvParameters )
-{
-portTickType xDelayPeriod = mainNO_ERROR_FLASH_PERIOD;
-
- /* Just to stop compiler warnings. */
- ( void ) pvParameters;
-
- /* Cycle for ever, delaying then checking all the other tasks are still
- operating without error. If an error is detected then the delay period
- is decreased from mainNO_ERROR_FLASH_PERIOD to mainERROR_FLASH_PERIOD so
- the on board LED flash rate will increase. */
-
- for( ;; )
- {
- /* Delay until it is time to execute again. */
- vTaskDelay( xDelayPeriod );
-
- /* Check all the standard demo application tasks are executing without
- error. */
- if( prvCheckOtherTasksAreStillRunning() != pdPASS )
- {
- /* An error has been detected in one of the tasks - flash faster. */
- xDelayPeriod = mainERROR_FLASH_PERIOD;
- }
-
- /* The toggle rate of the LED depends on how long this task delays for.
- An error reduces the delay period and so increases the toggle rate. */
- vParTestToggleLED( mainON_BOARD_LED_BIT );
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvSetupHardware( void )
-{
- /* Initialise LED outputs. */
- vParTestInitialise();
-}
-/*-----------------------------------------------------------*/
-
-static long prvCheckOtherTasksAreStillRunning( void )
-{
-long lReturn = pdPASS;
-
- /* Check all the demo tasks (other than the flash tasks) to ensure
- that they are all still running, and that none of them have detected
- an error. */
-
- if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
- {
- lReturn = pdFAIL;
- }
-
- if( xAreComTestTasksStillRunning() != pdTRUE )
- {
- lReturn = pdFAIL;
- }
-
- if( xArePollingQueuesStillRunning() != pdTRUE )
- {
- lReturn = pdFAIL;
- }
-
- if( xAreSemaphoreTasksStillRunning() != pdTRUE )
- {
- lReturn = pdFAIL;
- }
-
- if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
- {
- lReturn = pdFAIL;
- }
-
- if( xAreBlockingQueuesStillRunning() != pdTRUE )
- {
- lReturn = pdFAIL;
- }
-
- return lReturn;
-}
-/*-----------------------------------------------------------*/
-
-void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
-{
- /* This function will be called if a task overflows its stack. Inspect
- pxCurrentTCB to find the offending task if the overflow was sever enough
- to corrupt the pcTaskName parameter. */
- vParTestSetLED( 4, 1 );
- for( ;; );
-}
-/*-----------------------------------------------------------*/
-
-void vApplicationMallocFailedHook( void )
-{
- /* This function will be called if a call to pvPortMalloc() fails to return
- the requested memory. pvPortMalloc() is called internally by the scheduler
- whenever a task, queue or semaphore is created. */
- vParTestSetLED( 4, 1 );
- for( ;; );
-}
-/*-----------------------------------------------------------*/
-
-
-
+/*\r
+ FreeRTOS V7.1.0 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+ \r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS tutorial books are available in pdf and paperback. *\r
+ * Complete, revised, and edited pdf reference manuals are also *\r
+ * available. *\r
+ * *\r
+ * Purchasing FreeRTOS documentation will not only help you, by *\r
+ * ensuring you get running as quickly as possible and with an *\r
+ * in-depth knowledge of how to use FreeRTOS, it will also help *\r
+ * the FreeRTOS project to continue with its mission of providing *\r
+ * professional grade, cross platform, de facto standard solutions *\r
+ * for microcontrollers - completely free of charge! *\r
+ * *\r
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *\r
+ * *\r
+ * Thank you for using FreeRTOS, and thank you for your support! *\r
+ * *\r
+ ***************************************************************************\r
+\r
+\r
+ This file is part of the FreeRTOS distribution.\r
+\r
+ FreeRTOS is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU General Public License (version 2) as published by the\r
+ Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+ >>>NOTE<<< The modification to the GPL is included to allow you to\r
+ distribute a combined work that includes FreeRTOS without being obliged to\r
+ provide the source code for proprietary components outside of the FreeRTOS\r
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but\r
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
+ more details. You should have received a copy of the GNU General Public\r
+ License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+ by writing to Richard Barry, contact details for whom are available on the\r
+ FreeRTOS WEB site.\r
+\r
+ 1 tab == 4 spaces!\r
+\r
+ http://www.FreeRTOS.org - Documentation, latest information, license and\r
+ contact details.\r
+\r
+ http://www.SafeRTOS.com - A version that is certified for use in safety\r
+ critical systems.\r
+\r
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
+ licensing and training services.\r
+*/\r
+\r
+/*\r
+ * Creates all the demo application tasks, then starts the scheduler.\r
+ *\r
+ * Main.c also creates a task called "Check". This only executes every three\r
+ * seconds but has the highest priority so is guaranteed to get processor time.\r
+ * Its main function is to check that all the other tasks are still operational.\r
+ * Each task (other than the "flash" tasks) maintains a unique count that is\r
+ * incremented each time the task successfully completes its function. Should\r
+ * any error occur within such a task the count is permanently halted. The\r
+ * check task inspects the count of each task to ensure it has changed since\r
+ * the last time the check task executed. If all the count variables have\r
+ * changed all the tasks are still executing error free, and the check task\r
+ * toggles the on board LED. Should any task contain an error at any time\r
+ * the LED toggle rate will change from 3 seconds to 500ms.\r
+ *\r
+ * NOTE: The demo application includes tasks that send and receive characters\r
+ * over the UART. The characters sent by one task are received by another -\r
+ * with an error condition being flagged should any characters be missed or\r
+ * received out of order. A loopback connector is required on the 9way D socket\r
+ * for this mechanism to operation (pins 2 and 3 the socket should be connected\r
+ * together - a paper clip is normally sufficient).\r
+ *\r
+ */\r
+\r
+/* Standard includes. */\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+/* Scheduler includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+/* Demo application includes. */\r
+#include "partest.h"\r
+#include "flash.h"\r
+#include "integer.h"\r
+#include "PollQ.h"\r
+#include "comtest2.h"\r
+#include "semtest.h"\r
+#include "flop.h"\r
+#include "dynamic.h"\r
+#include "BlockQ.h"\r
+#include "serial.h"\r
+#include "demoGpio.h"\r
+#include "7seg.h"\r
+#include "RegTest.h"\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Constants for the ComTest tasks. */\r
+#define mainCOM_TEST_BAUD_RATE ( ( unsigned long ) 115200 )\r
+#define mainCOM_TEST_LED ( 5 )\r
+\r
+/* Priorities for the demo application tasks. */\r
+#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )\r
+#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
+#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
+#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )\r
+#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )\r
+#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
+#define main7SEG_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
+\r
+/* The rate at which the on board LED will toggle when there is/is not an\r
+error. */\r
+#define mainNO_ERROR_FLASH_PERIOD ( ( portTickType ) 3000 / portTICK_RATE_MS )\r
+#define mainERROR_FLASH_PERIOD ( ( portTickType ) 500 / portTICK_RATE_MS )\r
+#define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 )\r
+\r
+/* The size of the memory blocks allocated by the vMemCheckTask() task. */\r
+#define mainMEM_CHECK_SIZE_1 ( ( size_t ) 51 )\r
+#define mainMEM_CHECK_SIZE_2 ( ( size_t ) 52 )\r
+#define mainMEM_CHECK_SIZE_3 ( ( size_t ) 151 )\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Checks that all the demo application tasks are still executing without error\r
+ * - as described at the top of the file.\r
+ */\r
+static long prvCheckOtherTasksAreStillRunning( void );\r
+\r
+/*\r
+ * The task that executes at the highest priority and calls\r
+ * prvCheckOtherTasksAreStillRunning(). See the description at the top\r
+ * of the file.\r
+ */\r
+static void vErrorChecks( void *pvParameters );\r
+\r
+/*\r
+ * Configure the processor for use with the Olimex demo board. This includes\r
+ * setup for the I/O, system clock, and access timings.\r
+ */\r
+static void prvSetupHardware( void );\r
+\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Starts all the other tasks, then starts the scheduler.\r
+ */\r
+int main( void )\r
+{\r
+ /* Setup the hardware for use with the Xilinx evaluation board. */\r
+ prvSetupHardware();\r
+\r
+ /* Start the demo/test application tasks. */\r
+ vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
+ vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );\r
+ vStartLEDFlashTasks( mainLED_TASK_PRIORITY );\r
+ vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
+ vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
+ vStartDynamicPriorityTasks();\r
+ vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
+ vStart7SegTasks( main7SEG_TASK_PRIORITY );\r
+ vStartRegTestTasks();\r
+\r
+ /* Start the check task - which is defined in this file. */\r
+ xTaskCreate( vErrorChecks, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
+\r
+ /* Now all the tasks have been started - start the scheduler. */\r
+ vTaskStartScheduler();\r
+\r
+ /* Should never reach here! */\r
+ for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void vErrorChecks( void *pvParameters )\r
+{\r
+portTickType xDelayPeriod = mainNO_ERROR_FLASH_PERIOD;\r
+\r
+ /* Just to stop compiler warnings. */\r
+ ( void ) pvParameters;\r
+\r
+ /* Cycle for ever, delaying then checking all the other tasks are still\r
+ operating without error. If an error is detected then the delay period\r
+ is decreased from mainNO_ERROR_FLASH_PERIOD to mainERROR_FLASH_PERIOD so\r
+ the on board LED flash rate will increase. */\r
+\r
+ for( ;; )\r
+ {\r
+ /* Delay until it is time to execute again. */\r
+ vTaskDelay( xDelayPeriod );\r
+\r
+ /* Check all the standard demo application tasks are executing without\r
+ error. */\r
+ if( prvCheckOtherTasksAreStillRunning() != pdPASS )\r
+ {\r
+ /* An error has been detected in one of the tasks - flash faster. */\r
+ xDelayPeriod = mainERROR_FLASH_PERIOD;\r
+ }\r
+\r
+ /* The toggle rate of the LED depends on how long this task delays for.\r
+ An error reduces the delay period and so increases the toggle rate. */\r
+ vParTestToggleLED( mainON_BOARD_LED_BIT );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSetupHardware( void )\r
+{\r
+ /* Initialise LED outputs. */\r
+ vParTestInitialise();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static long prvCheckOtherTasksAreStillRunning( void )\r
+{\r
+long lReturn = pdPASS;\r
+\r
+ /* Check all the demo tasks (other than the flash tasks) to ensure\r
+ that they are all still running, and that none of them have detected\r
+ an error. */\r
+\r
+ if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
+ {\r
+ lReturn = pdFAIL;\r
+ }\r
+\r
+ if( xAreComTestTasksStillRunning() != pdTRUE )\r
+ {\r
+ lReturn = pdFAIL;\r
+ }\r
+\r
+ if( xArePollingQueuesStillRunning() != pdTRUE )\r
+ {\r
+ lReturn = pdFAIL;\r
+ }\r
+\r
+ if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
+ {\r
+ lReturn = pdFAIL;\r
+ }\r
+\r
+ if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
+ {\r
+ lReturn = pdFAIL;\r
+ }\r
+\r
+ if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
+ {\r
+ lReturn = pdFAIL;\r
+ }\r
+\r
+ if( xAreRegTestTasksStillRunning() != pdTRUE )\r
+ {\r
+ lReturn = pdFAIL;\r
+ }\r
+\r
+ return lReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
+{\r
+ /* This function will be called if a task overflows its stack. Inspect\r
+ pxCurrentTCB to find the offending task if the overflow was sever enough\r
+ to corrupt the pcTaskName parameter. */\r
+ vParTestSetLED( 4, 1 );\r
+ for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationMallocFailedHook( void )\r
+{\r
+ /* This function will be called if a call to pvPortMalloc() fails to return\r
+ the requested memory. pvPortMalloc() is called internally by the scheduler\r
+ whenever a task, queue or semaphore is created. */\r
+ vParTestSetLED( 4, 1 );\r
+ for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Provide an exit function to prevent a whole load of standard library functions\r
+being brought into the build. */\r
+void exit( int status )\r
+{\r
+ for( ;; );\r
+}\r
+\r
+\r