From 7b962b22a1702f0aeaf0b5cdb794d18e441a8b0f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 12 Aug 2020 14:50:59 +0200 Subject: working AEMR timing benchmarks on stm32f446re --- include/arch/stm32f446re-nucleo/driver/gpio.h | 40 +++++++++++++++++++++++---- src/arch/stm32f446re-nucleo/Makefile.inc | 2 ++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/include/arch/stm32f446re-nucleo/driver/gpio.h b/include/arch/stm32f446re-nucleo/driver/gpio.h index 378a84f..787b33d 100644 --- a/include/arch/stm32f446re-nucleo/driver/gpio.h +++ b/include/arch/stm32f446re-nucleo/driver/gpio.h @@ -40,22 +40,52 @@ class GPIO { gpio_toggle(GPIOA, GPIO5); } #pragma GCC diagnostic pop - /* inline void input(unsigned char const pin) { + if (pin < pb_0) { + gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_NONE, 1 << pin); + } else if (pin < pc_0) { + gpio_mode_setup(GPIOB, GPIO_MODE_INPUT, GPIO_PUPD_NONE, 1 << (pin - pb_0)); + } else if (pin < PIN_INVALID) { + gpio_mode_setup(GPIOC, GPIO_MODE_INPUT, GPIO_PUPD_NONE, 1 << (pin - PIN_INVALID)); + } } inline void input(unsigned char const pin, unsigned char const pull) { } inline void output(unsigned char const pin) { + if (pin < pb_0) { + gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, 1 << pin); + } else if (pin < pc_0) { + gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, 1 << (pin - pb_0)); + } else if (pin < PIN_INVALID) { + gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, 1 << (pin - PIN_INVALID)); + } } + /* inline void output(unsigned char const pin, unsigned char const value) { } inline unsigned char read(unsigned char const pin) { - } + }*/ inline void write(unsigned char const pin, unsigned char value) { + if (pin < pb_0) { + if (value) { + gpio_port_write(GPIOA, gpio_port_read(GPIOA) | (1 << pin)); + } else { + gpio_port_write(GPIOA, gpio_port_read(GPIOA) & ~(1 << pin)); + } + } else if (pin < pc_0) { + if (value) { + gpio_port_write(GPIOB, gpio_port_read(GPIOB) | (1 << (pin-pc_0))); + } else { + gpio_port_write(GPIOB, gpio_port_read(GPIOB) & ~(1 << (pin-pc_0))); + } + } else if (pin < PIN_INVALID) { + if (value) { + gpio_port_write(GPIOC, gpio_port_read(GPIOC) | (1 << (pin-PIN_INVALID))); + } else { + gpio_port_write(GPIOC, gpio_port_read(GPIOC) & ~(1 << (pin-PIN_INVALID))); + } + } } - inline void write_mask(unsigned char const pin_base, unsigned char set_mask, unsigned char clear_mask) { - } - */ }; extern GPIO gpio; diff --git a/src/arch/stm32f446re-nucleo/Makefile.inc b/src/arch/stm32f446re-nucleo/Makefile.inc index 263fb2f..8dfaecd 100644 --- a/src/arch/stm32f446re-nucleo/Makefile.inc +++ b/src/arch/stm32f446re-nucleo/Makefile.inc @@ -2,6 +2,8 @@ SERIAL_PORT ?= ttyACM0 +cpu_freq ?= 168000000 + INCLUDES += -Iext/libopencm3/include COMMON_FLAGS += --static -nostartfiles -g3 -Os -fno-common -- cgit v1.2.3