PS2 Library

Dependents:   Pong Brickbreaker

Committer:
wjohnsto
Date:
Sun Feb 27 23:34:31 2011 +0000
Revision:
0:ce15490e89e9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wjohnsto 0:ce15490e89e9 1 /**
wjohnsto 0:ce15490e89e9 2 * PS/2 mouse interface control class (Version 0.0.1)
wjohnsto 0:ce15490e89e9 3 *
wjohnsto 0:ce15490e89e9 4 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
wjohnsto 0:ce15490e89e9 5 * http://shinta.main.jp/
wjohnsto 0:ce15490e89e9 6 */
wjohnsto 0:ce15490e89e9 7 #ifndef _PS2MS_INIT_H_
wjohnsto 0:ce15490e89e9 8 #define _PS2MS_INIT_H_
wjohnsto 0:ce15490e89e9 9
wjohnsto 0:ce15490e89e9 10 #include "mbed.h"
wjohnsto 0:ce15490e89e9 11
wjohnsto 0:ce15490e89e9 12 /**
wjohnsto 0:ce15490e89e9 13 * PS2 mouse initializer.
wjohnsto 0:ce15490e89e9 14 */
wjohnsto 0:ce15490e89e9 15 class PS2MS_INIT {
wjohnsto 0:ce15490e89e9 16 public:
wjohnsto 0:ce15490e89e9 17
wjohnsto 0:ce15490e89e9 18 /**
wjohnsto 0:ce15490e89e9 19 * Create.
wjohnsto 0:ce15490e89e9 20 */
wjohnsto 0:ce15490e89e9 21 PS2MS_INIT(PinName clk_pin, PinName dat_pin);
wjohnsto 0:ce15490e89e9 22
wjohnsto 0:ce15490e89e9 23 /**
wjohnsto 0:ce15490e89e9 24 * Destroy.
wjohnsto 0:ce15490e89e9 25 */
wjohnsto 0:ce15490e89e9 26 ~PS2MS_INIT();
wjohnsto 0:ce15490e89e9 27 private:
wjohnsto 0:ce15490e89e9 28 DigitalInOut clk;
wjohnsto 0:ce15490e89e9 29 DigitalInOut dat;
wjohnsto 0:ce15490e89e9 30
wjohnsto 0:ce15490e89e9 31 static const int MAX_RETRY = 1000000;
wjohnsto 0:ce15490e89e9 32
wjohnsto 0:ce15490e89e9 33 /**
wjohnsto 0:ce15490e89e9 34 * Send a byte data.
wjohnsto 0:ce15490e89e9 35 *
wjohnsto 0:ce15490e89e9 36 * @param c a character.
wjohnsto 0:ce15490e89e9 37 *
wjohnsto 0:ce15490e89e9 38 * @return Negative value is a error number.
wjohnsto 0:ce15490e89e9 39 */
wjohnsto 0:ce15490e89e9 40 int send(uint8_t c);
wjohnsto 0:ce15490e89e9 41
wjohnsto 0:ce15490e89e9 42 /**
wjohnsto 0:ce15490e89e9 43 * Receive a byte data.
wjohnsto 0:ce15490e89e9 44 *
wjohnsto 0:ce15490e89e9 45 * @return return a data. Negative value is a error number.
wjohnsto 0:ce15490e89e9 46 */
wjohnsto 0:ce15490e89e9 47 int recv(void);
wjohnsto 0:ce15490e89e9 48
wjohnsto 0:ce15490e89e9 49 /**
wjohnsto 0:ce15490e89e9 50 * Wait a clock down edge.
wjohnsto 0:ce15490e89e9 51 *
wjohnsto 0:ce15490e89e9 52 * @return true if wait done.
wjohnsto 0:ce15490e89e9 53 */
wjohnsto 0:ce15490e89e9 54 bool waitClockDownEdge(void);
wjohnsto 0:ce15490e89e9 55
wjohnsto 0:ce15490e89e9 56 /**
wjohnsto 0:ce15490e89e9 57 * Wait a clock up level.
wjohnsto 0:ce15490e89e9 58 *
wjohnsto 0:ce15490e89e9 59 * @return true if wait done.
wjohnsto 0:ce15490e89e9 60 */
wjohnsto 0:ce15490e89e9 61 bool waitClockUpLevel(void);
wjohnsto 0:ce15490e89e9 62 };
wjohnsto 0:ce15490e89e9 63
wjohnsto 0:ce15490e89e9 64 #endif