From acb2c692d34eb42ca567b4f80f5dc90da5323789 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Sat, 26 Dec 2020 07:44:03 +0000 Subject: [PATCH] Add power led always on to pockettype bring up --- .../boards/shields/pockettype/CMakeLists.txt | 6 +++ .../boards/shields/pockettype/pwr_led.c | 46 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 keyboards/zmk-config/config/boards/shields/pockettype/CMakeLists.txt create mode 100644 keyboards/zmk-config/config/boards/shields/pockettype/pwr_led.c diff --git a/keyboards/zmk-config/config/boards/shields/pockettype/CMakeLists.txt b/keyboards/zmk-config/config/boards/shields/pockettype/CMakeLists.txt new file mode 100644 index 00000000..59c48b00 --- /dev/null +++ b/keyboards/zmk-config/config/boards/shields/pockettype/CMakeLists.txt @@ -0,0 +1,6 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +target_sources(app PRIVATE pwr_led.c) diff --git a/keyboards/zmk-config/config/boards/shields/pockettype/pwr_led.c b/keyboards/zmk-config/config/boards/shields/pockettype/pwr_led.c new file mode 100644 index 00000000..54a043f4 --- /dev/null +++ b/keyboards/zmk-config/config/boards/shields/pockettype/pwr_led.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include +#include + +#define PWR_LED_NODE DT_ALIAS(led_p) + +#if DT_NODE_HAS_STATUS(PWR_LED_NODE, okay) +#define PWR_LED DT_GPIO_LABEL(PWR_LED_NODE, gpios) +#define PWR_LED_PIN DT_GPIO_PIN(PWR_LED_NODE, gpios) +#else +/* A build error here means your board isn't set up to blink an LED. */ +#error "Unsupported board: pwr_led devicetree alias is not defined" +#define PWR_LED "" +#define PIN 0 +#define FLAGS 0 +#endif + +static int pwr_led_init(const struct device *_arg) { + ARG_UNUSED(_arg); + + const struct device *dev; + int ret; + + dev = device_get_binding(PWR_LED); + if (dev == NULL) { + return; + } + + ret = gpio_pin_configure(dev, PWR_LED_PIN, GPIO_OUTPUT_ACTIVE); + if (ret < 0) { + return; + } + + gpio_pin_set(dev, PIN, (int)true); + + return 0; +} + +SYS_INIT(pwr_led_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);