Add standard demo tasks to SAM4E demo.

This commit is contained in:
Richard Barry 2013-11-16 18:06:57 +00:00
parent dc2e20bb0a
commit b690b26861
8 changed files with 349 additions and 30 deletions

View File

@ -375,6 +375,7 @@
<Value>../../../../FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI</Value>
<Value>../../../../FreeRTOS-Plus/Source/FreeRTOS-Plus-FAT-SL/api</Value>
<Value>../../../../FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_UDP_Demos/CLICommands</Value>
<Value>../../Common/include</Value>
</ListValues>
</armgcc.compiler.directories.IncludePaths>
<armgcc.compiler.optimization.OtherFlags>-fdata-sections</armgcc.compiler.optimization.OtherFlags>
@ -516,6 +517,46 @@
<SubType>compile</SubType>
<Link>src\FreeRTOS+\FreeRTOS+FAT SL\PSP\Target\RTC\psp_rtc.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\blocktim.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\blocktim.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\countsem.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\countsem.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\dynamic.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\dynamic.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\flash_timer.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\flash_timer.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\GenQTest.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\GenQTest.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\QPeek.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\QPeek.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\QueueOverwrite.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\QueueOverwrite.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\QueueSet.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\QueueSet.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\recmutex.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\recmutex.c</Link>
</Compile>
<Compile Include="..\Common\Minimal\semtest.c">
<SubType>compile</SubType>
<Link>src\Common Demo Tasks\semtest.c</Link>
</Compile>
<Compile Include="src\ASF\sam\utils\syscalls\gcc\syscalls.c">
<SubType>compile</SubType>
</Compile>
@ -534,6 +575,9 @@
<Compile Include="src\main_full.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\ParTest.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\printf-stdarg.c">
<SubType>compile</SubType>
</Compile>
@ -1078,6 +1122,7 @@
<Folder Include="src\FreeRTOS+\FreeRTOS+CLI" />
<Folder Include="src\FreeRTOS+\FreeRTOS+FAT SL" />
<Folder Include="src\FreeRTOS\portable" />
<Folder Include="src\Common Demo Tasks" />
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>

View File

@ -62,10 +62,11 @@ extern "C" {
/* @endcond */
#ifdef __GNUC__
void Dummy_Hardfault_Handler( void );
/* Cortex-M4 core handlers */
void Reset_Handler (void ) __attribute__ ((weak, alias("Dummy_Handler")));
void NMI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Hardfault_Handler")));
void MemManage_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
void BusFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
void UsageFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
@ -186,6 +187,12 @@ void Dummy_Handler(void)
}
}
void Dummy_Hardfault_Handler(void)
{
while (1) {
}
}
/* @cond 0 */
/**INDENT-OFF**/
#ifdef __cplusplus

View File

@ -0,0 +1,121 @@
/*
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that has become a de facto standard. *
* *
* Help yourself get started quickly and support the FreeRTOS *
* project by purchasing a FreeRTOS tutorial book, reference *
* manual, or both from: http://www.FreeRTOS.org/Documentation *
* *
* Thank you! *
* *
***************************************************************************
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 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. Full license text is available from the following
link: http://www.freertos.org/a00114.html
1 tab == 4 spaces!
***************************************************************************
* *
* Having a problem? Start by reading the FAQ "My application does *
* not run, what could be wrong?" *
* *
* http://www.FreeRTOS.org/FAQHelp.html *
* *
***************************************************************************
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
license and Real Time Engineers Ltd. contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and 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!
*/
/*-----------------------------------------------------------
* Simple IO routines to control the LEDs.
*-----------------------------------------------------------*/
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
/* Demo includes. */
#include "partest.h"
/* The number of LEDs available to the user on the evaluation kit. */
#define partestNUM_LEDS ( 3UL )
/* The index of the pins to which the LEDs are connected. The ordering of the
LEDs in this array is intentional and matches the order they appear on the
hardware. */
static const uint32_t ulLED[] = { LED0_GPIO, LED1_GPIO, LED2_GPIO };
/*-----------------------------------------------------------*/
void vParTestInitialise( void )
{
/* LEDs are initialised in the Atmel provided board initialisation
function. */
}
/*-----------------------------------------------------------*/
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
{
if( uxLED < partestNUM_LEDS )
{
/* Turn the LED off. */
taskENTER_CRITICAL();
{
ioport_set_pin_level( ulLED[ uxLED ], !xValue );
}
taskEXIT_CRITICAL();
}
}
/*-----------------------------------------------------------*/
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
if( uxLED < partestNUM_LEDS )
{
taskENTER_CRITICAL();
{
ioport_toggle_pin_level( ulLED[ uxLED ] );
}
taskEXIT_CRITICAL();
}
}

View File

@ -84,13 +84,14 @@
#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#define configUSE_QUEUE_SETS 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_TICK_HOOK 1
#define configCPU_CLOCK_HZ ( ( unsigned long ) CHIP_FREQ_CPU_MAX )
#define configTICK_RATE_HZ ( 1000 )
#define configMAX_PRIORITIES ( 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 22800 ) )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 34 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 10 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0

View File

@ -80,6 +80,9 @@
#include "FreeRTOS.h"
#include "task.h"
/* Demo application includes. */
#include "partest.h"
/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
or 0 to run the more comprehensive demo application that includes add-on
components. */
@ -128,6 +131,7 @@ static void prvSetupHardware( void )
board_init();
sysclk_init();
pmc_enable_periph_clk( ID_GMAC );
vParTestInitialise();
}
/*-----------------------------------------------------------*/
@ -143,8 +147,7 @@ void vApplicationMallocFailedHook( void )
FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
to query the size of free heap space that remains (although it does not
provide information on how the remaining heap might be fragmented). */
taskDISABLE_INTERRUPTS();
for( ;; );
vAssertCalled( __LINE__, __FILE__ );
}
/*-----------------------------------------------------------*/
@ -179,8 +182,7 @@ void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName
/* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. */
taskDISABLE_INTERRUPTS();
for( ;; );
vAssertCalled( __LINE__, __FILE__ );
}
/*-----------------------------------------------------------*/
@ -191,6 +193,15 @@ void vApplicationTickHook( void )
added here, but the tick hook is called from an interrupt context, so
code must not attempt to block, and only the interrupt safe FreeRTOS API
functions can be used (those that end in FromISR()). */
/* The simple blinky demo does not use the tick hook - the full demo does. */
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
{
extern void vFullDemoTickHook( void );
vFullDemoTickHook();
}
#endif
}
/*-----------------------------------------------------------*/

View File

@ -100,6 +100,9 @@
#include "queue.h"
#include "timers.h"
/* Demo application includes. */
#include "partest.h"
/* Priorities at which the tasks are created. */
#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
@ -126,8 +129,8 @@ converted to ticks using the portTICK_RATE_MS constant. */
#define mainDONT_BLOCK ( 0 )
/* The LEDs toggled by the timer and queue receive task respectively. */
#define mainTIMER_LED LED0_GPIO
#define mainTASK_LED LED1_GPIO
#define mainTIMER_LED 0
#define mainTASK_LED 1
/*-----------------------------------------------------------*/
@ -250,7 +253,7 @@ unsigned long ulReceivedValue;
is it the expected value? If it is, toggle the LED. */
if( ulReceivedValue == 100UL )
{
ioport_toggle_pin_level( mainTASK_LED );
vParTestToggleLED( mainTASK_LED );
ulReceivedValue = 0U;
}
}
@ -265,7 +268,7 @@ static void prvBlinkyTimerCallback( xTimerHandle xTimer )
/* This function is called when the blinky software time expires. All the
function does is toggle the LED. LED mainTIMER_LED should therefore toggle
with the period set by mainBLINKY_TIMER_PERIOD. */
ioport_toggle_pin_level( mainTIMER_LED );
vParTestToggleLED( mainTIMER_LED );
}
/*-----------------------------------------------------------*/

View File

@ -73,6 +73,48 @@
/* Demo application includes. */
#include "UDPCommandInterpreter.h"
#include "partest.h"
#include "blocktim.h"
#include "flash_timer.h"
#include "semtest.h"
#include "GenQTest.h"
#include "QPeek.h"
#include "IntQueue.h"
#include "countsem.h"
#include "dynamic.h"
#include "QueueOverwrite.h"
#include "QueueSet.h"
#include "recmutex.h"
/* 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 )
/* 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 )
/* The priorities of the various demo application tasks. */
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainQUEUE_OVERWRITE_TASK_PRIORITY ( tskIDLE_PRIORITY )
/* The LED controlled by the 'check' software timer. */
#define mainCHECK_LED ( 2 )
/* The number of LEDs that should be controlled by the flash software timer
standard demo. In this case it is only 1 as the starter kit has three LEDs, one
of which is controlled by the check timer and one of which is controlled by the
ISR triggered task. */
#define mainNUM_FLASH_TIMER_LEDS ( 1 )
/* Misc. */
#define mainDONT_BLOCK ( 0 )
/* Note: If the application is started without the network cable plugged in
then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to
@ -90,10 +132,16 @@ passed into the network event hook is eNetworkUp). */
#define mainUDP_CLI_PORT_NUMBER ( 5001UL )
#define mainUDP_CLI_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2U )
/* Simple toggles an LED to show the program is running. */
static void prvFlashTimerCallback( xTimerHandle xTimer );
/*-----------------------------------------------------------*/
/* Creates a set of sample files on a RAM disk. */
/*
* The check timer callback function, as described at the top of this file.
*/
static void prvCheckTimerCallback( xTimerHandle xTimer );
/*
* Creates a set of sample files on a RAM disk.
*/
extern void vCreateAndVerifySampleFiles( void );
/*
@ -125,7 +173,7 @@ const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_
/*-----------------------------------------------------------*/
int main_full( void )
{
xTimerHandle xFlashTimer;
xTimerHandle xTimer = NULL;
/* If the file system is only going to be accessed from one task then
F_FS_THREAD_AWARE can be set to 0 and the set of example files are created
@ -150,15 +198,6 @@ xTimerHandle xFlashTimer;
interpreter. */
vRegisterFileSystemCLICommands();
/* Create the timer that just toggles an LED to indicate that the
application is running. */
xFlashTimer = xTimerCreate( ( const signed char * const ) "Flash", 200 / portTICK_RATE_MS, pdTRUE, NULL, prvFlashTimerCallback );
configASSERT( xFlashTimer );
/* Start the timer. As the scheduler is not running a block time cannot be
used and is set to 0. */
xTimerStart( xFlashTimer, 0 );
/* Initialise the network interface. Tasks that use the network are
created in the network event hook when the network is connected and ready
for use. The address values passed in here are used if ipconfigUSE_DHCP is
@ -167,6 +206,31 @@ xTimerHandle xFlashTimer;
ipconfigFREERTOS_PLUS_NABTO is set to 1 in FreeRTOSIPConfig.h. */
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
/* Create all the other standard demo tasks. */
vStartLEDFlashTimers( mainNUM_FLASH_TIMER_LEDS );
vCreateBlockTimeTasks();
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
vStartQueuePeekTasks();
vStartCountingSemaphoreTasks();
vStartDynamicPriorityTasks();
vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_TASK_PRIORITY );
vStartQueueSetTasks();
vStartRecursiveMutexTasks();
/* Create the software timer that performs the 'check' functionality, as
described at the top of this file. */
xTimer = 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( xTimer != NULL )
{
xTimerStart( xTimer, mainDONT_BLOCK );
}
/* Start the scheduler itself. */
vTaskStartScheduler();
@ -179,14 +243,71 @@ xTimerHandle xFlashTimer;
}
/*-----------------------------------------------------------*/
static void prvFlashTimerCallback( xTimerHandle xTimer )
static void prvCheckTimerCallback( xTimerHandle xTimer )
{
/* The parameter is not used. */
static long lChangedTimerPeriodAlready = pdFALSE;
unsigned long ulErrorOccurred = pdFALSE;
/* Avoid compiler warnings. */
( void ) xTimer;
/* Timer callback function that does nothing other than toggle an LED to
indicate that the application is still running. */
ioport_toggle_pin_level( LED0_GPIO );
/* Have any of the standard demo tasks detected an error in their
operation? */
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 3UL );
}
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 4UL );
}
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 5UL );
}
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 6UL );
}
else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 8UL );
}
else if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 9UL );
}
else if( xIsQueueOverwriteTaskStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 10UL );
}
else if( xAreQueueSetTasksStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 11UL );
}
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
{
ulErrorOccurred |= ( 0x01UL << 12UL );
}
if( ulErrorOccurred != pdFALSE )
{
/* An error occurred. Increase the frequency at which the check timer
toggles its LED to give visual feedback of the potential error
condition. */
if( lChangedTimerPeriodAlready == pdFALSE )
{
lChangedTimerPeriodAlready = pdTRUE;
/* This call to xTimerChangePeriod() uses a zero block time.
Functions called from inside of a timer callback function must
*never* attempt to block as to do so could impact other software
timers. */
xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );
}
}
vParTestToggleLED( mainCHECK_LED );
}
/*-----------------------------------------------------------*/
@ -245,6 +366,16 @@ void vFullDemoIdleHook( void )
}
#endif
}
/*-----------------------------------------------------------*/
void vFullDemoTickHook( void )
{
/* Call the periodic queue overwrite from ISR demo. */
vQueueOverwritePeriodicISRDemo();
/* Call the queue set ISR test function. */
vQueueSetAccessQueueSetFromISR();
}