22
Atmel AVR8015
32185A-AVR-01/12
The macros for the pin configurability are defined in the
touch_config_at32uc3l.h
.
Now build the project, and if everything has been done as per the guidelines given,
you should be able to build successfully with no errors.
4.4 Task 4: Configure the global options and enable/set the sensors
4.4.1 Setting up the code
Initialize the library.
After this initial configuration, we need to initialize thdone by calling
touch_qm_sensors_calibrate ();
Add the code given below under
the label: /* Initialize touch sensing. */ to initialize Touch Library.
touch_ret = touch_qm_sensors_calibrate ();
if (touch_ret != TOUCH_SUCCESS)
{
while (1u);
}
Adding more Touch Library configuration.
Next, we need to set up some runtime global QMatrix parameters. For this add the
following macros under the label: /* QMATRIX GLOBAL SENSOR CONFIGURATION
INFO. */ in the structure static
touch_qm_config_t qm_config.
QM_DI,
QM_NEG_DRIFT_RATE,
QM_POS_DRIFT_RATE,
QM_MAX_ON_DURATION,
QM_DRIFT_HOLD_TIME,
QM_POS_RECAL_DELAY,
QM_RECAL_THRESHOLD,
These macros are defined in the file
touch_config_at32uc3l.h
. Touch Library will
shift the value specified to the corresponding register offset of the CAT Module.
Adding the timer ISR.
Call
init_timer();
to configure timer ISR to fire regularly. Add this under the label
/* Configure timer to fire ISR regularly. */
Find this function and add the following code to it:
volatile avr32_tc_t *tc = EXAMPLE_TC;
/* options for waveform generation. */
static const tc_waveform_opt_t WAVEFORM_OPT = {
.channel = EXAMPLE_TC_CHANNEL,
/* Channel selection. */
.bswtrg = TC_EVT_EFFECT_NOOP,
/* Software trigger effect on
TIOB. */
.beevt = TC_EVT_EFFECT_NOOP,
/* External event effect on
TIOB. */