//! \brief Configure the Sensors as keys and Rotor/Sliders for 32 channels only. static void config_32ch_krs(void) { // enable sensor 0: a keys on channel 0 qt_enable_key( CHANNEL_0, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 1: a slider on channels 1..3 qt_enable_slider( CHANNEL_1, CHANNEL_3, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); // enable sensor 2: a key on channel 4 qt_enable_key( CHANNEL_4, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 3: a rotor on channels 5..7 qt_enable_rotor( CHANNEL_5, CHANNEL_7, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); // enable sensor 4: a keys on channel 8 qt_enable_key( CHANNEL_8, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 5: a slider on channels 9..11 qt_enable_slider( CHANNEL_9, CHANNEL_11, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); // enable sensor 6: a keys on channel 12 qt_enable_key( CHANNEL_12, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 7: a slider on channels 13..15 qt_enable_rotor( CHANNEL_13, CHANNEL_15, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); // enable sensor 0: a keys on channel 0 qt_enable_key( CHANNEL_16, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 1: a slider on channels 1..3 qt_enable_slider( CHANNEL_17, CHANNEL_19, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); // enable sensor 2: a key on channel 4 qt_enable_key( CHANNEL_20, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 3: a rotor on channels 5..7 qt_enable_rotor( CHANNEL_21, CHANNEL_23, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); // enable sensor 4: a keys on channel 8 qt_enable_key( CHANNEL_24, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 5: a slider on channels 9..11 qt_enable_slider( CHANNEL_25, CHANNEL_27, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); // enable sensor 6: a keys on channel 12 qt_enable_key( CHANNEL_28, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 7: a slider on channels 13..15 qt_enable_rotor( CHANNEL_29, CHANNEL_31, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); }
static void config_32ch_krs(void) { /* enable sensors 0..7: keys on channels 0..7 */ qt_enable_key( CHANNEL_0, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_1, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_2, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_3, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_4, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_5, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_6, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_7, AKS_GROUP_1, 10u, HYST_6_25 ); /* enable sensors 8..15: keys on channels 8..15 */ qt_enable_key( CHANNEL_8, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_9, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_10, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_11, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_12, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_13, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_14, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_15, AKS_GROUP_1, 10u, HYST_6_25 ); /* enable sensors : rotor on channels respectively */ qt_enable_rotor( CHANNEL_16, CHANNEL_19, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); /* enable sensors : rotor on channels respectively */ qt_enable_rotor( CHANNEL_20, CHANNEL_23, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); /* enable sensors : slider on channels respectively */ qt_enable_slider( CHANNEL_24, CHANNEL_27, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); /* enable sensors : slider on channels respectively */ qt_enable_slider( CHANNEL_28, CHANNEL_31, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); }
/** * \brief Configure the sensors. */ static void config_sensors(void) { qt_enable_slider(BOARD_SLIDER_START_CHANNEL, BOARD_SLIDER_END_CHANNEL, AKS_GROUP_1, 16u, HYST_6_25, RES_8_BIT, 0u); qt_enable_key(BOARD_LEFT_KEY_CHANNEL, AKS_GROUP_1, 18u, HYST_6_25); qt_enable_key(BOARD_RIGHT_KEY_CHANNEL, AKS_GROUP_1, 18u, HYST_6_25); }
/*============================================================================ Name : config_sensors - ------------------------------------------------------------------------------ Purpose : Configure the sensors Input : n/a Output : n/a Notes : Generated code from QTouch Studio. Do not change ============================================================================*/ static void config_sensors(void) { qt_enable_key( CHANNEL_3, NO_AKS_GROUP, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_4, NO_AKS_GROUP, 10u, HYST_6_25 ); qt_enable_slider( CHANNEL_0, CHANNEL_2, NO_AKS_GROUP, 10u, HYST_6_25, RES_8_BIT, 0u ); }
static void config_8ch_krs(void) { /* enable sensor 0: a rotor on channels 0..3 */ qt_enable_rotor( CHANNEL_0, CHANNEL_3, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); /* enable sensors 1: wlider on channels 4..7 respectively */ qt_enable_slider( CHANNEL_4, CHANNEL_7, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); }
static void config_8ch_krs(void) { // enable sensor 0: a key on channel 0 qt_enable_key( CHANNEL_0, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 1: a slider on channels 1..3 */ qt_enable_slider( CHANNEL_1, CHANNEL_3, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u); // enable sensor 2: a key on channel 4 qt_enable_key( CHANNEL_4, AKS_GROUP_2, 10u, HYST_6_25 ); // enable sensor 3: a rotor on channels 5..7 qt_enable_rotor( CHANNEL_5, CHANNEL_7, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); }
static void config_16ch_krs(void) { /* enable sensors 0..7: keys on channels 0..7 */ qt_enable_key( CHANNEL_0, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_1, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_2, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_3, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_4, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_5, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_6, AKS_GROUP_1, 10u, HYST_6_25 ); qt_enable_key( CHANNEL_7, AKS_GROUP_1, 10u, HYST_6_25 ); /* enable sensor 8: a rotor on channels 8..11 */ qt_enable_rotor( CHANNEL_8, CHANNEL_11, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); /* enable sensors 9: sliders on channels 12..15 respectively */ qt_enable_slider( CHANNEL_12, CHANNEL_15, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); }
/** * \brief Initializes the touch measurement timer. * * We need a timer that triggers approx. every millisecond. * The touch library seems to need this as time-base. */ static void init_timer(void) { volatile avr32_tc_t *tc = TOUCH_MEASUREMENT_TC; const tc_waveform_opt_t waveform_options = { .channel = TOUCH_MEASUREMENT_TC_CHANNEL, //! Software trigger effect on TIOB. .bswtrg = TC_EVT_EFFECT_NOOP, //! External event effect on TIOB. .beevt = TC_EVT_EFFECT_NOOP, //! RC compare effect on TIOB. .bcpc = TC_EVT_EFFECT_NOOP, //! RB compare effect on TIOB. .bcpb = TC_EVT_EFFECT_NOOP, //! Software trigger effect on TIOA. .aswtrg = TC_EVT_EFFECT_NOOP, //! External event effect on TIOA. .aeevt = TC_EVT_EFFECT_NOOP, //! RC compare effect on TIOA: toggle. .acpc = TC_EVT_EFFECT_NOOP, //! RA compare effect on TIOA: toggle. .acpa = TC_EVT_EFFECT_NOOP, //! Waveform selection .wavsel = TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER, //! External event trigger enable. .enetrg = 0, //! External event selection. .eevt = 0, //! External event edge selection. .eevtedg = TC_SEL_NO_EDGE, //! Counter disable when RC compare. .cpcdis = 0, //! Counter clock stopped with RC compare. .cpcstop = 0, //! Burst signal selection. .burst = 0, //! Clock inversion selection. .clki = 0, //! Internal source clock 3 (fPBA / 8). .tcclks = TC_CLOCK_SOURCE_TC3 }; const tc_interrupt_t tc_interrupt = { .etrgs = 0, .ldrbs = 0, .ldras = 0, .cpcs = 1, .cpbs = 0, .cpas = 0, .lovrs = 0, .covfs = 0, }; #if (defined __GNUC__) Disable_global_interrupt(); INTC_register_interrupt(&tc_irq, TOUCH_MEASUREMENT_TC_IRQ, AVR32_INTC_INT0); Enable_global_interrupt(); #endif /* initialize the timer/counter. */ sysclk_enable_peripheral_clock(&AVR32_TC1); tc_init_waveform(tc, &waveform_options); /* set the compare triggers. */ tc_write_rc(tc, TOUCH_MEASUREMENT_TC_CHANNEL, (sysclk_get_pba_hz() / 8) / 1000); tc_configure_interrupts(tc, TOUCH_MEASUREMENT_TC_CHANNEL, &tc_interrupt); tc_start(tc, TOUCH_MEASUREMENT_TC_CHANNEL); } /** * \brief Initializes the touch library configuration. * * Sets the correct configuration for the QTouch library. */ static void qt_set_parameters(void) { /* This will be modified by the user to different values. */ qt_config_data.qt_di = DEF_QT_DI; qt_config_data.qt_neg_drift_rate = DEF_QT_NEG_DRIFT_RATE; qt_config_data.qt_pos_drift_rate = DEF_QT_POS_DRIFT_RATE; qt_config_data.qt_max_on_duration = DEF_QT_MAX_ON_DURATION; qt_config_data.qt_drift_hold_time = DEF_QT_DRIFT_HOLD_TIME; qt_config_data.qt_recal_threshold = DEF_QT_RECAL_THRESHOLD; qt_config_data.qt_pos_recal_delay = DEF_QT_POS_RECAL_DELAY; /* * This function is called after the library has made capacitive * measurements, but before it has processed them. The user can use * this hook to apply filter functions to the measured signal * values. (Possibly to fix sensor layout faults). */ qt_filter_callback = NULL; } /** * \brief Initialize touch sensors * * The touch channels are connected on the GPIO controller 4 which is a part of * port X * * Touch Button: * GPIO * 98 SNSK1 CHANNEL1_SNS * 99 SNS1 CHANNEL1_SNSK * * Touch Slider: * 100 SNS0 CHANNEL2_SNS * 101 SNSK0 CHANNEL2_SNSK * 102 SNS1 CHANNEL3_SNS * 103 SNSK1 CHANNEL3_SNSK * 104 SNS2 CHANNEL4_SNS * 105 SNSK2 CHANNEL4_SNSK */ void touch_init(void) { /* * Reset sensing is only needed when doing re-initialization during * run-time */ // qt_reset_sensing(); qt_enable_key(CHANNEL_1, NO_AKS_GROUP, 30u, HYST_12_5); /* * Position hysteresis is not used in QTouch slider so this value will * be ignored */ qt_enable_slider(CHANNEL_2, CHANNEL_4, NO_AKS_GROUP, 20u, HYST_12_5, RES_8_BIT, 0); qt_init_sensing(); qt_set_parameters(); #ifdef _DEBUG_INTERFACE_ sysclk_enable_peripheral_clock(&AVR32_SPI0); /* Initialize debug protocol */ QDebug_Init(); /* Process commands from PC */ QDebug_ProcessCommands(); #endif init_timer(); }
static void config_4ch_krs(void) { qt_enable_key( CHANNEL_0, AKS_GROUP_2, 10u, HYST_6_25 ); qt_enable_slider( CHANNEL_1, CHANNEL_3, NO_AKS_GROUP, 16u, HYST_6_25, RES_8_BIT, 0u ); }