]> git.sur5r.net Git - freertos/blobdiff - Demo/CORTEX_LM3Sxxxx_IAR_Keil/main.c
New MicroBlaze port: Added a FreeRTOS exception handler, and installed it in each...
[freertos] / Demo / CORTEX_LM3Sxxxx_IAR_Keil / main.c
index f4ac88a4c0d44de77a95ecb5a229e13ec927e94d..2fbf6f84712e64b0a7fd25a69183a1028a6d4a6c 100644 (file)
@@ -1,50 +1,54 @@
 /*\r
-       FreeRTOS.org V5.0.0 - Copyright (C) 2003-2008 Richard Barry.\r
-\r
-       This file is part of the FreeRTOS.org distribution.\r
+    FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+       \r
 \r
-       FreeRTOS.org is free software; you can redistribute it and/or modify\r
-       it under the terms of the GNU General Public License as published by\r
-       the Free Software Foundation; either version 2 of the License, or\r
-       (at your option) any later version.\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
+     *    Complete, revised, and edited pdf reference manuals are also       *\r
+     *    available.                                                         *\r
+     *                                                                       *\r
+     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
+     *    ensuring you get running as quickly as possible and with an        *\r
+     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
+     *    the FreeRTOS project to continue with its mission of providing     *\r
+     *    professional grade, cross platform, de facto standard solutions    *\r
+     *    for microcontrollers - completely free of charge!                  *\r
+     *                                                                       *\r
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+     *                                                                       *\r
+     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *                                                                       *\r
+    ***************************************************************************\r
 \r
-       FreeRTOS.org is distributed in the hope that it will be useful,\r
-       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-       GNU General Public License for more details.\r
 \r
-       You should have received a copy of the GNU General Public License\r
-       along with FreeRTOS.org; if not, write to the Free Software\r
-       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+    This file is part of the FreeRTOS distribution.\r
 \r
-       A special exception to the GPL can be applied should you wish to distribute\r
-       a combined work that includes FreeRTOS.org, without being obliged to provide\r
-       the source code for any proprietary components.  See the licensing section\r
-       of http://www.FreeRTOS.org for full details of how and when the exception\r
-       can be applied.\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+    >>>NOTE<<< The modification to the GPL is included to allow you to\r
+    distribute a combined work that includes FreeRTOS without being obliged to\r
+    provide the source code for proprietary components outside of the FreeRTOS\r
+    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+    more details. You should have received a copy of the GNU General Public\r
+    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+    by writing to Richard Barry, contact details for whom are available on the\r
+    FreeRTOS WEB site.\r
 \r
-    ***************************************************************************\r
-    ***************************************************************************\r
-    *                                                                         *\r
-    * SAVE TIME AND MONEY!  We can port FreeRTOS.org to your own hardware,    *\r
-    * and even write all or part of your application on your behalf.          *\r
-    * See http://www.OpenRTOS.com for details of the services we provide to   *\r
-    * expedite your project.                                                  *\r
-    *                                                                         *\r
-    ***************************************************************************\r
-    ***************************************************************************\r
+    1 tab == 4 spaces!\r
 \r
-       Please ensure to read the configuration and relevant port sections of the\r
-       online documentation.\r
+    http://www.FreeRTOS.org - Documentation, latest information, license and\r
+    contact details.\r
 \r
-       http://www.FreeRTOS.org - Documentation, latest information, license and \r
-       contact details.\r
+    http://www.SafeRTOS.com - A version that is certified for use in safety\r
+    critical systems.\r
 \r
-       http://www.SafeRTOS.com - A version that is certified for use in safety \r
-       critical systems.\r
-\r
-       http://www.OpenRTOS.com - Commercial support, development, porting, \r
-       licensing and training services.\r
+    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+    licensing and training services.\r
 */\r
 \r
 \r
 \r
 \r
 \r
-/************************************************************************* \r
+/*************************************************************************\r
  * Please ensure to read http://www.freertos.org/portlm3sx965.html\r
  * which provides information on configuring and running this demo for the\r
  * various Luminary Micro EKs.\r
  *************************************************************************/\r
 \r
-\r
+/* Set the following option to 1 to include the WEB server in the build.  By\r
+default the WEB server is excluded to keep the compiled code size under the 32K\r
+limit imposed by the KickStart version of the IAR compiler.  The graphics\r
+libraries take up a lot of ROM space, hence including the graphics libraries\r
+and the TCP/IP stack together cannot be accommodated with the 32K size limit. */\r
+#define mainINCLUDE_WEB_SERVER         0\r
 \r
 \r
 /* Standard includes. */\r
 #include "bitmap.h"\r
 #include "GenQTest.h"\r
 #include "QPeek.h"\r
+#include "recmutex.h"\r
+#include "IntQueue.h"\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -191,9 +202,9 @@ static void prvSetupHardware( void );
  * Configures the high frequency timers - those used to measure the timing\r
  * jitter while the real time kernel is executing.\r
  */\r
-extern void vSetupTimer( void );\r
+extern void vSetupHighFrequencyTimer( void );\r
 \r
-/* \r
+/*\r
  * Hook functions that can get called by the kernel.\r
  */\r
 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName );\r
@@ -211,7 +222,7 @@ const portCHAR * const pcWelcomeMessage = "   www.FreeRTOS.org";
 /*-----------------------------------------------------------*/\r
 \r
 \r
-/************************************************************************* \r
+/*************************************************************************\r
  * Please ensure to read http://www.freertos.org/portlm3sx965.html\r
  * which provides information on configuring and running this demo for the\r
  * various Luminary Micro EKs.\r
@@ -224,22 +235,32 @@ int main( void )
        are received via this queue. */\r
        xOLEDQueue = xQueueCreate( mainOLED_QUEUE_SIZE, sizeof( xOLEDMessage ) );\r
 \r
-       /* Create the uIP task if running on a processor that includes a MAC and\r
-       PHY. */\r
-       if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) )\r
-       {\r
-               xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
-       }\r
-\r
        /* Start the standard demo tasks. */\r
-       vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
-    vCreateBlockTimeTasks();\r
-    vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
-    vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
     vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
     vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
-    vStartQueuePeekTasks();\r
-\r
+    vStartInterruptQueueTasks();\r
+       vStartRecursiveMutexTasks();    \r
+       vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
+       vCreateBlockTimeTasks();\r
+       vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
+       vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
+       vStartQueuePeekTasks();         \r
+\r
+       /* Exclude some tasks if using the kickstart version to ensure we stay within\r
+       the 32K code size limit. */\r
+       #if mainINCLUDE_WEB_SERVER != 0\r
+       {\r
+               /* Create the uIP task if running on a processor that includes a MAC and\r
+               PHY. */\r
+               if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) )\r
+               {\r
+                       xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
+               }\r
+       }\r
+       #endif\r
+       \r
+       \r
+       \r
        /* Start the tasks defined within this file/specific to this demo. */\r
        xTaskCreate( vOLEDTask, ( signed portCHAR * ) "OLED", mainOLED_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
 \r
@@ -249,10 +270,9 @@ int main( void )
     vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
 \r
        /* Configure the high frequency interrupt used to measure the interrupt\r
-       jitter time.  The Keil port does not yet include the\r
-       configKERNEL_INTERRUPT_PRIORITY functionality so cannot perform this test. */\r
-       vSetupTimer();\r
-       \r
+       jitter time. */\r
+       vSetupHighFrequencyTimer();\r
+\r
        /* Start the scheduler. */\r
        vTaskStartScheduler();\r
 \r
@@ -303,9 +323,17 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
                {\r
                        xMessage.pcMessage = "ERROR IN GEN Q";\r
                }\r
-               else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
+           else if( xIsCreateTaskStillRunning() != pdTRUE )\r
+           {\r
+               xMessage.pcMessage = "ERROR IN CREATE";\r
+           }\r
+           else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
+           {\r
+               xMessage.pcMessage = "ERROR IN MATH";\r
+           }\r
+               else if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR IN PEEK Q";\r
+                       xMessage.pcMessage = "ERROR IN INT QUEUE";\r
                }\r
                else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
                {\r
@@ -315,23 +343,23 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
                {\r
                        xMessage.pcMessage = "ERROR IN BLOCK TIME";\r
                }\r
-           else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
-           {\r
-               xMessage.pcMessage = "ERROR IN SEMAPHORE";\r
-           }\r
-           else if( xArePollingQueuesStillRunning() != pdTRUE )\r
-           {\r
-               xMessage.pcMessage = "ERROR IN POLL Q";\r
-           }\r
-           else if( xIsCreateTaskStillRunning() != pdTRUE )\r
-           {\r
-               xMessage.pcMessage = "ERROR IN CREATE";\r
-           }\r
-           else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
-           {\r
-               xMessage.pcMessage = "ERROR IN MATH";\r
-           }\r
-       \r
+               else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
+               {\r
+                       xMessage.pcMessage = "ERROR IN SEMAPHORE";\r
+               }\r
+               else if( xArePollingQueuesStillRunning() != pdTRUE )\r
+               {\r
+                       xMessage.pcMessage = "ERROR IN POLL Q";\r
+               }\r
+               else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
+               {\r
+                       xMessage.pcMessage = "ERROR IN PEEK Q";\r
+               }                       \r
+               else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+               {\r
+                       xMessage.pcMessage = "ERROR IN REC MUTEX";\r
+               }                       \r
+               \r
                /* Send the message to the OLED gatekeeper for display. */\r
                xHigherPriorityTaskWoken = pdFALSE;\r
                xQueueSendFromISR( xOLEDQueue, &xMessage, &xHigherPriorityTaskWoken );\r
@@ -345,6 +373,7 @@ xOLEDMessage xMessage;
 unsigned portLONG ulY, ulMaxY;\r
 static portCHAR cMessage[ mainMAX_MSG_LEN ];\r
 extern volatile unsigned portLONG ulMaxJitter;\r
+unsigned portBASE_TYPE uxUnusedStackOnEntry;\r
 const unsigned portCHAR *pucImage;\r
 \r
 /* Functions to access the OLED.  The one used depends on the dev kit\r
@@ -354,6 +383,9 @@ void ( *vOLEDStringDraw )( const portCHAR *, unsigned portLONG, unsigned portLON
 void ( *vOLEDImageDraw )( const unsigned portCHAR *, unsigned portLONG, unsigned portLONG, unsigned portLONG, unsigned portLONG ) = NULL;\r
 void ( *vOLEDClear )( void ) = NULL;\r
 \r
+       /* Just for demo purposes. */\r
+       uxUnusedStackOnEntry = uxTaskGetStackHighWaterMark( NULL );\r
+\r
        /* Map the OLED access functions to the driver functions that are appropriate\r
        for the evaluation kit being used. */   \r
        switch( HWREG( SYSCTL_DID1 ) & SYSCTL_DID1_PRTNO_MASK )\r