summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-04-21 16:20:34 -0400
committerPete Johanson <peter@peterjohanson.com>2020-04-21 16:20:34 -0400
commit85c8be89dea8f7a00e8efb06d38e2b32f3459935 (patch)
treeb87dcac5eeba3f67fd2db7e43712043d82b9a607 /src/main.c
Initial work.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..e487325
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <zephyr.h>
+#include <device.h>
+#include <devicetree.h>
+#include <drivers/gpio.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 main(void)
+{
+ struct device *dev;
+ bool led_is_on = true;
+ int ret;
+
+ dev = device_get_binding(LED0);
+ if (dev == NULL) {
+ return;
+ }
+
+ ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
+ if (ret < 0) {
+ return;
+ }
+
+ zmk_run();
+ // while (1) {
+ // gpio_pin_set(dev, PIN, (int)led_is_on);
+ // led_is_on = !led_is_on;
+ // k_msleep(SLEEP_TIME_MS);
+ // }
+}