Excuse me:
I now use NCS to develop nrf52840 applications. My applications require IO events of more than 8 channels. How should I configure them.
Excuse me:
I now use NCS to develop nrf52840 applications. My applications require IO events of more than 8 channels. How should I configure them.
Hi, when you configure the GPIOs you can change between GPIO_INT_LEVEL_ACTIVE and GPIO_INT_EDGE_TO_ACTIVE.
http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/peripherals/gpio.html
GPIO_INT_LEVEL_ACTIVE corresponds to "low accuracy" mode in the nRF5 SDK, and GPIO_INT_EDGE_TO_ACTIVE is "high accuracy".
Or if we are using the product specification terms:
GPIO_INT_LEVEL_ACTIVE corresponds to using the GPIO SENSE signal which triggers the GPIOTE PORT event. This does not consume any extra current and is therefore recommended for low power applications.GPIO_INT_EDGE_TO_ACTIVE corresponds to using the GPIOTE IN event, which consumes current in the 10-50 uA range, depending on the chip type.This behavior will be changed in an upcoming release, and will be using Kconfig options instead. Please have a look at this pull request: https://github.com/zephyrproject-rtos/zephyr/pull/31823
EDIT
This pull request I linked to above is already part of NCS 1.6.0 and it is possible to use the GPIOTE PORT event, a.k.a "low accuracy mode", by just enabling this Kconfig option in prj.conf: CONFIG_GPIO_NRF_INT_EDGE_USING_SENSE=y
Excuse me:
I want to use the GPIO SENSE signal which triggers the GPIOTE PORT event, My applications require IO events of more than 8 channels. How should I configure them in NCS?thank you very much!
You can add a GPIO input interrupt with a callback using the following code:
#define PIN 23
void button_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
{
printk("Button pressed");
}
void main(void)
{
const struct device *gpio_dev;
static struct gpio_callback button_cb_data;
gpio_dev = device_get_binding("GPIO_0");
gpio_pin_configure(gpio_dev, PIN, GPIO_INPUT | GPIO_PULL_UP);
gpio_pin_interrupt_configure(gpio_dev, PIN, GPIO_INT_EDGE_TO_INACTIVE);
gpio_init_callback(&button_cb_data, button_callback, BIT(PIN));
gpio_add_callback(gpio_dev, &button_cb_data);
}
To use GPIOTE PORT event instead of GPIOTE IN event, add the following to prj.conf:
CONFIG_GPIO_NRF_INT_EDGE_USING_SENSE=y