24
Atmel AVR8015
32185A-AVR-01/12
tc_start (tc, EXAMPLE_TC_CHANNEL);
Find the function ISR
tc_irq(void);
and add the following code to it:
/* update the current time */
current_time_m+;
/* every 25th ms */
if ((current_time_ms_touch % measurement_period_ms) == 0u)
{
/* set flag: it's time to measure touch */
time_to_measure_touch = 1u;
}
/* clear the interrupt flag. This is a side effect of reading the
TC SR. */
tc_read_sr (EXAMPLE_TC, EXAMPLE_TC_CHANNEL);
Now it’s time to configure our first sensor.
1. We use the following API call to configure a set of buttons. The below is for
configuring sensors channels 8 to 15 as buttons 2 to 9.
for (i = 8u; i < 16u; i++)
{
touch_ret =
touch_qm_sensor_config (SENSOR_TYPE_KEY, (channel_t) i,
(channel_t) i, AKS_GROUP_1, 20u,
HYST_6_25, RES_1_BIT, 0u, &sensor_id);
if (touch_ret != TOUCH_SUCCESS)
{
while (1u);
/* Check API Error return code. */
}
}
Where ‘
i
’ is the channel number assigned to a particular button. Place this under the
label /* Configure 8 single channel keys as Sensor's 2-9. */.
This tells Atmel QMatrix that the sensor corresponding to the particular sensor id
should be treated as a key and is assigned the
i
th
channel. We will look at the other
parameters a little later.
Similarly configure the other buttons under the corresponding labels.
2. To enable a slider using channels 4, 5, 6, and 7 the following code is used:
touch_ret =
touch_qm_sensor_config
(SENSOR_TYPE_SLIDER,
(channel_t)
4u,
(channel_t)
7u,
AKS_GROUP_1,
30u,
HYST_6_25,
RES_8_BIT,
0u,
&sensor_id);
if (touch_ret != TOUCH_SUCCESS)
{
while (1u);
/* Check API Error return code. */
}