当前位置: 首页 > news >正文

在MTK中添加TASK与常用函数分析

声明TASK的ID和MOD类型
在custom_config.h中custom_task_indx_type添加ID

如:

typedef enum {
INDX_CUSTOM1 = RPS_CUSTOM_TASKS_BEGIN,
INDX_CUSTOM2,
#if defined(__MIIPTS_TASK_SUPPORT__)
INDX_MIIPTS,
#endif
#if defined(__ELIVE_SUPPORT__)
INDX_ELIVE,
#if defined(__ELIVE_IPTV_SUPPORT__) || defined(__ELIVE_RDO_SUPPORT__)
INDX_ELIVECORE,
#endif
#endif
#if defined(__MOTION_SENSOR_SUPPORT_MMI_NEW__)
INDX_GSENSOR,
#endif
#if defined(FLASHLIGHT_LED_SUPPORT)
INDX_FLASHLIGHT,
#endif
#if defined(BCT3288_SUPPORT)
INDX_BCT3288LED,
#endif

#if defined(__OPEN_PLATFORM_SUPPORT__)
INDX_CUSTOM_OPEN,
#if defined(OPEN_CUSTOM_PRODUCT_QQ_DOWN_07A) && !defined(WIN32)
INDX_MQQ,
#endif // #if defined(OPEN_CUSTOM_PRODUCT_QQ_DOWN_07A) && !defined(WIN32)
#endif // #if defined(__OPEN_PLATFORM_SUPPORT__)

RPS_CUSTOM_TASKS_END
} custom_task_indx_type;

中的

#if defined(FLASHLIGHT_LED_SUPPORT)
INDX_FLASHLIGHT,
#endif
为新加ID;

在custom_module_type中添加模块类型

如:

typedef enum {
MOD_CUSTOM1 = MOD_CUSTOM_BEGIN,
MOD_CUSTOM2,
#if defined(__MIIPTS_TASK_SUPPORT__)
MOD_MIIPTS,
#endif
#if defined(__ELIVE_SUPPORT__)
MOD_ELIVE,
#if defined(__ELIVE_IPTV_SUPPORT__) || defined(__ELIVE_RDO_SUPPORT__)
MOD_ELIVECORE,
#endif
#endif
#if defined(__MOTION_SENSOR_SUPPORT_MMI_NEW__)
MOD_SC_GSENSOR,
#endif
#if defined(FLASHLIGHT_LED_SUPPORT)
MOD_FLASHLIGHT,
#endif
#if defined(BCT3288_SUPPORT)
MOD_BCT3288LED,
#endif

#if defined(__OPEN_PLATFORM_SUPPORT__)
MOD_CUSTOM_OPEN,
#if defined(OPEN_CUSTOM_PRODUCT_QQ_DOWN_07A) && !defined(WIN32)
MOD_MQQ,
#endif // #if defined(OPEN_CUSTOM_PRODUCT_QQ_DOWN_07A) && !defined(WIN32)
#endif // #if defined(__OPEN_PLATFORM_SUPPORT__)

MOD_CUSTOM_END
} custom_module_type;

#if defined(FLASHLIGHT_LED_SUPPORT)
MOD_FLASHLIGHT,
#endif
为新加MOD的类型;

在custom_config.c中的数组custom_mod_task_g中把声明的ID加入:

如:

custom_task_indx_type custom_mod_task_g[ MAX_CUSTOM_MODS ] =
{
INDX_CUSTOM1, /* MOD_CUSTOM1 */
INDX_CUSTOM2, /* MOD_CUSTOM2 */
#if defined(__MIIPTS_TASK_SUPPORT__)
INDX_MIIPTS, // MOD_MIIPTS
#endif
#if defined(__ELIVE_SUPPORT__)
INDX_ELIVE,
#if defined(__ELIVE_IPTV_SUPPORT__) || defined(__ELIVE_RDO_SUPPORT__)
INDX_ELIVECORE,
#endif
#endif
#if defined(__MOTION_SENSOR_SUPPORT_MMI_NEW__)
INDX_GSENSOR,
#endif
#if defined(FLASHLIGHT_LED_SUPPORT)
INDX_FLASHLIGHT,
#endif
#if defined(BCT3288_SUPPORT)
INDX_BCT3288LED,
#endif

#if defined(__OPEN_PLATFORM_SUPPORT__)
INDX_CUSTOM_OPEN, /* MOD_CUSTOM_OPEN */
#if defined(OPEN_CUSTOM_PRODUCT_QQ_DOWN_07A) && !defined(WIN32)
INDX_MQQ, /* MOD_QQ */
#endif // #if defined(OPEN_CUSTOM_PRODUCT_QQ_DOWN_07A) && !defined(WIN32)
#endif // #if defined(__OPEN_PLATFORM_SUPPORT__)

INDX_NIL /* Please end with INDX_NIL element */
};
在函数custom_comp_config_tbl中添加TASK的实现函数和TASK的信息声明

如:

{
/* 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
},
#if defined(__MIIPTS_TASK_SUPPORT__)
{"MiiPTS", "MiiPTS Q", 212, 1024*4, 10, 0, miipts_task_create, KAL_FALSE},
#endif
#if defined(__ELIVE_SUPPORT__)
{"ELIVE", "ELIVE Q", KAL_PRIORITY_CLASS17+2, 1024*3, 80, 0,
Elive_create, KAL_FALSE} ,
#if defined(__ELIVE_IPTV_SUPPORT__) || defined(__ELIVE_RDO_SUPPORT__)
{"ELIVECORE", "ELIVECORE Q", KAL_PRIORITY_CLASS17+4, 1024*3, 20, 10,
EliveCoreTask, KAL_FALSE} ,
#endif
#endif

#if defined(__MOTION_SENSOR_SUPPORT_MMI_NEW__)
/* INDX_GSENSOR */
{"Gsensor", "Gsensor Q", 195, 1024, 20, 10,
SC_gsensor_create, KAL_FALSE},
#endif
#if defined(FLASHLIGHT_LED_SUPPORT)
/* INDX_FLASHLIGHT */
{"FLHLT", "FLHLT Q", 200, 1024, 10, 0,
SC_flashlight_create, KAL_FALSE},
#endif
#if defined(BCT3288_SUPPORT)
/* INDX_BCT3288LED */
{"BCT3288", "BCT3288 Q", 200, 1024, 20, 0,
SC_BCT3288Flashlight_create, KAL_FALSE},
#endif


#if defined(__OPEN_PLATFORM_SUPPORT__)
{ "CUSTOPEN", "CUSTOPEN Q", 220, 4096, 64, 0, Open_TaskCreate, KAL_FALSE },
#if defined(OPEN_CUSTOM_PRODUCT_QQ_DOWN_07A) && !defined(WIN32)
{ "MQQ", "MQQ Q", 212, 4096, 100, 10, mqq_create, KAL_FALSE },
#endif // #if defined(OPEN_CUSTOM_PRODUCT_QQ_DOWN_07A) && !defined(WIN32)
#endif // #if defined(__OPEN_PLATFORM_SUPPORT__)

}

中的

#if defined(FLASHLIGHT_LED_SUPPORT)
/* INDX_FLASHLIGHT */
{"FLHLT", "FLHLT Q", 200, 1024, 10, 0,
SC_flashlight_create, KAL_FALSE},
#endif
如果TASK需要与别的TASK交互,要使用消息,消息ID在文件custom_sap.h中定义,该头文件被包含在文件stack_msgs.h中,最终合并入msg_type枚举中。

如:

MSG_ID_CUSTOM1_CUSTOM2 = CUSTOM_MSG_CODE_BEGIN,
MSG_ID_CUSTOM2_CUSTOM1,
#if defined(__MIIPTS_TASK_SUPPORT__)
MSG_ID_MIIPTS_ENCODE_REQ,
MSG_ID_MIIPTS_ENCODE_CNF,
MSG_ID_MIIPTS_DECODE_REQ,
MSG_ID_MIIPTS_DECODE_CNF,
#endif // __MIIPTS_TASK_SUPPORT__
#ifdef __ELIVE_SUPPORT__
MSG_ID_ELIVE_BASE,
MSG_ID_ELIVE_END = MSG_ID_ELIVE_BASE + 50,
#endif
#if defined(__ALLKEY_EINT_FOR_KEYBOARD__)
MSG_ID_ALLKEYBOARD,
#endif
#if defined(__MOTION_SENSOR_SUPPORT_MMI_NEW__)
MSG_ID_GSENSOR_CHECK_START_REQ,
MSG_ID_GSENSOR_CHECK_STOP_REQ,
MSG_ID_GSENSOR_CHECK_ROTATE_IND,
#endif
#if defined(FLASHLIGHT_LED_SUPPORT)
MSG_ID_FLASHLIGHT_PLAY_REQ,
MSG_ID_FLASHLIGHT_STOP_REQ,
#endif
#ifdef __MMI_IMAP__
MSG_ID_IMAP,
#endif
#if defined(FIVE_CLAM_SUPPORT)
MSG_ID_FIVE_CLAM_SUPPORT,
#endif
#if defined(FOUR_CLAM_SUPPORT)
MSG_ID_FOUR_CLAM_SUPPORT,
#endif
#if defined(E73_TWO_CLAM_SUPPORT)
MSG_ID_TWO_CLAM_SUPPORT,
#endif
#if defined(BCT3288_SUPPORT)
MSG_ID_BCT3288FLASHLIGHT_LEFTKEY_PRESS,
MSG_ID_BCT3288FLASHLIGHT_RIGHTKEY_PRESS,
MSG_ID_BCT3288FLASHLIGHT_UPKEY_PRESS,
MSG_ID_BCT3288FLASHLIGHT_DOWNKEY_PRESS,
MSG_ID_BCT3288FLASHLIGHT_RIGHT_ROTATE,
MSG_ID_BCT3288FLASHLIGHT_LEFT_ROTATE,
MSG_ID_BCT3288FLASHLIGHT_MP3_EFFECT,
MSG_ID_BCT3288FLASHLIGHT_STOP_REQ,
MSG_ID_BCT3288FLASHLIGHT_ROTATE_CNF,
#endif
中的

#if defined(FLASHLIGHT_LED_SUPPORT)
MSG_ID_FLASHLIGHT_PLAY_REQ,
MSG_ID_FLASHLIGHT_STOP_REQ,
#endif
再看TASK函数的实现和调用:

kal_bool SC_flashlight_create(comptask_handler_struct **handle)
{
static const comptask_handler_struct custom_handler_info =
{
SC_flashlight_task_main,/* task entry function */
SC_flashlight_init,/* task initialization function */
NULL, /* task configuration function */
NULL, /* task reset handler */
NULL, /* task termination handler */
};

*handle = (comptask_handler_struct *)&custom_handler_info;
return KAL_TRUE;
}

task的处理函数,主要是获取TASK的ID函数kal_get_my_task_index和获取消息内容函数receive_msg_ext_q:
void SC_flashlight_task_main(task_entry_struct * task_entry_ptr)
{
ilm_struct current_ilm;
kal_uint32 my_index;

kal_get_my_task_index(&my_index);

while(1)
{
receive_msg_ext_q( task_info_g[task_entry_ptr->task_indx].task_ext_qid,
&current_ilm);
stack_set_active_module_id( my_index, current_ilm.dest_mod_id);
if(current_ilm.msg_id==MSG_ID_FLASHLIGHT_PLAY_REQ)
{
//ET6204_init();
SC_et6204_play(&current_ilm);
}
else if(current_ilm.msg_id==MSG_ID_FLASHLIGHT_STOP_REQ)
{
StopTimer(LED_FLASH_TIMER);
ET6204_ALL_OFF();
Poweroff_ET6204();
}
free_ilm( &current_ilm);
}
}

初始化函数,进入该TASK里需要初始化的全局变量等:

kal_bool SC_flashlight_init(task_indx_type indx)
{
ET6204_init();
return KAL_TRUE;
}

消息处理函数,主要是收到消息的处理函数,掌握et6204_light_play_ind的定义与使用:

void SC_et6204_play(ilm_struct *ilm_ptr)
{
kal_uint16 et6204_display[7];
int i;
et6204_light_play_ind *play_data = (et6204_light_play_ind *)(ilm_ptr->local_para_ptr);

ET6204_POWER_HIGH;
ET6204_ALL_OFF();
if (get_phnset_led_setting() == 0)
{
ET6204_ALL_OFF();
Poweroff_ET6204();
return;
}

if(play_data->type == 0xf0)
{
et6204_incoming_flag=TRUE;
flash_count = 0;
et6204_incoming_number[et6204_incoming_length] = 0x30+10; //jacky added
et6204_incoming_length ++;
mmi_incoming_start_et6204_ind_nubmer();
return;
}
/*else if(play_data->type == 0x02)
{
et6204_audioplayer_flag = TRUE;
mmi_audioplayer_start_et6204_ind();
return;
}*/
else
{
g_led_count = 0;
g_ec6204_type = play_data->type;
g_ec6204_play_num = play_data->play_num;
mmi_start_et6204();
}
}
消息发送,主要是如何填充消息和发送函数OslMsgSendExtQueue:

void mmi_et6204_stop_display()
{
MYQUEUE Message;
et6204_light_play_ind *et6204_play_req;

ET6204_POWER_LOW;
et6204_incoming_flag = FALSE;
et6204_poweron_flag = FALSE;
et6204_audioplayer_flag = FALSE;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
Message.oslMsgId = MSG_ID_FLASHLIGHT_STOP_REQ;
et6204_play_req = OslConstructDataPtr(sizeof(et6204_light_play_ind));
et6204_play_req->type= 1;

Message.oslDataPtr = (oslParaType*) et6204_play_req;
Message.oslPeerBuffPtr = NULL;
Message.oslSrcId = MOD_MMI;
Message.oslDestId = MOD_FLASHLIGHT;
OslMsgSendExtQueue(&Message);
return;
}
void mmi_et6204_start_display(kal_uint8 type,kal_uint8 play_num)
{
MYQUEUE Message;
et6204_light_play_ind *et6204_play_req;
//kal_prompt_trace(MOD_BMT,"mmi_et6204_start_display::");
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
StopTimer(LED_FLASH_TIMER);
Message.oslMsgId = MSG_ID_FLASHLIGHT_PLAY_REQ;
et6204_play_req = OslConstructDataPtr(sizeof(et6204_light_play_ind));
et6204_play_req->type= type;
et6204_play_req->play_num= play_num;

Message.oslDataPtr = (oslParaType*) et6204_play_req;
Message.oslPeerBuffPtr = NULL;
Message.oslSrcId = MOD_MMI;
Message.oslDestId = MOD_FLASHLIGHT;
OslMsgSendExtQueue(&Message);
return;
}

数据结构:

typedef struct __et6204_light_play_ind
{
LOCAL_PARA_HDR
kal_uint8type;
kal_uint8play_num;
}et6204_light_play_ind;

typedef enum
{
ET6204_POWER_ON,
ET6204_INCOMING_IND,
ET6204_POWER_OFF,
ET6204_AUDIOPLAYER,
ET6204_NEW_MESSAGE,
ET6204_END
}ET6204_LIGHT_ID;

相关文章:

  • 大数据时代必不可少的大数据分析和制作工具大全
  • SubVersion服务器Windows安装指南
  • CentOS里ifcfg的device指的是什么?
  • SQLServer2005批量查询自定义对象脚本
  • 使用Let's encrypt保护你的网络通信
  • SQLServer中求两个字符串的交集
  • 139说客的优势和局限性
  • phpjm php加密的解密过程
  • 被遗忘的SQLServer比较运算符修饰词
  • PHP MySQL 数据字典生成器
  • 设计启动屏幕
  • CentOS 安装NodeJS
  • 潘多拉网吧防火墙 1.0 双线破解
  • 视频弹幕Demo
  • 《杜拉拉升职记》之经典语录
  • 《Java8实战》-第四章读书笔记(引入流Stream)
  • Android 初级面试者拾遗(前台界面篇)之 Activity 和 Fragment
  • Fabric架构演变之路
  • Java 多线程编程之:notify 和 wait 用法
  • javascript 总结(常用工具类的封装)
  • JS创建对象模式及其对象原型链探究(一):Object模式
  • Nodejs和JavaWeb协助开发
  • Python利用正则抓取网页内容保存到本地
  • tensorflow学习笔记3——MNIST应用篇
  • Vue2 SSR 的优化之旅
  • VuePress 静态网站生成
  • 安卓应用性能调试和优化经验分享
  • 闭包--闭包作用之保存(一)
  • 技术攻略】php设计模式(一):简介及创建型模式
  • 猫头鹰的深夜翻译:Java 2D Graphics, 简单的仿射变换
  • 收藏好这篇,别再只说“数据劫持”了
  • 腾讯优测优分享 | 你是否体验过Android手机插入耳机后仍外放的尴尬?
  • 微服务核心架构梳理
  • 正则与JS中的正则
  • ​Python 3 新特性:类型注解
  • ​插件化DPI在商用WIFI中的价值
  • #pragma once与条件编译
  • #WEB前端(HTML属性)
  • (博弈 sg入门)kiki's game -- hdu -- 2147
  • (附源码)spring boot建达集团公司平台 毕业设计 141538
  • (附源码)计算机毕业设计SSM基于java的云顶博客系统
  • (黑马C++)L06 重载与继承
  • (考研湖科大教书匠计算机网络)第一章概述-第五节1:计算机网络体系结构之分层思想和举例
  • (论文阅读30/100)Convolutional Pose Machines
  • (四) Graphivz 颜色选择
  • (四)七种元启发算法(DBO、LO、SWO、COA、LSO、KOA、GRO)求解无人机路径规划MATLAB
  • (原)Matlab的svmtrain和svmclassify
  • (转载)微软数据挖掘算法:Microsoft 时序算法(5)
  • .mysql secret在哪_MYSQL基本操作(上)
  • .net分布式压力测试工具(Beetle.DT)
  • ::before和::after 常见的用法
  • @ConditionalOnProperty注解使用说明
  • @staticmethod和@classmethod的作用与区别
  • [ Linux 长征路第二篇] 基本指令head,tail,date,cal,find,grep,zip,tar,bc,unname
  • [ARC066F]Contest with Drinks Hard