summaryrefslogtreecommitdiff
path: root/src/uart.c
diff options
context:
space:
mode:
authortaitep <taitep@taitep.se>2026-01-29 21:27:36 +0100
committertaitep <taitep@taitep.se>2026-01-29 21:27:36 +0100
commit4f32bbc46a48276bba949364dc44d532c19dae78 (patch)
tree8f54108788735efff25a4a9549bedbe7967d3c7b /src/uart.c
parent25bec21f20208a9369656a337cf5325e7b3a5a8d (diff)
i think i managed to make a working uart driver for the new interface??HEADmain
Diffstat (limited to 'src/uart.c')
-rw-r--r--src/uart.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/uart.c b/src/uart.c
new file mode 100644
index 0000000..86bc01f
--- /dev/null
+++ b/src/uart.c
@@ -0,0 +1,24 @@
+#include "uart.h"
+
+void uart_init(void) {
+ UART_TXCTRL = UART_TXCTRL_TXEN;
+ UART_RXCTRL = UART_RXCTRL_RXEN;
+}
+
+void uart_putc(char c) {
+ while (UART_TXDATA & UART_TXDATA_FULL) {}
+ UART_TXDATA = (uint32_t)c;
+}
+
+void uart_puts(const char* s) {
+ while (*s)
+ uart_putc(*s++);
+}
+
+char uart_getc(void) {
+ uint32_t data;
+ do {
+ data = UART_RXDATA;
+ } while (data & UART_RXDATA_EMPTY);
+ return (char)data;
+}