aboutsummaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-12-30 17:34:23 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-12-30 17:34:23 +0100
commitc9e045dc2170a99c9f32386e3e53aee9e01a8e7c (patch)
treefaa57aef89cd1a03efc665c1e5809cf4f0304269 /io.c
parenteae54c24e2e2b89f399bc2d3be195468c2e462a5 (diff)
downloadrpi-MMU-example-c9e045dc2170a99c9f32386e3e53aee9e01a8e7c.tar.gz
rpi-MMU-example-c9e045dc2170a99c9f32386e3e53aee9e01a8e7c.zip
io api rework
Diffstat (limited to 'io.c')
-rw-r--r--io.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/io.c b/io.c
new file mode 100644
index 0000000..f35fda9
--- /dev/null
+++ b/io.c
@@ -0,0 +1,64 @@
+#include <stddef.h>
+
+#include "io.h"
+#include "strings.h"
+
+void puts(char string[])
+{
+ prints(string);
+
+ putchar('\n');
+ putchar('\r');
+}
+
+void prints(char string[])
+{
+ for (size_t i = 0; string[i]; i++)
+ putchar(string[i]);
+}
+
+void printdec(uint32_t number)
+{
+ char buf[11];
+
+ uint32_to_decstring(number, buf);
+
+ prints(buf);
+}
+
+void printhex(uint32_t number)
+{
+ char buf[9];
+
+ uint32_to_hexstring(number, buf);
+
+ prints(buf);
+}
+
+void printbin(uint32_t number)
+{
+ char buf[33];
+
+ uint32_to_binstring(number, buf);
+
+ prints(buf);
+}
+
+void printdect(uint32_t number)
+{
+ char buf[11];
+
+ uint32_to_decstringt(number, buf);
+
+ prints(buf);
+}
+
+void printhext(uint32_t number)
+{
+ char buf[9];
+
+ uint32_to_hexstringt(number, buf);
+
+ prints(buf);
+}
+