X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FCORTEX_LM3Sxxxx_IAR_Keil%2Fmain.c;h=825dcbb519a763a2a7794b71aa7dae817232efac;hb=533a8d2a52fe9f6958fcd4c165640b1058c293f1;hp=79ba458fdca0254962de07b301516e919c8890e8;hpb=04f5830e5a04fd6d0d953fefe62e3c2ae922a5b1;p=freertos diff --git a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/main.c b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/main.c index 79ba458fd..825dcbb51 100644 --- a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/main.c +++ b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/main.c @@ -1,97 +1,29 @@ /* - FreeRTOS V8.2.0rc1 - Copyright (C) 2014 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. - - >>! 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 on 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?". Have you defined configASSERT()? * - * * - * http://www.FreeRTOS.org/FAQHelp.html * - * * - *************************************************************************** - - *************************************************************************** - * * - * 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. * - * * - * 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 * - * * - *************************************************************************** - - *************************************************************************** - * * - * Investing in training allows your team to be as productive as * - * possible as early as possible, lowering your overall development * - * cost, and enabling you to bring a more robust product to market * - * earlier than would otherwise be possible. Richard Barry is both * - * the architect and key author of FreeRTOS, and so also the world's * - * leading authority on what is the world's most popular real time * - * kernel for deeply embedded MCU designs. Obtaining your training * - * from Richard ensures your team will gain directly from his in-depth * - * product knowledge and years of usage experience. Contact Real Time * - * Engineers Ltd to enquire about the FreeRTOS Masterclass, presented * - * by Richard Barry: http://www.FreeRTOS.org/contact - * * - *************************************************************************** - - *************************************************************************** - * * - * You are receiving this top quality software for free. Please play * - * fair and reciprocate by reporting any suspected issues and * - * participating in the community forum: * - * http://www.FreeRTOS.org/support * - * * - * Thank you! * - * * - *************************************************************************** - - 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.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! -*/ + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* @@ -124,11 +56,12 @@ * * "uIP" task - This is the task that handles the uIP stack. All TCP/IP * processing is performed in this task. + * + * Use the following command to execute in QEMU from the IAR IDE: + * qemu-system-arm -machine lm3s6965evb -s -S -kernel [pat_to]\RTOSDemo.out + * and set IAR connect GDB server to "localhost,1234" in project debug options. */ - - - /************************************************************************* * Please ensure to read http://www.freertos.org/portlm3sx965.html * which provides information on configuring and running this demo for the @@ -157,17 +90,17 @@ and the TCP/IP stack together cannot be accommodated with the 32K size limit. */ #include "hw_memmap.h" #include "hw_types.h" #include "hw_sysctl.h" +#include "hw_uart.h" #include "sysctl.h" #include "gpio.h" #include "grlib.h" #include "rit128x96x4.h" #include "osram128x64x4.h" #include "formike128x128x16.h" +#include "uart.h" /* Demo app includes. */ -#include "BlockQ.h" #include "death.h" -#include "integer.h" #include "blocktim.h" #include "flash.h" #include "partest.h" @@ -181,6 +114,8 @@ and the TCP/IP stack together cannot be accommodated with the 32K size limit. */ #include "IntQueue.h" #include "QueueSet.h" #include "EventGroupsDemo.h" +#include "MessageBufferDemo.h" +#include "StreamBufferDemo.h" /*-----------------------------------------------------------*/ @@ -198,9 +133,7 @@ tick hook. */ #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) -#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) -#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) /* The maximum number of message that can be waiting for display at any one @@ -255,6 +188,7 @@ extern void vSetupHighFrequencyTimer( void ); void vApplicationStackOverflowHook( TaskHandle_t *pxTask, signed char *pcTaskName ); void vApplicationTickHook( void ); +static void prvPrintString( const char * pcString ); /*-----------------------------------------------------------*/ @@ -281,17 +215,17 @@ int main( void ) xOLEDQueue = xQueueCreate( mainOLED_QUEUE_SIZE, sizeof( xOLEDMessage ) ); /* Start the standard demo tasks. */ - vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); - vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); - vStartInterruptQueueTasks(); + vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); + vStartInterruptQueueTasks(); vStartRecursiveMutexTasks(); - vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); vCreateBlockTimeTasks(); vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); vStartQueuePeekTasks(); vStartQueueSetTasks(); vStartEventGroupTasks(); + vStartMessageBufferTasks( configMINIMAL_STACK_SIZE ); + vStartStreamBufferTasks(); /* Exclude some tasks if using the kickstart version to ensure we stay within the 32K code size limit. */ @@ -306,26 +240,24 @@ int main( void ) } #endif - - /* Start the tasks defined within this file/specific to this demo. */ xTaskCreate( vOLEDTask, "OLED", mainOLED_TASK_STACK_SIZE, NULL, tskIDLE_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 or not the correct/expected number of tasks are running at any given time. */ - vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); + vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); - /* Configure the high frequency interrupt used to measure the interrupt - jitter time. */ - vSetupHighFrequencyTimer(); + /* Uncomment the following line to configure the high frequency interrupt + used to measure the interrupt jitter time. + vSetupHighFrequencyTimer(); */ /* Start the scheduler. */ vTaskStartScheduler(); - /* Will only get here if there was insufficient memory to create the idle - task. */ - return 0; + /* Will only get here if there was insufficient memory to create the idle + task. */ + for( ;; ); } /*-----------------------------------------------------------*/ @@ -349,6 +281,11 @@ void prvSetupHardware( void ) GPIOPadConfigSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3 ), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD ); vParTestInitialise(); + + /* Initialise the UART - QEMU usage does not seem to require this + initialisation. */ + SysCtlPeripheralEnable( SYSCTL_PERIPH_UART0 ); + UARTEnable( UART0_BASE ); } /*-----------------------------------------------------------*/ @@ -366,6 +303,14 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; ulTicksSinceLastDisplay = 0; /* Has an error been found in any task? */ + if( xAreStreamBufferTasksStillRunning() != pdTRUE ) + { + xMessage.pcMessage = "ERROR IN STRM"; + } + else if( xAreMessageBufferTasksStillRunning() != pdTRUE ) + { + xMessage.pcMessage = "ERROR IN MSG"; + } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "ERROR IN GEN Q"; @@ -373,19 +318,11 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; else if( xIsCreateTaskStillRunning() != pdTRUE ) { xMessage.pcMessage = "ERROR IN CREATE"; - } - else if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) - { - xMessage.pcMessage = "ERROR IN MATH"; } else if( xAreIntQueueTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "ERROR IN INT QUEUE"; } - else if( xAreBlockingQueuesStillRunning() != pdTRUE ) - { - xMessage.pcMessage = "ERROR IN BLOCK Q"; - } else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "ERROR IN BLOCK TIME"; @@ -415,8 +352,6 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; xMessage.pcMessage = "ERROR IN EVNT GRP"; } - configASSERT( strcmp( ( const char * ) xMessage.pcMessage, "PASS" ) == 0 ); - /* Send the message to the OLED gatekeeper for display. */ xHigherPriorityTaskWoken = pdFALSE; xQueueSendFromISR( xOLEDQueue, &xMessage, &xHigherPriorityTaskWoken ); @@ -431,6 +366,16 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; } /*-----------------------------------------------------------*/ +static void prvPrintString( const char * pcString ) +{ + while( *pcString != 0x00 ) + { + UARTCharPut( UART0_BASE, *pcString ); + pcString++; + } +} +/*-----------------------------------------------------------*/ + void vOLEDTask( void *pvParameters ) { xOLEDMessage xMessage; @@ -503,14 +448,16 @@ void ( *vOLEDClear )( void ) = NULL; high priority time test. */ sprintf( cMessage, "%s [%uns]", xMessage.pcMessage, ulMaxJitter * mainNS_PER_CLOCK ); vOLEDStringDraw( cMessage, 0, ulY, mainFULL_SCALE ); + prvPrintString( cMessage ); } } /*-----------------------------------------------------------*/ +volatile signed char *pcOverflowedTask = NULL; void vApplicationStackOverflowHook( TaskHandle_t *pxTask, signed char *pcTaskName ) { ( void ) pxTask; - ( void ) pcTaskName; + pcOverflowedTask = pcTaskName; for( ;; ); } @@ -524,7 +471,7 @@ volatile unsigned long ulSetTo1InDebuggerToExit = 0; { while( ulSetTo1InDebuggerToExit == 0 ) { - /* Nothing do do here. Set the loop variable to a non zero value in + /* Nothing to do here. Set the loop variable to a non zero value in the debugger to step out of this function to the point that caused the assertion. */ ( void ) pcFile; @@ -533,3 +480,53 @@ volatile unsigned long ulSetTo1InDebuggerToExit = 0; } taskEXIT_CRITICAL(); } + +/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an +implementation of vApplicationGetIdleTaskMemory() to provide the memory that is +used by the Idle task. */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ +/* If the buffers to be provided to the Idle task are declared inside this +function then they must be declared static - otherwise they will be allocated on +the stack and so not exists after this function exits. */ +static StaticTask_t xIdleTaskTCB; +static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + + /* Pass out a pointer to the StaticTask_t structure in which the Idle task's + state will be stored. */ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = uxIdleTaskStack; + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the +application must provide an implementation of vApplicationGetTimerTaskMemory() +to provide the memory that is used by the Timer service task. */ +void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) +{ +/* If the buffers to be provided to the Timer task are declared inside this +function then they must be declared static - otherwise they will be allocated on +the stack and so not exists after this function exits. */ +static StaticTask_t xTimerTaskTCB; +static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + task's state will be stored. */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} +