aboutsummaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/uart.a.h8
-rw-r--r--src/drivers/uart.c22
-rw-r--r--src/drivers/uart.h7
3 files changed, 37 insertions, 0 deletions
diff --git a/src/drivers/uart.a.h b/src/drivers/uart.a.h
new file mode 100644
index 0000000..d4bf199
--- /dev/null
+++ b/src/drivers/uart.a.h
@@ -0,0 +1,8 @@
+#ifndef UART_AH
+#define UART_AH
+
+extern void uart_char(unsigned char c);
+extern void uart_hex(unsigned long data);
+extern void uart_string(char* message);
+
+#endif
diff --git a/src/drivers/uart.c b/src/drivers/uart.c
new file mode 100644
index 0000000..f7f15c2
--- /dev/null
+++ b/src/drivers/uart.c
@@ -0,0 +1,22 @@
+#include "uart.a.h"
+
+void uart_hexn(unsigned long c_val) {
+ uart_hex(c_val);
+ uart_char(0x0a);
+}
+
+void uart_10(unsigned long val) {
+ unsigned long t = val;
+ unsigned long c;
+ char buffer[11] = "0000000000\0";
+ char* dptr = buffer + 9;
+ for(int i = 0; i <= 10; i++) {
+ c = t%10;
+ *dptr = 0x30 + (c&0xF);
+ t /= 10;
+ if (t==0)
+ break;
+ dptr -= 1;
+ }
+ uart_string(dptr);
+}
diff --git a/src/drivers/uart.h b/src/drivers/uart.h
new file mode 100644
index 0000000..c78398b
--- /dev/null
+++ b/src/drivers/uart.h
@@ -0,0 +1,7 @@
+#ifndef UART_H
+#define UART_H
+
+void uart_hexn(unsigned long);
+void uart_10(unsigned long);
+
+#endif