1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 /* Notes:
16  * 1. Put all task priority and stack size definition in this file
17  * 2. If the task priority is less than 10, use ESP_TASK_PRIO_MIN + X style,
18  *    otherwise use ESP_TASK_PRIO_MAX - X style
19  * 3. If this is a daemon task, the macro prefix is ESP_TASKD_, otherwise
20  *    it's ESP_TASK_
21  * 4. If the configMAX_PRIORITIES is modified, please make all priority are
22  *    greater than 0
23  * 5. Make sure esp_task.h is consistent between wifi lib and idf
24  * 6. If changing system task priorities, please check the values documented in /api-guides/performance/speed.rst
25  * are up to date
26  */
27 
28 #ifndef _ESP_TASK_H_
29 #define _ESP_TASK_H_
30 
31 #include "sdkconfig.h"
32 #ifndef __ZEPHYR__
33 #include "freertos/FreeRTOS.h"
34 #include "freertos/FreeRTOSConfig.h"
35 #endif
36 
37 #define ESP_TASK_PRIO_MAX (configMAX_PRIORITIES)
38 #define ESP_TASK_PRIO_MIN (0)
39 
40 /* Bt contoller Task */
41 /* controller */
42 #define ESP_TASK_BT_CONTROLLER_PRIO   (ESP_TASK_PRIO_MAX - 2)
43 #ifdef CONFIG_NEWLIB_NANO_FORMAT
44 #define TASK_EXTRA_STACK_SIZE      (0)
45 #else
46 #define TASK_EXTRA_STACK_SIZE      (512)
47 #endif
48 
49 #define BT_TASK_EXTRA_STACK_SIZE      TASK_EXTRA_STACK_SIZE
50 #define ESP_TASK_BT_CONTROLLER_STACK  (3584 + TASK_EXTRA_STACK_SIZE)
51 
52 
53 /* idf task */
54 #define ESP_TASK_TIMER_PRIO           (ESP_TASK_PRIO_MAX - 3)
55 #define ESP_TASK_TIMER_STACK          (CONFIG_ESP_TIMER_TASK_STACK_SIZE +  TASK_EXTRA_STACK_SIZE)
56 #define ESP_TASKD_EVENT_PRIO          (ESP_TASK_PRIO_MAX - 5)
57 #if CONFIG_LWIP_TCPIP_CORE_LOCKING
58 #define ESP_TASKD_EVENT_STACK         (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE + 2048)
59 #else
60 #define ESP_TASKD_EVENT_STACK         (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
61 #endif /* CONFIG_LWIP_TCPIP_CORE_LOCKING */
62 #define ESP_TASK_TCPIP_PRIO           (ESP_TASK_PRIO_MAX - 7)
63 #define ESP_TASK_TCPIP_STACK          (CONFIG_LWIP_TCPIP_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
64 #define ESP_TASK_MAIN_PRIO            (ESP_TASK_PRIO_MIN + 1)
65 #define ESP_TASK_MAIN_STACK           (CONFIG_ESP_MAIN_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
66 #define ESP_TASK_MAIN_CORE            CONFIG_ESP_MAIN_TASK_AFFINITY
67 
68 #endif
69