1 在app_task_config.h 的最后添加 (hal_task_config.h)
#if 1
/*************************Task CFG Begin****************/
/*task_indx_type*/
task_index(INDX_UART)
/*module_type and mod_task_g*/
task_module_map(INDX_UART, MOD_UART_CLIENT)
/*task's parameters*/
task_name("UART")
task_queue_name("UART Q")
task_priority(TASK_PRIORITY_USB+1)
task_stack_size(2048)
task_create_function(uart_client_create)
task_stack_internalRAM(KAL_FALSE)
task_external_queue_size(10)
task_internal_queue_size(0)
task_boot_mode(NORMAL_M)
/*************************Task CFG END******************/
#endif
注意: 1 添加在文件app_task_config.h 的后面
2 不要在INDX_TST_FTRANS 之前添加任务否则你会得到运行时错误,
3 task_index(INDX_UART) 放在最前,
2 添加ID
在user_msgid_app.h文件最后添加
/************************************************************/
#ifdef KAL_MSGID_EXPANSION
#include "uart_client_sap.h"
MSG_ID_NAME(UART_CLIENT)
#else/*KAL_MSGID_EXPANSION*/
MSG_ID_RANGE(UART_CLIENT, 100)
#endif
/************************************************************/
在E:\kfree\project_one\MT2503D\SOURCE\interface\inet_ps 下创建 uart_client_sap.h
在文件中添加ID:
MSG_ID_UART_READ_REQ = MSG_ID_UART_CODE_BEGIN,
MSG_ID_UART_WRITE_REQ = MSG_ID_UART_CODE_IND,
3 创建一个文件E:\kfree\project_one\MT2503D\SOURCE\hal\peripheral\src\uart_client_test.c ,实现 task接口函数
kal_bool uart_client_create(comptask_handler_struct **handle)
{
static const comptask_handler_struct l1sp_handler_info =
{
uart_cliend_main, /* task entry function */
NULL, /* task initialization function */
NULL, /* task configuration function */
NULL, /* task reset handler */
NULL /* task termination handler */
};
*handle = (comptask_handler_struct *)&l1sp_handler_inf; //返回一个结构体
return KAL_TRUE;
}
static void jt_task_main(task_entry_struct * task_entry_ptr)
{
kal_uint32 my_index;
ilm_struct current_ilm;
kal_get_my_task_index(&my_index);
while (1)
{
receive_msg_ext_q(task_info_g[task_entry_ptr->task_indx].task_ext_qid,¤t_ilm);
stack_set_active_module_id( my_index, current_ilm.dest_mod_id );
if (ilm_ptr->msg_id == MSG_ID_UART_READ_REQ)
{
//消息处理
}
free_ilm(¤t_ilm);
}
}
4 在make/peripheral/peripheral.mak 文件中添加main文件路径(SRC_LIST 变量后添加)
SRC_LIST = hal\peripheral\src\dcl_eint.c \
hal\peripheral\src\auxmain.c \
hal\peripheral\src\uart_client_test.c
5 发送消息给自己创建的task(给MOD_JT发送MSG_ID_JT_STARTUP_REQ信号)
//实现结构体的内容,最终通过msg_send_int_queue(ilm_ptr)将数据发送到内容去
typedef struct ilm_struct {
module_type src_mod_id; //源 mod id
module_type dest_mod_id; //目的 mod id
sap_type sap_id; // Service Access Pointer Identifier 不清楚干什么用的
msg_type msg_id; // 消息 id 就是上面创建的消息 id(相当全局变量)
local_para_struct *local_para_ptr; //消息信息载体 1
peer_buff_struct *peer_buff_ptr; //消息信息载体 2
} ilm_struct;
==============================================
ilm_struct *ilm_ptr = NULL;
ilm_ptr = allocate_ilm(MOD_MMI); //申请空间,相当malloc()
ilm_ptr->msg_id = (msg_type) MSG_ID_JT_STARTUP_REQ;
ilm_ptr->local_para_ptr = NULL;//(local_para_struct*) local_data;
ilm_ptr->peer_buff_ptr = NULL;
SEND_ILM(MOD_MMI, MOD_JT, MMI_L4C_SAP, ilm_ptr);
|
ilm_ptr->src_mod_id = src_mod;
ilm_ptr->dest_mod_id = dest_mod;
ilm_ptr->sap_id = sap;
if (mod_task_g[src_mod] == mod_task_g[dest_mod]) {
msg_send_int_queue(ilm_ptr); //最终调用的函数
example:
#if 0 //给MOD_UART_CLIENT 发送信息
ilm_struct *ilm_ptr = NULL; //到用时要放在定义的地方
ilm_ptr = allocate_ilm(MOD_MMI); //申请空间,相当malloc()
ilm_ptr->msg_id = (msg_type) MSG_ID_UART_READY_TO_WRITE_IND;
ilm_ptr->local_para_ptr = NULL;//(local_para_struct*) local_data;
ilm_ptr->peer_buff_ptr = NULL;
SEND_ILM(MOD_MMI, MOD_UART_CLIENT, MMI_L4C_SAP, ilm_ptr);
#endif
6 获取数据(有数据接收,没数据等待)
receive_msg_ext_q(task_info_g[task_entry_ptr->task_indx].task_ext_qid, ¤t_ilm);
问题:自己创建的mod id 不是原来串口的id
MTK task
最新推荐文章于 2019-04-23 11:45:00 发布