X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FMicroBlaze_Kintex7_EthernetLite%2FRTOSDemo%2Fsrc%2Fmain.c;h=3466c3bf8e02a374063846a39fdea13d34df140d;hb=afe3a0193fb04714e0130b62a8352804c203064d;hp=fcd21298ef8f7654b2c1dd6d40fa773c26824310;hpb=609a4047ea829a54983e50fd9588f177ae9ca498;p=freertos diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/RTOSDemo/src/main.c b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/RTOSDemo/src/main.c index fcd21298e..3466c3bf8 100644 --- a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/RTOSDemo/src/main.c +++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/RTOSDemo/src/main.c @@ -1,79 +1,38 @@ /* - FreeRTOS V8.2.0 - 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. - - *************************************************************************** - >>! 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 - - *************************************************************************** - * * - * 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 * - * * - *************************************************************************** - - 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/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, 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.0 + * 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! + */ /****************************************************************************** - * This project provides two demo applications. A simple blinky style project, - * and a more comprehensive test and demo application. The - * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to - * select between the two. The simply blinky demo is implemented and described - * in main_blinky.c. The more comprehensive test and demo application is - * implemented and described in main_full.c. + * This project provides three demo applications. A simple blinky style + * project, a more comprehensive test and demo application, and an lwIP example. + * The mainSELECTED_APPLICATION setting (defined in this file) is used to + * select between the three. The simply blinky demo is implemented and + * described in main_blinky.c. The more comprehensive test and demo application + * is implemented and described in main_full.c. The lwIP example is implemented + * and described in main_lwIP.c. * * This file implements the code that is not demo specific, including the * hardware setup and FreeRTOS hook functions. @@ -99,16 +58,18 @@ #include "xtmrctr.h" #include "xil_cache.h" -/* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is used to select between the simply - * blinky demo and the comprehensive test and demo application. +/* mainSELECTED_APPLICATION is used to select between three demo applications, + * as described at the top of this file. + * + * When mainSELECTED_APPLICATION is set to 0 the simple blinky example will + * be run. * - * When mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 the simple blinky example - * will be run. + * When mainSELECTED_APPLICATION is set to 1 the comprehensive test and demo + * application will be run. * - * When mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 the comprehensive test - * and demo application will be run. + * When mainSELECTED_APPLICATION is set to 2 the lwIP example will be run. */ -#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0 +#define mainSELECTED_APPLICATION 0 /*-----------------------------------------------------------*/ @@ -118,13 +79,17 @@ static void prvSetupHardware( void ); /* - * See the comments at the top of this file and above the - * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY definition. - */ -#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) +* See the comments at the top of this file and above the +* mainSELECTED_APPLICATION definition. +*/ +#if ( mainSELECTED_APPLICATION == 0 ) extern void main_blinky( void ); -#else +#elif ( mainSELECTED_APPLICATION == 1 ) extern void main_full( void ); +#elif ( mainSELECTED_APPLICATION == 2 ) + extern void main_lwIP( void ); +#else + #error Invalid mainSELECTED_APPLICATION setting. See the comments at the top of this file and above the mainSELECTED_APPLICATION definition. #endif /* Prototypes for the standard FreeRTOS callback/hook functions implemented @@ -145,16 +110,20 @@ int main( void ) /* Configure the hardware ready to run the demo. */ prvSetupHardware(); - /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top + /* The mainSELECTED_APPLICATION setting is described at the top of this file. */ - #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) + #if( mainSELECTED_APPLICATION == 0 ) { main_blinky(); } - #else + #elif( mainSELECTED_APPLICATION == 1 ) { main_full(); } + #else + { + main_lwIP(); + } #endif /* Don't expect to reach here. */ @@ -168,12 +137,14 @@ static void prvSetupHardware( void ) #if defined( XPAR_MICROBLAZE_USE_ICACHE ) && ( XPAR_MICROBLAZE_USE_ICACHE != 0 ) { + Xil_ICacheInvalidate(); Xil_ICacheEnable(); } #endif #if defined( XPAR_MICROBLAZE_USE_DCACHE ) && ( XPAR_MICROBLAZE_USE_DCACHE != 0 ) { + Xil_DCacheInvalidate(); Xil_DCacheEnable(); } #endif @@ -206,14 +177,14 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, 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. Force an assertion - failuse. */ + failure. */ configASSERT( ( char * ) pxTask == pcTaskName ); } /*-----------------------------------------------------------*/ void vApplicationIdleHook( void ) { - #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) + #if( mainSELECTED_APPLICATION == 1 ) { extern void vFullDemoIdleHook( void ); @@ -247,7 +218,7 @@ volatile unsigned long ul = 0; void vApplicationTickHook( void ) { - #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) + #if( mainSELECTED_APPLICATION == 1 ) { extern void vFullDemoTickHook( void ); @@ -293,7 +264,9 @@ extern void vPortTickISR( void *pvUnused ); purpose. */ vPortEnableInterrupt( XPAR_INTC_0_TMRCTR_0_VEC_ID ); - /* Configure the timer interrupt handler. */ + /* Configure the timer interrupt handler. This installs the handler + directly, rather than through the Xilinx driver. This is done for + efficiency. */ XTmrCtr_SetHandler( &xTickTimerInstance, ( void * ) vPortTickISR, NULL ); /* Set the correct period for the timer. */ @@ -360,10 +333,15 @@ const uint32_t ulPrescale = 10, ulTCR2Offset = 24UL; if( ulTimeNow < ulLastTime ) { - ulOverflows += ( 1UL << ulPrescale ); + /* 32 as its a 32-bit number. */ + ulOverflows += ( 1UL << ( 32 - ulPrescale ) ); } + ulLastTime = ulTimeNow; ulReturn = ( ulTimeNow >> ulPrescale ) + ulOverflows; return ulReturn; } +/*-----------------------------------------------------------*/ + +