Skip to content
Snippets Groups Projects
Commit c39f4d83 authored by Gaëtan Harter's avatar Gaëtan Harter
Browse files

saul/gpio: add support to initialized state

parent 05402dea
No related branches found
No related tags found
No related merge requests found
File added
...@@ -34,8 +34,8 @@ extern "C" { ...@@ -34,8 +34,8 @@ extern "C" {
#ifdef MODULE_SAUL_GPIO #ifdef MODULE_SAUL_GPIO
typedef enum { typedef enum {
SAUL_GPIO_INVERTED = (1 << 0), /**< pin is used as inverted */ SAUL_GPIO_INVERTED = (1 << 0), /**< pin is used as inverted */
SAUL_GPIO_INIT_CLEAR = 1 << 1, /**< set pin inactive after initialization */ SAUL_GPIO_INIT_CLEAR = (1 << 1), /**< set pin inactive after init */
SAUL_GPIO_INIT_SET = 1 << 2, /**< set pin active after initialization */ SAUL_GPIO_INIT_SET = (1 << 2), /**< set pin active after init */
} saul_gpio_flags_t; } saul_gpio_flags_t;
/** /**
......
...@@ -66,6 +66,12 @@ void auto_init_gpio(void) ...@@ -66,6 +66,12 @@ void auto_init_gpio(void)
} }
/* initialize the GPIO pin */ /* initialize the GPIO pin */
gpio_init(p->pin, p->mode); gpio_init(p->pin, p->mode);
/* set initial pin state if configured */
if (p->flags & (SAUL_GPIO_INIT_CLEAR | SAUL_GPIO_INIT_SET)) {
phydat_t s;
s.val[0] = (p->flags & SAUL_GPIO_INIT_SET);
saul_reg_entries[i].driver->write(p, &s);
}
/* add to registry */ /* add to registry */
saul_reg_add(&(saul_reg_entries[i])); saul_reg_add(&(saul_reg_entries[i]));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment