CH552/examples/TouchKey/Main.C

59 lines
2.9 KiB
C++
Raw Normal View History

2018-10-17 10:44:45 +02:00
/********************************** (C) COPYRIGHT *******************************
* File Name : Main.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><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
#include "..\Public\CH554.H"
#include "..\Public\Debug.H"
#include "TouchKey.H"
#include "stdio.h"
#pragma NOAREGS
main( )
{
UINT8 i;
CfgFsys( ); //CH554ʱ<34><CAB1>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mDelaymS(5); //<2F>޸<EFBFBD><DEB8><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>оƬ<D0BE><C6AC><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD>
mInitSTDIO( ); //<2F><><EFBFBD><EFBFBD>0<EFBFBD><30>ʼ<EFBFBD><CABC>
printf("start ...\n");
P1_DIR_PU &= 0x0C; //<2F><><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD>
TouchKeyQueryCyl2ms(); //TouchKey<65><79>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>2ms
GetTouckKeyFreeBuf(); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׼ֵ
#if DE_PRINTF
for(i=KEY_FIRST;i<(KEY_LAST+1);i++) //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׼ֵ
{
printf("Channel %02x base sample %04x\n",(UINT16)i,KeyFree[i]);
}
#endif
#if INTERRUPT_TouchKey
EA = 1;
while(1)
{
if(KeyBuf) //key_buf<75><66>0<EFBFBD><30><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
printf("INT TouchKey Channel %02x \n",(UINT16)KeyBuf); //<2F><>ӡ<EFBFBD><D3A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>״̬ͨ<CCAC><CDA8>
KeyBuf = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>־
mDelaymS(100); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>壬ģ<E5A3AC>ⵥƬ<E2B5A5><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
mDelaymS(100); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>壬ģ<E5A3AC>ⵥƬ<E2B5A5><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
#else
while(1)
{
TouchKeyChannelQuery(); //<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
if(KeyBuf) //key_buf<75><66>0<EFBFBD><30><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
printf("Query TouchKey Channel %02x \n",(UINT16)KeyBuf); //<2F><>ӡ<EFBFBD><D3A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>״̬ͨ<CCAC><CDA8>
KeyBuf = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>־
mDelaymS(100); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>壬ģ<E5A3AC>ⵥƬ<E2B5A5><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
mDelaymS(100); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>壬ģ<E5A3AC>ⵥƬ<E2B5A5><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
#endif
}