/*---------------------------------------------------------------------------*/ void button_sensor_init(void) { struct extint_chan_conf config_extint_chan; struct port_config pin_conf; port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(BUTTON_0_PIN, &pin_conf); // extint_enable(); extint_chan_get_config_defaults(&config_extint_chan); config_extint_chan.gpio_pin = BUTTON_0_EIC_PIN; config_extint_chan.gpio_pin_mux = BUTTON_0_EIC_MUX; config_extint_chan.gpio_pin_pull = EXTINT_PULL_UP; config_extint_chan.detection_criteria = EXTINT_DETECT_FALLING; // config_extint_chan.detection_criteria = EXTINT_DETECT_BOTH; extint_chan_set_config(BUTTON_0_EIC_LINE, &config_extint_chan); extint_register_callback((extint_callback_t)extint_detection_callback, BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); timer_set(&debouncetimer, 0); system_interrupt_enable_global(); /* on by default */ button_sensor_configure(0, 1); }
/** Configures and registers the External Interrupt callback function with the * driver. */ static void configure_eic_callback(void) { extint_register_callback(extint_callback, BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); }
/*============================================================================== hal_extIntInit() =============================================================================*/ uint8_t hal_extIntInit( en_targetExtInt_t e_intSource, pfn_intCallb_t pfn_intCallback ) { int8_t c_ret = 0; if( pfn_intCallback != NULL ) { switch( e_intSource ) { case E_TARGET_RADIO_INT: //! [setup_init] //extint_enable(); //! [conf_channel] //! [setup_1] extint_chan_get_config_defaults( &( radio_extInt.st_chan ) ); //! [setup_1] //! [setup_2] radio_extInt.st_chan.gpio_pin = radio_extInt.l_pin; //EXT1_IRQ_PIN; radio_extInt.st_chan.gpio_pin_mux = radio_extInt.l_pinMux; //MUX_PB04A_EIC_EXTINT4; radio_extInt.st_chan.gpio_pin_pull = radio_extInt.c_pinPull; //EXTINT_PULL_DOWN; radio_extInt.st_chan.detection_criteria = radio_extInt.c_detCrit; //EXTINT_DETECT_RISING; //! [setup_2] //! [setup_3] extint_chan_set_config( (uint8_t)radio_extInt.l_line, &( radio_extInt.st_chan ) ); //! [setup_3] _radio_callback = pfn_intCallback; //! [setup_4] extint_register_callback( (extint_callback_t)_isr_radio_callback, (uint8_t)radio_extInt.l_line, EXTINT_CALLBACK_TYPE_DETECT ); //! [setup_4] //! [setup_5] extint_chan_enable_callback( (uint8_t)radio_extInt.l_line, //EXT1_IRQ_INPUT, EXTINT_CALLBACK_TYPE_DETECT ); //! [setup_6] //! [conf_channel] //! [setup_init] system_interrupt_enable_global(); c_ret = 1; break; case E_TARGET_USART_INT: break; default: break; } } return c_ret; } /* hal_extIntInit() */
void configure_extint_callbacks(void) { //! [setup_5] extint_register_callback(extint_detection_callback, BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); //! [setup_5] //! [setup_6] extint_chan_enable_callback(BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); //! [setup_6] }
void cph_deca_init_gpio(void) { struct extint_chan_conf config_chan; extint_chan_get_config_defaults(&config_chan); config_chan.gpio_pin = DW_IRQ_PIN; config_chan.gpio_pin_mux = DW_IRQ_PIN_MUX; config_chan.gpio_pin_pull = DW_IRQ_PIN_PULL; config_chan.detection_criteria = DW_IRQ_PIN_DETECT; extint_chan_set_config(DW_IRQ_LINE, &config_chan); extint_register_callback(cph_deca_isr, DW_IRQ_LINE, EXTINT_CALLBACK_TYPE_DETECT); }
void config_wind_speed() { struct extint_chan_conf wind_speed_chan; extint_chan_get_config_defaults(&wind_speed_chan); wind_speed_chan.gpio_pin = WIND_SPEED_INTERRUPT_PIN; wind_speed_chan.gpio_pin_mux = WIND_SPEED_INTERRUPT_MUX; wind_speed_chan.gpio_pin_pull = EXTINT_PULL_UP; wind_speed_chan.detection_criteria = EXTINT_DETECT_RISING; extint_chan_set_config(WIND_SPEED_INTERRUPT_LINE, &wind_speed_chan); extint_register_callback(wind_click_handle, WIND_SPEED_INTERRUPT_LINE, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(WIND_SPEED_INTERRUPT_LINE, EXTINT_CALLBACK_TYPE_DETECT); return; }
WEATHER_ERR_T config_rain_guage() { struct extint_chan_conf rain_extint_chan; extint_chan_get_config_defaults(&rain_extint_chan); rain_extint_chan.gpio_pin = RAIN_INTERRUPT_PIN; rain_extint_chan.gpio_pin_mux = RAIN_INTERRUPT_MUX; rain_extint_chan.gpio_pin_pull = EXTINT_PULL_UP; rain_extint_chan.detection_criteria = EXTINT_DETECT_RISING; extint_chan_set_config(RAIN_INTERRUPT_LINE, &rain_extint_chan); extint_register_callback(rain_click_handle, RAIN_INTERRUPT_LINE, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(RAIN_INTERRUPT_LINE, EXTINT_CALLBACK_TYPE_DETECT); return W_ERR_NONE; }
/** * \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); }
/* * @fn nm_bsp_register_isr * @brief Register interrupt service routine * @param[IN] pfIsr * Pointer to ISR handler */ void nm_bsp_register_isr(tpfNmBspIsr pfIsr) { struct extint_chan_conf config_extint_chan; gpfIsr = pfIsr; extint_chan_get_config_defaults(&config_extint_chan); config_extint_chan.gpio_pin = CONF_WINC_SPI_INT_PIN; config_extint_chan.gpio_pin_mux = CONF_WINC_SPI_INT_MUX; config_extint_chan.gpio_pin_pull = EXTINT_PULL_UP; config_extint_chan.detection_criteria = EXTINT_DETECT_FALLING; extint_chan_set_config(CONF_WINC_SPI_INT_EIC, &config_extint_chan); extint_register_callback(chip_isr, CONF_WINC_SPI_INT_EIC, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(CONF_WINC_SPI_INT_EIC, EXTINT_CALLBACK_TYPE_DETECT); }
//! [config_eic] static void configure_eic(void) { //! [eic_chan_setup] //! [eic_setup_1] struct extint_chan_conf config; //! [eic_setup_1] //! [eic_setup_2] extint_chan_get_config_defaults(&config); //! [eic_setup_2] //! [eic_setup_3] config.filter_input_signal = true; config.detection_criteria = EXTINT_DETECT_BOTH; config.gpio_pin = CONF_FAULT_EIC_PIN; config.gpio_pin_mux = CONF_FAULT_EIC_PIN_MUX; //! [eic_setup_3] //! [eic_setup_4] extint_chan_set_config(CONF_FAULT_EIC_LINE, &config); //! [eic_setup_4] //! [eic_chan_setup] //! [eic_event_setup] //! [eic_event_setup_1] struct extint_events events; memset(&events, 0, sizeof(struct extint_events)); //! [eic_event_setup_1] //! [eic_event_setup_2] events.generate_event_on_detect[CONF_FAULT_EIC_LINE] = true; //! [eic_event_setup_2] //! [eic_event_setup_3] extint_enable_events(&events); //! [eic_event_setup_3] //! [eic_event_setup] //! [eic_callback_setup] //! [eic_callback_setup_1] extint_register_callback(eic_callback_to_clear_halt, CONF_FAULT_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); //! [eic_callback_setup_1] //! [eic_callback_setup_2] extint_chan_enable_callback(CONF_FAULT_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); //! [eic_callback_setup_2] //! [eic_callback_setup] }
void configurationPPS(void){ struct extint_chan_conf eint_chan_conf; extint_chan_get_config_defaults(&eint_chan_conf); // put the button as EXTINT eint_chan_conf.gpio_pin = PIN_PA28A_EIC_EXTINT8; eint_chan_conf.gpio_pin_mux = MUX_PA28A_EIC_EXTINT8; /** Detect rising signal edges */ eint_chan_conf.detection_criteria = EXTINT_DETECT_RISING; eint_chan_conf.filter_input_signal = false; extint_chan_set_config(8, &eint_chan_conf); //configuration callback extint_register_callback(ppsISR,8,EXTINT_CALLBACK_TYPE_DETECT); //activation callback extint_chan_enable_callback(8,EXTINT_CALLBACK_TYPE_DETECT); pin_state=false; }
void ui_init(void) { struct extint_chan_conf config_extint_chan; extint_chan_get_config_defaults(&config_extint_chan); config_extint_chan.gpio_pin = BUTTON_0_EIC_PIN; config_extint_chan.gpio_pin_mux = BUTTON_0_EIC_MUX; config_extint_chan.gpio_pin_pull = EXTINT_PULL_UP; config_extint_chan.filter_input_signal = true; config_extint_chan.detection_criteria = EXTINT_DETECT_FALLING; extint_chan_set_config(BUTTON_0_EIC_LINE, &config_extint_chan); extint_register_callback(ui_wakeup_handler, BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(BUTTON_0_EIC_LINE,EXTINT_CALLBACK_TYPE_DETECT); /* Initialize LEDs */ LED_On(LED_0_PIN); }
/** * USB ID pin configuration */ static void usb_id_config(void) { struct extint_chan_conf eint_chan_conf; extint_chan_get_config_defaults(&eint_chan_conf); eint_chan_conf.gpio_pin = USB_ID_PIN; eint_chan_conf.gpio_pin_mux = USB_ID_EIC_MUX; eint_chan_conf.detection_criteria = EXTINT_DETECT_BOTH; eint_chan_conf.filter_input_signal = true; extint_chan_disable_callback(USB_ID_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_set_config(USB_ID_EIC_LINE, &eint_chan_conf); extint_register_callback(usb_id_handler, USB_ID_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(USB_ID_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); }
/** * \brief Configure the INTN interrupt. * * \param p_handler callback pointer to use when INTN interrupt raises. */ void configure_intn(void (*p_handler) (void)) { struct extint_chan_conf eic_conf; /* Configure the external interrupt channel. */ extint_chan_get_config_defaults(&eic_conf); eic_conf.gpio_pin = KSZ8851SNL_INTN_EIC_PIN; eic_conf.gpio_pin_mux = KSZ8851SNL_INTN_EIC_PIN_MUX; eic_conf.gpio_pin_pull = EXTINT_PULL_UP; eic_conf.detection_criteria = EXTINT_DETECT_FALLING; eic_conf.filter_input_signal = true; extint_chan_set_config(KSZ8851SNL_INTN_EIC_CHANNEL, &eic_conf); /* Register and enable the callback function. */ extint_register_callback(p_handler, KSZ8851SNL_INTN_EIC_CHANNEL, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(KSZ8851SNL_INTN_EIC_CHANNEL, EXTINT_CALLBACK_TYPE_DETECT); }
/** * \internal * \brief Setup function for callback mode test. * * This function sets up the GPIO pin, the external interrupt channel & * the callback function. * * \param test Current test case. */ static void setup_extint_callback_mode_test(const struct test_case *test) { /* Configure the GPIO pin */ port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_OUTPUT; pin_conf.input_pull = PORT_PIN_PULL_NONE; port_pin_set_config(GPIO_TEST_PIN_EXTINT, &pin_conf); port_pin_set_output_level(GPIO_TEST_PIN_EXTINT, true); /* Configure the external interrupt channel */ extint_chan_get_config_defaults(&eic_conf); eic_conf.gpio_pin = EIC_TEST_PIN; eic_conf.gpio_pin_mux = EIC_TEST_PIN_MUX; eic_conf.gpio_pin_pull = EXTINT_PULL_UP; eic_conf.detection_criteria = EXTINT_DETECT_FALLING; extint_chan_set_config(EIC_TEST_CHANNEL, &eic_conf); /* Register and enable the callback function */ extint_register_callback(extint_user_callback, EIC_TEST_CHANNEL, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(EIC_TEST_CHANNEL, EXTINT_CALLBACK_TYPE_DETECT); }
/*---------------------------------------------------------------------------*/ static void configure_button(void) { /* Set buttons as inputs */ struct port_config pin_conf; port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(BUTTON_0_PIN, &pin_conf); /* Configure interrupt */ struct extint_chan_conf config_extint_chan; extint_chan_get_config_defaults(&config_extint_chan); config_extint_chan.gpio_pin = BUTTON_0_EIC_PIN; config_extint_chan.gpio_pin_mux = BUTTON_0_EIC_MUX; config_extint_chan.gpio_pin_pull = EXTINT_PULL_UP; config_extint_chan.detection_criteria = EXTINT_DETECT_BOTH; extint_chan_set_config(BUTTON_0_EIC_LINE, &config_extint_chan); /* Register interrupt callbacks */ extint_register_callback(extint_detection_callback, BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); }
void configure_extint_callbacks(void) { extint_register_callback(extint_detection_callback_1, 2, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(2, EXTINT_CALLBACK_TYPE_DETECT); }