]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/ARM7_LPC2368_Eclipse/RTOSDemo/main.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / ARM7_LPC2368_Eclipse / RTOSDemo / main.c
index 50e0bb3206ee74633a0e2d3cbc96172a171cc7c1..6f3f59bf23c12100ec093a2d006148a9c14a1405 100644 (file)
@@ -1,67 +1,29 @@
 /*\r
-    FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. \r
-    All rights reserved\r
-\r
-    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
-\r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS provides completely free yet professionally developed,    *\r
-     *    robust, strictly quality controlled, supported, and cross          *\r
-     *    platform software that has become a de facto standard.             *\r
-     *                                                                       *\r
-     *    Help yourself get started quickly and support the FreeRTOS         *\r
-     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
-     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
-     *                                                                       *\r
-     *    Thank you!                                                         *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
-    This file is part of the FreeRTOS distribution.\r
-\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
-\r
-    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
-    >>! a combined work that includes FreeRTOS without being obliged to provide\r
-    >>! the source code for proprietary components outside of the FreeRTOS\r
-    >>! kernel.\r
-\r
-    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
-    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
-    link: http://www.freertos.org/a00114.html\r
-\r
-    1 tab == 4 spaces!\r
-\r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    Having a problem?  Start by reading the FAQ "My application does   *\r
-     *    not run, what could be wrong?"                                     *\r
-     *                                                                       *\r
-     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
-    license and Real Time Engineers Ltd. contact details.\r
-\r
-    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
-    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
-    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
-\r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
-    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
-    licenses offer ticketed support, indemnification and middleware.\r
-\r
-    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
-    engineered and independently SIL3 certified version for use in safety and\r
-    mission critical applications that require provable dependability.\r
-\r
-    1 tab == 4 spaces!\r
-*/\r
+ * FreeRTOS Kernel V10.3.0\r
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
 \r
 /*\r
  * Creates all the demo application tasks, then starts the scheduler.  The WEB\r
  * for messages - waking and displaying the messages as they arrive.\r
  *\r
  * "Check" hook -  This only executes every five seconds from the tick hook.\r
- * Its main function is to check that all the standard demo tasks are still \r
- * operational.  Should any unexpected behaviour within a demo task be discovered \r
- * the tick hook will write an error to the LCD (via the LCD task).  If all the \r
- * demo tasks are executing with their expected behaviour then the check task \r
+ * Its main function is to check that all the standard demo tasks are still\r
+ * operational.  Should any unexpected behaviour within a demo task be discovered\r
+ * the tick hook will write an error to the LCD (via the LCD task).  If all the\r
+ * demo tasks are executing with their expected behaviour then the check task\r
  * writes PASS to the LCD (again via the LCD task), as described above.\r
  *\r
  * "uIP" task -  This is the task that handles the uIP stack.  All TCP/IP\r
 \r
 /* Demo application definitions. */\r
 #define mainQUEUE_SIZE                                         ( 3 )\r
-#define mainCHECK_DELAY                                                ( ( portTickType ) 5000 / portTICK_RATE_MS )\r
+#define mainCHECK_DELAY                                                ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )\r
 #define mainBASIC_WEB_STACK_SIZE            ( configMINIMAL_STACK_SIZE * 6 )\r
 \r
 /* Task priorities. */\r
 #define mainBLOCK_Q_PRIORITY                           ( tskIDLE_PRIORITY + 2 )\r
 #define mainFLASH_PRIORITY                  ( tskIDLE_PRIORITY + 2 )\r
 #define mainCREATOR_TASK_PRIORITY           ( tskIDLE_PRIORITY + 3 )\r
-#define mainGEN_QUEUE_TASK_PRIORITY                    ( tskIDLE_PRIORITY ) \r
+#define mainGEN_QUEUE_TASK_PRIORITY                    ( tskIDLE_PRIORITY )\r
 \r
 /* Constants to setup the PLL. */\r
-#define mainPLL_MUL                    ( ( unsigned portLONG ) ( 8 - 1 ) )\r
-#define mainPLL_DIV                    ( ( unsigned portLONG ) 0x0000 )\r
-#define mainCPU_CLK_DIV                ( ( unsigned portLONG ) 0x0003 )\r
-#define mainPLL_ENABLE         ( ( unsigned portLONG ) 0x0001 )\r
-#define mainPLL_CONNECT                ( ( ( unsigned portLONG ) 0x0002 ) | mainPLL_ENABLE )\r
-#define mainPLL_FEED_BYTE1     ( ( unsigned portLONG ) 0xaa )\r
-#define mainPLL_FEED_BYTE2     ( ( unsigned portLONG ) 0x55 )\r
-#define mainPLL_LOCK           ( ( unsigned portLONG ) 0x4000000 )\r
-#define mainPLL_CONNECTED      ( ( unsigned portLONG ) 0x2000000 )\r
-#define mainOSC_ENABLE         ( ( unsigned portLONG ) 0x20 )\r
-#define mainOSC_STAT           ( ( unsigned portLONG ) 0x40 )\r
-#define mainOSC_SELECT         ( ( unsigned portLONG ) 0x01 )\r
+#define mainPLL_MUL                    ( ( unsigned long ) ( 8 - 1 ) )\r
+#define mainPLL_DIV                    ( ( unsigned long ) 0x0000 )\r
+#define mainCPU_CLK_DIV                ( ( unsigned long ) 0x0003 )\r
+#define mainPLL_ENABLE         ( ( unsigned long ) 0x0001 )\r
+#define mainPLL_CONNECT                ( ( ( unsigned long ) 0x0002 ) | mainPLL_ENABLE )\r
+#define mainPLL_FEED_BYTE1     ( ( unsigned long ) 0xaa )\r
+#define mainPLL_FEED_BYTE2     ( ( unsigned long ) 0x55 )\r
+#define mainPLL_LOCK           ( ( unsigned long ) 0x4000000 )\r
+#define mainPLL_CONNECTED      ( ( unsigned long ) 0x2000000 )\r
+#define mainOSC_ENABLE         ( ( unsigned long ) 0x20 )\r
+#define mainOSC_STAT           ( ( unsigned long ) 0x40 )\r
+#define mainOSC_SELECT         ( ( unsigned long ) 0x01 )\r
 \r
 /* Constants to setup the MAM. */\r
-#define mainMAM_TIM_3          ( ( unsigned portCHAR ) 0x03 )\r
-#define mainMAM_MODE_FULL      ( ( unsigned portCHAR ) 0x02 )\r
+#define mainMAM_TIM_3          ( ( unsigned char ) 0x03 )\r
+#define mainMAM_MODE_FULL      ( ( unsigned char ) 0x02 )\r
 \r
-/* \r
+/*\r
  * The task that handles the uIP stack.  All TCP/IP processing is performed in\r
  * this task.\r
  */\r
 extern void vuIP_Task( void *pvParameters );\r
 \r
 /*\r
- * The LCD is written two by more than one task so is controlled by a \r
- * 'gatekeeper' task.  This is the only task that is actually permitted to \r
+ * The LCD is written two by more than one task so is controlled by a\r
+ * 'gatekeeper' task.  This is the only task that is actually permitted to\r
  * access the LCD directly.  Other tasks wanting to display a message send\r
  * the message to the gatekeeper.\r
  */\r
@@ -152,38 +114,38 @@ static void vLCDTask( void *pvParameters );
 static void prvSetupHardware( void );\r
 \r
 /* The queue used to send messages to the LCD task. */\r
-xQueueHandle xLCDQueue;\r
+QueueHandle_t xLCDQueue;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 int main( void )\r
 {\r
        prvSetupHardware();\r
-       \r
+\r
        /* Create the queue used by the LCD task.  Messages for display on the LCD\r
        are received via this queue. */\r
        xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );\r
 \r
        /* Create the uIP task.  This uses the lwIP RTOS abstraction layer.*/\r
-    xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
+    xTaskCreate( vuIP_Task, "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
 \r
        /* Start the standard demo tasks. */\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
     vCreateBlockTimeTasks();\r
     vStartLEDFlashTasks( mainFLASH_PRIORITY );\r
     vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
-    vStartQueuePeekTasks();   \r
+    vStartQueuePeekTasks();\r
     vStartDynamicPriorityTasks();\r
 \r
        /* Start the tasks defined within this file/specific to this demo. */\r
-       xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
+       xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
 \r
        /* Start the scheduler. */\r
        vTaskStartScheduler();\r
 \r
     /* Will only get here if there was insufficient memory to create the idle\r
     task. */\r
-       return 0; \r
+       return 0;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -191,7 +153,7 @@ void vApplicationTickHook( void )
 {\r
 unsigned portBASE_TYPE uxColumn = 0;\r
 static xLCDMessage xMessage = { 0, "PASS" };\r
-static unsigned portLONG ulTicksSinceLastDisplay = 0;\r
+static unsigned long ulTicksSinceLastDisplay = 0;\r
 static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 \r
        /* Called from every tick interrupt.  Have enough ticks passed to make it\r
@@ -200,7 +162,7 @@ static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
        if( ulTicksSinceLastDisplay >= mainCHECK_DELAY )\r
        {\r
                ulTicksSinceLastDisplay = 0;\r
-               \r
+\r
                /* Has an error been found in any task? */\r
 \r
         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
@@ -217,17 +179,17 @@ static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
                {\r
                        xMessage.pcMessage = "ERROR - GENQ";\r
                }\r
-               \r
+\r
                if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
                {\r
                        xMessage.pcMessage = "ERROR - PEEKQ";\r
-               }       \r
-               \r
+               }\r
+\r
                if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
                {\r
                        xMessage.pcMessage = "ERROR - DYNAMIC";\r
                }\r
-        \r
+\r
         xMessage.xColumn++;\r
 \r
                /* Send the message to the LCD gatekeeper for display. */\r
@@ -244,7 +206,7 @@ xLCDMessage xMessage;
        /* Initialise the LCD and display a startup message. */\r
        LCD_init();\r
        LCD_cur_off();\r
-    LCD_cls();    \r
+    LCD_cls();\r
     LCD_gotoxy( 1, 1 );\r
     LCD_puts( "www.FreeRTOS.org" );\r
 \r
@@ -252,7 +214,7 @@ xLCDMessage xMessage;
        {\r
                /* Wait for a message to arrive that requires displaying. */\r
                while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );\r
-               \r
+\r
                /* Display the message.  Print each message to a different position. */\r
                LCD_cls();\r
                LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );\r
@@ -268,17 +230,17 @@ static void prvSetupHardware( void )
                /* Remap the interrupt vectors to RAM if we are are running from RAM. */\r
                SCB_MEMMAP = 2;\r
        #endif\r
-       \r
+\r
        /* Disable the PLL. */\r
        PLLCON = 0;\r
        PLLFEED = mainPLL_FEED_BYTE1;\r
        PLLFEED = mainPLL_FEED_BYTE2;\r
-       \r
+\r
        /* Configure clock source. */\r
        SCS |= mainOSC_ENABLE;\r
        while( !( SCS & mainOSC_STAT ) );\r
-       CLKSRCSEL = mainOSC_SELECT; \r
-       \r
+       CLKSRCSEL = mainOSC_SELECT;\r
+\r
        /* Setup the PLL to multiply the XTAL input by 4. */\r
        PLLCFG = ( mainPLL_MUL | mainPLL_DIV );\r
        PLLFEED = mainPLL_FEED_BYTE1;\r
@@ -288,20 +250,20 @@ static void prvSetupHardware( void )
        PLLCON = mainPLL_ENABLE;\r
        PLLFEED = mainPLL_FEED_BYTE1;\r
        PLLFEED = mainPLL_FEED_BYTE2;\r
-       CCLKCFG = mainCPU_CLK_DIV;      \r
+       CCLKCFG = mainCPU_CLK_DIV;\r
        while( !( PLLSTAT & mainPLL_LOCK ) );\r
-       \r
+\r
        /* Connecting the clock. */\r
        PLLCON = mainPLL_CONNECT;\r
        PLLFEED = mainPLL_FEED_BYTE1;\r
        PLLFEED = mainPLL_FEED_BYTE2;\r
-       while( !( PLLSTAT & mainPLL_CONNECTED ) ); \r
-       \r
-       /* \r
+       while( !( PLLSTAT & mainPLL_CONNECTED ) );\r
+\r
+       /*\r
        This code is commented out as the MAM does not work on the original revision\r
        LPC2368 chips.  If using Rev B chips then you can increase the speed though\r
        the use of the MAM.\r
-       \r
+\r
        Setup and turn on the MAM.  Three cycle access is used due to the fast\r
        PLL used.  It is possible faster overall performance could be obtained by\r
        tuning the MAM and PLL settings.\r
@@ -309,7 +271,7 @@ static void prvSetupHardware( void )
        MAMTIM = mainMAM_TIM_3;\r
        MAMCR = mainMAM_MODE_FULL;\r
        */\r
-       \r
+\r
        /* Setup the led's on the MCB2300 board */\r
        vParTestInitialise();\r
 }\r