Commit 28662174 authored by Sergei Miroshnichenko's avatar Sergei Miroshnichenko

RM#1313 gpio: stm32: Append gpio API with get()

parent 7c239aed
......@@ -316,3 +316,24 @@ s32 stm32f2_gpout_set(const struct stm32f2_gpio_dsc *dsc, int state)
out:
return rv;
}
int stm32f2_gpout_get(const struct stm32f2_gpio_dsc *dsc)
{
volatile struct stm32f2_gpio_regs *gpio_regs;
int state;
if (!dsc || dsc->port >= ARRAY_SIZE(io_base) || dsc->pin > 15) {
if (gd->have_console) {
printf("%s: incorrect params %d.%d.\n", __func__,
dsc ? dsc->port : -1,
dsc ? dsc->pin : -1);
}
return -EINVAL;
}
gpio_regs = (struct stm32f2_gpio_regs *)io_base[dsc->port];
state = !!(gpio_regs->idr & (1 << dsc->pin));
return state;
}
......@@ -103,5 +103,6 @@ int stm32f2_gpio_config(const struct stm32f2_gpio_dsc *gpio_dsc,
* Set GPOUT to the state specified (1, 0)
*/
int stm32f2_gpout_set(const struct stm32f2_gpio_dsc *gpio_dsc, int state);
int stm32f2_gpout_get(const struct stm32f2_gpio_dsc *dsc);
#endif /* _STM32F2_GPIO_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment