rusEFI
The most advanced open source ECU
thread_priority.h
Go to the documentation of this file.
1 /**
2  * @file thread_priority.h
3  * @brief This file sets the thread priority for the threads running on rusEFI
4  *
5  * @date February 27, 2021
6  * @author Matthew Kennedy, (c) 2021
7  */
8 
9 #pragma once
10 
11 // ADC and ETB get highest priority - not much else actually runs the engine
12 #define PRIO_ADC (NORMALPRIO + 10)
13 #define PRIO_ETB (NORMALPRIO + 9)
14 
15 // GPIO chips should be fast and go right back to sleep, plus can be timing sensitive
16 #define PRIO_GPIOCHIP (NORMALPRIO + 8)
17 
18 // TX higher priority than RX because the ECU is generally the one transmitting the highest priority messages
19 #define PRIO_CAN_TX (NORMALPRIO + 7)
20 #define PRIO_CAN_RX (NORMALPRIO + 6)
21 
22 // Less critical harware
23 #define PRIO_SERVO (NORMALPRIO + 5)
24 #define PRIO_STEPPER (NORMALPRIO + 5)
25 
26 // Logging buffer flush is *slightly* above PRIO_CONSOLE so that we don't starve logging buffers during initialization and console commands
27 #define PRIO_TEXT_LOG (NORMALPRIO + 4)
28 
29 #define TCPIP_THREAD_PRIO (NORMALPRIO + 3)
30 #define LWIP_THREAD_PRIORITY (NORMALPRIO + 2)
31 
32 // Console thread
33 #define PRIO_CONSOLE (NORMALPRIO + 1)
34 
35 #define WIFI_THREAD_PRIORITY (NORMALPRIO)
36 
37 // Less important things
38 #define PRIO_MMC (NORMALPRIO - 1)
39 
40 // These can get starved without too much adverse effect
41 #define PRIO_AUX_SERIAL NORMALPRIO
42 #define PRIO_KNOCK_PROCESS (NORMALPRIO - 10)
43 #define PRIO_HIP9011 (NORMALPRIO - 10)
44 #define PRIO_BENCH_TEST (NORMALPRIO - 10)
45 
46 // These are intentionally low priority so they can't get in the way of anything else
47 #define PRIO_FLASH_WRITE LOWPRIO + 20
48 
49 // USB mass storage
50 #define MSD_THD_PRIO LOWPRIO + 20
51 
52 // Lua interpreter must be lowest priority, as the user's code may get stuck in an infinite loop
53 #define PRIO_LUA LOWPRIO + 10
54 
55 // MAX31855 driver
56 #define MAX31855_PRIO NORMALPRIO