Skip to content

Commit

Permalink
tests: input: add a gpio-kbd-matrix test suite
Browse files Browse the repository at this point in the history
Add an initial test suite for the gpio-kbd-matrix driver.

Signed-off-by: Fabio Baltieri <[email protected]>
  • Loading branch information
fabiobaltieri committed Dec 21, 2023
1 parent 109c53d commit 978b0bb
Show file tree
Hide file tree
Showing 7 changed files with 507 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/drivers/input/gpio_kbd_matrix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(input_gpio_kbd_matrix)

target_include_directories(app PRIVATE ${ZEPHYR_BASE}/drivers/input)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
7 changes: 7 additions & 0 deletions tests/drivers/input/gpio_kbd_matrix/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2023 Google LLC
# SPDX-License-Identifier: Apache-2.0

config INPUT_KBD_DRIVE_COLUMN_HOOK
default y

source "Kconfig.zephyr"
49 changes: 49 additions & 0 deletions tests/drivers/input/gpio_kbd_matrix/boards/native_sim.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2023 Google LLC
*
* SPDX-License-Identifier: Apache-2.0
*/

&gpio0 {
ngpios = <12>;
};

/ {
kbd_matrix_interrupt: kbd-matrix-interrupt {
compatible = "gpio-kbd-matrix";
row-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
<&gpio0 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
col-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>,
<&gpio0 3 GPIO_ACTIVE_LOW>;
debounce-down-ms = <80>;
debounce-up-ms = <40>;
poll-timeout-ms = <500>;
};

kbd_matrix_poll: kbd-matrix-poll {
compatible = "gpio-kbd-matrix";
row-gpios = <&gpio0 4 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
<&gpio0 5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
col-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>,
<&gpio0 7 GPIO_ACTIVE_LOW>;
debounce-down-ms = <40>;
debounce-up-ms = <80>;
poll-timeout-ms = <500>;
idle-mode = "poll";
col-drive-inactive;
};

kbd_matrix_scan: kbd-matrix-scan {
compatible = "gpio-kbd-matrix";
/* pins out of sequence to test non direct read */
row-gpios = <&gpio0 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
<&gpio0 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
col-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>,
<&gpio0 10 GPIO_ACTIVE_LOW>;
debounce-down-ms = <80>;
debounce-up-ms = <40>;
poll-timeout-ms = <0>;
col-drive-inactive;
idle-mode = "scan";
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright 2023 Google LLC
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "native_sim.overlay"
6 changes: 6 additions & 0 deletions tests/drivers/input/gpio_kbd_matrix/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_ZTEST=y
CONFIG_GPIO=y
CONFIG_INPUT=y
CONFIG_INPUT_MODE_SYNCHRONOUS=y
Loading

0 comments on commit 978b0bb

Please sign in to comment.