Lots of clean up, basic kscan working, remove zephyr-rust.

This commit is contained in:
Pete Johanson 2020-05-01 14:58:00 -04:00
parent 5b4e43cebd
commit 52bfc9dd84
11 changed files with 46 additions and 93 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "zephyr-rust"]
path = zephyr-rust
url = https://github.com/tylerwhall/zephyr-rust.git

View File

@ -1,14 +1,9 @@
# Find Zephyr. This also loads Zephyr's build system. # Find Zephyr. This also loads Zephyr's build system.
cmake_minimum_required(VERSION 3.13.1) 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) find_package(Zephyr)
project(zmk) project(zmk)
# Add your source file to the "app" target. This must come after # Add your source file to the "app" target. This must come after

View File

@ -16,7 +16,6 @@
zephyr,shell-uart = &usart1; zephyr,shell-uart = &usart1;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zmk,matrix = &matrix0;
}; };
leds { leds {
@ -55,25 +54,23 @@
}; };
}; };
matrix0: kscan_matrix { kscan {
rows { compatible = "gpio-kscan";
gpio-map = <0 0 &gpioa 10 0>, label = "Keyscan Matrix";
<1 0 &gpioa 9 0>, row-gpios = <&gpioa 10 GPIO_ACTIVE_HIGH>,
<2 0 &gpioa 8 0>, <&gpioa 9 GPIO_ACTIVE_HIGH>,
<3 0 &gpiob 15 0>, <&gpioa 8 GPIO_ACTIVE_HIGH>,
<4 0 &gpioc 13 0>, <&gpiob 15 GPIO_ACTIVE_HIGH>,
<5 0 &gpioc 14 0>, <&gpioc 13 GPIO_ACTIVE_HIGH>,
<6 0 &gpioc 15 0>, <&gpioc 14 GPIO_ACTIVE_HIGH>,
<7 0 &gpioa 2 0>; <&gpioc 15 GPIO_ACTIVE_HIGH>,
}; <&gpioa 2 GPIO_ACTIVE_HIGH>;
columns { col-gpios = <&gpiob 11 GPIO_ACTIVE_HIGH>,
gpio-map = <0 0 &gpiob 11 0>, <&gpiob 10 GPIO_ACTIVE_HIGH>,
<1 0 &gpiob 10 0>, <&gpiob 2 GPIO_ACTIVE_HIGH>,
<2 0 &gpiob 2 0>, <&gpiob 1 GPIO_ACTIVE_HIGH>,
<3 0 &gpiob 1 0>, <&gpioa 7 GPIO_ACTIVE_HIGH>,
<4 0 &gpioa 7 0>, <&gpiob 0 GPIO_ACTIVE_HIGH>;
<5 0 &gpiob 0 0>;
};
}; };
gpio_keys { gpio_keys {

View File

@ -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)

View File

@ -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)>;
};
};

View File

@ -1,4 +1,4 @@
CONFIG_RUST=y # CONFIG_RUST=y
CONFIG_RUST_ALLOC_POOL=y # CONFIG_RUST_ALLOC_POOL=y
CONFIG_KSCAN=y CONFIG_KSCAN=y
CONFIG_KSCAN_GPIO=y CONFIG_KSCAN_GPIO=y

View File

@ -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);
}
}

View File

@ -10,59 +10,24 @@
#include <drivers/gpio.h> #include <drivers/gpio.h>
#include <drivers/kscan.h> #include <drivers/kscan.h>
#include "zmk_lib.h"
/* 1000 msec = 1 sec */ void zmk_kscan_callback(struct device *dev, u32_t row, u32_t column, bool pressed) {
#define SLEEP_TIME_MS 1000 printk("Row: %d, col: %d, pressed: %s\n", row, column, (pressed ? "true" : "false"));
}
/* 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 main(void) void main(void)
{ {
/*
struct device *dev; struct device *dev;
bool led_is_on = true; printk("Welcome to ZMK!\n");
int ret;
dev = device_get_binding(LED0); dev = device_get_binding(CONFIG_KSCAN_MATRIX_DEV_NAME);
if (dev == NULL) { if (dev == NULL) {
printk("NO DEVICE!\n");
return; return;
} }
ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS); kscan_config(dev, zmk_kscan_callback);
if (ret < 0) {
return;
}
*/
zmk_run(); kscan_enable_callback(dev);
// while (1) {
// gpio_pin_set(dev, PIN, (int)led_is_on);
// led_is_on = !led_is_on;
// k_msleep(SLEEP_TIME_MS);
// }
} }

View File

@ -1,7 +0,0 @@
#ifndef ZMK_LIB_H
#define ZMK_LIB_H
void zmk_run(void);
#endif

@ -1 +0,0 @@
Subproject commit 78b433aa9e0255a719fb0c3c9ac303f3924c1348