From b38248cf7610e1876d49b8ac56a6885e40af3a85 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Fri, 8 Aug 2008 12:47:06 +0000 Subject: [PATCH] Basic demo up and running. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@436 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../RTOSDemo/FreeRTOSConfig.h | 3 +- .../RTOSDemo/FreeRTOS_Tick_Setup.c | 17 ++-- .../RTOSDemo/Makefile | 1 + Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/main.c | 95 +++++++++++++++++-- 4 files changed, 99 insertions(+), 17 deletions(-) diff --git a/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/FreeRTOSConfig.h b/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/FreeRTOSConfig.h index e01917f0b..d0575a0fc 100644 --- a/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/FreeRTOSConfig.h +++ b/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/FreeRTOSConfig.h @@ -67,7 +67,7 @@ #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 25000000 ) #define configTICK_RATE_HZ ( ( portTickType ) 1000 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 60 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 90 ) #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 24000 ) ) #define configMAX_TASK_NAME_LEN ( 12 ) #define configUSE_TRACE_FACILITY 1 @@ -94,6 +94,7 @@ to exclude the API function. */ #define INCLUDE_vTaskDelay 1 #define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define configYIELD_INTERRUPT_VECTOR 63UL #define configKERNEL_INTERRUPT_PRIORITY 1 #define configMAX_SYSCALL_INTERRUPT_PRIORITY 4 diff --git a/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/FreeRTOS_Tick_Setup.c b/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/FreeRTOS_Tick_Setup.c index 1d325b239..73e57857c 100644 --- a/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/FreeRTOS_Tick_Setup.c +++ b/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/FreeRTOS_Tick_Setup.c @@ -48,6 +48,7 @@ */ #include "FreeRTOS.h" +#include "task.h" #define portPRESCALE_VALUE 64 #define portPRESCALE_REG_SETTING ( 5 << 8 ) @@ -69,14 +70,16 @@ const unsigned portSHORT usCompareMatchValue = ( ( configCPU_CLOCK_HZ / portPRES MCF_PIT0_PCSR = ( portPRESCALE_REG_SETTING | MCF_PIT_PCSR_PIE | MCF_PIT_PCSR_RLD | MCF_PIT_PCSR_EN ); MCF_PIT0_PMR = usCompareMatchValue; } +/*-----------------------------------------------------------*/ -void __attribute__ ((interrupt)) __cs3_isr_interrupt_127(void) -{ - MCF_INTC0_INTFRCH &= ~( 1UL << 31UL ); -} - -void __attribute__ ((interrupt)) __cs3_isr_interrupt_119(void) +void __attribute__ ((interrupt)) __cs3_isr_interrupt_119( void ) { MCF_PIT0_PCSR |= MCF_PIT_PCSR_PIF; - MCF_INTC0_INTFRCH |= ( 1UL << 31UL ); + vTaskIncrementTick(); + + #if configUSE_PREEMPTION == 1 + { + taskYIELD(); + } + #endif } diff --git a/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/Makefile b/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/Makefile index 614f00259..0c6bccd56 100644 --- a/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/Makefile +++ b/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/Makefile @@ -13,6 +13,7 @@ VPATH=$(FREERTOS_SOURCE_DIR) : $(PORT_SOURCE_DIR) : $(COMMON_DEMO_CODE_DIR) : $( OBJS = $(OUTPUT_DIR)/portasm.o \ $(OUTPUT_DIR)/main.o \ + $(OUTPUT_DIR)/flash.o \ $(OUTPUT_DIR)/ParTest.o \ $(OUTPUT_DIR)/BlockQ.o \ $(OUTPUT_DIR)/blocktim.o \ diff --git a/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/main.c b/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/main.c index 02a6c8f26..3c63ed3f7 100644 --- a/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/main.c +++ b/Demo/ColdFire_MCF5282_Eclipse/RTOSDemo/main.c @@ -90,7 +90,14 @@ /* The time between cycles of the 'check' functionality (defined within the tick hook. */ -#define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS ) +#define mainNO_ERROR_PERIOD ( ( portTickType ) 5000 / portTICK_RATE_MS ) + +/* The rate at which the LED controlled by the 'check' task will flash when an +error has been detected. */ +#define mainERROR_PERIOD ( 500 ) + +/* The LED controlled by the 'check' task. */ +#define mainCHECK_LED ( 3 ) /* Task priorities. */ #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 ) @@ -107,6 +114,13 @@ tick hook. */ */ static void prvSetupHardware( void ); +/* + * Implements the 'check' task functionality as described at the top of this + * file. + */ +static void prvCheckTask( void *pvParameters ); + + /*-----------------------------------------------------------*/ int main( void ) @@ -114,14 +128,18 @@ int main( void ) prvSetupHardware(); /* Start the standard demo tasks. */ + vStartLEDFlashTasks( tskIDLE_PRIORITY ); vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); - vCreateBlockTimeTasks(); - vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); - vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); - vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); - vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); - vStartQueuePeekTasks(); - vStartRecursiveMutexTasks(); + vCreateBlockTimeTasks(); + vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); + vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); + vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); + vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); + vStartQueuePeekTasks(); + vStartRecursiveMutexTasks(); + + /* Create the check task. */ + xTaskCreate( prvCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); /* The suicide tasks must be created last as they need to know how many tasks were running prior to their creation in order to ascertain whether @@ -133,7 +151,66 @@ int main( void ) /* Will only get here if there was insufficient memory to create the idle task. */ - return 0; + for( ;; ); +} +/*-----------------------------------------------------------*/ + +static void prvCheckTask( void *pvParameters ) +{ +unsigned ulTicksToWait = mainNO_ERROR_PERIOD; +portTickType xLastExecutionTime; + + ( void ) pvParameters; + + /* Initialise the variable used to control our iteration rate prior to + its first use. */ + xLastExecutionTime = xTaskGetTickCount(); + + for( ;; ) + { + /* Wait until it is time to run the tests again. */ + vTaskDelayUntil( &xLastExecutionTime, ulTicksToWait ); + + /* Has an error been found in any task? */ + if( xAreGenericQueueTasksStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + else if( xAreQueuePeekTasksStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + else if( xAreBlockingQueuesStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + else if( xAreSemaphoreTasksStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + else if( xArePollingQueuesStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + else if( xIsCreateTaskStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + else if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) + { + ulTicksToWait = mainERROR_PERIOD; + } + + vParTestToggleLED( mainCHECK_LED ); + } } /*-----------------------------------------------------------*/ -- 2.39.5