summaryrefslogtreecommitdiff
path: root/src/arch/stm32f746zg-nucleo/driver
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2024-02-08 13:46:48 +0100
committerBirte Kristina Friesel <birte.friesel@uos.de>2024-02-08 13:46:48 +0100
commitec871ef8ae230bcb779c8535c3c4526817fd5d93 (patch)
tree558e731639f7ece070d7abd14c3c82afa11f9647 /src/arch/stm32f746zg-nucleo/driver
parent18db600341bcf1c21e4282515d458b898639f349 (diff)
Add preliminary STM32F746ZG-Nucleo support
Diffstat (limited to 'src/arch/stm32f746zg-nucleo/driver')
-rw-r--r--src/arch/stm32f746zg-nucleo/driver/counter.cc19
-rw-r--r--src/arch/stm32f746zg-nucleo/driver/gpio.cc8
-rw-r--r--src/arch/stm32f746zg-nucleo/driver/stdout.cc36
-rw-r--r--src/arch/stm32f746zg-nucleo/driver/uptime.cc8
4 files changed, 71 insertions, 0 deletions
diff --git a/src/arch/stm32f746zg-nucleo/driver/counter.cc b/src/arch/stm32f746zg-nucleo/driver/counter.cc
new file mode 100644
index 0000000..5f007f1
--- /dev/null
+++ b/src/arch/stm32f746zg-nucleo/driver/counter.cc
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2024 Birte Kristina Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "arch.h"
+#include "driver/counter.h"
+
+Counter counter;
+
+void tim2_isr(void)
+{
+ if (timer_get_flag(TIM2, TIM_SR_UIF)) {
+ timer_clear_flag(TIM2, TIM_SR_UIF);
+ if (counter.overflow < 4294967295) {
+ counter.overflow++;
+ }
+ }
+}
diff --git a/src/arch/stm32f746zg-nucleo/driver/gpio.cc b/src/arch/stm32f746zg-nucleo/driver/gpio.cc
new file mode 100644
index 0000000..82a9fd0
--- /dev/null
+++ b/src/arch/stm32f746zg-nucleo/driver/gpio.cc
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2024 Birte Kristina Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "driver/gpio.h"
+
+GPIO gpio;
diff --git a/src/arch/stm32f746zg-nucleo/driver/stdout.cc b/src/arch/stm32f746zg-nucleo/driver/stdout.cc
new file mode 100644
index 0000000..9a5bdfb
--- /dev/null
+++ b/src/arch/stm32f746zg-nucleo/driver/stdout.cc
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2024 Birte Kristina Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "driver/stdout.h"
+
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/gpio.h>
+#include <libopencm3/stm32/usart.h>
+
+void StandardOutput::setup()
+{
+ rcc_periph_clock_enable(RCC_USART3);
+ gpio_mode_setup(GPIOD, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO8);
+ gpio_set_af(GPIOD, GPIO_AF7, GPIO8);
+
+ usart_set_baudrate(USART3, 115200);
+ usart_set_databits(USART3, 8);
+ usart_set_stopbits(USART3, USART_STOPBITS_1);
+ usart_set_mode(USART3, USART_MODE_TX);
+ usart_set_parity(USART3, USART_PARITY_NONE);
+ usart_set_flow_control(USART3, USART_FLOWCONTROL_NONE);
+
+ usart_enable(USART3);
+}
+
+void StandardOutput::put(char c)
+{
+ usart_send_blocking(USART3, c);
+ if (c == '\n') {
+ put('\r');
+ }
+}
+
+StandardOutput kout;
diff --git a/src/arch/stm32f746zg-nucleo/driver/uptime.cc b/src/arch/stm32f746zg-nucleo/driver/uptime.cc
new file mode 100644
index 0000000..8ddb57a
--- /dev/null
+++ b/src/arch/stm32f746zg-nucleo/driver/uptime.cc
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2024 Birte Kristina Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "driver/uptime.h"
+
+Uptime uptime;