81 lines
3.1 KiB
C
81 lines
3.1 KiB
C
|
|
|||
|
/********************************** (C) COPYRIGHT *******************************
|
|||
|
* File Name : Touch_Key.C
|
|||
|
* Author : WCH
|
|||
|
* Version : V1.0
|
|||
|
* Date : 2017/01/20
|
|||
|
* Description : CH554 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>ͨ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*******************************************************************************/
|
|||
|
|
|||
|
#include "CH554.H"
|
|||
|
#include "DEBUG.H"
|
|||
|
#include "Key.h"
|
|||
|
#include "stdio.h"
|
|||
|
|
|||
|
#pragma NOAREGS
|
|||
|
|
|||
|
/*******************************************************************************
|
|||
|
* Function Name : TouchKeyQueryCylSet1Or2ms(UINT8 cyl)
|
|||
|
* Description : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Input : UINT8 cyl ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
1 2ms
|
|||
|
0 1ms
|
|||
|
* Output : None
|
|||
|
* Return : None
|
|||
|
*******************************************************************************/
|
|||
|
void TouchKeyQueryCylSet1Or2ms(UINT8 cyl)
|
|||
|
{
|
|||
|
if(cyl)
|
|||
|
{
|
|||
|
TKEY_CTRL |= bTKC_2MS;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
TKEY_CTRL &= ~bTKC_2MS;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/*******************************************************************************
|
|||
|
* Function Name : TouchKeyChanelSelect(UINT8 ch)
|
|||
|
* Description : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
|||
|
* Input : UINT8 ch <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>
|
|||
|
* Output : None
|
|||
|
* Return : <EFBFBD>ɹ<EFBFBD> SUCCESS
|
|||
|
ʧ<EFBFBD><EFBFBD> FAIL
|
|||
|
*******************************************************************************/
|
|||
|
UINT8 TouchKeyChanelSelect(UINT8 ch)
|
|||
|
{
|
|||
|
TKEY_CTRL &= 0xF8;
|
|||
|
if(ch == 0){;} //<2F>رյ<D8B1><D5B5>ݼ<EFBFBD><DDBC>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD>1ms<6D><73><EFBFBD><EFBFBD>2ms<6D><73>ʱ<EFBFBD>ж<EFBFBD>
|
|||
|
else if(ch == 1){P1_DIR_PU &= 0xFE; TKEY_CTRL |= 0x01;} //TIN0(P10)
|
|||
|
else if(ch == 2){P1_DIR_PU &= 0xFD; TKEY_CTRL |= 0x02;} //TIN0(P11)
|
|||
|
else if(ch == 3){P1_DIR_PU &= 0xEF; TKEY_CTRL |= 0x03;} //TIN0(P14)
|
|||
|
else if(ch == 4){P1_DIR_PU &= 0xDF; TKEY_CTRL |= 0x04;} //TIN0(P15)
|
|||
|
else if(ch == 5){P1_DIR_PU &= 0xBF; TKEY_CTRL |= 0x05;} //TIN0(P16)
|
|||
|
else if(ch == 6){P1_DIR_PU &= 0x7F; TKEY_CTRL |= 0x06;} //TIN0(P17)
|
|||
|
else if(ch == 7){TKEY_CTRL |= 0x07;} //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>⣬<EFBFBD><E2A3AC><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>
|
|||
|
else return FAIL;
|
|||
|
|
|||
|
#if INTERRUPT_TouchKey
|
|||
|
IE_TKEY = 1; //ʹ<><CAB9>Touch_Key<65>ж<EFBFBD>
|
|||
|
#endif
|
|||
|
return SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
#if INTERRUPT_TouchKey
|
|||
|
/*******************************************************************************
|
|||
|
* Function Name : Touch_KeyInterrupt(void)
|
|||
|
* Description : Touch_Key <EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*******************************************************************************/
|
|||
|
void Touch_KeyInterrupt( void ) interrupt INT_NO_TKEY using 1 //Touch_Key<65>жϷ<D0B6><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ʹ<>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD>1
|
|||
|
{
|
|||
|
UINT16 KeyData;
|
|||
|
IE_TKEY = 0; //<2F><><EFBFBD>ж<EFBFBD>
|
|||
|
KeyData = TKEY_DAT; //<2F><><EFBFBD><EFBFBD>87us,<2C><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
|
|||
|
#ifdef DE_PRINTF
|
|||
|
printf("DATA: %04x\n",KeyData&0x7FFF);
|
|||
|
#endif
|
|||
|
}
|
|||
|
#endif
|
|||
|
|