在创建任务时要注意,在任务中不要使用太大的内存,因为在创建任务时,已经限制了任务堆栈的大小,如果超过了堆栈的大小,会出错的。
第一步:
在custom_config.h中添加:
typedef enum {
INDX_CUSTOM1 = RPS_CUSTOM_TASKS_BEGIN,
INDX_CUSTOM2,
INDX_MOD_CUSTOM_SOC,
RPS_CUSTOM_TASKS_END
} custom_task_indx_type;
/*************************************************************************
* [Very Important Message]
* 1. Component task's module id (Please add before system service)
* 2. Customers are allowed to create at most 16 task module ID as defined
* in config\include\stack_config.h (MAX_CUSTOM_MODS = 16)
*************************************************************************/
typedef enum {
MOD_CUSTOM1 = MOD_CUSTOM_BEGIN,
MOD_CUSTOM2,
MOD_CUSTOM_SOC,
MOD_CUSTOM_END
} custom_module_type;
第二步:
在custom_config.C中添加:
extern kal_bool socket_customer_ext_create(comptask_handler_struct **handle);
custom_task_indx_type custom_mod_task_g[ MAX_CUSTOM_MODS ] =
{
INDX_CUSTOM1, /* MOD_CUSTOM1 */
INDX_CUSTOM2, /* MOD_CUSTOM2 */
INDX_MOD_CUSTOM_SOC,
INDX_NIL /* Please end with INDX_NIL element */
};
/*************************************************************************
* Global
* custom_comp_config_tbl
*
* DESCRIPTION
* The array contains system component tasks' configuration information
*
* GLOBALS AFFECTED
*
*************************************************************************/
const comptask_info_struct custom_comp_config_tbl[ MAX_CUSTOM_TASKS ] =
{
/* INDX_CUSTOM1 */
{"CUST1", "CUST1 Q", 210, 1024, 10, 0,
#ifdef CUSTOM1_EXIST
custom1_create, KAL_FALSE
#else
NULL, KAL_FALSE
#endif
},
/* INDX_CUSTOM2 */
{"CUST2", "CUST2 Q", 211, 1024, 10, 0,
#ifdef CUSTOM2_EXIST
custom2_create, KAL_FALSE
#else
NULL, KAL_FALSE
#endif
},
{"LH_soc", "LH_soc Q", 212, 1024, 10, 0,
//注意,这个结构体的参数,一定要认真看一下文档,其中的1024 是任务堆栈的大小。
#ifdef LH_SOCKET_EXIST
socket_customer_ext_create, KAL_FALSE
#else
NULL, KAL_FALSE
#endif
},
};
第三步:
在custom1_create.c文件 中添加任务的实现。
kal_bool socket_customer_ext_create(comptask_handler_struct **handle)
以上文档只是记录我的开发过程,方便自己以后查看。