2020-04-22 06:20:34 +10:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zephyr.h>
|
|
|
|
#include <device.h>
|
|
|
|
#include <devicetree.h>
|
|
|
|
#include <drivers/gpio.h>
|
2020-04-26 12:41:20 +10:00
|
|
|
#include <drivers/kscan.h>
|
2020-04-22 06:20:34 +10:00
|
|
|
|
|
|
|
|
2020-05-02 04:58:00 +10:00
|
|
|
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"));
|
|
|
|
}
|
2020-04-26 12:41:20 +10:00
|
|
|
|
2020-04-22 06:20:34 +10:00
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
struct device *dev;
|
2020-05-02 04:58:00 +10:00
|
|
|
printk("Welcome to ZMK!\n");
|
2020-04-22 06:20:34 +10:00
|
|
|
|
2020-05-02 04:58:00 +10:00
|
|
|
dev = device_get_binding(CONFIG_KSCAN_MATRIX_DEV_NAME);
|
2020-04-22 06:20:34 +10:00
|
|
|
if (dev == NULL) {
|
2020-05-02 04:58:00 +10:00
|
|
|
printk("NO DEVICE!\n");
|
2020-04-22 06:20:34 +10:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-02 04:58:00 +10:00
|
|
|
kscan_config(dev, zmk_kscan_callback);
|
2020-04-22 06:20:34 +10:00
|
|
|
|
2020-05-02 04:58:00 +10:00
|
|
|
kscan_enable_callback(dev);
|
2020-04-22 06:20:34 +10:00
|
|
|
}
|