From: Nathael Pajani Date: Tue, 26 Apr 2016 23:00:19 +0000 (+0200) Subject: Add gpio_read() helper X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=eee75bcadeb0c64583df34c7eaf7e43589bc357a;p=soft%2Flpc122x%2Fcore Add gpio_read() helper --- 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