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

no-image

AT42QTAN0040

Manufacturer Part Number
AT42QTAN0040
Description
Driving the AT42QT2160 QMatrix Sensor IC
Manufacturer
ATMEL [ATMEL Corporation]
Datasheet
6. Source Code
8
/*=====================================================================================
Project:
=====================================================================================*/
typedef unsigned char uint8_t;
enum {
#define QT2160_ID
#define QT_STATUS_SDET
#define QT_STATUS_RES
#define QT_GPIO_1
#define QT_GPIO_2
#define QT_GPIO_3
#define SLIDER_8BIT_RES
#define CHANGE_ASSERTED_LOW
#define QT2160_I2C_ADDRESS
uint8_t QtStatus[5];
uint8_t QtData;
/* Port-assignment for QT2160-interface pins */
sbit SCL
sbit SDA
sbit CHANGE_PIN = P0 ^ 3;
/* I2C driver – Function prototypes */
uint8_t WriteQtI2c ( uint8_t SlaveAddress,
uint8_t ReadQtI2c ( uint8_t SlaveAddress,
QT_CHIP_ID = 0,
QT_KEY_STATUS_2,
QT_RESET,
QT_POS_DRIFT_COMP,
QT_SLIDER_CONTROL,
QT_KEY_BL = 54,
QT_GPO_PWM,
QT_COMM_CHG_KEYS_1,
};
uint8_t WriteAddress, uint8_t WriteLength, uint8_t *WritePtr );
uint8_t ReadAddress, uint8_t ReadLength, uint8_t *ReadPtr );
Driving the AT42QT2160
/* QT2160 registers */
= P0 ^ 7;
= P0 ^ 6;
QT_CODE_VERSION,
QT_SLIDER_POSITION,
QT_LP_MODE,
QT_DI_LIMIT,
QT_SLIDER_OPTIONS,
QT_GPO_DRIVE = 70,
QT_GPIO_PWM,
QT_COMM_CHG_KEYS_2
/* application storage for QT2160 device-status */
/* data buffer used for single-byte read and write transfers */
0x11
0x01
0x80
0x04
0x08
0x10
0x00
AT42QT2160-MMU Example Code
0
0x0d
/* Chip ID (read from device-address 0) */
/* bitmask for Slider-detect bit at device-address 2 */
/* bitmask for Reset bit at device-address 2 */
/* bitmask for GPIO1 */
/* bitmask for GPIO2 */
/* bitmask for GPIO3 */
/* 8-bit resolution (written to device-address 21) */
/* asserted state for /CHANGE pin */
/* I2C address used by demo. I2CA1 = I2CA0 = 0 */
QT_GENERAL_STATUS,
QT_GPIO_READ,
QT_AWAKE_TIMEOUT = 14, QT_NEG_DRIFT_COMP,
QT_NEG_RECAL_DELAY,
QT_KEY_CONTROL,
QT_GPIO_DRIVE,
QT_PWM_LEVEL,
QT_KEY_STATUS_1,
QT_CALIBRATE = 10,
QT_DRIFT_HOLD_TIME,
QT_KEY_NTHR = 38,
QT_GPIO_DIR = 73,
QT_GPIO_WAKE,
10702A–AT42–07/08

Related parts for AT42QTAN0040