From 4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 19 Jun 2014 16:13:35 +0900 Subject: Port ps2_usb to mbed --- protocol/ps2_io_mbed.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 protocol/ps2_io_mbed.c (limited to 'protocol/ps2_io_mbed.c') 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 +#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); +} -- cgit v1.2.3