![](/media/cache/profiles/1006ff12c465532f8c574aeaa4461b16.50x50_q85.jpg)
A test program for PS2 library.
mylib/PS2/PS2KB.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 | |
shintamainjp | 4:47b51250a168 | 8 | #ifndef _PS2KB_H_ |
shintamainjp | 4:47b51250a168 | 9 | #define _PS2KB_H_ |
shintamainjp | 4:47b51250a168 | 10 | |
shintamainjp | 4:47b51250a168 | 11 | #include "mbed.h" |
shintamainjp | 4:47b51250a168 | 12 | |
shintamainjp | 4:47b51250a168 | 13 | /** |
shintamainjp | 4:47b51250a168 | 14 | * PS/2 keyboard interface control class. |
shintamainjp | 4:47b51250a168 | 15 | */ |
shintamainjp | 4:47b51250a168 | 16 | class PS2KB { |
shintamainjp | 4:47b51250a168 | 17 | public: |
shintamainjp | 4:47b51250a168 | 18 | /** |
shintamainjp | 4:47b51250a168 | 19 | * Create. |
shintamainjp | 4:47b51250a168 | 20 | * |
shintamainjp | 4:47b51250a168 | 21 | * @param clk_pin Clock pin. |
shintamainjp | 4:47b51250a168 | 22 | * @param dat_pin Data pin. |
shintamainjp | 4:47b51250a168 | 23 | */ |
shintamainjp | 4:47b51250a168 | 24 | PS2KB(PinName clk_pin, PinName dat_pin); |
shintamainjp | 4:47b51250a168 | 25 | |
shintamainjp | 4:47b51250a168 | 26 | /** |
shintamainjp | 4:47b51250a168 | 27 | * Destory. |
shintamainjp | 4:47b51250a168 | 28 | */ |
shintamainjp | 4:47b51250a168 | 29 | virtual ~PS2KB(); |
shintamainjp | 4:47b51250a168 | 30 | |
shintamainjp | 4:47b51250a168 | 31 | /** |
shintamainjp | 4:47b51250a168 | 32 | * Get a data from a PS/2 device. |
shintamainjp | 4:47b51250a168 | 33 | * |
shintamainjp | 4:47b51250a168 | 34 | * @return A data from a PS/2 device. |
shintamainjp | 4:47b51250a168 | 35 | */ |
shintamainjp | 4:47b51250a168 | 36 | virtual int getc(void); |
shintamainjp | 4:47b51250a168 | 37 | |
shintamainjp | 4:47b51250a168 | 38 | /** |
shintamainjp | 4:47b51250a168 | 39 | * Set timeout. |
shintamainjp | 4:47b51250a168 | 40 | * |
shintamainjp | 4:47b51250a168 | 41 | * @param ms Timeout ms. |
shintamainjp | 4:47b51250a168 | 42 | */ |
shintamainjp | 4:47b51250a168 | 43 | virtual void setTimeout(int ms); |
shintamainjp | 4:47b51250a168 | 44 | |
shintamainjp | 4:47b51250a168 | 45 | private: |
shintamainjp | 4:47b51250a168 | 46 | static const int RINGBUFSIZ = 256; |
shintamainjp | 4:47b51250a168 | 47 | InterruptIn clk; /**< Interrupt input for CLK. */ |
shintamainjp | 4:47b51250a168 | 48 | DigitalIn dat; /**< Digital input for DAT. */ |
shintamainjp | 4:47b51250a168 | 49 | Timeout wdt; /**< Watch dog timer. */ |
shintamainjp | 4:47b51250a168 | 50 | Timer tot; /**< Timeout timer. */ |
shintamainjp | 4:47b51250a168 | 51 | int timeout; /**< Timeout[ms] for getc(). */ |
shintamainjp | 4:47b51250a168 | 52 | |
shintamainjp | 4:47b51250a168 | 53 | typedef struct { |
shintamainjp | 4:47b51250a168 | 54 | int bitcnt; |
shintamainjp | 4:47b51250a168 | 55 | int cStart; |
shintamainjp | 4:47b51250a168 | 56 | int cEnd; |
shintamainjp | 4:47b51250a168 | 57 | uint8_t buffer[RINGBUFSIZ]; |
shintamainjp | 4:47b51250a168 | 58 | } work_t; |
shintamainjp | 4:47b51250a168 | 59 | work_t work; |
shintamainjp | 4:47b51250a168 | 60 | |
shintamainjp | 4:47b51250a168 | 61 | void func_timeout(void); |
shintamainjp | 4:47b51250a168 | 62 | void func_fall(void); |
shintamainjp | 4:47b51250a168 | 63 | |
shintamainjp | 4:47b51250a168 | 64 | void init_work(void); |
shintamainjp | 4:47b51250a168 | 65 | }; |
shintamainjp | 4:47b51250a168 | 66 | |
shintamainjp | 4:47b51250a168 | 67 | #endif |