Add power led always on to pockettype bring up

This commit is contained in:
KemoNine 2020-12-26 07:44:03 +00:00
parent 0b3f933ebe
commit acb2c692d3
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,6 @@
#
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
target_sources(app PRIVATE pwr_led.c)

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <zephyr.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h>
#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);