From eee75bcadeb0c64583df34c7eaf7e43589bc357a Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Wed, 27 Apr 2016 01:00:19 +0200 Subject: [PATCH] Add gpio_read() helper --- include/drivers/gpio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/drivers/gpio.h b/include/drivers/gpio.h index 777284d..86bb8bb 100644 --- a/include/drivers/gpio.h +++ b/include/drivers/gpio.h @@ -99,6 +99,12 @@ void gpio_off(void); gpio_port->toggle = (1 << gpio.pin);\ } +static inline uint32_t gpio_read(const struct pio gpio) +{ + struct lpc_gpio* gpio_port = LPC_GPIO_REGS(gpio.port); + return (gpio_port->in & (1 << gpio.pin)); +} + /* GPIO Configuration * This function calls the config_pio() function for the gpio with the given -- 2.43.0