Hi. Currently evaluating this DK.
I'm using project that is based on samples\subsys\usb\hid-keyboard example from SDK v2.8.0-rc2.
I have added more input pins via Zephyr Input subsystem to use them as button pins with pull-up, active-low mode.
Pins are located on P2, pins 0-7.
Project DTS app.overlay looks like this:
/* * Copyright (c) 2023 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr/dt-bindings/input/input-event-codes.h> #include <zephyr/dt-bindings/gpio/gpio.h> / { hid_dev_0: hid_dev_0 { compatible = "zephyr,hid-device"; interface-name = "HID0"; protocol-code = "none"; in-report-size = <64>; in-polling-period-us = <1000>; out-report-size = <64>; out-polling-period-us = <1000>; }; buttons { compatible = "gpio-keys"; polling-mode; // DK Button 0 // GPIO P0.8 button0: button_0 { gpios = < &gpio0 0x8 0x11 >; label = "Push button 0"; zephyr,code = < INPUT_KEY_0 >; }; // DK Button 1 // GPIO P0.9 button1: button_1 { gpios = < &gpio0 0x9 0x11 >; label = "Push button 1"; zephyr,code = < INPUT_KEY_1 >; }; // DK Button 2 // GPIO P0.10 button2: button_2 { gpios = < &gpio0 0xa 0x11 >; label = "Push button 2"; zephyr,code = < INPUT_KEY_2 >; }; // DK Button 3 // GPIO P0.11 button3: button_3 { gpios = < &gpio0 0xb 0x11 >; label = "Push button 3"; zephyr,code = < INPUT_KEY_3 >; }; // aux button board connected to P2 // GPIO P2.0 buttonY: button_Y { gpios = < &gpio2 0x0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >; label = "Button Y"; zephyr,code = < INPUT_BTN_0 >; }; // GPIO P2.1 buttonX: button_X { gpios = < &gpio2 0x1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >; label = "Button X"; zephyr,code = < INPUT_BTN_1 >; }; // GPIO P2.2 buttonB: button_B { gpios = < &gpio2 0x2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >; label = "Button B"; zephyr,code = < INPUT_BTN_2 >; }; // GPIO P2.3 buttonA: button_A { gpios = < &gpio2 0x3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >; label = "Button A"; zephyr,code = < INPUT_BTN_3 >; }; // GPIO P2.4 buttonDown: button_Down { gpios = < &gpio2 0x4 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >; label = "Button Down"; zephyr,code = < INPUT_BTN_DPAD_DOWN >; }; // GPIO P2.5 buttonLeft: button_Left { gpios = < &gpio2 0x5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >; label = "Button Left"; zephyr,code = < INPUT_BTN_DPAD_LEFT >; }; // GPIO P2.6 buttonRight: button_Right { gpios = < &gpio2 0x6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >; label = "Button Right"; zephyr,code = < INPUT_BTN_DPAD_RIGHT >; }; // GPIO P2.7 buttonUp: button_Up { gpios = < &gpio2 0x7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >; label = "Button Up"; zephyr,code = < INPUT_BTN_DPAD_UP >; }; }; }; &gpio2 { status = "okay"; };
However I cannot get input events for buttons that short pins P2.05 and P2.07 to ground because they do not have pull-up voltage and register as always low.
Adding debug level log to Zephyr Input shows that these pins are indeed constantly "pressed", and thus not being able to change and generate input event.
[00:00:17.760,258] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=0[0m [00:00:17.770,130] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=1[0m [00:00:17.780,073] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=2[0m [00:00:17.790,018] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=3[0m [00:00:17.799,961] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=4[0m [00:00:17.809,904] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=5[0m [00:00:17.819,848] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=6[0m [00:00:17.829,793] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=7[0m [00:00:17.839,738] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=8[0m [00:00:17.849,679] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=1, new_pressed=1, key_index=9[0m [00:00:17.859,622] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=0, new_pressed=0, key_index=10[0m [00:00:17.869,653] [0m<dbg> gpio_keys: gpio_keys_poll_pin: buttons: pin_state=1, new_pressed=1, key_index=11[0m
Moving input to P1 by changing gpio2 everywhere in overlay to gpio1 makes every required button work normally except the one on pin P1.07 - it does not have pull-up voltage too, and is constantly in low state.
Is there an initialization missing somewhere?
Another question - I had to resort to use polling method for Input subsystem for these pins (by adding polling-mode property to buttons node in DTS), because when kernel initializes Input on start, it encounters device initialization error on pin P2.04 and exits initialization, leaving only pins P2.00-P2.03 initialized as inputs. Am I correct assuming that either pins P2.04 and higher either do not support edge interrupts in this SDK, or interrupt count is limited somehow? Is this expected behavior?