![](/media/cache/profiles/1006ff12c465532f8c574aeaa4461b16.50x50_q85.jpg)
A test program for PS2 library.
mylib/PS2/PS2KB_INIT.h@4:47b51250a168, 2010-10-13 (annotated)
- Committer:
- shintamainjp
- Date:
- Wed Oct 13 10:50:55 2010 +0000
- Revision:
- 4:47b51250a168
First version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shintamainjp | 4:47b51250a168 | 1 | /** |
shintamainjp | 4:47b51250a168 | 2 | * PS/2 keyboard interface control class (Version 0.0.1) |
shintamainjp | 4:47b51250a168 | 3 | * |
shintamainjp | 4:47b51250a168 | 4 | * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) |
shintamainjp | 4:47b51250a168 | 5 | * http://shinta.main.jp/ |
shintamainjp | 4:47b51250a168 | 6 | */ |
shintamainjp | 4:47b51250a168 | 7 | #ifndef _PS2KB_INIT_H_ |
shintamainjp | 4:47b51250a168 | 8 | #define _PS2KB_INIT_H_ |
shintamainjp | 4:47b51250a168 | 9 | |
shintamainjp | 4:47b51250a168 | 10 | #include "mbed.h" |
shintamainjp | 4:47b51250a168 | 11 | |
shintamainjp | 4:47b51250a168 | 12 | /** |
shintamainjp | 4:47b51250a168 | 13 | * PS2 keyboard initializer. |
shintamainjp | 4:47b51250a168 | 14 | */ |
shintamainjp | 4:47b51250a168 | 15 | class PS2KB_INIT { |
shintamainjp | 4:47b51250a168 | 16 | public: |
shintamainjp | 4:47b51250a168 | 17 | |
shintamainjp | 4:47b51250a168 | 18 | /** |
shintamainjp | 4:47b51250a168 | 19 | * Create. |
shintamainjp | 4:47b51250a168 | 20 | */ |
shintamainjp | 4:47b51250a168 | 21 | PS2KB_INIT(PinName clk_pin, PinName dat_pin); |
shintamainjp | 4:47b51250a168 | 22 | |
shintamainjp | 4:47b51250a168 | 23 | /** |
shintamainjp | 4:47b51250a168 | 24 | * Destroy. |
shintamainjp | 4:47b51250a168 | 25 | */ |
shintamainjp | 4:47b51250a168 | 26 | ~PS2KB_INIT(); |
shintamainjp | 4:47b51250a168 | 27 | private: |
shintamainjp | 4:47b51250a168 | 28 | DigitalInOut clk; |
shintamainjp | 4:47b51250a168 | 29 | DigitalInOut dat; |
shintamainjp | 4:47b51250a168 | 30 | |
shintamainjp | 4:47b51250a168 | 31 | static const int MAX_RETRY = 1000000; |
shintamainjp | 4:47b51250a168 | 32 | |
shintamainjp | 4:47b51250a168 | 33 | /** |
shintamainjp | 4:47b51250a168 | 34 | * Send a byte data. |
shintamainjp | 4:47b51250a168 | 35 | * |
shintamainjp | 4:47b51250a168 | 36 | * @param c a character. |
shintamainjp | 4:47b51250a168 | 37 | * |
shintamainjp | 4:47b51250a168 | 38 | * @return Negative value is a error number. |
shintamainjp | 4:47b51250a168 | 39 | */ |
shintamainjp | 4:47b51250a168 | 40 | int send(uint8_t c); |
shintamainjp | 4:47b51250a168 | 41 | |
shintamainjp | 4:47b51250a168 | 42 | /** |
shintamainjp | 4:47b51250a168 | 43 | * Receive a byte data. |
shintamainjp | 4:47b51250a168 | 44 | * |
shintamainjp | 4:47b51250a168 | 45 | * @return return a data. Negative value is a error number. |
shintamainjp | 4:47b51250a168 | 46 | */ |
shintamainjp | 4:47b51250a168 | 47 | int recv(void); |
shintamainjp | 4:47b51250a168 | 48 | |
shintamainjp | 4:47b51250a168 | 49 | /** |
shintamainjp | 4:47b51250a168 | 50 | * Wait a clock down edge. |
shintamainjp | 4:47b51250a168 | 51 | * |
shintamainjp | 4:47b51250a168 | 52 | * @return true if wait done. |
shintamainjp | 4:47b51250a168 | 53 | */ |
shintamainjp | 4:47b51250a168 | 54 | bool waitClockDownEdge(void); |
shintamainjp | 4:47b51250a168 | 55 | |
shintamainjp | 4:47b51250a168 | 56 | /** |
shintamainjp | 4:47b51250a168 | 57 | * Wait a clock up level. |
shintamainjp | 4:47b51250a168 | 58 | * |
shintamainjp | 4:47b51250a168 | 59 | * @return true if wait done. |
shintamainjp | 4:47b51250a168 | 60 | */ |
shintamainjp | 4:47b51250a168 | 61 | bool waitClockUpLevel(void); |
shintamainjp | 4:47b51250a168 | 62 | }; |
shintamainjp | 4:47b51250a168 | 63 | |
shintamainjp | 4:47b51250a168 | 64 | #endif |