]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_IoT_SDK/TaskPool/main.c
Create a project that builds a subset of the dependencies of the IoT SDK that have...
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_IoT_SDK / TaskPool / main.c
1 /* Kernel includes. */\r
2 #include "FreeRTOS.h"\r
3 #include "task.h"\r
4 \r
5 void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );\r
6 void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize );\r
7 \r
8 \r
9 int main( void )\r
10 {\r
11         return 0;\r
12 }\r
13 \r
14 /*-----------------------------------------------------------*/\r
15 \r
16 void vApplicationMallocFailedHook( void )\r
17 {\r
18         /* vApplicationMallocFailedHook() will only be called if\r
19         configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
20         function that will get called if a call to pvPortMalloc() fails.\r
21         pvPortMalloc() is called internally by the kernel whenever a task, queue,\r
22         timer or semaphore is created.  It is also called by various parts of the\r
23         demo application.  If heap_1.c, heap_2.c or heap_4.c is being used, then the\r
24         size of the     heap available to pvPortMalloc() is defined by\r
25         configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()\r
26         API function can be used to query the size of free heap space that remains\r
27         (although it does not provide information on how the remaining heap might be\r
28         fragmented).  See http://www.freertos.org/a00111.html for more\r
29         information. */\r
30         vAssertCalled( __LINE__, __FILE__ );\r
31 }\r
32 /*-----------------------------------------------------------*/\r
33 \r
34 void vApplicationIdleHook( void )\r
35 {\r
36         /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set\r
37         to 1 in FreeRTOSConfig.h.  It will be called on each iteration of the idle\r
38         task.  It is essential that code added to this hook function never attempts\r
39         to block in any way (for example, call xQueueReceive() with a block time\r
40         specified, or call vTaskDelay()).  If application tasks make use of the\r
41         vTaskDelete() API function to delete themselves then it is also important\r
42         that vApplicationIdleHook() is permitted to return to its calling function,\r
43         because it is the responsibility of the idle task to clean up memory\r
44         allocated by the kernel to any task that has since deleted itself. */\r
45 }\r
46 /*-----------------------------------------------------------*/\r
47 \r
48 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
49 {\r
50         ( void ) pcTaskName;\r
51         ( void ) pxTask;\r
52 \r
53         /* Run time stack overflow checking is performed if\r
54         configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook\r
55         function is called if a stack overflow is detected.  This function is\r
56         provided as an example only as stack overflow checking does not function\r
57         when running the FreeRTOS Windows port. */\r
58         vAssertCalled( __LINE__, __FILE__ );\r
59 }\r
60 /*-----------------------------------------------------------*/\r
61 \r
62 void vApplicationTickHook( void )\r
63 {\r
64         /* This function will be called by each tick interrupt if\r
65         configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h.  User code can be\r
66         added here, but the tick hook is called from an interrupt context, so\r
67         code must not attempt to block, and only the interrupt safe FreeRTOS API\r
68         functions can be used (those that end in FromISR()). */\r
69 }\r
70 /*-----------------------------------------------------------*/\r
71 \r
72 void vApplicationDaemonTaskStartupHook( void )\r
73 {\r
74         /* This function will be called once only, when the daemon task starts to\r
75         execute (sometimes called the timer task).  This is useful if the\r
76         application includes initialisation code that would benefit from executing\r
77         after the scheduler has been started. */\r
78 }\r
79 /*-----------------------------------------------------------*/\r
80 \r
81 void vAssertCalled( unsigned long ulLine, const char * const pcFileName )\r
82 {\r
83 volatile uint32_t ulSetToNonZeroInDebuggerToContinue = 0;\r
84 \r
85         /* Called if an assertion passed to configASSERT() fails.  See\r
86         http://www.freertos.org/a00110.html#configASSERT for more information. */\r
87 \r
88         /* Parameters are not used. */\r
89         ( void ) ulLine;\r
90         ( void ) pcFileName;\r
91 \r
92 \r
93         taskENTER_CRITICAL();\r
94         {\r
95                 /* You can step out of this function to debug the assertion by using\r
96                 the debugger to set ulSetToNonZeroInDebuggerToContinue to a non-zero\r
97                 value. */\r
98                 while( ulSetToNonZeroInDebuggerToContinue == 0 )\r
99                 {\r
100                         __asm volatile( "NOP" );\r
101                         __asm volatile( "NOP" );\r
102                 }\r
103         }\r
104         taskEXIT_CRITICAL();\r
105 }\r
106 /*-----------------------------------------------------------*/\r
107 \r
108 /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an\r
109 implementation of vApplicationGetIdleTaskMemory() to provide the memory that is\r
110 used by the Idle task. */\r
111 void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )\r
112 {\r
113 /* If the buffers to be provided to the Idle task are declared inside this\r
114 function then they must be declared static - otherwise they will be allocated on\r
115 the stack and so not exists after this function exits. */\r
116 static StaticTask_t xIdleTaskTCB;\r
117 static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];\r
118 \r
119         /* Pass out a pointer to the StaticTask_t structure in which the Idle task's\r
120         state will be stored. */\r
121         *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;\r
122 \r
123         /* Pass out the array that will be used as the Idle task's stack. */\r
124         *ppxIdleTaskStackBuffer = uxIdleTaskStack;\r
125 \r
126         /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.\r
127         Note that, as the array is necessarily of type StackType_t,\r
128         configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
129         *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;\r
130 }\r
131 /*-----------------------------------------------------------*/\r
132 \r
133 /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the\r
134 application must provide an implementation of vApplicationGetTimerTaskMemory()\r
135 to provide the memory that is used by the Timer service task. */\r
136 void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )\r
137 {\r
138 /* If the buffers to be provided to the Timer task are declared inside this\r
139 function then they must be declared static - otherwise they will be allocated on\r
140 the stack and so not exists after this function exits. */\r
141 static StaticTask_t xTimerTaskTCB;\r
142 static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];\r
143 \r
144         /* Pass out a pointer to the StaticTask_t structure in which the Timer\r
145         task's state will be stored. */\r
146         *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;\r
147 \r
148         /* Pass out the array that will be used as the Timer task's stack. */\r
149         *ppxTimerTaskStackBuffer = uxTimerTaskStack;\r
150 \r
151         /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.\r
152         Note that, as the array is necessarily of type StackType_t,\r
153         configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
154         *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
155 }\r
156 \r