diff options
author | tmk <nobody@nowhere> | 2014-06-19 16:13:35 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2014-07-30 14:07:43 +0900 |
commit | 4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856 (patch) | |
tree | 2141d2e168ad043ea18bcb3aee3f3a03dd2a2f1b /protocol/ps2_busywait.c | |
parent | 80c3ff5fa03429f1e4ea15032f665ceb88c9b8c3 (diff) |
Port ps2_usb to mbed
Diffstat (limited to 'protocol/ps2_busywait.c')
-rw-r--r-- | protocol/ps2_busywait.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/protocol/ps2_busywait.c b/protocol/ps2_busywait.c index 05dd7b27e6..a64933219e 100644 --- a/protocol/ps2_busywait.c +++ b/protocol/ps2_busywait.c @@ -40,8 +40,9 @@ POSSIBILITY OF SUCH DAMAGE. */ #include <stdbool.h> -#include <util/delay.h> +#include "wait.h" #include "ps2.h" +#include "ps2_io.h" #include "debug.h" @@ -58,8 +59,11 @@ uint8_t ps2_error = PS2_ERR_NONE; void ps2_host_init(void) { + clock_init(); + data_init(); + // POR(150-2000ms) plus BAT(300-500ms) may take 2.5sec([3]p.20) - _delay_ms(2500); + wait_ms(2500); inhibit(); } @@ -71,7 +75,7 @@ uint8_t ps2_host_send(uint8_t data) /* terminate a transmission if we have */ inhibit(); - _delay_us(100); // 100us [4]p.13, [5]p.50 + wait_us(100); // 100us [4]p.13, [5]p.50 /* 'Request to Send' and Start bit */ data_lo(); @@ -80,7 +84,7 @@ uint8_t ps2_host_send(uint8_t data) /* Data bit */ for (uint8_t i = 0; i < 8; i++) { - _delay_us(15); + wait_us(15); if (data&(1<<i)) { parity = !parity; data_hi(); @@ -92,13 +96,13 @@ uint8_t ps2_host_send(uint8_t data) } /* Parity bit */ - _delay_us(15); + wait_us(15); if (parity) { data_hi(); } else { data_lo(); } WAIT(clock_hi, 50, 4); WAIT(clock_lo, 50, 5); /* Stop bit */ - _delay_us(15); + wait_us(15); data_hi(); /* Ack */ |