Fork of PS/2 Keyboard lib.

Dependents:   C64Synth

Fork of PS2 by Pallavi Prasad

Committer:
pprasad7
Date:
Thu Oct 11 20:15:09 2012 +0000
Revision:
0:62b62530a82f
PS/2 Input;

Who changed what in which revision?

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