summaryrefslogtreecommitdiff
path: root/protocol/ps2_io_mbed.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-06-19 16:13:35 +0900
committertmk <nobody@nowhere>2014-07-30 14:07:43 +0900
commit4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856 (patch)
tree2141d2e168ad043ea18bcb3aee3f3a03dd2a2f1b /protocol/ps2_io_mbed.c
parent80c3ff5fa03429f1e4ea15032f665ceb88c9b8c3 (diff)
Port ps2_usb to mbed
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);
+}