示例#1
0
/**
 * \brief Touch Library & Sensors Intialization
 * - Register the CAT interrupt with priority level 3
 * - Initialize the touch library
 * - Intilialize the Autonomous touch sensor
 *
 * \retval STATUS_OK         Configuration success
 * \retval ERR_INVALID_ARG   Error in configuration parameters
 */
static status_code_t touch_api_init()
{
	touch_ret_t touch_ret = TOUCH_SUCCESS;
	/* Enable CAT PBA clock */
	sysclk_enable_pba_module(SYSCLK_CAT);
	/* Disable global interrupts */
	cpu_irq_disable();

	/*
	 * Initialize the interrupt vectors
	 * Note: This function does nothing for IAR as the interrupts are
	 *handled
	 * by the IAR compiler itself. It provides an abstraction between GCC &
	 * IAR compiler to use interrupts.
	 * Refer function implementation in interrupt_avr32.h
	 */
	irq_initialize_vectors();

	/*
	 * Register the Touch Library CAT interrupt handler to the interrupt
	 * controller.
	 * Note: The Touch Library CAT interrupt level for the case
	 * of IAR is fixed to Interrupt level 3. This function does nothing for
	 * IAR as the interrupts are handled by the IAR compiler itself. It
	 * provides an abstraction between GCC & IAR compiler to use interrupts.
	 * Refer function implementation in interrupt_avr32.h
	 */
	irq_register_handler(&touch_acq_done_irq, AVR32_CAT_IRQ, 3);
	/* Enable global interrupt */
	cpu_irq_enable();

	/* Initialize touch library and CAT module for Autonomous QTouch
	 * operation. */
	touch_ret = touch_at_sensor_init(&touch_config);
	/* Check API Error return code. */
	if (touch_ret != TOUCH_SUCCESS) {
		return ERR_INVALID_ARG;
	}

	/*
	 * Enable Autonomous QTouch sensor for continuous acquisition. IN_TOUCH
	 * or OUT_OF_TOUCH status is continuously updated until the sensor is
	 * disabled using the touch_at_sensor_disable() API.
	 */
	touch_ret
		= touch_at_sensor_enable(touch_at_status_change_interrupt_callback);
	/* Check API Error return code. */
	if (touch_ret != TOUCH_SUCCESS) {
		return ERR_INVALID_ARG;
	}

	return STATUS_OK;
} /* End of touch_api_init() */
示例#2
0
文件: touch.c 项目: thegeek82000/asf
/*! \brief This API is used to enable Autonomous QTouch Sensor that can
 * be used to Wakeup the CPU from Deep-Sleep modes.
 * \return touch_ret_t: QTouch Library Error status.
 */
touch_ret_t
touch_autonomous_sensor_enable (void)
{
    touch_ret_t touch_ret = TOUCH_SUCCESS;

    touch_ret =
        touch_at_sensor_enable( &touch_config );

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

    return (touch_ret);
}