This driver offers configuration as well as checking the status of the touch sensor.
The communication with the sensor is done via the TWI interface and a change of the sensor status is signalled via a GPIO. The driver offers the possibility to add callback function from the application which will be executed each time a change in the sensor is detected.
#define AT42QT1060_ACTIVE_LEVEL_MASK 0x1C |
#define AT42QT1060_AKS_MASK 0x19 |
#define AT42QT1060_CAL 0x80 |
#define AT42QT1060_CALIBRATE 0x0C |
#define AT42QT1060_CHIP_ID 0x00 |
#define AT42QT1060_DETECTION_MASK 0x1B |
#define AT42QT1060_DETECTION_STATUS 0x04 |
#define AT42QT1060_DEVICE_MINOR_VERSION 0x00 |
#define AT42QT1060_DEVICE_VERSION 0x03 |
#define AT42QT1060_DI 0x1E |
#define AT42QT1060_DRIFT_OPTION 0x0E |
#define AT42QT1060_INPUT_PORT_STATUS 0x05 |
#define AT42QT1060_IO_0 0x01 |
#define AT42QT1060_IO_1 0x02 |
#define AT42QT1060_IO_2 0x04 |
#define AT42QT1060_IO_3 0x08 |
#define AT42QT1060_IO_4 0x10 |
#define AT42QT1060_IO_5 0x20 |
#define AT42QT1060_IO_6 0x40 |
#define AT42QT1060_IO_MASK 0x17 |
#define AT42QT1060_KEY_0 0x01 |
#define AT42QT1060_KEY_0_NTHR 0x10 |
#define AT42QT1060_KEY_0_REF_DATA_LSB 0x34 |
#define AT42QT1060_KEY_0_REF_DATA_MSB 0x35 |
#define AT42QT1060_KEY_0_SIGNAL_LSB 0x28 |
#define AT42QT1060_KEY_0_SIGNAL_MSB 0x29 |
#define AT42QT1060_KEY_1 0x02 |
#define AT42QT1060_KEY_1_NTHR 0x11 |
#define AT42QT1060_KEY_1_REF_DATA_LSB 0x36 |
#define AT42QT1060_KEY_1_REF_DATA_MSB 0x37 |
#define AT42QT1060_KEY_1_SIGNAL_LSB 0x2A |
#define AT42QT1060_KEY_1_SIGNAL_MSB 0x2B |
#define AT42QT1060_KEY_2 0x04 |
#define AT42QT1060_KEY_2_NTHR 0x12 |
#define AT42QT1060_KEY_2_REF_DATA_LSB 0x38 |
#define AT42QT1060_KEY_2_REF_DATA_MSB 0x39 |
#define AT42QT1060_KEY_2_SIGNAL_LSB 0x2C |
#define AT42QT1060_KEY_2_SIGNAL_MSB 0x2D |
#define AT42QT1060_KEY_3 0x08 |
#define AT42QT1060_KEY_3_NTHR 0x13 |
#define AT42QT1060_KEY_3_REF_DATA_LSB 0x3A |
#define AT42QT1060_KEY_3_REF_DATA_MSB 0x3B |
#define AT42QT1060_KEY_3_SIGNAL_LSB 0x2E |
#define AT42QT1060_KEY_3_SIGNAL_MSB 0x2F |
#define AT42QT1060_KEY_4 0x10 |
#define AT42QT1060_KEY_4_NTHR 0x14 |
#define AT42QT1060_KEY_4_REF_DATA_LSB 0x3C |
#define AT42QT1060_KEY_4_REF_DATA_MSB 0x3D |
#define AT42QT1060_KEY_4_SIGNAL_LSB 0x30 |
#define AT42QT1060_KEY_4_SIGNAL_MSB 0x31 |
#define AT42QT1060_KEY_5 0x20 |
#define AT42QT1060_KEY_5_NTHR 0x15 |
#define AT42QT1060_KEY_5_REF_DATA_LSB 0x3E |
#define AT42QT1060_KEY_5_REF_DATA_MSB 0x3F |
#define AT42QT1060_KEY_5_SIGNAL_LSB 0x32 |
#define AT42QT1060_KEY_5_SIGNAL_MSB 0x33 |
#define AT42QT1060_KEY_MASK 0x18 |
#define AT42QT1060_LP_MODE 0x16 |
#define AT42QT1060_MINOR_VERSION 0x02 |
#define AT42QT1060_POS_RECALIBRATION_DELAY 0x0F |
#define AT42QT1060_PWM_LEVEL 0x1F |
#define AT42QT1060_PWM_MASK 0x1A |
#define AT42QT1060_RESET 0x0D |
#define AT42QT1060_USER_OUTPUT_BUFFER 0x1D |
#define AT42QT1060_VERSION 0x01 |
void at42qt1060_calibrate |
( |
void |
| ) |
|
Starts a re-calibration or the sensor.
uint8_t at42qt1060_get_detect_status |
( |
void |
| ) |
|
void at42qt1060_init |
( |
int32_t |
fcpu | ) |
|
Initialize touch sensor with default configuration values.
References AT42QT1060_DI, at42qt1060_get_detect_status(), AT42QT1060_IO_MASK, AT42QT1060_KEY_0_NTHR, AT42QT1060_KEY_1_NTHR, AT42QT1060_KEY_2_NTHR, AT42QT1060_KEY_3_NTHR, AT42QT1060_KEY_4_NTHR, AT42QT1060_KEY_5_NTHR, AT42QT1060_KEY_MASK, AT42QT1060_LP_MODE, at42qt1060_read_reg(), at42qt1060_write_reg(), and cpu_hz.
uint8_t at42qt1060_read_reg |
( |
uint8_t |
reg_index | ) |
|
Read register data.
- Parameters
-
- Returns
- Register value
Read register data.
- Parameters
-
reg_index | Register address. |
- Returns
- Register content.
References twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, cpu_delay_us(), cpu_hz, data, twi_package_t::length, twi_master_read(), twi_master_write(), and TWI_SUCCESS.
Referenced by at42qt1060_get_detect_status(), and at42qt1060_init().
void at42qt1060_register_eic_int |
( |
void(*)(void) |
touch_detect_callback | ) |
|
Register a interrupt handler for the EIC controller.
If the detect signal is on an input of the EIC controller this function can be used to register a interrupt handler for it.
- Parameters
-
touch_detect_callback | Pointer to callback function that should be called when the interrupt triggers. Keep this function as short as possible. |
void at42qt1060_register_int |
( |
void(*)(void) |
touch_detect_callback | ) |
|
void at42qt1060_reset |
( |
void |
| ) |
|
Performs a software reset of the touch sensor.
void at42qt1060_set_low_power_mode |
( |
uint8_t |
lp_mode | ) |
|
Sets the current power mode of the device.
- Parameters
-
lp_mode | Determines the number of 16ms intervals between key measurements. Longer intervals between measurements -> lower power consumption but slower response A value of 0 causes the device to sleep and no measurements are performed. A value of 255 causes the device to enter "free-run" mode where measurements are continuously taken. 1 = 16ms between measurements 2 = 32ms between measurements ... |
void at42qt1060_write_reg |
( |
uint8_t |
reg_index, |
|
|
uint8_t |
data |
|
) |
| |