summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--CMakeLists.txt7
-rw-r--r--boards/arm/planck/planck_rev6.dts37
-rw-r--r--boards/shields/petejohanson_handwire/Kconfig.defconfig0
-rw-r--r--boards/shields/petejohanson_handwire/Kconfig.shield6
-rw-r--r--boards/shields/petejohanson_handwire/petejohanson_handwire.overlay12
-rw-r--r--prj.conf4
-rw-r--r--src/lib.rs11
-rw-r--r--src/main.c51
-rw-r--r--src/zmk_lib.h7
m---------zephyr-rust0
11 files changed, 46 insertions, 92 deletions
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index c41b243..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "zephyr-rust"]
- path = zephyr-rust
- url = https://github.com/tylerwhall/zephyr-rust.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index baeedcc..9667067 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,9 @@
# Find Zephyr. This also loads Zephyr's build system.
cmake_minimum_required(VERSION 3.13.1)
-list(APPEND BOARD_ROOT .)
+list(APPEND BOARD_ROOT ${CMAKE_SOURCE_DIR})
-get_filename_component(ZEPHYR_RUST ${CMAKE_CURRENT_SOURCE_DIR}/zephyr-rust ABSOLUTE)
-list(APPEND ZEPHYR_EXTRA_MODULES ${ZEPHYR_RUST})
-
-include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
find_package(Zephyr)
-
project(zmk)
# Add your source file to the "app" target. This must come after
diff --git a/boards/arm/planck/planck_rev6.dts b/boards/arm/planck/planck_rev6.dts
index a3e14f7..58de7a4 100644
--- a/boards/arm/planck/planck_rev6.dts
+++ b/boards/arm/planck/planck_rev6.dts
@@ -16,7 +16,6 @@
zephyr,shell-uart = &usart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
- zmk,matrix = &matrix0;
};
leds {
@@ -55,25 +54,23 @@
};
};
- matrix0: kscan_matrix {
- rows {
- gpio-map = <0 0 &gpioa 10 0>,
- <1 0 &gpioa 9 0>,
- <2 0 &gpioa 8 0>,
- <3 0 &gpiob 15 0>,
- <4 0 &gpioc 13 0>,
- <5 0 &gpioc 14 0>,
- <6 0 &gpioc 15 0>,
- <7 0 &gpioa 2 0>;
- };
- columns {
- gpio-map = <0 0 &gpiob 11 0>,
- <1 0 &gpiob 10 0>,
- <2 0 &gpiob 2 0>,
- <3 0 &gpiob 1 0>,
- <4 0 &gpioa 7 0>,
- <5 0 &gpiob 0 0>;
- };
+ kscan {
+ compatible = "gpio-kscan";
+ label = "Keyscan Matrix";
+ row-gpios = <&gpioa 10 GPIO_ACTIVE_HIGH>,
+ <&gpioa 9 GPIO_ACTIVE_HIGH>,
+ <&gpioa 8 GPIO_ACTIVE_HIGH>,
+ <&gpiob 15 GPIO_ACTIVE_HIGH>,
+ <&gpioc 13 GPIO_ACTIVE_HIGH>,
+ <&gpioc 14 GPIO_ACTIVE_HIGH>,
+ <&gpioc 15 GPIO_ACTIVE_HIGH>,
+ <&gpioa 2 GPIO_ACTIVE_HIGH>;
+ col-gpios = <&gpiob 11 GPIO_ACTIVE_HIGH>,
+ <&gpiob 10 GPIO_ACTIVE_HIGH>,
+ <&gpiob 2 GPIO_ACTIVE_HIGH>,
+ <&gpiob 1 GPIO_ACTIVE_HIGH>,
+ <&gpioa 7 GPIO_ACTIVE_HIGH>,
+ <&gpiob 0 GPIO_ACTIVE_HIGH>;
};
gpio_keys {
diff --git a/boards/shields/petejohanson_handwire/Kconfig.defconfig b/boards/shields/petejohanson_handwire/Kconfig.defconfig
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/boards/shields/petejohanson_handwire/Kconfig.defconfig
diff --git a/boards/shields/petejohanson_handwire/Kconfig.shield b/boards/shields/petejohanson_handwire/Kconfig.shield
new file mode 100644
index 0000000..7e8ad48
--- /dev/null
+++ b/boards/shields/petejohanson_handwire/Kconfig.shield
@@ -0,0 +1,6 @@
+# Copyright (c) 2019 Linaro Limited
+# SPDX-License-Identifier: Apache-2.0
+
+config SHIELD_PETEJOHANSON_HANDWIRE
+ def_bool $(shields_list_contains,petejohanson_handwire)
+
diff --git a/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay b/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay
new file mode 100644
index 0000000..678070e
--- /dev/null
+++ b/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay
@@ -0,0 +1,12 @@
+
+/ {
+ kscan {
+ compatible = "gpio-kscan";
+ label = "Handwired GPIO KSCAN matrix";
+
+ row-gpios = <&arduino_header 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
+ <&arduino_header 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
+ col-gpios = <&arduino_header 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
+ <&arduino_header 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
+ };
+};
diff --git a/prj.conf b/prj.conf
index 382a34a..5c21d2c 100644
--- a/prj.conf
+++ b/prj.conf
@@ -1,4 +1,4 @@
-CONFIG_RUST=y
-CONFIG_RUST_ALLOC_POOL=y
+# CONFIG_RUST=y
+# CONFIG_RUST_ALLOC_POOL=y
CONFIG_KSCAN=y
CONFIG_KSCAN_GPIO=y
diff --git a/src/lib.rs b/src/lib.rs
deleted file mode 100644
index 75ada98..0000000
--- a/src/lib.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-#[no_mangle]
-pub extern "C" fn zmk_run() {
-}
-
-#[cfg(test)]
-mod tests {
- #[test]
- fn it_works() {
- assert_eq!(2 + 2, 4);
- }
-}
diff --git a/src/main.c b/src/main.c
index 21f481a..6640e47 100644
--- a/src/main.c
+++ b/src/main.c
@@ -10,59 +10,24 @@
#include <drivers/gpio.h>
#include <drivers/kscan.h>
-#include "zmk_lib.h"
-/* 1000 msec = 1 sec */
-#define SLEEP_TIME_MS 1000
-
-/* The devicetree node identifier for the "led0" alias. */
-/*
-#define LED0_NODE DT_ALIAS(led0)
-
-#if DT_HAS_NODE(LED0_NODE)
-#define LED0 DT_GPIO_LABEL(LED0_NODE, gpios)
-#define PIN DT_GPIO_PIN(LED0_NODE, gpios)
-#if DT_PHA_HAS_CELL(LED0_NODE, gpios, flags)
-#define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios)
-#endif
-#else
-*/
-/* A build error here means your board isn't set up to blink an LED. */
-/*
-#error "Unsupported board: led0 devicetree alias is not defined"
-#define LED0 ""
-#define PIN 0
-#endif
-
-#ifndef FLAGS
-#define FLAGS 0
-#endif
-
-*/
+void zmk_kscan_callback(struct device *dev, u32_t row, u32_t column, bool pressed) {
+ printk("Row: %d, col: %d, pressed: %s\n", row, column, (pressed ? "true" : "false"));
+}
void main(void)
{
- /*
struct device *dev;
- bool led_is_on = true;
- int ret;
+ printk("Welcome to ZMK!\n");
- dev = device_get_binding(LED0);
+ dev = device_get_binding(CONFIG_KSCAN_MATRIX_DEV_NAME);
if (dev == NULL) {
+ printk("NO DEVICE!\n");
return;
}
- ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
- if (ret < 0) {
- return;
- }
- */
+ kscan_config(dev, zmk_kscan_callback);
- zmk_run();
- // while (1) {
- // gpio_pin_set(dev, PIN, (int)led_is_on);
- // led_is_on = !led_is_on;
- // k_msleep(SLEEP_TIME_MS);
- // }
+ kscan_enable_callback(dev);
}
diff --git a/src/zmk_lib.h b/src/zmk_lib.h
deleted file mode 100644
index 0b7706e..0000000
--- a/src/zmk_lib.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef ZMK_LIB_H
-#define ZMK_LIB_H
-
-void zmk_run(void);
-
-#endif
-
diff --git a/zephyr-rust b/zephyr-rust
deleted file mode 160000
-Subproject 78b433aa9e0255a719fb0c3c9ac303f3924c134