Atmel Software Framework

Quick start guide for the maXTouch component

This is the quick start guide for the maXTouch component The guide will give you a step-by-step introduction on how to setup and use the component to be able to read touch responses from the maXTouch Xplained kit.

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

In this basic use case, the maXTouch component is configured for:

  • Checking the defined CHG pin is indicating messages in the queue
  • Reading touch events from the device

Note: In this basic use case the application code will check for new events by polling of the CHG pin. The application code can be modified into receiving interrupts on touch events by configuring a pin change interrupt on the CHG pin.

Setup steps

Prerequisites

For the setup code of this use csse to work, the following is needed:

  1. An empty XMEGA-A1 Xplained board project.
  2. A XMEGA-A1 Xplained kit.
  3. A mXT143E Xplained top module with pre-loaded configuration mounted on the XMEGA-A1 Xplained kit.

Example code

Add to the initialization code:

Workflow

  1. define a variable of type struct mxt_device, a pointer to this struct must be available to every function using the maXTouch component API:
  2. call the maXTouch component probe function to check if there is any maXTouch device on the defined bus and address:
  3. call the maXTouch component init function to initialize the component. On the XMEGA-A1 Xplained you have use the TWIF module for data communication and pin 2 on port F as CHG pin interface:
  4. then we have to do a softreset of the maXTouch device to get it into a known state:
  5. We have to wait for the reset to complete:
  6. The last ting we have to do before the device is ready for use is to set the CHG pin modus to 1. Which means that the pin will stay low until the message queue is empty instead of strobing each time a new message is received. To achieve that we write 1 to the CHG_MODE bit position in the T18 objects control register:

Example code

// Add to application:
#define LED_PORT PORTE
int function read_touch(struct mxt_device &device,
struct mxt_touch_event *touch_event)
{
return mxt_read_touch_event(device, touch_event);
return ERR_TIMEOUT;
}

Workflow

  1. check if there is any messages waiting in the queue:
  2. if there is any messages pending, check if any of these messages is a touch event and store it in the touch_event variable. Return with the return value from the mxt_read_touch_event function:
  3. if no pending message was found, return with ERR_TIMEOUT code: