typedef struct
{
osThreadAttr_t attr;
osThreadFunc_t func;
uint32_t *task_handle;
CreateQueueFunction_t create_queue_fn_p;
} app_task_definition_t;
app_task_definition_t app_tasks[] =
{
{{"user_task", 0, NULL, 0, NULL, (500), TASK_PRIORITY, 0, 0}, (osThreadFunc_t)user_main, NULL, user_create_queue}
}
void app_os_init( void * unused1, unsigned int unused2 )
{
UNUSED( unused1 );
UNUSED( unused2 );
// Create queues before tasks in case they are used during initialisation.
for (uint8 i = 0; i < M_NUM_TASKS; i++)
{
if (app_tasks[i].create_queue_fn_p)
{
app_tasks[i].create_queue_fn_p();
}
}
// Now create tasks
for (uint8 i = 0; i < M_NUM_TASKS; i++)
{
app_tasks[i].task_handle = osThreadNew(app_tasks[i].func, NULL, &(app_tasks[i].attr));
if(app_tasks[i].task_handle == NULL)
{
panic(PANIC_TASK_CREATE_FAILED, i);
}
}
}
网友评论