multiple buttons

Dear all,

I wanted to create 10 buttons using 10 gpio pins :

int gpio_pins_0[10] = {29, 31, 10, 9, 24, 22, 20, 17, 15, 13};

When creating gpio interrupt with below enclosed code, I realized that only 4 buttons were active but no other:

const struct device *pin0 = device_get_binding("GPIO_0");
    if (!device_is_ready(pin0)) {
        printk("GPIO device %s is not ready!\n", pin0->name);
        return ret;
    }

for (int i = 0; i <= 9; i++) {
    printk("configuring pin:%d\n",i);
        gpio_pin_configure(pin0, gpio_pins_0[i], GPIO_INPUT);
    printk("init callback of pin:%d\n",i);
        gpio_init_callback(&gpio_callbacks[i], gpio_callback_handlers[i], BIT(gpio_pins_0[i]));
    printk("adding callback of pin:%d\n",i);
        gpio_add_callback(pin0, &gpio_callbacks[i]);
    printk("configuring interrupt of of pin:%d\n",i);
        ret = gpio_pin_interrupt_configure(pin0, gpio_pins_0[i], GPIO_INT_EDGE_TO_ACTIVE);
        if (ret != 0) {
            printk("cannot configure button %d on pin %d\n", i, gpio_pins_0[i]);
            return ret;
        }
    }

Therefore I had to skip so called GPIOTE method which is reduced to 4 interrupts only and use method of gpio masking in dts file this way:

&gpio0 {
status = "okay";
/* sense-edge-mask = < 0xffffffff >;*/
sense-edge-mask = <((1 << 29) | (1 << 31) | (1 << 10) | (1 << 9) | (1 << 24) | (1 << 22) | (1 << 20) | (1 << 17) | (1 << 15) | (1 << 13))>;
};

But I am seeing a rather strange behaviour when connecting voltage VDD out with every configured GPIO pin in a sense that bits 29 and 31 are working perfectly when tapping on them with the voltage, but when connecting VDD out with pin 9, callback of pin 9 as well as callback of pin 10 is triggered simultaneously, pin 24,22,17,15,13 are not working at all and pin 20 is working randomly. I flashed the same firmware on another board to make sure the board is not faulty and I experience the same behaviour.

Pins 22 and 24 are also configured in dts in uart0 section, but I disabled uart0 this way;

&uart0 {
compatible = "nordic,nrf-uarte";
current-speed = <115200>;
pinctrl-0 = <&uart0_default>;
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
status = "disabled";
};

Does anyone know what the problem might be?

When using GPIOTE all 4 pins are behaving correctly, but I need more than 4 buttons.

Parents Reply Children
No Data
Related