/*! \brief Example application entry function.
 */
touch_ret_t touch_sensors_init(void)
{
	touch_ret_t touch_ret = TOUCH_SUCCESS;

	/* Setup and enable generic clock source for PTC module. */
	touch_configure_ptc_clock();

	touch_time.measurement_period_ms = DEF_TOUCH_MEASUREMENT_PERIOD_MS;

	/* Initialize touch library for Mutual Cap operation. */
	touch_ret = touch_mutlcap_sensors_init(&touch_config);
	if (touch_ret != TOUCH_SUCCESS) {
		while (1u) {    /* Check API Error return code. */
		}
	}

#if DEF_TOUCH_QDEBUG_ENABLE == 1
	QDebug_Init();
#endif

	/* configure the touch library sensors. */
	touch_ret = touch_sensors_config();
	if (touch_ret != TOUCH_SUCCESS) {
		while (1u) {    /* Check API Error return code. */
		}
	}

	touch_ret = touch_mutlcap_sensors_calibrate();
	if (touch_ret != TOUCH_SUCCESS) {
		while (1u) {    /* Check API Error return code. */
		}
	}

	return (touch_ret);
}
Example #2
0
File: touch.c Project: Mazetti/asf
/*! \brief Example application entry function.
 */
touch_ret_t touch_sensors_init(void)
{
	touch_ret_t touch_ret = TOUCH_SUCCESS;

	/* Setup and enable generic clock source for PTC module. */
	touch_configure_ptc_clock();

	touch_time.measurement_period_ms = DEF_TOUCH_MEASUREMENT_PERIOD_MS;

	/* Initialize touch library for Mutual Cap operation. */
	touch_ret = touch_mutlcap_sensors_init(&touch_config);
	if (touch_ret != TOUCH_SUCCESS) {
		while (1u) {    /* Check API Error return code. */
		}
	}

#if DEF_TOUCH_QDEBUG_ENABLE == 1
	QDebug_Init();
#endif

	/* configure the touch library sensors. */
	touch_ret = touch_sensors_config();
	if (touch_ret != TOUCH_SUCCESS) {
		while (1u) {    /* Check API Error return code. */
		}
	}

	/* Auto Tuning setting for calibration.
	 *
	 * AUTO_TUNE_PRSC: When Auto tuning of pre-scaler is selected
	 * the PTC uses the user defined internal series resistor setting
	 * (DEF_MUTLCAP_SENSE_RESISTOR) and the pre-scaler is adjusted
	 * to slow down the PTC operation to ensure full charge transfer.
	 *
	 * AUTO_TUNE_RSEL: When Auto tuning of the series resistor is
	 * selected the PTC runs at user defined pre-scaler setting speed
	 * (DEF_MUTLCAP_CLK_PRESCALE) and the internal series resistor is
	 * tuned automatically to the optimum value to allow for full
	 * charge transfer.
	 *
	 * AUTO_TUNE_NONE: When manual tuning option is selected (AUTO_TUNE_NONE),
	 * the user defined values of PTC pre-scaler and series resistor is used
	 * for PTC operation as given in DEF_MUTLCAP_CLK_PRESCALE and
	 * DEF_MUTLCAP_SENSE_RESISTOR
	 *
	 */
	touch_ret = touch_mutlcap_sensors_calibrate(AUTO_TUNE_RSEL);
	if (touch_ret != TOUCH_SUCCESS) {
		while (1u) {    /* Check API Error return code. */
		}
	}

	return (touch_ret);
}
Example #3
0
/*! \brief Example application entry function.
 */
touch_ret_t
touch_sensors_init (void)
{

    touch_ret_t touch_ret = TOUCH_SUCCESS;

    touch_qt_time.measurement_period_ms = TOUCH_MEASUREMENT_PERIOD_MS;

    /* Initialize touch library and sam4l cat module for QTouch Library operation. */
    touch_ret = touch_qt_sensors_init (&touch_config);
    if (touch_ret != TOUCH_SUCCESS)
    {
        while (1u);		/* Check API Error return code. */
    }

#if DEF_TOUCH_QDEBUG_ENABLE == 1
    /* Initialize the debug interface. */
    QDebug_Init ();
#endif

    /* configure the touch library sensors. */
    touch_ret = touch_sensors_config ();
    if (touch_ret != TOUCH_SUCCESS)
    {
        while (1u);		/* Check API Error return code. */
    }

    /* Initialize touch sensing. */
    touch_ret = touch_qt_sensors_calibrate ();
    if (touch_ret != TOUCH_SUCCESS)
    {
        while (1u);		/* Check API Error return code. */
    }


    // Set up CATB interrupt handler
    NVIC_ClearPendingIRQ(CATB_IRQn);
    NVIC_SetPriority(CATB_IRQn,0);
    NVIC_EnableIRQ(CATB_IRQn);

    return (touch_ret);

}