📄 irda_task.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* irda_task.c
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* The file implements irda task that controls LAP/LMP/IAS/TTP flow
*
*
* Author:
* -------
* -------
*
****************************************************************************/
/*******************************************************************************
* Include files
*******************************************************************************/
#include "kal_release.h" /* Basic data type */
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "tst_ltlcom.h"
#include "syscomp_config.h"
#include "task_config.h" /* Task creation */
#include "stacklib.h" /* Basic type for dll, evshed, stacktimer */
#include "stack_timer.h" /* Stack timer */
#include "gprs_flc_kal.h"
#include "gprs_flc_common_data_types.h"
#include "flc_tunable_para.h"
#include "IrFramer_hw.h"
#include "IrFramer_sw.h"
#include "irda_enums.h" /* irda enum */
#include "irconfig.h" /* system configuration */
#include "lap.h" /* LAP source header file */
#include "irda.h"
#include "lmp.h" /* LMP source header file */
#include "ttp.h"
#include "iap_p.h" /* IAP primary stack header file */
#include "iap_s.h" /* IAP secondary stack header file */
#include "iastab.h" /* IAS table configuraton header file */
#include "support.h" /* system support functions */
#include "externs.h" /* system external definitions */
#include "stack_config.h"
#include "kal_trace.h"
#include "irda_trace.h"
/*******************************************************************************
* Internal structure definition
*******************************************************************************/
irda_timer_struct irda_context;
/*******************************************************************************
* Function declaration
*******************************************************************************/
static void irda_main( task_entry_struct * task_entry_ptr );
static kal_bool irda_init(task_indx_type task_indx);
extern kal_uint8 L1SM_GetHandle( void );
/*Sleep Mode Handle*/
kal_uint8 irda_PDNhandle;
/*************************************************************************
* FUNCTION
* irda_create
*
* DESCRIPTION
* This function implements irda task entity's create handler.
*
* PARAMETERS
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_bool
irda_create(comptask_handler_struct **handle)
{
static const comptask_handler_struct irda_handler_info =
{
irda_main, /* task entry function */
irda_init, /* task initialization function */
NULL, /* task configuration function */
NULL, /* task reset handler */
NULL /* task termination handler */
};
*handle = (comptask_handler_struct *)&irda_handler_info;
return KAL_TRUE;
}
/*************************************************************************
* FUNCTION
* check_irda_timer
*
* DESCRIPTION
* This function is used to check timer index
*
* PARAMETERS
* stack_timer_struct* timer_struct
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void check_irda_timer(stack_timer_struct* timer_struct)
{
stack_timer_struct *check_timer_index;
check_timer_index = (stack_timer_struct *) timer_struct;
switch(check_timer_index->timer_indx)
{
case WD_TIMER_INDEX:
if(stack_is_time_out_valid(&irda_context.wd_timer))
Check_WD_Timer();
stack_process_time_out(&irda_context.wd_timer);
break;
case F_TIMER_INDEX:
if(stack_is_time_out_valid(&irda_context.f_timer))
Check_F_Timer();
stack_process_time_out(&irda_context.f_timer);
break;
case P_TIMER_INDEX:
if(stack_is_time_out_valid(&irda_context.p_timer))
Check_P_Timer();
stack_process_time_out(&irda_context.p_timer);
break;
case SLOT_TIMER_INDEX:
Test_primary_query_status();
break;
case MEDIA_TIMER_INDEX:
IrLAP_DISCOVERY_request();
break;
case IRDA_I_FRMAE_TIMER_INDEX:
//if(stack_is_time_out_valid(&irda_context.i_frame_timer))
IrLAP_I_frame_timeout();
break;
default:
break;
}
}
/**************************************************************************
* FUNCTION
* irda_lap_process_external_msgda_timer
*
* DESCRIPTION
* This function is used to process external messages from IRDA driver
* and Timer
* PARAMETERS
* ilm_struct* timer_struct
* RETURNS
* None
*
* GLOBALS AFFECTED
*
**************************************************************************/
void irda_lap_process_external_msg(ilm_struct receive_ilm)
{
stack_timer_struct *stack_timer_ptr;
switch (receive_ilm.msg_id)
{
case MSG_ID_TIMER_EXPIRY:/*Timer*/
stack_timer_ptr = (stack_timer_struct *) receive_ilm.local_para_ptr;
check_irda_timer((stack_timer_struct*) receive_ilm.local_para_ptr);
break;
case MSG_ID_IRDA_READY_TO_WRITE_IND: /*IrFramer*/
IrDA_Task();/*process IrDA frame*/
break;
default:
break;
}
}
/*************************************************************************
* FUNCTION
* irda_main
*
* DESCRIPTION
* This routine creates system service debug task 1.
*
* PARAMETERS
*
* RETURNS
* kal_taskid (Id of the created task)
*
* GLOBALS AFFECTED
*
*************************************************************************/
void
irda_main ( task_entry_struct * task_entry_ptr )
{
kal_uint32 Task_Time = 0;
ilm_struct current_ilm;
kal_uint32 my_index;
//int i;
kal_get_my_task_index (&my_index);
stack_set_active_module_id ( my_index, MOD_LAP );
/*IrDA */
irda_PDNhandle = L1SM_GetHandle();
while ( 1 )
{
Task_Time++;
irda_ttp_lmp_main();
receive_msg_ext_q(task_info_g[task_entry_ptr->task_indx].task_ext_qid, ¤t_ilm );
switch (current_ilm.dest_mod_id)
{
case MOD_TTP:
irda_ttp_process_external_msg(current_ilm);
break;
case MOD_LMP:
irda_lmp_process_external_msg(current_ilm);
break;
case MOD_LAP:
irda_lap_process_external_msg(current_ilm);
break;
default:
break;
}
free_ilm(¤t_ilm);
}
}
/*************************************************************************
* FUNCTION
* irda_init
*
* DESCRIPTION
* This routine creates irda task
*
* PARAMETERS
*
* RETURNS
* kal_taskid (Id of the created task)
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_bool irda_init(task_indx_type task_indx)
{
/*initialize irda protocol*/
#ifdef __MTK_TARGET__
InitBuf();
IrLAP_LINK_init();
init_irda_lmp();
init_irda_ttp();
IAS_Disconnect_Indication();/*@@@ i need to modified this */
IR_Init(CONTENTION_BAUD);
#endif
/* Initialize ILM, and timer */
stack_init_timer(&irda_context.wd_timer, "WD_TIMER", MOD_LAP);
stack_init_timer(&irda_context.f_timer, "F_TIMER", MOD_LAP);
stack_init_timer(&irda_context.p_timer, "P_TIMER", MOD_LAP);
stack_init_timer(&irda_context.slot_timer, "SLOT_TIMER", MOD_LAP);
stack_init_timer(&irda_context.media_timer, "MEDIA_TIMER", MOD_LAP);
stack_init_timer(&irda_context.irda_open_timer,"IrDA Open Timer",MOD_LMP);
stack_init_timer(&irda_context.i_frame_timer, "I_TIMER", MOD_LAP);
return KAL_TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -