summaryrefslogtreecommitdiff
path: root/protocol/ps2_io_mbed.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-07-30 14:37:05 +0900
committertmk <nobody@nowhere>2014-07-30 14:37:05 +0900
commitadbb86b1ec8b07e86ae7425374e95b82122e48a7 (patch)
tree0a02e89376f69ef975096af9490034725d8eb751 /protocol/ps2_io_mbed.c
parent79840c678e13f9a737f80048bc3b9c9c55e3fc77 (diff)
parenta9f5f201ad6b009675fdf16c4447033cc2ac0995 (diff)
Merge branch 'mbed' into dev
Diffstat (limited to 'protocol/ps2_io_mbed.c')
-rw-r--r--protocol/ps2_io_mbed.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/protocol/ps2_io_mbed.c b/protocol/ps2_io_mbed.c
new file mode 100644
index 0000000000..83bdcef7f5
--- /dev/null
+++ b/protocol/ps2_io_mbed.c
@@ -0,0 +1,60 @@
+#include <stdbool.h>
+#include "ps2_io.h"
+#include "gpio_api.h"
+
+
+static gpio_t clock;
+static gpio_t data;
+
+/*
+ * Clock
+ */
+void clock_init(void)
+{
+ gpio_init(&clock, P0_9);
+ gpio_mode(&clock, OpenDrain|PullNone);
+}
+
+void clock_lo(void)
+{
+ gpio_dir(&clock, PIN_OUTPUT);
+ gpio_write(&clock, 0);
+}
+void clock_hi(void)
+{
+ gpio_dir(&clock, PIN_OUTPUT);
+ gpio_write(&clock, 1);
+}
+
+bool clock_in(void)
+{
+ gpio_dir(&clock, PIN_INPUT);
+ return gpio_read(&clock);
+}
+
+/*
+ * Data
+ */
+void data_init(void)
+{
+ gpio_init(&data, P0_8);
+ gpio_mode(&data, OpenDrain|PullNone);
+}
+
+void data_lo(void)
+{
+ gpio_dir(&data, PIN_OUTPUT);
+ gpio_write(&data, 0);
+}
+
+void data_hi(void)
+{
+ gpio_dir(&data, PIN_OUTPUT);
+ gpio_write(&data, 1);
+}
+
+bool data_in(void)
+{
+ gpio_dir(&data, PIN_INPUT);
+ return gpio_read(&data);
+}