diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-09-10 13:32:25 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-09-10 13:32:25 +0200 |
commit | 112bb4911ffc669bae1cd2ce883d59679da6da62 (patch) | |
tree | b6d537d0de5b7848bd358fd9b348b7a09a087d31 | |
parent | da25f533e1c25766bee540bf7de00353930bf29d (diff) |
stm32f446re: implement gpio.read
-rw-r--r-- | include/arch/stm32f446re-nucleo/driver/gpio.h | 11 |
1 files changed, 9 insertions, 2 deletions
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) { |