Browse Source

refactor(ext-power): Add init-delay-ms option

Co-authored-by: Pete Johanson <peter@peterjohanson.com>
xmkb
Nick Winans 4 years ago committed by Pete Johanson
parent
commit
57661362ea
  1. 4
      app/dts/bindings/zmk,ext-power-generic.yaml
  2. 8
      app/src/ext_power_generic.c

4
app/dts/bindings/zmk,ext-power-generic.yaml

@ -15,3 +15,7 @@ properties:
label: label:
type: string type: string
required: true required: true
init-delay-ms:
type: int
description: Number of milliseconds to delay after initializing driver
required: false

8
app/src/ext_power_generic.c

@ -23,6 +23,7 @@ struct ext_power_generic_config {
const char *label; const char *label;
const uint8_t pin; const uint8_t pin;
const uint8_t flags; const uint8_t flags;
const uint16_t init_delay_ms;
}; };
struct ext_power_generic_data { struct ext_power_generic_data {
@ -171,6 +172,10 @@ static int ext_power_generic_init(const struct device *dev) {
ext_power_enable(dev); ext_power_enable(dev);
#endif #endif
if (config->init_delay_ms) {
k_msleep(config->init_delay_ms);
}
return 0; return 0;
} }
@ -210,7 +215,8 @@ static int ext_power_generic_pm_control(const struct device *dev, uint32_t ctrl_
static const struct ext_power_generic_config config = { static const struct ext_power_generic_config config = {
.label = DT_INST_GPIO_LABEL(0, control_gpios), .label = DT_INST_GPIO_LABEL(0, control_gpios),
.pin = DT_INST_GPIO_PIN(0, control_gpios), .pin = DT_INST_GPIO_PIN(0, control_gpios),
.flags = DT_INST_GPIO_FLAGS(0, control_gpios)}; .flags = DT_INST_GPIO_FLAGS(0, control_gpios),
.init_delay_ms = DT_INST_PROP_OR(0, init_delay_ms, 0)};
static struct ext_power_generic_data data = { static struct ext_power_generic_data data = {
.status = false, .status = false,

Loading…
Cancel
Save