@@ -77,7 +77,7 @@ osThreadDef(g_highPriorityThread, highPriorityThreadMainLoop, osPriorityAboveNor
7777osThreadId g_highPriorityThreadHandle;
7878
7979#if defined(EEZ_PLATFORM_STM32)
80- #define HIGH_PRIORITY_QUEUE_SIZE 10
80+ #define HIGH_PRIORITY_QUEUE_SIZE 50
8181#endif
8282
8383#if defined(EEZ_PLATFORM_SIMULATOR)
@@ -117,9 +117,12 @@ static uint32_t g_timer1LastTickCount;
117117
118118// //////////////////////////////////////////////////////////////////////////////
119119
120- void startHighPriorityThread () {
120+ void initHighPriorityMessageQueue () {
121121 g_highPriorityMessageQueueId = osMessageCreate (osMessageQ (g_highPriorityMessageQueue), NULL );
122- g_highPriorityThreadHandle = osThreadCreate (osThread (g_highPriorityThread), nullptr );
122+ }
123+
124+ void startHighPriorityThread () {
125+ g_highPriorityThreadHandle = osThreadCreate (osThread (g_highPriorityThread), nullptr );
123126}
124127
125128void highPriorityThreadOneIter ();
@@ -128,6 +131,8 @@ void highPriorityThreadMainLoop(const void *) {
128131#ifdef __EMSCRIPTEN__
129132 highPriorityThreadOneIter ();
130133#else
134+ g_highPriorityThreadHandle = osThreadGetId ();
135+
131136 while (1 ) {
132137 highPriorityThreadOneIter ();
133138 }
@@ -143,11 +148,6 @@ void highPriorityThreadOneIter() {
143148 psu::onThreadMessage (type, param);
144149 } else {
145150 WATCHDOG_RESET ();
146-
147- if (!g_isBooted) {
148- return ;
149- }
150-
151151 for (int i = 0 ; i < NUM_SLOTS; i++) {
152152 g_slots[i]->tick ();
153153 }
@@ -157,7 +157,7 @@ void highPriorityThreadOneIter() {
157157}
158158
159159bool isPsuThread () {
160- return osThreadGetId () == g_highPriorityThreadHandle;
160+ return !g_isBooted || osThreadGetId () == g_highPriorityThreadHandle;
161161}
162162
163163void sendMessageToPsu (HighPriorityThreadMessage messageType, uint32_t messageParam, uint32_t timeoutMillisec) {
@@ -184,6 +184,8 @@ void lowPriorityThreadMainLoop(const void *) {
184184 lowPriorityThreadOneIter ();
185185 }
186186#else
187+ g_lowPriorityTaskHandle = osThreadGetId ();
188+
187189 while (g_isLowPriorityThreadAlive) {
188190 lowPriorityThreadOneIter ();
189191 }
0 commit comments