AT42QTAN0040 ATMEL [ATMEL Corporation], AT42QTAN0040 Datasheet - Page 9

no-image

AT42QTAN0040

Manufacturer Part Number
AT42QTAN0040
Description
Driving the AT42QT2160 QMatrix Sensor IC
Manufacturer
ATMEL [ATMEL Corporation]
Datasheet
10702A–AT42–07/08
/*=====================================================================================
=====================================================================================*/
void main ( void )
{
/*------------------------------- Initialisation -------------------------------------*/
/* (1) Establish communication with the QT2160 touch-sensor */
/* (2) Check that the responding device is a QT2160! */
/*------------------------ End of Initialisation -------------------------------------*/
/*------------------------ Main Loop -------------------------------------------------*/
Function:
/* wait for successful transfer at the QT2160's address - Read Chip-ID */
while ( !ReadQtI2c (QT2160_I2C_ADDRESS, QT_CHIP_ID, 1, &QtData) );
while ( QtData != QT2160_ID );
while (1) {
if ( CHANGE_PIN == CHANGE_ASSERTED_LOW )
{
/* If /CHANGE is asserted, read all status-bytes */
ReadQtI2c ( QT2160_I2C_ADDRESS, QT_GENERAL_STATUS, 5, QtStatus );
/* reading these registers will restore /CHANGE pin to the inactive (hi) state */
/* Has device just reset? */
if ( QtStatus[0] & QT_STATUS_RES )
{
}
/* After any reset, configure device for demo requirements:
The demo uses power-up default values for all touch-related registers.
All keys are enabled by default and the slider is set to use 5-keys.
QtData = QT_GPIO_3;
/* Set GPIO3 for output mode */
WriteQtI2c ( QT2160_I2C_ADDRESS, QT_GPIO_DIR, 1, &QtData );
/* Configure GPIO3 for PWM mode */
WriteQtI2c ( QT2160_I2C_ADDRESS, QT_GPIO_PWM, 1, &QtData );
/* Configure Slider for 8-bit resolution */
QtData = SLIDER_8BIT_RES;
WriteQtI2c ( QT2160_I2C_ADDRESS, QT_SLIDER_OPTIONS, 1, &QtData );
/* Send calibrate command */
QtData = 1;
WriteQtI2c ( QT2160_I2C_ADDRESS, QT_CALIBRATE, 1, &QtData );
main()
/* test /CHANGE pin */
Driving the AT42QT2160
*/
9

Related parts for AT42QTAN0040