美文网首页
2019-11-06批量创建任务

2019-11-06批量创建任务

作者: 林定益想去NASA捡垃圾 | 来源:发表于2019-11-06 16:52 被阅读0次
    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);
            }
        }
    
    }
    

    相关文章

      网友评论

          本文标题:2019-11-06批量创建任务

          本文链接:https://www.haomeiwen.com/subject/yeaubctx.html