⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 昆腾电容触摸按键的开发程序,keil环境下,51单片机控制
💻 C
字号:
/*============================================================================
    Project     QT60xx0 Example code
    File        main.c
    Function    Sample application
    Requires    
    Originated	D Spokes
    
    (c) Quantum Research Group
============================================================================*/
#include "C8051F310.H"
#include <float.h>
#include "common.h"
#include "timer.h"
#include "i2c.h"
#include "qt60xx0.h"

xdata UINT8 Key[3]; /* application storage for QT60xx0 key states */


main ()
{
	UINT16 Time; /* time-stamp used in main loop */


/*****************************************************************/	                                
/* Initialisation here is required for C8051F310 target system and
	should be used as example only */
	
	OSCICN = 0x83;	/* Internal Oscillator Control Register */
    PCA0MD = 0x00;  /* PCA Mode Register - disable watchdog */
	XBR1 = 0xc0;	/* enable crossbar, pull-ups off */

	InitTimer ();	/* start timebase generator - used by main-loop only */
    EA = 1;			/* enable global interrupts */
/****************************************************************/	                                

	InitI2c ();	/* initialise I2c interface */


	/* Specify QT60xx0 I2C device address to QT driver */
	SetQtAddress( 117 );
	
	/* wait for QT60xx0 to respond to I2C read transfers */
	while (!ReadQtKeys());

	/* read the QT60xx0 setup block */
	ReadQtSetup ();

	/* loop forever */
	while (1) {	
		if (CheckTimer (Time, 20) )
		{
			Time = StartTimer();
			if ( ReadQtKeys() )	/* poll QT60xx0 for key states */
			{	/* get key states for onward procesing.... */
				Key[0] = GetQtKeys(0);
				Key[1] = GetQtKeys(1);
				Key[2] = GetQtKeys(2);
			}
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -