mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-30 05:40:45 +00:00
examples/foc: terminate main loop if FOC control loop terminated
This commit is contained in:
parent
19b9c2371c
commit
f38d7d2ed3
1 changed files with 34 additions and 0 deletions
|
|
@ -458,6 +458,33 @@ errout:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: foc_threads_terminated
|
||||
****************************************************************************/
|
||||
|
||||
static bool foc_threads_terminated(void)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
pthread_mutex_unlock(&g_cntr_lock);
|
||||
|
||||
if (1
|
||||
#ifdef CONFIG_INDUSTRY_FOC_FLOAT
|
||||
&& g_float_thr_cntr <= 0
|
||||
#endif
|
||||
#ifdef CONFIG_INDUSTRY_FOC_FIXED16
|
||||
&& g_fixed16_thr_cntr <= 0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&g_cntr_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: foc_threads_init
|
||||
****************************************************************************/
|
||||
|
|
@ -931,6 +958,13 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
/* Terminate main loop if threads terminated */
|
||||
|
||||
if (foc_threads_terminated() == true)
|
||||
{
|
||||
terminate = true;
|
||||
}
|
||||
|
||||
usleep(MAIN_LOOP_USLEEP);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue