summaryrefslogtreecommitdiff
path: root/include/arch/stm32f446re-nucleo
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-08-12 14:50:59 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2020-08-12 14:50:59 +0200
commit7b962b22a1702f0aeaf0b5cdb794d18e441a8b0f (patch)
tree75096d99ae9f1e29cb5108bcd1f1b29c6fa0558c /include/arch/stm32f446re-nucleo
parent3d26238ec60d82fb58e5a306e5ea78b564d5fb3a (diff)
working AEMR timing benchmarks on stm32f446re
Diffstat (limited to 'include/arch/stm32f446re-nucleo')
-rw-r--r--include/arch/stm32f446re-nucleo/driver/gpio.h40
1 files changed, 35 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;