Yao Lu / PS2

Dependents:   uVGAII_WebBrowser

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PS2KB_INIT.h Source File

PS2KB_INIT.h

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