When I program an interrupt, the NRF52840 requires 250uA extra. I read something about the sense interrupt, but I cannot find any working example. How should I implement an interrupt when my power is on a budget?
static const struct gpio_dt_spec signal = GPIO_DT_SPEC_GET(ZEPHYR_USER_NODE, signal_gpios); static struct gpio_callback _interrupt; void _isr(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { LOG_INF("isr given"); k_work_schedule(&_proces, K_NO_WAIT); } void attachinterrupt(void) { __ASSERT(device_is_ready(signal.port), "custom device not ready"); if(gpio_pin_configure_dt(&signal, GPIO_INPUT)) { LOG_ERR("error configure signalgpio"); } if(gpio_pin_interrupt_configure_dt(&signal, GPIO_INT_EDGE_TO_ACTIVE)) { LOG_ERR("error configure interrupt signalgpio"); }; gpio_init_callback(&_interrupt, _isr, BIT(signal.pin)); if(gpio_add_callback(signal.port, &_interrupt)) { LOG_ERR("callback for interrupt not set"); }; }
I tried to replace gpio_pin_interrupt_configure_dt with a sense configuration, but I don't really get how this is suppose to work:
#include <hal/nrf_gpio.h> nrf_gpio_cfg_input(signal.pin, NRF_GPIO_PIN_PULLDOWN); nrf_gpio_cfg_sense_set(signal.pin, NRF_GPIO_PIN_SENSE_HIGH);
Also, I read a pin interrupt consumes more than a port interrupt. How would I implement a port interrupt (my system needs only 1 interrupt)?