Skip to content

Commit

Permalink
refactor(ext-power): Add init-delay-ms option
Browse files Browse the repository at this point in the history
Co-authored-by: Pete Johanson <peter@peterjohanson.com>
  • Loading branch information
Nicell and petejohanson committed Feb 16, 2021
1 parent b43fb85 commit 5766136
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/dts/bindings/zmk,ext-power-generic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ properties:
label:
type: string
required: true
init-delay-ms:
type: int
description: Number of milliseconds to delay after initializing driver
required: false
8 changes: 7 additions & 1 deletion app/src/ext_power_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct ext_power_generic_config {
const char *label;
const uint8_t pin;
const uint8_t flags;
const uint16_t init_delay_ms;
};

struct ext_power_generic_data {
Expand Down Expand Up @@ -171,6 +172,10 @@ static int ext_power_generic_init(const struct device *dev) {
ext_power_enable(dev);
#endif

if (config->init_delay_ms) {
k_msleep(config->init_delay_ms);
}

return 0;
}

Expand Down Expand Up @@ -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 = {
.label = DT_INST_GPIO_LABEL(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 = {
.status = false,
Expand Down

0 comments on commit 5766136

Please sign in to comment.