]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c
Update version numbers in preparation for V8.2.0 release candidate 1.
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4E_Atmel_Studio / src / main.c
index 81582ce0f87a80465e6d34d24924c1f9f280a807..919077191a8fd6a2a402067661e6b5707f5c2071 100644 (file)
@@ -1,37 +1,23 @@
 /*\r
-    FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+    FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS provides completely free yet professionally developed,    *\r
-     *    robust, strictly quality controlled, supported, and cross          *\r
-     *    platform software that has become a de facto standard.             *\r
-     *                                                                       *\r
-     *    Help yourself get started quickly and support the FreeRTOS         *\r
-     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
-     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
-     *                                                                       *\r
-     *    Thank you!                                                         *\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
 \r
-    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
-    >>! a combined work that includes FreeRTOS without being obliged to provide\r
-    >>! the source code for proprietary components outside of the FreeRTOS\r
-    >>! kernel.\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
 \r
     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
     link: http://www.freertos.org/a00114.html\r
 \r
     1 tab == 4 spaces!\r
     ***************************************************************************\r
      *                                                                       *\r
      *    Having a problem?  Start by reading the FAQ "My application does   *\r
-     *    not run, what could be wrong?"                                     *\r
+     *    not run, what could be wrong?".  Have you defined configASSERT()?  *\r
      *                                                                       *\r
      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *   Investing in training allows your team to be as productive as       *\r
+     *   possible as early as possible, lowering your overall development    *\r
+     *   cost, and enabling you to bring a more robust product to market     *\r
+     *   earlier than would otherwise be possible.  Richard Barry is both    *\r
+     *   the architect and key author of FreeRTOS, and so also the world's   *\r
+     *   leading authority on what is the world's most popular real time     *\r
+     *   kernel for deeply embedded MCU designs.  Obtaining your training    *\r
+     *   from Richard ensures your team will gain directly from his in-depth *\r
+     *   product knowledge and years of usage experience.  Contact Real Time *\r
+     *   Engineers Ltd to enquire about the FreeRTOS Masterclass, presented  *\r
+     *   by Richard Barry:  http://www.FreeRTOS.org/contact\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    You are receiving this top quality software for free.  Please play *\r
+     *    fair and reciprocate by reporting any suspected issues and         *\r
+     *    participating in the community forum:                              *\r
+     *    http://www.FreeRTOS.org/support                                    *\r
+     *                                                                       *\r
+     *    Thank you!                                                         *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
     license and Real Time Engineers Ltd. contact details.\r
 \r
     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
 \r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
-    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
-    licenses offer ticketed support, indemnification and middleware.\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
 \r
     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
     engineered and independently SIL3 certified version for use in safety and\r
 \r
 /******************************************************************************\r
  * This project provides two demo applications.  A simple blinky style project,\r
- * and a more comprehensive application that makes use of FreeRTOS+ add-on\r
- * components.  The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this \r
- * file) is used to select between the two.  The simply blinky demo is \r
- * implemented and described in main_blinky.c.  The more comprehensive demo \r
- * application is implemented and described in main_full.c.\r
+ * and a more comprehensive application that includes FreeRTOS+CLI, FreeRTOS+UDP\r
+ * and FreeRTOS+FAT SL.  The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined\r
+ * in this file) is used to select between the two.  The simply blinky demo is\r
+ * implemented and described in main_blinky.c.  The more comprehensive demo\r
+ * application is implemented and described in main_full.c and full user\r
+ * instructions are provided on the following URL:\r
+ * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html\r
  *\r
  * This file implements the code that is not demo specific, including the\r
  * hardware setup and FreeRTOS hook functions.\r
 #include "partest.h"\r
 \r
 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
-or 0 to run the more comprehensive demo application that includes add-on \r
+or 0 to run the more comprehensive demo application that includes add-on\r
 components. */\r
-#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY     0\r
+#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY     1\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -111,15 +143,17 @@ int main( void )
 \r
        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
        of this file. */\r
-       #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1\r
+       #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )\r
        {\r
                main_blinky();\r
        }\r
        #else\r
        {\r
+               /* Full user instructions are provided on the following URL:\r
+               http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html */\r
                main_full();\r
        }\r
-       #endif\r
+       #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */\r
 \r
        return 0;\r
 }\r
@@ -131,12 +165,14 @@ static void prvSetupHardware( void )
        board_init();\r
        sysclk_init();\r
        pmc_enable_periph_clk( ID_GMAC );\r
-       vParTestInitialise();\r
+       pmc_enable_periph_clk( ID_SMC );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 void vApplicationMallocFailedHook( void )\r
 {\r
+static volatile uint32_t ulCount = 0;\r
+\r
        /* vApplicationMallocFailedHook() will only be called if\r
        configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
        function that will get called if a call to pvPortMalloc() fails.\r
@@ -146,8 +182,12 @@ void vApplicationMallocFailedHook( void )
        heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in\r
        FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used\r
        to query the size of free heap space that remains (although it does not\r
-       provide information on how the remaining heap might be fragmented). */\r
-       vAssertCalled( __LINE__, __FILE__ );\r
+       provide information on how the remaining heap might be fragmented). \r
+       \r
+       Just count the number of malloc fails as some failures may occur simply\r
+       because the network load is very high, resulting in the consumption of a\r
+       lot of network buffers. */\r
+       ulCount++;      \r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -162,26 +202,27 @@ void vApplicationIdleHook( void )
        important that vApplicationIdleHook() is permitted to return to its calling\r
        function, because it is the responsibility of the idle task to clean up\r
        memory allocated by the kernel to any task that has since been deleted. */\r
-       \r
+\r
        /* The simple blinky demo does not use the idle hook - the full demo does. */\r
        #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )\r
        {\r
                extern void vFullDemoIdleHook( void );\r
-               \r
+\r
+               /* Implemented in main_full.c. */\r
                vFullDemoIdleHook();\r
        }\r
        #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
+void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
 {\r
        ( void ) pcTaskName;\r
        ( void ) pxTask;\r
 \r
        /* Run time stack overflow checking is performed if\r
-       configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook\r
-       function is called if a stack overflow is detected. */\r
+       configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook function is\r
+       called if a stack overflow is detected. */\r
        vAssertCalled( __LINE__, __FILE__ );\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -193,12 +234,13 @@ void vApplicationTickHook( void )
        added here, but the tick hook is called from an interrupt context, so\r
        code must not attempt to block, and only the interrupt safe FreeRTOS API\r
        functions can be used (those that end in FromISR()). */\r
-       \r
+\r
        /* The simple blinky demo does not use the tick hook - the full demo does. */\r
        #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )\r
        {\r
                extern void vFullDemoTickHook( void );\r
-               \r
+\r
+               /* Implemented in main_full.c. */\r
                vFullDemoTickHook();\r
        }\r
        #endif\r
@@ -209,18 +251,18 @@ void vAssertCalled( uint32_t ulLine, const char *pcFile )
 {\r
 /* The following two variables are just to ensure the parameters are not\r
 optimised away and therefore unavailable when viewed in the debugger. */\r
-volatile uint32_t ulLineNumber = ulLine, ulSetNoneZeroInDebuggerToReturn = 0;\r
+volatile uint32_t ulLineNumber = ulLine, ulSetNonZeroInDebuggerToReturn = 0;\r
 volatile const char * const pcFileName = pcFile;\r
 \r
        taskENTER_CRITICAL();\r
-       while( ulSetNoneZeroInDebuggerToReturn == 0 )\r
+       while( ulSetNonZeroInDebuggerToReturn == 0 )\r
        {\r
                /* If you want to set out of this function in the debugger to see the\r
-               assert() location then set ulSetNoneZeroInDebuggerToReturn to a non-zero\r
+               assert() location then set ulSetNonZeroInDebuggerToReturn to a non-zero\r
                value. */\r
        }\r
        taskEXIT_CRITICAL();\r
-       \r
+\r
        ( void ) pcFileName;\r
        ( void ) ulLineNumber;\r
 }\r
@@ -233,14 +275,22 @@ void _exit_( int status )
        vAssertCalled( __LINE__, __FILE__ );\r
        for( ;; );\r
 }\r
+/*-----------------------------------------------------------*/\r
 \r
+/* Provided to keep the linker happy. */\r
 int _read( void )\r
 {\r
        return 0;\r
 }\r
+/*-----------------------------------------------------------*/\r
 \r
+/* Provided to keep the linker happy. */\r
 int _write( int x )\r
 {\r
        ( void ) x;\r
        return 0;\r
-}
\ No newline at end of file
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+\r