+++ /dev/null
-/*\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
- 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 !<<\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 on the following\r
- link: http://www.freertos.org/a00114.html\r
-\r
- 1 tab == 4 spaces!\r
-\r
- ***************************************************************************\r
- * *\r
- * Having a problem? Start by reading the FAQ "My application does *\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
- http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\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 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
- mission critical applications that require provable dependability.\r
-\r
- 1 tab == 4 spaces!\r
-*/\r
-\r
-/******************************************************************************\r
- * This project provides two demo applications. A simple blinky style project,\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
- *\r
- */\r
-\r
-/* Kernel includes. */\r
-#include "FreeRTOS.h"\r
-#include "task.h"\r
-\r
-/* Demo application includes. */\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
-components. */\r
-#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 1\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-/*\r
- * Set up the hardware ready to run this demo.\r
- */\r
-static void prvSetupHardware( void );\r
-\r
-/*\r
- * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
- * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.\r
- */\r
-extern void main_blinky( void );\r
-extern void main_full( void );\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-int main( void )\r
-{\r
- /* Prepare the hardware to run this demo. */\r
- prvSetupHardware();\r
-\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
- {\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 /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */\r
-\r
- return 0;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvSetupHardware( void )\r
-{\r
- /* Call the ASF initialisation functions. */\r
- board_init();\r
- sysclk_init();\r
- pmc_enable_periph_clk( ID_GMAC );\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
- pvPortMalloc() is called internally by the kernel whenever a task, queue,\r
- timer or semaphore is created. It is also called by various parts of the\r
- demo application. If heap_1.c or heap_2.c are used, then the size of the\r
- 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
- \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
-void vApplicationIdleHook( void )\r
-{\r
- /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set\r
- to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle\r
- task. It is essential that code added to this hook function never attempts\r
- to block in any way (for example, call xQueueReceive() with a block time\r
- specified, or call vTaskDelay()). If the application makes use of the\r
- vTaskDelete() API function (as this demo application does) then it is also\r
- 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
- /* 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
- /* Implemented in main_full.c. */\r
- vFullDemoIdleHook();\r
- }\r
- #endif\r
-}\r
-/*-----------------------------------------------------------*/\r
-\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 function is\r
- called if a stack overflow is detected. */\r
- vAssertCalled( __LINE__, __FILE__ );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vApplicationTickHook( void )\r
-{\r
- /* This function will be called by each tick interrupt if\r
- configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be\r
- 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
- /* 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
- /* Implemented in main_full.c. */\r
- vFullDemoTickHook();\r
- }\r
- #endif\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vAssertCalled( uint32_t ulLine, const char *pcFile )\r
-{\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, ulSetNonZeroInDebuggerToReturn = 0;\r
-volatile const char * const pcFileName = pcFile;\r
-\r
- taskENTER_CRITICAL();\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 ulSetNonZeroInDebuggerToReturn to a non-zero\r
- value. */\r
- }\r
- taskEXIT_CRITICAL();\r
-\r
- ( void ) pcFileName;\r
- ( void ) ulLineNumber;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-/* Provided to keep the linker happy. */\r
-void _exit_( int status )\r
-{\r
- ( void ) status;\r
- 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
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-\r
-\r