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