summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/arch/stm32f446re-nucleo/driver/gpio.h40
-rw-r--r--src/arch/stm32f446re-nucleo/Makefile.inc2
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