Aleksandar Kodzhabashev / Mbed 2 deprecated TrackballQuery

Dependencies:   Servo mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PS2MS_INIT.h Source File

PS2MS_INIT.h

00001 /**
00002  * PS/2 mouse interface control class (Version 0.0.1)
00003  *
00004  * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
00005  * http://shinta.main.jp/
00006  */
00007 #ifndef _PS2MS_INIT_H_
00008 #define _PS2MS_INIT_H_
00009 
00010 #include "mbed.h"
00011 
00012 /**
00013  * PS2 mouse initializer.
00014  */
00015 class PS2MS_INIT {
00016 public:
00017 
00018     /**
00019      * Create.
00020      */
00021     PS2MS_INIT(PinName clk_pin, PinName dat_pin);
00022 
00023     /**
00024      * Destroy.
00025      */
00026     ~PS2MS_INIT();
00027     
00028     /**
00029      * Send a byte data.
00030      *
00031      * @param c a character.
00032      *
00033      * @return Negative value is a error number.
00034      */
00035     int send(uint8_t c);
00036     
00037     /**
00038      * Receive a byte data.
00039      *
00040      * @return return a data. Negative value is a error number.
00041      */
00042     int recv(void);
00043     
00044 private:
00045     DigitalInOut clk;
00046     DigitalInOut dat;
00047 
00048     static const int MAX_RETRY = 1000000;
00049 
00050     
00051 
00052     
00053 
00054     /**
00055      * Wait a clock down edge.
00056      *
00057      * @return true if wait done.
00058      */
00059     bool waitClockDownEdge(void);
00060 
00061     /**
00062      * Wait a clock up level.
00063      *
00064      * @return true if wait done.
00065      */
00066     bool waitClockUpLevel(void);
00067 };
00068 
00069 #endif