您的位置:首页 > 其它

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

2010-05-06 11:43 288 查看
声明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,

¤t_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(¤t_ilm);

}

else
if(current_ilm.msg_id==MSG_ID_FLASHLIGHT_STOP_REQ)

{

StopTimer(LED_FLASH_TIMER);

ET6204_ALL_OFF();

Poweroff_ET6204();

}

free_ilm(
¤t_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_uint8 type;

kal_uint8 play_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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: