summaryrefslogtreecommitdiff
path: root/include/arch/rm46l8lp/driver
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2022-07-18 11:25:27 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2022-07-18 11:25:27 +0200
commite6cef3c547e8f73cbf2d3c7ba639cb7d9934c475 (patch)
treeb38bf797c9cd5c226de250e8f569031ebc6131d0 /include/arch/rm46l8lp/driver
parent4da20a683273f252940ff2752d2f497040800b3d (diff)
Add Hercules RM46L8 Launchpad support (Cortex R4F)
Diffstat (limited to 'include/arch/rm46l8lp/driver')
-rw-r--r--include/arch/rm46l8lp/driver/counter.h40
-rw-r--r--include/arch/rm46l8lp/driver/gpio.h74
-rw-r--r--include/arch/rm46l8lp/driver/stdout.h24
-rw-r--r--include/arch/rm46l8lp/driver/uptime.h30
4 files changed, 168 insertions, 0 deletions
diff --git a/include/arch/rm46l8lp/driver/counter.h b/include/arch/rm46l8lp/driver/counter.h
new file mode 100644
index 0000000..ee4b595
--- /dev/null
+++ b/include/arch/rm46l8lp/driver/counter.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2020 Daniel Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#ifndef COUNTER_H
+#define COUNTER_H
+
+#include "rti.h"
+#include <stdint.h>
+
+typedef uint32_t counter_value_t;
+typedef uint32_t counter_overflow_t;
+
+class Counter {
+ private:
+ Counter(const Counter &copy);
+
+ public:
+ uint32_t value;
+ uint32_t overflow;
+
+ Counter() : overflow(0) {}
+
+ inline void start() {
+ rtiREG1->CNT[0].UCx = 0;
+ rtiREG1->CNT[0].FRCx = 0;
+ rtiREG1->GCTRL |= ((uint32)1 << (rtiCOUNTER_BLOCK0 & 3));
+ }
+
+ inline void stop() {
+ rtiREG1->GCTRL &= ~(uint32)((uint32)1 << (rtiCOUNTER_BLOCK0 & 3));
+ overflow = rtiREG1->CNT[0].FRCx;
+ value = rtiREG1->CNT[0].UCx;
+ }
+};
+
+extern Counter counter;
+
+#endif
diff --git a/include/arch/rm46l8lp/driver/gpio.h b/include/arch/rm46l8lp/driver/gpio.h
new file mode 100644
index 0000000..0cefae1
--- /dev/null
+++ b/include/arch/rm46l8lp/driver/gpio.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2022 Daniel Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#ifndef GPIO_H
+#define GPIO_H
+
+#include "gio.h"
+
+class GPIO {
+ private:
+ GPIO(const GPIO &copy);
+
+ public:
+ GPIO () {}
+
+ enum Pin : unsigned char {
+ a_0 = 0, a_1, a_2, a_3, a_4, a_5, a_6, a_7,
+ b_0, b_1, b_2, b_3, b_4, b_5, b_6, b_7,
+ PIN_INVALID
+ };
+
+ inline void setup() {
+ gioInit();
+ }
+ inline void led_on(unsigned char id = 0) {
+ if (id == 0) {
+ gioSetBit(gioPORTB,1, 1);
+ } else {
+ gioSetBit(gioPORTB,2, 1);
+ }
+ }
+ inline void led_off(unsigned char id = 0) {
+ if (id == 0) {
+ gioSetBit(gioPORTB,1, 0);
+ } else {
+ gioSetBit(gioPORTB,2, 0);
+ }
+ }
+ inline void led_toggle(unsigned char id = 0) {
+ if (id == 0) {
+ gioToggleBit(gioPORTB,1);
+ } else {
+ gioToggleBit(gioPORTB,2);
+ }
+ }
+ inline void input(unsigned char const pin) {
+ // TODO
+ }
+ inline void input(unsigned char const pin, unsigned char const pull) {
+ // TODO
+ }
+ inline void output(unsigned char const pin) {
+ // TODO
+ }
+ inline void output(unsigned char const pin, unsigned char const value) {
+ // TODO
+ }
+ inline unsigned char read(unsigned char const pin) {
+ // TODO
+ return 0;
+ }
+ inline void write(unsigned char const pin, unsigned char value) {
+ // TODO
+ }
+ inline void write_mask(unsigned char const pin_base, unsigned char set_mask, unsigned char clear_mask) {
+ // TODO
+ }
+};
+
+extern GPIO gpio;
+
+#endif
diff --git a/include/arch/rm46l8lp/driver/stdout.h b/include/arch/rm46l8lp/driver/stdout.h
new file mode 100644
index 0000000..b701dc1
--- /dev/null
+++ b/include/arch/rm46l8lp/driver/stdout.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2022 Daniel Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#ifndef STANDARDOUTPUT_H
+#define STANDARDOUTPUT_H
+
+#include "object/outputstream.h"
+
+class StandardOutput : public OutputStream {
+ private:
+ StandardOutput(const StandardOutput &copy);
+
+ public:
+ StandardOutput () {}
+ void setup();
+
+ virtual void put(char c) override;
+};
+
+extern StandardOutput kout;
+
+#endif
diff --git a/include/arch/rm46l8lp/driver/uptime.h b/include/arch/rm46l8lp/driver/uptime.h
new file mode 100644
index 0000000..b4e7523
--- /dev/null
+++ b/include/arch/rm46l8lp/driver/uptime.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2020 Daniel Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#ifndef UPTIME_H
+#define UPTIME_H
+
+class Uptime {
+ private:
+ Uptime(const Uptime &copy);
+#ifdef TIMER_S
+ unsigned int seconds;
+#endif
+
+ public:
+#ifdef TIMER_S
+ Uptime () : seconds(0) {}
+#else
+ Uptime () {}
+#endif
+#ifdef TIMER_S
+ inline unsigned int get_s() { return seconds; }
+ inline void tick_s() { seconds++; }
+#endif
+};
+
+extern Uptime uptime;
+
+#endif