Example #1
0
/**
 * \internal
 * \brief Test for external interrupt detection by polling.
 *
 * This test changes the logic level of PB05 from high to low
 * so that the external interrupt channel detects the edge.
 *
 * Detection is tested for both rising and falling edges.
 *
 * \param test Current test case.
 */
static void run_extint_polled_mode_test(const struct test_case *test)
{
	/* Testing the falling edge detection */
	/* Generate falling edge */
	port_pin_set_output_level(GPIO_TEST_PIN_EXTINT, false);
	/* Wait for the pin level to stabilize */
	delay_ms(1);
	result = extint_chan_is_detected(EIC_TEST_CHANNEL);
	test_assert_true(test, result,
			"External interrupt falling edge detection by polling failed");
	extint_chan_clear_detected(EIC_TEST_CHANNEL);

	/* Testing the rising edge detection */
	result = false;
	eic_conf.detection_criteria = EXTINT_DETECT_RISING;
	extint_chan_set_config(EIC_TEST_CHANNEL, &eic_conf);
	/* Generate rising edge */
	port_pin_set_output_level(GPIO_TEST_PIN_EXTINT, true);
	/* Wait for the pin level to stabilize */
	delay_ms(1);
	result = extint_chan_is_detected(EIC_TEST_CHANNEL);
	test_assert_true(test, result,
			"External interrupt rising edge detection by polling failed");
	extint_chan_clear_detected(EIC_TEST_CHANNEL);
}
int main(void)
{
    system_init();

    //! [setup_init]
    configure_extint_channel();
    //! [setup_init]

    //! [main]
    while (true) {
        //! [main_1]
        if (extint_chan_is_detected(BUTTON_0_EIC_LINE)) {
            //! [main_1]

            //! [main_2]
            // Do something in response to EXTINT edge detection
            bool button_pin_state = port_pin_get_input_level(BUTTON_0_PIN);
            port_pin_set_output_level(LED_0_PIN, button_pin_state);
            //! [main_2]

            //! [main_3]
            extint_chan_clear_detected(BUTTON_0_EIC_LINE);
            //! [main_3]
        }
    }
    //! [main]
}
Example #3
0
int main(void)
{
	system_init();
	configure_usart();
	configure_usart_callbacks();
	
	struct port_config pin_conf;
	port_get_config_defaults(&pin_conf);

	/* Configure LEDs as outputs, turn them off */
	pin_conf.direction  = PORT_PIN_DIR_OUTPUT;
	port_pin_set_config(LED_1_PIN, &pin_conf);
	port_pin_set_output_level(LED_1_PIN, LED_1_INACTIVE);

	/* Set buttons as inputs */
	pin_conf.direction  = PORT_PIN_DIR_INPUT;
	pin_conf.input_pull = PORT_PIN_PULL_UP;
	port_pin_set_config(BUTTON_1_PIN, &pin_conf);


#if USE_EIC == true
	configure_extint();
#endif

#if USE_INTERRUPTS == true
#  if USE_EIC == false
	configure_systick_handler();
#  else
	configure_eic_callback();
#  endif

	system_interrupt_enable_global();

	uint16_t temp;
	while (true) {
		/* Do nothing - use interrupts */
		//if (usart_read_wait(&usart_instance, &temp) == STATUS_OK)
		//{
			//while (usart_write_wait(&usart_instance, temp) != STATUS_OK);
		//}
		usart_read_buffer_job(&usart_instance, (uint8_t *)rx_buffer, 1);
		//sleepmgr_sleep(SLEEPMGR_STANDBY);
	}
#else
#  if USE_EIC == false
	while (true) {
		update_led_state();
	}
#  else
	while (true) {
		if (extint_chan_is_detected(BUTTON_1_EIC_LINE)) {
			extint_chan_clear_detected(BUTTON_1_EIC_LINE);

			update_led_state();
		}
	}
#  endif
#endif
}
Example #4
0
/** Handler for the EXTINT hardware module interrupt. */
void EIC_Handler(void)
{
	/* Find any triggered channels, run associated callback handlers */
	for (uint8_t i = 0; i < EIC_NUMBER_OF_INTERRUPTS ; i++) {
		if (extint_chan_is_detected(i)) {
			/* Clear flag */
			extint_chan_clear_detected(i);
			/* Find any associated callback entries in the callback table */
			if (_extint_dev.callbacks[i] != NULL) {
				/* Run the registered callback */
				_extint_dev.callbacks[i]();
			}
		}
	}
}
Example #5
0
/**
 * \brief Initializes and enables interrupt pin change
 */
static void ui_enable_asynchronous_interrupt(void)
{
	/* Initialize EIC for button wakeup */
	struct extint_chan_conf eint_chan_conf;
	extint_chan_get_config_defaults(&eint_chan_conf);

	eint_chan_conf.gpio_pin            = BUTTON_0_EIC_PIN;
	eint_chan_conf.gpio_pin_mux        = BUTTON_0_EIC_MUX;
	eint_chan_conf.detection_criteria  = EXTINT_DETECT_FALLING;
	eint_chan_conf.filter_input_signal = true;
	extint_chan_set_config(BUTTON_0_EIC_LINE, &eint_chan_conf);
	extint_register_callback(UI_WAKEUP_HANDLER,
			BUTTON_0_EIC_LINE,
			EXTINT_CALLBACK_TYPE_DETECT);
	extint_chan_clear_detected(BUTTON_0_EIC_LINE);
	extint_chan_enable_callback(BUTTON_0_EIC_LINE,
			EXTINT_CALLBACK_TYPE_DETECT);
}
Example #6
0
void gpio_irq(void)
{
    uint32_t current_channel;
    uint32_t mask;
    gpio_irq_event event;
    PortGroup *port_base;

    for (current_channel = 0; current_channel < EIC_NUMBER_OF_INTERRUPTS ; current_channel++) {
        if (extint_chan_is_detected(current_channel)) {
            extint_chan_clear_detected(current_channel);
            port_base = (PortGroup*)port_get_group_from_gpio_pin(ext_int_pins[current_channel]);
            mask = gpio_set(ext_int_pins[current_channel]);
            if ((port_base->IN.reg & mask) != 0) {
                event = IRQ_RISE;
            } else {
                event = IRQ_FALL;
            }
            if(irq_handler) {
                irq_handler(channel_ids[current_channel], event);
            }
        }
    }
}
Example #7
0
int main(void)
{
	system_init();

#if USE_EIC == true
	configure_extint();
#endif

#if USE_INTERRUPTS == true
#  if USE_EIC == false
	configure_systick_handler();
#  else
	configure_eic_callback();
#  endif

	system_interrupt_enable_global();

	while (true) {
		/* Do nothing - use interrupts */
	}
#else
#  if USE_EIC == false
	while (true) {
		update_led_state();
	}
#  else
	while (true) {
		if (extint_chan_is_detected(BUTTON_0_EIC_LINE)) {
			extint_chan_clear_detected(BUTTON_0_EIC_LINE);

			update_led_state();
		}
	}
#  endif
#endif
}
void interruptValueInitializzation(void) {
    TCA6416a_input_ports_values(&portsValue);
    // clear Interrupt
    extint_chan_clear_detected(SME_INT_IOEXT_EIC_LINE);
}