Atmel Software Framework

Quick start guide for QTouch component

This is the quick start guide for the QTouch device driver for I2C interface, with step-by-step instructions on how to configure and use the driver for a specific use case.

The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.

Basic use case

This basic use case will demonstrate how to use the host TWI interface to read real time touch information from QT devices. It also demonstrates the procedure to read and write the setup block which helps to tune the operating parameters of the device.

Basic Setup Steps

Prerequisites

This module requires the following service

Setup Code Example

Add this to the main loop or a setup function:

struct qt_status status;
struct qt_setup_block setup_block;
enum status_code ret;
// Initialize I2C communication interface
memset((void *)&twi_opt, 0, sizeof(twi_master_options_t));
twi_opt.speed = 50000; // 50K for I2C speed
// Reset QT device
// Check communication is ready and able to read Chip ID
if (ret != STATUS_OK) {
while (1) {
// Infinite loop here
}
}
// Read setup block
qt_read_setup_block(&setup_block);
// TODO:Modify setup block parameters according to application
// Write setup block
qt_write_setup_block(&setup_block);

Setup Workflow

  1. Initialize I2C communication interface
    memset((void *)&twi_opt, 0, sizeof(twi_master_options_t));
    twi_opt.speed = 50000; // 50K for I2C speed
  2. Reset QT device (optional)
  3. Check communication is ready and able to read Chip ID
    if (ret != STATUS_OK) {
    while (1) {
    // Infinite loop here
    }
    }
  4. Read setup block from QT device
    qt_read_setup_block(&setup_block);
  5. Modify parameters in setup block if desired
    // For example, to set Detect Integrator to 5.
    setup_block.detect_integrator = 5;
  6. Wrtie setup block to QT device
    qt_write_setup_block(&setup_block);

Basic Usage Steps

Basic Usage Example

while (1) {
// Read Qtouch status if CHANGE pin is asserted
// Read all status bytes
qt_get_status(&status);
// TODO: process the received data by application
// Add application code here
}
}