X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FCORTEX_M4_ATSAM4S_Atmel_Studio%2Fsrc%2Fmain_full.c;h=4c82c39bff8db876a321e38bec5f77a956e7d379;hb=fe5eccd892a7b67dc33f9f9f26aeedbb123d30a9;hp=84ab35a448439b6140db027ab12f4c2801391da0;hpb=a97a430d525b824853f6528cb60d160468690963;p=freertos diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c index 84ab35a44..4c82c39bf 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c @@ -1,75 +1,70 @@ /* - FreeRTOS V7.4.2 - Copyright (C) 2013 Real Time Engineers Ltd. - - FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT - http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** + FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd. + All rights reserved + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 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. + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - >>>>>>NOTE<<<<<< The modification 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. + *************************************************************************** + >>! NOTE: The modification 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 Real Time Engineers Ltd., contact details for whom are available - on the FreeRTOS WEB site. - - 1 tab == 4 spaces! + FOR A PARTICULAR PURPOSE. Full license text is available on the following + link: http://www.freertos.org/a00114.html *************************************************************************** * * - * Having a problem? Start by reading the FAQ "My application does * - * not run, what could be wrong?" * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that is more than just the market leader, it * + * is the industry's de facto standard. * * * - * http://www.FreeRTOS.org/FAQHelp.html * + * Help yourself get started quickly while simultaneously helping * + * to support the FreeRTOS project by purchasing a FreeRTOS * + * tutorial book, reference manual, or both: * + * http://www.FreeRTOS.org/Documentation * * * *************************************************************************** + http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading + the FAQ page "My application does not run, what could be wrong?". Have you + defined configASSERT()? - http://www.FreeRTOS.org - Documentation, books, training, latest versions, - license and Real Time Engineers Ltd. contact details. + http://www.FreeRTOS.org/support - In return for receiving this top quality + embedded software for free we request you assist our global community by + participating in the support forum. + + http://www.FreeRTOS.org/training - Investing in training allows your team to + be as productive as possible as early as possible. Now you can receive + FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers + Ltd, and the world's leading authority on the world's leading RTOS. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, and our new - fully thread aware and reentrant UDP/IP stack. - - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems, who sell the code with commercial support, - indemnification and middleware, under the OpenRTOS brand. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. + Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. + + http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High + Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and commercial middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and mission critical applications that require provable dependability. + + 1 tab == 4 spaces! */ /****************************************************************************** @@ -132,6 +127,11 @@ #include "partest.h" #include "comtest2.h" #include "QueueSet.h" +#include "IntQueue.h" +#include "TaskNotify.h" +#include "TimerDemo.h" +#include "EventGroupsDemo.h" +#include "IntSemTest.h" /* Atmel library includes. */ #include "asf.h" @@ -149,13 +149,13 @@ /* The period after which the check timer will expire, in ms, provided no errors have been reported by any of the standard demo tasks. ms are converted to the -equivalent in ticks using the portTICK_RATE_MS constant. */ -#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_RATE_MS ) +equivalent in ticks using the portTICK_PERIOD_MS constant. */ +#define mainCHECK_TIMER_PERIOD_MS ( pdMS_TO_TICKS( 3000UL ) ) /* The period at which the check timer will expire, in ms, if an error has been reported in one of the standard demo tasks. ms are converted to the equivalent -in ticks using the portTICK_RATE_MS constant. */ -#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_RATE_MS ) +in ticks using the portTICK_PERIOD_MS constant. */ +#define mainERROR_CHECK_TIMER_PERIOD_MS ( pdMS_TO_TICKS( 200UL ) ) /* The standard demo flash timers can be used to flash any number of LEDs. In this case, because only three LEDs are available, and one is in use by the @@ -173,22 +173,36 @@ standard demo flash timers. */ for the comtest, so the LED number is deliberately out of range. */ #define mainCOM_TEST_LED ( 3 ) +/* Used by the standard demo timer tasks. */ +#define mainTIMER_TEST_PERIOD ( 50 ) + /*-----------------------------------------------------------*/ +/* + * Called by the idle hook function when the project is configured to run the + * full (as opposed to the blinky) demo. + */ +void vFullDemoIdleHook( void ); + +/* + * Called by the tick hook function when the project is configured to run the + * full (as opposed to the blinky) demo. + */ +void vFullDemoTickHook( void ); + /* * The check timer callback function, as described at the top of this file. */ -static void prvCheckTimerCallback( xTimerHandle xTimer ); +static void prvCheckTimerCallback( TimerHandle_t xTimer ); /*-----------------------------------------------------------*/ void main_full( void ) { -xTimerHandle xCheckTimer = NULL; - /* Start all the other standard demo/test tasks. The have not particular functionality, but do demonstrate how to use the FreeRTOS API and test the kernel port. */ + vStartInterruptQueueTasks(); vStartIntegerMathTasks( tskIDLE_PRIORITY ); vStartDynamicPriorityTasks(); vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); @@ -198,23 +212,12 @@ xTimerHandle xCheckTimer = NULL; vStartRecursiveMutexTasks(); vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); - vStartLEDFlashTimers( mainNUMBER_OF_FLASH_TIMERS_LEDS ); vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED ); vStartQueueSetTasks(); - - /* Create the software timer that performs the 'check' functionality, - as described at the top of this file. */ - xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */ - ( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */ - pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */ - ( void * ) 0, /* The ID is not used, so can be set to anything. */ - prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */ - ); - - if( xCheckTimer != NULL ) - { - xTimerStart( xCheckTimer, mainDONT_BLOCK ); - } + vStartTaskNotifyTask(); + vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); + vStartEventGroupTasks(); + vStartInterruptSemaphoreTasks(); /* The set of tasks created by the following function call have to be created last as they keep account of the number of tasks they expect to see @@ -233,7 +236,7 @@ xTimerHandle xCheckTimer = NULL; } /*-----------------------------------------------------------*/ -static void prvCheckTimerCallback( xTimerHandle xTimer ) +static void prvCheckTimerCallback( TimerHandle_t xTimer ) { static long lChangedTimerPeriodAlready = pdFALSE; unsigned long ulErrorFound = pdFALSE; @@ -241,60 +244,86 @@ unsigned long ulErrorFound = pdFALSE; /* Check all the demo tasks (other than the flash tasks) to ensure they are all still running, and that none have detected an error. */ + if( xAreIntQueueTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 0UL; + } + if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 1UL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 2UL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 3UL; } if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 4UL; } if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 5UL; } if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 6UL; } if( xIsCreateTaskStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 7UL; } if( xArePollingQueuesStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 8UL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 9UL; } if( xAreComTestTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 10UL; } - if( xAreQueueSetTasksStillRunning() != pdPASS ) + if( xAreQueueSetTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 11UL; + } + + if( xAreTaskNotificationTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 12UL; + } + + if( xAreTimerDemoTasksStillRunning( mainCHECK_TIMER_PERIOD_MS ) != pdTRUE ) + { + ulErrorFound |= 1UL << 13UL; + } + + if( xAreEventGroupTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 14UL; + } + + if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 15UL; } + /* Toggle the check LED to give an indication of the system status. If the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then @@ -320,3 +349,49 @@ unsigned long ulErrorFound = pdFALSE; } /*-----------------------------------------------------------*/ +void vFullDemoIdleHook( void ) +{ +static TimerHandle_t xCheckTimer = NULL; + + if( xCheckTimer == NULL ) + { + /* Create the software timer that performs the 'check' + functionality, in the full demo. This is not done before the + scheduler is started as to do so would prevent the standard demo + timer tasks from passing their tests (they expect the timer + command queue to be empty. */ + xCheckTimer = xTimerCreate( "CheckTimer", /* A text name, purely to help debugging. */ + mainCHECK_TIMER_PERIOD_MS, /* The timer period, in this case 3000ms (3s). */ + pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */ + ( void * ) 0, /* The ID is not used, so can be set to anything. */ + prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */ + ); + + if( xCheckTimer != NULL ) + { + xTimerStart( xCheckTimer, mainDONT_BLOCK ); + } + + /* Also start some timers that just flash LEDs. */ + vStartLEDFlashTimers( mainNUMBER_OF_FLASH_TIMERS_LEDS ); + } +} +/*-----------------------------------------------------------*/ + +void vFullDemoTickHook( void ) +{ + /* In this case the tick hook is used as part of the queue set test. */ + vQueueSetAccessQueueSetFromISR(); + + /* Use task notifications from an interrupt. */ + xNotifyTaskFromISR(); + + /* Use timers from an interrupt. */ + vTimerPeriodicISRTests(); + + /* Use event groups from an interrupt. */ + vPeriodicEventGroupsProcessing(); + + /* Use mutexes from interrupts. */ + vInterruptSemaphorePeriodicTest(); +}