Add timer demo to TriCore port. Add mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY into main.c. Finish commenting main.c.

This commit is contained in:
Richard Barry 2011-10-25 11:16:59 +00:00
parent 0997b286bc
commit 7f8a5ae148
4 changed files with 372 additions and 251 deletions

View file

@ -549,11 +549,15 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/RTOSDemo/FreeRTOS_Source/portable/GCC/TriCore_1782}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/RTOSDemo/FreeRTOS_Source/portable/GCC/TriCore_1782}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${TRICORE_TOOLS}/tricore/include&quot;"/> <listOptionValue builtIn="false" value="&quot;${TRICORE_TOOLS}/tricore/include&quot;"/>
</option> </option>
<option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.assembler.symbols.defined.212143771" name="Defined symbols (-D)" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.assembler.symbols.defined" valueType="definedSymbols">
<listOptionValue builtIn="false" value=""/>
</option>
<inputType id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.assembler.input.1744794783" name="Assembler Input NO GUI" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.assembler.input"/> <inputType id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.assembler.input.1744794783" name="Assembler Input NO GUI" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.assembler.input"/>
</tool> </tool>
<tool id="com.rt.hightec.buildsystem.tricore.new.compiler.c.1160628898" name="TriCore C Compiler" superClass="com.rt.hightec.buildsystem.tricore.new.compiler.c"> <tool id="com.rt.hightec.buildsystem.tricore.new.compiler.c.1160628898" name="TriCore C Compiler" superClass="com.rt.hightec.buildsystem.tricore.new.compiler.c">
<option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.symbols.defined.827024089" name="Defined symbols (-D)" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.symbols.defined" valueType="stringList"> <option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.symbols.defined.827024089" name="Defined symbols (-D)" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.symbols.defined" valueType="stringList">
<listOptionValue builtIn="false" value="TRIBOARD_TC1782"/> <listOptionValue builtIn="false" value="TRIBOARD_TC1782"/>
<listOptionValue builtIn="false" value="BUILD_FOR_RAM_EXECUTION"/>
</option> </option>
<option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.general.paths.666426724" name="Include Paths" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.general.paths" valueType="includePath"> <option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.general.paths.666426724" name="Include Paths" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.general.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/RTOSDemo/Common_Demo_Source/include}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/RTOSDemo/Common_Demo_Source/include}&quot;"/>
@ -565,7 +569,10 @@
<option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.optimization.optimization.1251458415" name="Optimization Level" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.optimization.optimization" value="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.code.optimization.0" valueType="enumerated"/> <option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.optimization.optimization.1251458415" name="Optimization Level" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.optimization.optimization" value="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.code.optimization.0" valueType="enumerated"/>
<option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.miscellaneous.options.538537192" name="Other options" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.miscellaneous.options" valueType="stringList"> <option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.miscellaneous.options.538537192" name="Other options" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.miscellaneous.options" valueType="stringList">
<listOptionValue builtIn="false" value="-Wextra"/> <listOptionValue builtIn="false" value="-Wextra"/>
<listOptionValue builtIn="false" value="-ffunction-sections"/>
<listOptionValue builtIn="false" value="-fdata-sections"/>
</option> </option>
<option id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.CodeGeneration.FShortDouble.640153542" name="Treat double as float (-fshort-double)" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.CodeGeneration.FShortDouble" value="false" valueType="boolean"/>
<inputType id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.c.inputType.1866405312" name="INPUT" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.c.inputType"/> <inputType id="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.c.inputType.1866405312" name="INPUT" superClass="com.rt.hightec.framework.buildsystem.abstract.hightec.tool.compiler.c.inputType"/>
</tool> </tool>
<tool id="com.rt.hightec.buildsystem.tricore.new.compiler.cpp.820930352" name="TriCore C++ Compiler" superClass="com.rt.hightec.buildsystem.tricore.new.compiler.cpp"> <tool id="com.rt.hightec.buildsystem.tricore.new.compiler.cpp.820930352" name="TriCore C++ Compiler" superClass="com.rt.hightec.buildsystem.tricore.new.compiler.cpp">

File diff suppressed because one or more lines are too long

View file

@ -68,50 +68,58 @@
/*----------------------------------------------------------*/ /*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1 #define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0 #define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0 /* CPU is actually 150MHz but FPIDIV is 1 meaning divide by 2 for the
/* CPU is actually 150MHz but FPIDIV is 1 meaning divide by 2. */ peripheral clock. */
#define configCPU_CLOCK_HZ ( ( unsigned long ) 150000000UL ) #define configCPU_CLOCK_HZ ( ( unsigned long ) 150000000UL )
#define configPERIPHERAL_CLOCK_HZ ( ( unsigned long ) configCPU_CLOCK_HZ / 2UL ) #define configPERIPHERAL_CLOCK_HZ ( ( unsigned long ) configCPU_CLOCK_HZ / 2UL )
#define configTICK_RATE_HZ ( ( portTickType ) 1000UL ) #define configTICK_RATE_HZ ( ( portTickType ) 1000UL )
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 ) ) #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 16 ) #define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 0 #define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0 #define configIDLE_SHOULD_YIELD 0
#define configUSE_MALLOC_FAILED_HOOK 1 #define configUSE_MALLOC_FAILED_HOOK 1
#define configCHECK_FOR_STACK_OVERFLOW 0 #define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_MUTEXES 1
/* Co-routine definitions. */ /* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0 #define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) #define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Mutual Exclusion. */ /* Timer functionality. For space constraint reasons, the standard demo timer
#define configUSE_COUNTING_SEMAPHORES 1 tests are only included in the build configuration that generates code that
#define configUSE_RECURSIVE_MUTEXES 1 runs from Flash, and not in the build configuration that generates code that
#define configUSE_MUTEXES 1 runs from RAM. */
#ifdef BUILD_FOR_RAM_EXECUTION
#define configUSE_TIMERS 0
#define configUSE_TICK_HOOK 0
#else
#define configUSE_TIMER 1
#define configUSE_TICK_HOOK 1
#endif
/* Timer functionality. */ #define configTIMER_TASK_PRIORITY ( 4 )
#define configUSE_TIMERS 0 #define configTIMER_QUEUE_LENGTH ( 5 )
#define configTIMER_TASK_PRIORITY ( 4 ) #define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
#define configTIMER_QUEUE_LENGTH ( 2 )
/* Set the following definitions to 1 to include the API function, or zero /* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. to exclude the API function.
We use --gc-sections when linking, so there is no harm is setting all of these to 1 */ We use --gc-sections when linking, so there is no harm is setting all of these to 1 */
#define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1 #define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 1 #define INCLUDE_vTaskCleanUpResources 1
#define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1 #define INCLUDE_vTaskDelay 1
#define BLOCKQ_1 0
#endif /* FREERTOS_CONFIG_H */ #endif /* FREERTOS_CONFIG_H */

View file

@ -51,9 +51,52 @@
licensing and training services. licensing and training services.
*/ */
/******************************************************************************
/* _RB_ Add description here. */ * >>>>>> NOTE: <<<<<<
*
* main() can be configured to create either a very simple LED flasher demo, or
* a more comprehensive test/demo application.
*
* To create a very simple LED flasher example, set the
* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant (defined below) to 1. When
* this is done, only the standard demo flash tasks are created, whereby three
* tasks each toggle an LED at a fixed but different frequency.
*
* To create a more comprehensive test and demo application, set
* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0.
******************************************************************************
*
* main() creates all the demo application tasks and timers, then starts the
* scheduler. The web documentation provides more details of the standard demo
* application tasks, which provide no particular functionality, but do provide
* a good example of how to use the FreeRTOS API.
*
* In addition to the standard demo tasks, the following tasks and tests are
* defined and/or created within this file:
*
* "Reg test" tasks - These fill the registers with known values, then check
* that each register maintains its expected value for the lifetime of the
* task. Each task uses a different set of values. The reg test tasks execute
* with a very low priority, so get preempted very frequently. A register
* containing an unexpected value is indicative of an error in the context
* switching mechanism.
*
* "Check" task - The check task period is initially set to five seconds.
* Each time it executes, the check task checks that all the standard demo
* tasks, and the register check tasks, are not only still executing, but are
* executing without reporting any errors. If the check task discovers that a
* task has either stalled, or reported an error, then it changes its own
* execution period from the initial five seconds, to just 500ms. The check
* task also toggles an LED each time it is called. This provides a visual
* indication of the system status: If the LED toggles every five seconds,
* then no issues have been discovered. If the LED toggles every 500ms, then
* an issue has been discovered with at least one task.
*
* ***NOTE*** This demo uses the standard comtest tasks, which has special
* hardware requirements as a loopback connector, or UART echo server are
* required. See the documentation page for this demo on the FreeRTOS.org web
* site for more information.
*/
/* Standard includes. */ /* Standard includes. */
#include <stdlib.h> #include <stdlib.h>
@ -79,6 +122,8 @@
#include "recmutex.h" #include "recmutex.h"
#include "serial.h" #include "serial.h"
#include "death.h" #include "death.h"
#include "TimerDemo.h"
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* Constants for the ComTest tasks. */ /* Constants for the ComTest tasks. */
@ -100,6 +145,14 @@ error. */
#define mainERROR_FLASH_PERIOD ( ( portTickType ) 500 / portTICK_RATE_MS ) #define mainERROR_FLASH_PERIOD ( ( portTickType ) 500 / portTICK_RATE_MS )
#define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 ) #define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 )
/* Constant used by the standard timer test functions. */
#define mainTIMER_TEST_PERIOD ( 50 )
/* Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 1 to create a simple demo.
Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0 to create a much more
comprehensive test application. See the comments at the top of this file. */
#define mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY 0
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* /*
@ -124,8 +177,8 @@ static void prvSetupHardware( void );
* Writes to and checks the value of each register that is used in the context * Writes to and checks the value of each register that is used in the context
* of a task. * of a task.
*/ */
static void prvRegTask1( void *pvParameters ); static void prvRegisterCheckTask1( void *pvParameters );
static void prvRegTask2( void *pvParameters ); static void prvRegisterCheckTask2( void *pvParameters );
/* /*
* Specific check to see if the Register test functions are still operating * Specific check to see if the Register test functions are still operating
@ -133,6 +186,17 @@ static void prvRegTask2( void *pvParameters );
*/ */
static portBASE_TYPE prvAreRegTestTasksStillRunning( void ); static portBASE_TYPE prvAreRegTestTasksStillRunning( void );
/*
* This file can be used to create either a simple LED flasher example, or a
* comprehensive test/demo application - depending on the setting of the
* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant defined above. If
* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1, then the following
* function will create a lot of additional tasks and timers. If
* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0, then the following
* function will do nothing.
*/
static void prvOptionallyCreateComprehensveTestApplication( void );
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* Used by the register test tasks to indicated liveness. */ /* Used by the register test tasks to indicated liveness. */
@ -149,30 +213,17 @@ int main( void )
/* Setup the hardware for use with the TriCore evaluation board. */ /* Setup the hardware for use with the TriCore evaluation board. */
prvSetupHardware(); prvSetupHardware();
/* Start standard demo/test application tasks. */ /* Start standard demo/test application tasks. See the comments at the
vStartIntegerMathTasks( tskIDLE_PRIORITY ); top of this file. The LED flash tasks are always created. The other tasks
are only created if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1 (at
the top of this file). See the comments at the top of this file for more
information. */
vStartLEDFlashTasks( mainLED_TASK_PRIORITY ); vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartDynamicPriorityTasks();
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
vCreateBlockTimeTasks();
vStartCountingSemaphoreTasks();
vStartGenericQueueTasks( tskIDLE_PRIORITY );
vStartRecursiveMutexTasks();
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
/* _RB_ Create the timer test task here too. */
/* Create the register test tasks, as described at the top of this file. */ /* The following function will only create more tasks and timers if
xTaskCreate( prvRegTask1, ( signed char * ) "Reg 1", configMINIMAL_STACK_SIZE, &ulRegisterTest1Count, tskIDLE_PRIORITY, NULL ); mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1 (at the top of this
xTaskCreate( prvRegTask2, ( signed char * ) "Reg 2", configMINIMAL_STACK_SIZE, &ulRegisterTest2Count, tskIDLE_PRIORITY, NULL ); file). See the comments at the top of this file for more information. */
prvOptionallyCreateComprehensveTestApplication();
/* Start the check task - which is defined in this file. */
xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* This task has to be created last as it keeps account of the number of tasks
it expects to see running. */
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
/* Now all the tasks have been started - start the scheduler. */ /* Now all the tasks have been started - start the scheduler. */
vTaskStartScheduler(); vTaskStartScheduler();
@ -289,6 +340,17 @@ long lReturn = pdPASS;
lReturn = pdFAIL; lReturn = pdFAIL;
} }
#if configUSE_TIMERS == 1
{
/* For space constraint reasons, do not include the timer demo in
builds that execute from RAM. */
if( xAreTimerDemoTasksStillRunning( mainNO_ERROR_FLASH_PERIOD ) != pdTRUE )
{
lReturn = pdFAIL;
}
}
#endif
return lReturn; return lReturn;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -325,10 +387,18 @@ void vApplicationMallocFailedHook( void )
void vApplicationTickHook( void ) void vApplicationTickHook( void )
{ {
/* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY != 1
to 1 in FreeRTOSConfig.h. It is a hook function that will get called during {
each FreeRTOS tick interrupt. Note that vApplicationTickHook() is called /* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set
from an interrupt context. */ to 1 in FreeRTOSConfig.h. It is a hook function that will get called during
each FreeRTOS tick interrupt. Note that vApplicationTickHook() is called
from an interrupt context. */
/* Call the periodic timer test, which tests the timer API functions that
can be called from an ISR. */
vTimerPeriodicISRTests();
}
#endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -371,7 +441,7 @@ portBASE_TYPE xReturn = pdPASS;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvRegTask1( void *pvParameters ) static void prvRegisterCheckTask1( void *pvParameters )
{ {
/* Make space on the stack for the parameter and a counter. */ /* Make space on the stack for the parameter and a counter. */
__asm volatile( " sub.a %sp, 4 \n" __asm volatile( " sub.a %sp, 4 \n"
@ -479,7 +549,7 @@ static void prvRegTask1( void *pvParameters )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvRegTask2( void *pvParameters ) static void prvRegisterCheckTask2( void *pvParameters )
{ {
/* Make space on the stack for the parameter and a counter. */ /* Make space on the stack for the parameter and a counter. */
__asm volatile( " sub.a %sp, 4 \n" \ __asm volatile( " sub.a %sp, 4 \n" \
@ -586,3 +656,50 @@ static void prvRegTask2( void *pvParameters )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvOptionallyCreateComprehensveTestApplication( void )
{
#if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0
{
vStartIntegerMathTasks( tskIDLE_PRIORITY );
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartDynamicPriorityTasks();
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
vCreateBlockTimeTasks();
vStartCountingSemaphoreTasks();
vStartGenericQueueTasks( tskIDLE_PRIORITY );
vStartRecursiveMutexTasks();
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
#if configUSE_TIMERS == 1
{
/* For space constraint reasons, do not include the timer demo in
builds that execute from RAM. */
vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
}
#endif /* configUSE_TIMERS */
/* Create the register test tasks, as described at the top of this file. */
xTaskCreate( prvRegisterCheckTask1, ( signed char * ) "Reg 1", configMINIMAL_STACK_SIZE, &ulRegisterTest1Count, tskIDLE_PRIORITY, NULL );
xTaskCreate( prvRegisterCheckTask2, ( signed char * ) "Reg 2", configMINIMAL_STACK_SIZE, &ulRegisterTest2Count, tskIDLE_PRIORITY, NULL );
/* Start the check task - which is defined in this file. */
xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* This task has to be created last as it keeps account of the number of tasks
it expects to see running. */
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
}
#else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
{
/* Just to prevent compiler warnings when the configuration options are
set such that these static functions are not used. */
( void ) prvCheckTask;
( void ) prvRegisterCheckTask1;
( void ) prvRegisterCheckTask2;
}
#endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
}
/*-----------------------------------------------------------*/