www.pudn.com > drivers.rar > GPIO_DETECT.c
/**************************************************************
Designed by tianhj For Legend Poloview HandSet
DATA: 2003/2/21
VERSION: 2.0
Copyright belong to LEGEND
*****************************************************************/
//#include "..\..\Condat\gpf\inc\nuc\arm7\nucleus.h" /* used for HISR */
#include "GPIO_DETECT.h"
#include "peripherals.h"
//#include "../midi/userapi.h"
//#include "armio.h"
#include "audio/audio_userapi.h"
unsigned char gFlip_Key_Statu,gData_Plug_Statu,gAudio_Plug_Statu;
void TM_Timer1Handler (void);
static T_Dectect_Gpio Dectect_Gpio_hisr = {0};
U8 MmiCcDataPortProcess(U8 cDataPort_Status);
U8 MmiCcEarphoneProcess(U8 cEarphone_Status);
extern void TM_ResetTimer (SYS_UWORD16 timerNum, SYS_UWORD16 countValue,
SYS_UWORD16 autoReload, SYS_UWORD16 clockScale);
#if (CHIPSET != 12) && (CHIPSET != 15)
extern void AI_EnableBit(int bit);
#endif
extern void AI_ConfigBitAsInput(int bit);
extern void AI_ConfigBitAsOutput(int bit);
void Switch_FlashLight(U8 ucOnOff);
// U8 Data_Cable_Detect(void);
U8 Earphone_Hook_Detect(void);
U8 Earphone_Plug_Detect(void);
/*******************************************************************************************
added by zou peng for detect the GPIO condition
Gpio_Detect_hisr 软件中断处理GPIO检测程序
2002/5/17
**********************************************************************************************/
void Dectect_Gp_hisr(void)
{
unsigned short Gpio_Statu_Temp;
Gpio_Statu_Temp = *((volatile unsigned short *) 0xfffe4800); /*read Gpio Input status*/
if((!(Gpio_Statu_Temp&0x01))&&(gData_Plug_Statu==0)) /* judge the Gpio_0 status = low data send */
{
MmiCcDataPortProcess(1); /* inform high program data plug in*/
gData_Plug_Statu = 1;
}
else if((Gpio_Statu_Temp&0x01)&&(gData_Plug_Statu ==1))
{
MmiCcDataPortProcess(0); /* inform high program data plut out */
gData_Plug_Statu = 0;
}
if((Gpio_Statu_Temp&0x08)&&(gAudio_Plug_Statu==0)) /*judge the Gpio_3 status = high data */
{
MmiCcEarphoneProcess(1); /* inform high progam audio plug in*/
gAudio_Plug_Statu = 1;
}
else if((!(Gpio_Statu_Temp&0x08))&&(gAudio_Plug_Statu==1))
{
MmiCcEarphoneProcess(0); /* inform high progam audio plug in*/
gAudio_Plug_Statu = 0;
}
if((!(Gpio_Statu_Temp&0x04))&&(gFlip_Key_Statu == 1)) /*judge the Gpio_2 status = low data */
{
/*inform high program flip key put down*/
gFlip_Key_Statu = 0;
}
if((Gpio_Statu_Temp&0x04)&&(gFlip_Key_Statu == 0)) /*judge the Gpio_2 status = hign data */
{
/*inform high program flip key put up*/
gFlip_Key_Statu = 1;
}
}
/*********************************************************************************
added by zoupeng for detect the GPIO condition
initial timer1
2002/5/15
*********************************************************************************/
void Gpio_Detect_Timer1_init(void)
{
TM_ResetTimer(1,0x252C,1,0x7); /*initial timer1 autoreload 0XC64 = 1S 0X252C = 3S */
*((volatile unsigned short *) 0xfffffa08) &= 0xfffd; /*open the timer interrupt*/
*((volatile unsigned short *) 0xfffe4804) |= 0x9; /* set the GPIO0 GPIO3 OUTPUT*/
gFlip_Key_Statu = 1;
gData_Plug_Statu = 0; /*初始设置数据接口未插入 0未插入 1 已插入*/
gAudio_Plug_Statu = 0; /*初始设置语音接口未插入 0未插入 1 已插入*/
NU_Create_HISR(&Dectect_Gpio_hisr.hisr,
"DECTECT_HISR",
Dectect_Gp_hisr,
2,
Dectect_Gpio_hisr.hisr_stack,
sizeof(Dectect_Gpio_hisr.hisr_stack));
}
/*****************************************************************************
added by zoupeng for detect the GPIO condition
detect the GPIO0 GPIO3
2002/5/15
*******************************************************************************/
void TM_Timer1Handler (void)
{
NU_Activate_HISR(&Dectect_Gpio_hisr.hisr);
}
U8 MmiCcDataPortProcess(U8 cDataPort_Status)
{
return 1;
}
U8 MmiCcEarphoneProcess(U8 cEarphone_Status)
{
return 1;
}
/********************************************************************
* function:
* Switch_FlashLight()
* description:
* [ Control the switch of flash light by GPIO10 ]
* Input:
* onoff 1-Open Light
* 0-Close Light
* Output:
* void
* created by: fangcj
* created time: 2005/12/31
* modified history:
* 1)
* 2)
***********************************************************************/
void Switch_FlashLight(U8 ucOnOff)
{
#if (LEN_PDT_ID == 1)
return;
#endif
//maggie add 2007-10-10
#if (LEN_PDT_ID == 3)
return;
#endif
//add end
#if (CHIPSET != 12) && (CHIPSET != 15)
AI_EnableBit(6);
#endif
AI_ConfigBitAsOutput(10);
if(ucOnOff)
{
AI_SetBit(10);
}
else
{
AI_ResetBit(10);
}
return;
}
#if 0
/**************************************************************************
Added by Tianhj for detect DATA_DETECT
detect the GPIO10
2002/9/29
***************************************************************************/
U8 Data_Cable_Detect(void)
{
unsigned short Gpio_Statu;
AI_EnableBit(6);
AI_ConfigBitAsInput(10);
Gpio_Statu = *((volatile unsigned short *) 0xfffe4800); /*read Gpio Input status*/
if(Gpio_Statu & 0x0400)
return 0;
else
return 1;
}
#endif
/*********************
check hook status
**********************/
U8 Earphone_Hook_Detect(void)
{
return drvGetHookCurStatus();
}
/*********************
check jack status
**********************/
U8 Earphone_Plug_Detect(void)//jack
{
return drvGetJackCurStatus();
}
/*************************************************************************
Added by yulei for change the uart/earphone
GPIO4 = 0,select the uart function.
2004/5/11
**************************************************************************/
void Switch_Uart(void)
{
;
}
/*************************************************************************
Added by yulei for change the uart/earphone
GPIO4 = 1,select the earphone function.
2004/5/11
**************************************************************************/
void Switch_Earphone(void)
{
;
}