summaryrefslogtreecommitdiff
path: root/src/arch/msp430fr5969lp/driver
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-01-27 19:51:48 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2024-01-27 19:51:48 +0100
commitd4b6bef1c4a6495a4b6fc8ca9f2c438e23754261 (patch)
treef8c4085888b38be36a8dfd29f585583613e38124 /src/arch/msp430fr5969lp/driver
parent2c26e3702413f62649f1aa38a407927df5f6fe30 (diff)
msp430fr5969: add UART input on eUSCI_A1
Diffstat (limited to 'src/arch/msp430fr5969lp/driver')
-rw-r--r--src/arch/msp430fr5969lp/driver/stdin1.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/arch/msp430fr5969lp/driver/stdin1.cc b/src/arch/msp430fr5969lp/driver/stdin1.cc
new file mode 100644
index 0000000..efb7f90
--- /dev/null
+++ b/src/arch/msp430fr5969lp/driver/stdin1.cc
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2020 Birte Kristina Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "driver/stdin1.h"
+#include <msp430.h>
+
+void StandardInput1::setup()
+{
+ UCA1CTLW0 |= UCSWRST;
+ P2SEL0 &= ~BIT6;
+ P2SEL1 |= BIT6;
+ UCA1CTLW0 &= ~UCSWRST;
+ UCA1IE |= UCRXIE;
+}
+
+bool StandardInput1::hasKey()
+{
+ if (write_pos != read_pos) {
+ return true;
+ }
+ return false;
+}
+
+char StandardInput1::getKey()
+{
+ char ret = buffer[read_pos++];
+ read_pos %= bufsize;
+ return ret;
+}
+
+StandardInput1 kin1;
+
+__attribute__((interrupt(USCI_A1_VECTOR))) __attribute__((wakeup)) void handle_stdin1()
+{
+ if (UCA1IFG & UCRXIFG) {
+ kin1.addKey(UCA1RXBUF);
+ }
+}