A version of the PS/2 library customized for MbedConsole. Also includes a few things that make it's behavior easier to control and a few bug fixes.
Fork of PS2 by
Diff: PS2KB.h
- Revision:
- 4:fc7f4cc9fbe8
- Parent:
- 1:823c2798e398
--- a/PS2KB.h Wed Sep 26 04:12:42 2012 +0000 +++ b/PS2KB.h Wed Sep 26 05:21:38 2012 +0000 @@ -10,6 +10,10 @@ #include "mbed.h" +class PS2KB; + +typedef void (*KeyboardCallback)(PS2KB* kb, uint8_t val); + /** * PS/2 keyboard interface control class. */ @@ -21,8 +25,10 @@ * @param clk_pin Clock pin. * @param dat_pin Data pin. */ - PS2KB(PinName clk_pin, PinName dat_pin); - + PS2KB(PinName clk_pin, PinName dat_pin, KeyboardCallback cb); + + KeyboardCallback callback; + /** * Destory. */ @@ -33,31 +39,30 @@ * * @return A data from a PS/2 device. */ - virtual int getc(void); + //virtual int getc(void); + - /** - * Set timeout. - * - * @param ms Timeout ms. - */ - virtual void setTimeout(int ms); + + private: - static const int RINGBUFSIZ = 256; + //static const int RINGBUFSIZ = 256; InterruptIn clk; /**< Interrupt input for CLK. */ DigitalIn dat; /**< Digital input for DAT. */ - Timeout wdt; /**< Watch dog timer. */ - Timer tot; /**< Timeout timer. */ - int timeout; /**< Timeout[ms] for getc(). */ + //Timeout wdt; /**< Watch dog timer. */ + //Timer tot; /**< Timeout timer. */ + //int timeout; /**< Timeout[ms] for getc(). */ - typedef struct { + /*typedef struct { int bitcnt; int cStart; int cEnd; uint8_t buffer[RINGBUFSIZ]; } work_t; work_t work; - + */ + uint8_t buffer; + int bitcnt; void func_timeout(void); void func_fall(void);