]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M4F_STM32F407ZG-SK/main.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / CORTEX_M4F_STM32F407ZG-SK / main.c
index 04ce49e7ed5df2d4bf159477d6e784fbe1801dbe..ad86e6a3238ae0cc7afc4ebe6bfa0b2a9b6bd935 100644 (file)
@@ -1,76 +1,29 @@
 /*\r
-    FreeRTOS V7.4.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
-\r
-    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
-    http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
-\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
-\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\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.\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.  See the GNU General Public License for more\r
-    details. You should have received a copy of the GNU General Public License\r
-    and the FreeRTOS license exception along with FreeRTOS; if not it can be\r
-    viewed here: http://www.freertos.org/a00114.html and also obtained by\r
-    writing to Real Time Engineers Ltd., contact details for whom are available\r
-    on the FreeRTOS WEB site.\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
-\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, and our new\r
-    fully thread aware and reentrant UDP/IP stack.\r
-\r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High \r
-    Integrity Systems, who sell the code with commercial support, \r
-    indemnification and middleware, under the OpenRTOS brand.\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
+ * 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
  * >>>>>> NOTE 1: <<<<<<\r
 \r
 /* The period after which the check timer will expire, in ms, provided no errors\r
 have been reported by any of the standard demo tasks.  ms are converted to the\r
-equivalent in ticks using the portTICK_RATE_MS constant. */\r
-#define mainCHECK_TIMER_PERIOD_MS                      ( 3000UL / portTICK_RATE_MS )\r
+equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
+#define mainCHECK_TIMER_PERIOD_MS                      ( 3000UL / portTICK_PERIOD_MS )\r
 \r
 /* The period at which the check timer will expire, in ms, if an error has been\r
 reported in one of the standard demo tasks.  ms are converted to the equivalent\r
-in ticks using the portTICK_RATE_MS constant. */\r
-#define mainERROR_CHECK_TIMER_PERIOD_MS        ( 200UL / portTICK_RATE_MS )\r
+in ticks using the portTICK_PERIOD_MS constant. */\r
+#define mainERROR_CHECK_TIMER_PERIOD_MS        ( 200UL / portTICK_PERIOD_MS )\r
 \r
 /* Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 1 to create a simple demo.\r
 Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0 to create a much more\r
@@ -217,7 +170,7 @@ static void prvSetupHardware( void );
 /*\r
  * The check timer callback function, as described at the top of this file.\r
  */\r
-static void prvCheckTimerCallback( xTimerHandle xTimer );\r
+static void prvCheckTimerCallback( TimerHandle_t xTimer );\r
 \r
 /*\r
  * Configure the interrupts used to test the interrupt nesting depth as\r
@@ -257,7 +210,7 @@ static void prvOptionallyCreateComprehensveTestApplication( void );
 \r
 /* The following two variables are used to communicate the status of the\r
 register check tasks to the check software timer.  If the variables keep\r
-incrementing, then the register check tasks has not discovered any errors.  If\r
+incrementing, then the register check tasks have not discovered any errors.  If\r
 a variable stops incrementing, then an error has been found. */\r
 volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
 \r
@@ -270,7 +223,7 @@ volatile unsigned long ulFPUInterruptNesting = 0UL, ulMaxFPUInterruptNesting = 0
 \r
 /* The semaphore used to demonstrate a task being synchronised with an\r
 interrupt. */\r
-static xSemaphoreHandle xTestSemaphore = NULL;\r
+static SemaphoreHandle_t xTestSemaphore = NULL;\r
 \r
 /* The variable that is incremented by the task synchronised with the button\r
 interrupt. */\r
@@ -282,7 +235,7 @@ int main(void)
 {\r
        /* Configure the hardware ready to run the test. */\r
        prvSetupHardware();\r
-       \r
+\r
        /* Start standard demo/test application flash tasks.  See the comments at\r
        the top of this file.  The LED flash tasks are always created.  The other\r
        tasks are only created if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to\r
@@ -297,17 +250,17 @@ int main(void)
 \r
        /* Start the scheduler. */\r
        vTaskStartScheduler();\r
-       \r
+\r
        /* If all is well, the scheduler will now be running, and the following line\r
        will never be reached.  If the following line does execute, then there was\r
        insufficient FreeRTOS heap memory available for the idle and/or timer tasks\r
        to be created.  See the memory management section on the FreeRTOS web site\r
        for more details. */\r
-       for( ;; );      \r
+       for( ;; );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCheckTimerCallback( xTimerHandle xTimer )\r
+static void prvCheckTimerCallback( TimerHandle_t xTimer )\r
 {\r
 static long lChangedTimerPeriodAlready = pdFALSE;\r
 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
@@ -365,7 +318,7 @@ long lErrorFound = pdFALSE;
        {\r
                lErrorFound = pdTRUE;\r
        }\r
-       \r
+\r
        /* Check that the register test 1 task is still running. */\r
        if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
        {\r
@@ -383,8 +336,8 @@ long lErrorFound = pdFALSE;
        /* Toggle the check LED to give an indication of the system status.  If\r
        the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then\r
        everything is ok.  A faster toggle indicates an error. */\r
-       vParTestToggleLED( mainCHECK_LED );     \r
-       \r
+       vParTestToggleLED( mainCHECK_LED );\r
+\r
        /* Have any errors been latch in lErrorFound?  If so, shorten the\r
        period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds.\r
        This will result in an increase in the rate at which mainCHECK_LED\r
@@ -394,7 +347,7 @@ long lErrorFound = pdFALSE;
                if( lChangedTimerPeriodAlready == pdFALSE )\r
                {\r
                        lChangedTimerPeriodAlready = pdTRUE;\r
-                       \r
+\r
                        /* This call to xTimerChangePeriod() uses a zero block time.\r
                        Functions called from inside of a timer callback function must\r
                        *never* attempt to block. */\r
@@ -412,11 +365,11 @@ static void prvButtonTestTask( void *pvParameters )
        an interrupt.  Each time the button interrupt gives the semaphore, this task\r
        will unblock, increment its execution counter, then return to block\r
        again. */\r
-       \r
+\r
        /* Take the semaphore before started to ensure it is in the correct\r
        state. */\r
        xSemaphoreTake( xTestSemaphore, mainDONT_BLOCK );\r
-       \r
+\r
        for( ;; )\r
        {\r
                xSemaphoreTake( xTestSemaphore, portMAX_DELAY );\r
@@ -429,13 +382,13 @@ static void prvSetupHardware( void )
 {\r
        /* Setup STM32 system (clock, PLL and Flash configuration) */\r
        SystemInit();\r
-       \r
+\r
        /* Ensure all priority bits are assigned as preemption priority bits. */\r
        NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );\r
-       \r
+\r
        /* Setup the LED outputs. */\r
        vParTestInitialise();\r
-       \r
+\r
        /* Configure the button input.  This configures the interrupt to use the\r
        lowest interrupt priority, so it is ok to use the ISR safe FreeRTOS API\r
        from the button interrupt handler. */\r
@@ -453,18 +406,18 @@ void vApplicationTickHook( void )
 \r
                /* Fill the FPU registers with 0. */\r
                vRegTestClearFlopRegistersToParameterValue( 0UL );\r
-               \r
+\r
                /* Trigger a timer 2 interrupt, which will fill the registers with a\r
                different value and itself trigger a timer 3 interrupt.  Note that the\r
                timers are not actually used.  The timer 2 and 3 interrupt vectors are\r
                just used for convenience. */\r
                NVIC_SetPendingIRQ( TIM2_IRQn );\r
-       \r
+\r
                /* Ensure that, after returning from the nested interrupts, all the FPU\r
                registers contain the value to which they were set by the tick hook\r
                function. */\r
                configASSERT( ulRegTestCheckFlopRegistersContainParameterValue( 0UL ) );\r
-               \r
+\r
                ulFPUInterruptNesting--;\r
        }\r
        #endif\r
@@ -484,7 +437,7 @@ NVIC_InitTypeDef NVIC_InitStructure;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\r
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\r
        NVIC_Init( &NVIC_InitStructure );\r
-       \r
+\r
        /* Enable the TIM3 interrupt in the NVIC.  The timer itself is not used,\r
        just its interrupt vector to force nesting from software.  TIM2 must have\r
        a lower priority than TIM3, and both must have priorities above\r
@@ -502,7 +455,7 @@ void TIM3_IRQHandler( void )
        /* Just to verify that the interrupt nesting behaves as expected, increment\r
        ulFPUInterruptNesting on entry, and decrement it on exit. */\r
        ulFPUInterruptNesting++;\r
-       \r
+\r
        /* This is the highest priority interrupt in the chain of forced nesting\r
        interrupts, so latch the maximum value reached by ulFPUInterruptNesting.\r
        This is done purely to allow verification that the nesting depth reaches\r
@@ -515,7 +468,7 @@ void TIM3_IRQHandler( void )
        /* Fill the FPU registers with 99 to overwrite the values written by\r
        TIM2_IRQHandler(). */\r
        vRegTestClearFlopRegistersToParameterValue( 99UL );\r
-       \r
+\r
        ulFPUInterruptNesting--;\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -525,10 +478,10 @@ void TIM2_IRQHandler( void )
        /* Just to verify that the interrupt nesting behaves as expected, increment\r
        ulFPUInterruptNesting on entry, and decrement it on exit. */\r
        ulFPUInterruptNesting++;\r
-       \r
+\r
        /* Fill the FPU registers with 1. */\r
        vRegTestClearFlopRegistersToParameterValue( 1UL );\r
-       \r
+\r
        /* Trigger a timer 3 interrupt, which will fill the registers with a\r
        different value. */\r
        NVIC_SetPendingIRQ( TIM3_IRQn );\r
@@ -537,7 +490,7 @@ void TIM2_IRQHandler( void )
        registers contain the value to which they were set by this interrupt\r
        function. */\r
        configASSERT( ulRegTestCheckFlopRegistersContainParameterValue( 1UL ) );\r
-       \r
+\r
        ulFPUInterruptNesting--;\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -546,7 +499,7 @@ static void prvOptionallyCreateComprehensveTestApplication( void )
 {\r
        #if ( mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0 )\r
        {\r
-       xTimerHandle xCheckTimer = NULL;\r
+       TimerHandle_t xCheckTimer = NULL;\r
 \r
                /* Configure the interrupts used to test FPU registers being used from\r
                nested interrupts. */\r
@@ -565,28 +518,28 @@ static void prvOptionallyCreateComprehensveTestApplication( void )
 \r
                /* Most importantly, start the tasks that use the FPU. */\r
                vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
-               \r
+\r
                /* Create the register check tasks, as described at the top of this\r
                file */\r
-               xTaskCreate( vRegTest1Task, ( signed char * ) "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
-               xTaskCreate( vRegTest2Task, ( signed char * ) "Reg2", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
+               xTaskCreate( vRegTest1Task, "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
+               xTaskCreate( vRegTest2Task, "Reg2", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
 \r
                /* Create the semaphore that is used to demonstrate a task being\r
                synchronised with an interrupt. */\r
                vSemaphoreCreateBinary( xTestSemaphore );\r
 \r
                /* Create the task that is unblocked by the demonstration interrupt. */\r
-               xTaskCreate( prvButtonTestTask, ( signed char * ) "BtnTest", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
-               \r
+               xTaskCreate( prvButtonTestTask, "BtnTest", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
+\r
                /* Create the software timer that performs the 'check' functionality,\r
                as described at the top of this file. */\r
-               xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */\r
-                                                                       ( mainCHECK_TIMER_PERIOD_MS ),          /* The timer period, in this case 3000ms (3s). */\r
-                                                                       pdTRUE,                                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
-                                                                       ( void * ) 0,                                           /* The ID is not used, so can be set to anything. */\r
-                                                                       prvCheckTimerCallback                           /* The callback function that inspects the status of all the other tasks. */\r
-                                                                 );    \r
-               \r
+               xCheckTimer = xTimerCreate( "CheckTimer",                                       /* A text name, purely to help debugging. */\r
+                                                                       ( mainCHECK_TIMER_PERIOD_MS ),  /* The timer period, in this case 3000ms (3s). */\r
+                                                                       pdTRUE,                                                 /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
+                                                                       ( void * ) 0,                                   /* The ID is not used, so can be set to anything. */\r
+                                                                       prvCheckTimerCallback                   /* The callback function that inspects the status of all the other tasks. */\r
+                                                                 );\r
+\r
                if( xCheckTimer != NULL )\r
                {\r
                        xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
@@ -616,12 +569,12 @@ long lHigherPriorityTaskWoken = pdFALSE;
        /* Only line 6 is enabled, so there is no need to test which line generated\r
        the interrupt. */\r
        EXTI_ClearITPendingBit( EXTI_Line6 );\r
-       \r
+\r
        /* This interrupt does nothing more than demonstrate how to synchronise a\r
        task with an interrupt.  First the handler releases a semaphore.\r
        lHigherPriorityTaskWoken has been initialised to zero. */\r
        xSemaphoreGiveFromISR( xTestSemaphore, &lHigherPriorityTaskWoken );\r
-       \r
+\r
        /* If there was a task that was blocked on the semaphore, and giving the\r
        semaphore caused the task to unblock, and the unblocked task has a priority\r
        higher than the currently executing task (the task that this interrupt\r
@@ -663,7 +616,7 @@ void vApplicationIdleHook( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
+void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
 {\r
        ( void ) pcTaskName;\r
        ( void ) pxTask;\r