Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TOUCH - AT42QT1060 QTouch 6-channel sensor

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.

Macros

#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
 

Functions

void at42qt1060_calibrate (void)
 Starts a re-calibration or the sensor. More...
 
uint8_t at42qt1060_get_detect_status (void)
 Gets the touch detect status of the sensor. More...
 
void at42qt1060_init (int32_t fcpu)
 Initialize touch sensor with default configuration values. More...
 
uint8_t at42qt1060_read_reg (uint8_t reg_index)
 Read register data. More...
 
void at42qt1060_register_eic_int (void(*touch_detect_callback)(void))
 Register a interrupt handler for the EIC controller. More...
 
void at42qt1060_register_int (void(*touch_detect_callback)(void))
 Register a pin interrupt handler. More...
 
void at42qt1060_reset (void)
 Performs a software reset of the touch sensor. More...
 
void at42qt1060_set_low_power_mode (uint8_t lp_mode)
 Sets the current power mode of the device. More...
 
void at42qt1060_write_reg (uint8_t reg_index, uint8_t data)
 Write data to a sensor register. More...
 

#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

Referenced by at42qt1060_init().

#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

Referenced by at42qt1060_init().

#define AT42QT1060_KEY_0   0x01
#define AT42QT1060_KEY_0_NTHR   0x10

Referenced by at42qt1060_init().

#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

Referenced by at42qt1060_init().

#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

Referenced by at42qt1060_init().

#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

Referenced by at42qt1060_init().

#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

Referenced by at42qt1060_init().

#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

Referenced by at42qt1060_init().

#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

Referenced by at42qt1060_init().

#define AT42QT1060_LP_MODE   0x16

Referenced by at42qt1060_init().

#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  )

Gets the touch detect status of the sensor.

Returns
Register content of the touch detect register.

References AT42QT1060_DETECTION_STATUS, AT42QT1060_INPUT_PORT_STATUS, at42qt1060_read_reg(), and status.

Referenced by at42qt1060_init().

uint8_t at42qt1060_read_reg ( uint8_t  reg_index)

Read register data.

Parameters
reg_indexRegister index
Returns
Register value

Read register data.

Parameters
reg_indexRegister 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_callbackPointer 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)

Register a pin interrupt handler.

The detect signal from the touch sensor is used to generate a pin interrupt.

Parameters
touch_detect_callbackPointer to callback function that should be called when the interrupt triggers. Keep this function as short as possible.

Register a pin interrupt handler.

References at42qt1060, cpu_irq_restore(), cpu_irq_save(), gpio_clear_pin_interrupt_flag(), gpio_enable_pin_interrupt(), GPIO_FALLING_EDGE, irq_register_handler, and 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_modeDetermines 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 
)

Write data to a sensor register.

Parameters
reg_indexRegister index number
dataRegister data

Write data to a sensor register.

Parameters
reg_indexRegister address. Use macros as defined in the header file.
dataData that should be written to the device register.

References twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, data, twi_package_t::length, twi_master_write(), and TWI_SUCCESS.

Referenced by at42qt1060_init().