/** * @brief Function for enabling event on pin (if not yet enabled) or disabling the event if no other * user requires it. * * @param pin Pin to enable * @param enable If true function will attempt to enable the pin else it will attempt to disable it. */ static void pin_event_enable(uint32_t pin, bool enable) { uint32_t i; uint32_t pin_mask = 1UL << pin; bool enabled = false; //search if any user already enabled given pin for (i = 0; i < m_user_count; i++) { if (mp_users[i].enabled && (mp_users[i].pins_mask & pin_mask)) { enabled = true; break; } } if (!enabled) { if (enable) { m_last_pins_state = nrf_gpio_pins_read(); nrf_drv_gpiote_in_event_enable(pin, true); } else { nrf_drv_gpiote_in_event_disable(pin); } } }
void gpio_input_disable_all(void) { uint8_t i; for (i=0; i<_gpio_count; ++i) { uint8_t pin_no = _gpio_cfgs[i].pin_no; if (_pin_direction[pin_no] == PIN_GPIOTE_IN || _pin_direction[pin_no] == PIN_PORT_IN) { nrf_drv_gpiote_in_event_disable(pin_no); } } }
uint32_t app_button_disable(void) { ASSERT(mp_buttons); uint32_t i; for (i = 0; i < m_button_count; i++) { nrf_drv_gpiote_in_event_disable(mp_buttons[i].pin_no); } // Make sure polling timer is not running. return app_timer_stop(m_detection_delay_timer_id); }
IOEventFlags jshPinWatch(Pin pin, bool shouldWatch) { if (!jshIsPinValid(pin)) return EV_NONE; uint32_t p = (uint32_t)pinInfo[pin].pin; if (shouldWatch) { nrf_drv_gpiote_in_config_t cls_1_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true); nrf_drv_gpiote_in_init(p, &cls_1_config, jsvPinWatchHandler); nrf_drv_gpiote_in_event_enable(p, true); return jshGetEventFlagsForWatchedPin(p); } else { nrf_drv_gpiote_in_event_disable(p); return EV_NONE; } } // start watching pin - return the EXTI associated with it
void gpio_irq_disable(gpio_irq_t *obj) { m_gpio_irq_enabled &= ~((gpio_mask_t)1 << obj->ch); nrf_drv_gpiote_in_event_disable(obj->ch); }