From 112bb4911ffc669bae1cd2ce883d59679da6da62 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 10 Sep 2020 13:32:25 +0200 Subject: stm32f446re: implement gpio.read --- include/arch/stm32f446re-nucleo/driver/gpio.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/arch') diff --git a/include/arch/stm32f446re-nucleo/driver/gpio.h b/include/arch/stm32f446re-nucleo/driver/gpio.h index dbb0465..b98078d 100644 --- a/include/arch/stm32f446re-nucleo/driver/gpio.h +++ b/include/arch/stm32f446re-nucleo/driver/gpio.h @@ -62,9 +62,16 @@ class GPIO { } /* inline void output(unsigned char const pin, unsigned char const value) { - } - inline unsigned char read(unsigned char const pin) { }*/ + inline unsigned int read(unsigned char const pin) { + if (pin < pb_0) { + return gpio_get(GPIOA, 1 << pin); + } else if (pin < pc_0) { + return gpio_get(GPIOB, 1 << (pin-pb_0)); + } else if (pin < PIN_INVALID) { + return gpio_get(GPIOC, 1 << (pin-pc_0)); + } + } inline void write(unsigned char const pin, unsigned char value) { if (pin < pb_0) { if (value) { -- cgit v1.2.3