]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c
Final check in before tagging V9.0.0.
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo / src / main.c
index 2e68aed5451c8d2b81534750b969a378a4429589..12935c525dfaa2bfe64fe39e38f477ce8e12e73f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -68,6 +68,9 @@
 */\r
 \r
 /******************************************************************************\r
+ *\r
+ * See http://www.freertos.org/RTOS-Xilinx-Zynq.html for instructions.\r
+ *\r
  * This project provides three demo applications.  A simple blinky style\r
  * project, a more comprehensive test and demo application, and an lwIP example.\r
  * The mainSELECTED_APPLICATION setting (defined in this file) is used to\r
  * !!! IMPORTANT NOTE !!!\r
  * The GCC libraries that ship with the Xilinx SDK make use of the floating\r
  * point registers.  To avoid this causing corruption it is necessary to avoid\r
- * their use.  For this reason main.c contains very basic C implementations of\r
- * the standard C library functions memset(), memcpy() and memcmp(), which are\r
- * are used by FreeRTOS itself.  Defining these functions in the project\r
- * prevents the linker pulling them in from the library.  Any other standard C\r
- * library functions that are used by the application must likewise be defined\r
- * in C.\r
+ * their use unless a task has been given a floating point context.  See\r
+ * http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html\r
+ * for information on how to give a task a floating point context, and how to\r
+ * handle floating point operations in interrupts.  As this demo does not give\r
+ * all tasks a floating point context main.c contains very basic C\r
+ * implementations of the standard C library functions memset(), memcpy() and\r
+ * memcmp(), which are are used by FreeRTOS itself.  Defining these functions in\r
+ * the project prevents the linker pulling them in from the library.  Any other\r
+ * standard C library functions that are used by the application must likewise\r
+ * be defined in C.\r
  *\r
  * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON\r
  * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO\r
@@ -182,11 +189,13 @@ XScuGic xInterruptController;
 \r
 int main( void )\r
 {\r
+       /* See http://www.freertos.org/RTOS-Xilinx-Zynq.html for instructions. */\r
+\r
        /* Configure the hardware ready to run the demo. */\r
        prvSetupHardware();\r
 \r
-       /* The mainSELECTED_APPLICATION setting is described at the top\r
-       of this file. */\r
+       /* The mainSELECTED_APPLICATION setting is described at the top of this\r
+       file. */\r
        #if( mainSELECTED_APPLICATION == 0 )\r
        {\r
                main_blinky();\r
@@ -268,7 +277,7 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
 \r
 void vApplicationIdleHook( void )\r
 {\r
-volatile size_t xFreeHeapSpace;\r
+volatile size_t xFreeHeapSpace, xMinimumEverFreeHeapSpace;\r
 \r
        /* This is just a trivial example of an idle hook.  It is called on each\r
        cycle of the idle task.  It must *NOT* attempt to block.  In this case the\r
@@ -278,9 +287,11 @@ volatile size_t xFreeHeapSpace;
        configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up\r
        RAM. */\r
        xFreeHeapSpace = xPortGetFreeHeapSize();\r
+       xMinimumEverFreeHeapSpace = xPortGetMinimumEverFreeHeapSize();\r
 \r
        /* Remove compiler warning about xFreeHeapSpace being set but never used. */\r
        ( void ) xFreeHeapSpace;\r
+       ( void ) xMinimumEverFreeHeapSpace;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -405,28 +416,53 @@ const uint32_t ulMaxDivisor = 0xff, ulDivisorShift = 0x08;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationGetIdleTaskMemory( StaticTCB_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize )\r
+/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an\r
+implementation of vApplicationGetIdleTaskMemory() to provide the memory that is\r
+used by the Idle task. */\r
+void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )\r
 {\r
-       /* configUSE_STATIC_ALLOCATION is set to 1, so the application has the\r
-       opportunity to supply the buffers that will be used by the Idle task as its\r
-       stack and to hold its TCB.  If these are set to NULL then the buffers will\r
-       be allocated dynamically, just as if xTaskCreate() had been called. */\r
-       *ppxIdleTaskTCBBuffer = NULL;\r
-       *ppxIdleTaskStackBuffer = NULL;\r
-       *pusIdleTaskStackSize = configMINIMAL_STACK_SIZE; /* In words.  NOT in bytes! */\r
+/* If the buffers to be provided to the Idle task are declared inside this\r
+function then they must be declared static - otherwise they will be allocated on\r
+the stack and so not exists after this function exits. */\r
+static StaticTask_t xIdleTaskTCB;\r
+static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];\r
+\r
+       /* Pass out a pointer to the StaticTask_t structure in which the Idle task's\r
+       state will be stored. */\r
+       *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;\r
+\r
+       /* Pass out the array that will be used as the Idle task's stack. */\r
+       *ppxIdleTaskStackBuffer = uxIdleTaskStack;\r
+\r
+       /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.\r
+       Note that, as the array is necessarily of type StackType_t,\r
+       configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
+       *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationGetTimerTaskMemory( StaticTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize )\r
+/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the\r
+application must provide an implementation of vApplicationGetTimerTaskMemory()\r
+to provide the memory that is used by the Timer service task. */\r
+void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )\r
 {\r
-       /* configUSE_STATIC_ALLOCATION is set to 1, so the application has the\r
-       opportunity to supply the buffers that will be used by the Timer/RTOS daemon\r
-       task as its     stack and to hold its TCB.  If these are set to NULL then the\r
-       buffers will be allocated dynamically, just as if xTaskCreate() had been\r
-       called. */\r
-       *ppxTimerTaskTCBBuffer = NULL;\r
-       *ppxTimerTaskStackBuffer = NULL;\r
-       *pusTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; /* In words.  NOT in bytes! */\r
+/* If the buffers to be provided to the Timer task are declared inside this\r
+function then they must be declared static - otherwise they will be allocated on\r
+the stack and so not exists after this function exits. */\r
+static StaticTask_t xTimerTaskTCB;\r
+static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];\r
+\r
+       /* Pass out a pointer to the StaticTask_t structure in which the Timer\r
+       task's state will be stored. */\r
+       *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;\r
+\r
+       /* Pass out the array that will be used as the Timer task's stack. */\r
+       *ppxTimerTaskStackBuffer = uxTimerTaskStack;\r
+\r
+       /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.\r
+       Note that, as the array is necessarily of type StackType_t,\r
+       configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
+       *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
 }\r
 \r
 \r